WebServices : Updating Public Content

Hi,
I have a program which uses the API to update and transition items. This works fine before the item has ever been made Public. I can make as many updates and transitions as I like. However, once the item has been in a Public state, if I use the same code to make an update, the SaveItems request fails.

The problem is a PSContractViolationFault …

java.lang.IllegalArgumentException: The revision ‘X’ does not specify the edit revision for the item with content id ‘8,112’ but the user ‘YYYYYYY’ has the item checked out.

The item is checked out because I call prepareForEdit right before I try to update the item.

Am I missing something when updating items that have a published version?

Nick.

With help from Nate Chadwick’s post “Content web service API : java.lang.IllegalArgumentException on saveItems” I have resolved this.
The issue was caused by my code loading the item before the call to prepareEdit. In the situations where prepareEdit transitioned the item this meant that my code had a handle to the wrong item version in Percussion. I resolved this by always re-loading the item after a prepareEdit call. Nate’s solution is slightly different and handles the version numbers separately.

I do something like (i’ve removed try/catch statements), I don’t worry about revision numbers… ymmv:


// contentId is what it seems to be...
  IPSGuid guid = gmgr.makeGuid(new PSLocator(contentId));
  List guidList = Collections.singletonList(guid); 
  List statusList = cws.prepareForEdit(guidList);
  List itemList = cws.loadItems(guidList, false, false, false, false);
  PSCoreItem item = (PSCoreItem) itemList.get(0);

// do edits to the PSCoreItem

// now save
  List savedGuidList = cws.saveItems(itemList, false, false);
 
// check item back in and release from editing
  cws.releaseFromEdit(statusList, false); 
  cws.checkinItems(guidList, "");


Yes. I think loading your items after prepareEdit is the way to go.
I didn’t realise you could use Lists for those calls. So that’s another thing I’ve learned from this thread!