I'm developing a publish plug-in for lightroom. For clarity, the 'service' is where I'm publishing the photos to. The Collection Set name or the Collection name needs to be unique on the 'service' side. Therefore, I'd like to validate the Collection name against the 'service' and either accept or reject the proposed name.

The validatePublishedCollectionName function states:

you should accept the name here and reject the name when the server-side operation is attempted.

But, I don't know when the "server-side" operation is being performed. Is it in updateCollectionSettings? If so, how do I cancel the collection creation?

I'm outside my area of experience. Although the following would certainly be critical:

* renamePublishedCollection

* reparentPublishedCollection

I can't see any function for initial creation/naming either though. Hmmmmm..... another hole?

I suppose you could create an asynchronous task to poll the server for existing names, and if the results are not in yet, return false, "hang on..." from validatePublishedCollectionName, else compare entered value to existing names...

Hey Rob! Thanks for the reply. I'm not sure about this, but here's how I solved it: From within updateCollectionSettings when I determine there is a name collision I use the following code to remove the collection:

local catalog = import "LrApplication".activeCatalog()

LrTasks.startAsyncTask( function()

catalog:withWriteAccessDo( "Remove invalid collection", function()

info.publishedCollection:delete()

end)

end)

It works. Not sure it's the best solution, but I'm running with it for now.

I tried to hook into renamePublishedCollection and reparentPublishedCollection but it appears that those methods don't fire when the Published Collection is created. I indeed got them to fire when I'm renaming or reparenting aPublished Collection, but I can't find any other way to prevent the creation of a Published Collection other than in updateCollectionSettings.

Rob, yes! That's a great way to go. Although, I'll still have to implement the other code (collection appears and then dissapears) because, while I can obtain a list of collections from the service for the user and ensure the the uniqueness among the user's collection, I still must ensure the unqiueness of the name across ALL service users - and then only way to do that is to contact the service with the proposed name.