Skip navigation
evlogimenos
Currently Being Moderated

How to set remoteId for new PublishedCollection?

May 23, 2012 9:47 AM

Tags: #plugin #publish

I am writing a PublishService plugin and I am stuck on how to properly implement creation of new Collections/CollectionSets.

 

When an existing PublishedCollection is changed (renamed and collection settings are changed) renamePublishedCollection and updateCollectionSettings are called in that order. This allows setting the new name and different collection settings for the PublishedCollection.

 

When a new PublishedCollection is created, only updateCollectionSettings is called. In this case the PublishedCollection lacks a remoteId (and there was no way to set it). Even if the remoteId is set inside this call, it ends up being overwritten by the caller of this function.

 

How did you guys worked around this?

 

Is there a chance for a change in 4.1 to call renamePublishedCollection after a new PublishedCollection creation and treat info.remoteId and info.remoteUrl as input parameters that are going to be persisted after this call returns?

 

Message was edited by: disht

 
Replies
  • Currently Being Moderated
    May 23, 2012 10:51 AM   in reply to evlogimenos

    I'm not entirely sure what you're trying to do that isn't working, but I think you're having trouble setting a new (but not necessarily the initial?) LrPublishedCollection's remoteId field.  In updateCollectionSettings(), did you try

     

        info.publishedCollection:setRemoteId( myRemoteId )

     

    Reading between the lines, it looks like you may be trying to set the value by updating the read-only "info" table.

     

    The renamePublishedCollection() callback is intended to let you, for example, rename the remote representation of the collection if the user renames the local one.  Is that how you're trying to use it?

     

    Post back with more details if I'm misunderstanding what you're trying to do.

     

    -Don

     
    |
    Mark as:
  • Currently Being Moderated
    May 23, 2012 3:01 PM   in reply to evlogimenos

    I just put this code in my updateCollectionSettings() callback:

     

    local collection = info.publishedCollection

     

    if collection:getRemoteId() == nil then

       debug("Remote ID not set.  Setting now....")

       collection.catalog:withWriteAccessDo( "Set Remote ID", function()

          collection:setRemoteId( "My Remote ID" )

       end)

    else

       debugf("Remote ID set to '%s'", collection:getRemoteId() )

    end

     

    The first time through (after selecting 'Rename' from the published collection's context menu), this is logged:

     

    DEBUG Remote ID not set.  Setting now....

     

    The second time through (after selecting 'Rename' again), this is what I see:

     

    DEBUG Remote ID set to 'My Remote ID'

     

    If you can't figure out what's going wrong, post your code and maybe someone here will spot the problem.

     

    -Don

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points