I’m trying to use the Web services to import items into our Rhythmyx site. I got everything working, but now I’m trying to get the content id of each item that I save, the numbers I’m getting back are something like -665719928530
I can pass this ID to check the items in and it works just fine. But I need the actual content id. The 4 digit number, any ideas?
I’m assuming that the id comes as binary revision-contentid? if so is there a way to extract the content id from it?
The global ID used in webservices is actually 3 fields mashed together in an unsigned long (64-bit) number. In workbench, you’ll see them a lot in the object inspector.
The fields look something like:
|---- revision ----|- type -|------- object id -------|
Revision: 3 bytes. In general, you’ll use a -1 value, which translates to “not revision specific”. When you are reading data from a content item, this field will have a meaningful value.
Type: 1 byte. For content items, this value will always be 101.
Object Id: 4 bytes. This is the content id of your item.
For content items, you can simply mask off the parts of the ID that you don’t need… you shouldn’t recast to an int as a negative value may cause the content id to become negative too… the best way to get the content id from the returned id is probably something like:
int contentId = (int)(rawId & 0xFFFFFFFFL);
I’ve attached a Java class that may make things a bit simpler and has some more type codes that I’ve been able to decipher if you need them.
Is there any way to get the otherway around like from content explorer I need to determine the longid. My requirement is from the content explorer looking at a content item the user will type in the content id in a standalone web page and i need to load the content item.
Thank you.