Content web service API : java.lang.IllegalArgumentException on saveItems

I am getting an illegal argument error on save items and am trying to debug where the logic is off. Has anyone seen something like this before?

cws.checkinItems(guids, “Checkin by System”);

status = cws.prepareForEdit(guids);

guids = cws.saveItems(psItems, false, false);

(where cws is the Content web service)

java.lang.IllegalArgumentException: The revision ‘19’ does not specify the edit revision for the item with content id ‘4,247’ but the user ‘admin1’ has the item checked out.

-n

Solved the problem.

Because the prepare edit was happening after a checkin and a load I had to get the component summary and bump the revisions prior to saving.

So

PSComponentSummary tmpSummary = summ.loadComponentSummary(psItems.get(0).getContentId());

psItems.get(0).setEditRevision(tmpSummary.getEditLocator().getRevision());
psItems.get(0).setRequestedRevision(tmpSummary.getEditLocator().getRevision());
psItems.get(0).setRevision(tmpSummary.getEditLocator().getRevision());

Nate,
What’s the ‘summ’ object you’re using here? And how do I get a handle to it?
I think I’ve run into the same issue as you.

Thanks!

Hi,

It’s the ComponentSummaries service. You can get at that using the com.percussion.services.legacy.PSCmsContentSummariesLocator.

I’ve also found that in some of these scenarios if you supply “-1” to the various Revisions on the item after the Prepare for Edit, that will cause the system to treat the item in “revision-less” mode and use the latest “edit” / “tip” revision from CONTENTSTATUS.

As I understand it, specifying the Edit Revision for the item will be more accurate than -1 (maybe more future proof / easier to read) but both approaches should work.

-n

Nate,
My code was loading an item, then checking to see if an update was required, and if it was, only then calling prepareEdit. This worked fine as long as prepareEdit didn’t transition the item. If it did I was seeing the error message you mentioned at the start of this thread. I have changed my code so that the item is always re-loaded after the call to prepareEdit. In some cases this means I effectively load the item twice but I can live with that for now.
Without your post about this error I doubt I’d have worked this out so appreciate the help.

Nick.