Hello All,
Are there any examples on how to get full path of a node ID with Content Web Services 10.0.0 on CS10(U12) ?
Thanks,
Jackson
Hi, what exactly do you mean by the full path of a node ID? Are you talking about its ancestors? (breadcrumbs)
Each Node has a parentid and Volumeid concept so if you know the node,you know its immediate parent all the way upto where it is -1.-1 is where everybody terminates .In Oscript we have some easy to use functions and I was thinking that web services has some too.In any case it is not that difficult for one to do that .Morover if you know SQL this can be done via that and fatser.You would then call a LR from CWS.Search APi also returns the bread crumb.
I wrote these it was a port from lapi,oscript etc so it should work
Usage in my code
GetPathByDataID(17626, dm, dmOTAuth);
Console.WriteLine(concatName);
***************************************Listing starts*********************************************
static string concatName=""; static void GetPathByDataID(int dataid,DocumentManagement.DocumentManagementClient dm,DocumentManagement.OTAuthentication dmOTAuth) {
/*NO ERROR HANDLING WHATSOEVER * NO SUPPORT FOR OTHER VOLUMES THAT WILL EXIT THIS CODE * ALL YOU HAVE TO DO IS IF YOU GET A NEGATIVE DATAID LIKE A 172635 MULTIPLY IT BY -1 TO * MAKE IT POSITIVE AND IT WILL TRAVERSE * */
if ((dataid <0) && (dataid != -1)) { dataid=dataid*-1; //To handle negative volumes like Projects,CDs,Discussions etc } //Really find the node and see what we can do with it
GetNodePath.DocumentManagement.Node myNode = dm.GetNode(ref dmOTAuth, dataid);
if (dataid == -1) concatName = "Enterprise hard code encountered"; else { concatName = myNode.Name + ":" + concatName; }
if (myNode.ParentID != -1) { GetPathByDataID(myNode.ParentID, dm, dmOTAuth); }
}
******************************************Listing ends********************************************
Yes, bread crumb trail with ":" colon as the path separator. For example below.
Home:TEST FOLDER:Sub Folder 1:Sub Folder 2:Test File.doc
- Jackson
This is for LAPI (you can extend it to CWS… just replace the calls.). It is a recursive function looping up until it hits the top level. The initial pass in of path is "":
public static String getPath( String path, int volumeID, int objectID )
{
LLValue objectInfo = ( new LLValue() ).setAssocNotSet();
int status1 = 0, status2 = 0, status3 = 0;
int objID = 0;
status1 = oDocs.GetObjectInfo(volumeID, objectID, objectInfo );
if (status1 == 0)
if (!path.equalsIgnoreCase(""))
path = objectInfo.toString( "NAME" ) + ":" + path;
else
path = objectInfo.toString( "NAME" );
objID = objectInfo.toInteger( "PARENTID" );
if (objID != -1)
path = getPath(path, volumeID, objID);
return path;
From: eLink Entry: Content Web Services Forum [mailto:otdncontentwebservices971forum@elinkkc.opentext.com]Sent: Wednesday, March 11, 2015 1:17 PMTo: eLink RecipientSubject: Any Examples on How to Get Full Path of a Node ID with Content Web Services 2
Any Examples on How to Get Full Path of a Node ID with Content Web Services 2
Posted byjackson.s.shu@altria.com (Shu, Jackson) On 03/11/2015 01:10 PM
Quoted Kevin Mark on 03/11/2015 01:10 PM:
[To post a comment, use the normal reply function]
Topic:
Any Examples on How to Get Full Path of a Node ID with Content Web Services
Forum:
Content Web Services Forum
Content Server:
Knowledge Center
This code sample would not perform well. It gets recursively node information about every ancestor on the path to the requested node. The longer the node path, the longer it 'd take and the more server load it'd cause. It would serve well in a prototype, but not in a product, IMHO. I'd suggest you filing a feature request for this, or implement a SOAP or REST service yourself. LAPI would work too, but it has been deprecated.
There is a workaround which you might be able to use, if you have the search index ready - the XML Search API. If you execurte a query for the specific node ID, it should be reasonable fast and the node path can be returned among the other search regions. I think that the search results contain it by default.
Thanks for all the helpful suggestion. We going to try the run LiveReport route since we already have a simple livereport that outputs a full path already.
Regards,
If using SQL you could use the attached functions. GetFullPath is a Scalar function, and GetFullPaths is a Table Valued Function.
Example:
SELECT *, GetFullPath(DT.DataID)FROM DTree DT JOIN DTreeAncestors DTA ON DTA.DataID = DT.DataID AND DTA.AncestorID = 65025;
SELECT DT.*, GFP.FullPathFROM DTree DT JOIN DTreeAncestors DTA ON DTA.DataID = DT.DataID AND DTA.AncestorID = 65025 CROSS APPLY GetFullPaths(DT.DataID) GFP;