Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
Java access to categories in the category ws
Kurt_Nicklas_(pva_kurt_-_(deleted))
How do I acquire the names,vol id and obj id of each of the categories in the category workspace? I can create the enumeration object in the following snippet but looping through the object doesn't seem to produce what I need. Where do I look? Is the following a correct approach in the first place??? LLValueEnumeration enumeration; LAPI_DOCUMENTS doc = new LAPI_DOCUMENTS(session); categoryws = (new LLValue()).setAssocNotSet(); children = (new LLValue()).setAssocNotSet(); if(doc.AccessCategoryWS(categoryws) != 0) { // handleError(session); return; } else { lVolumeID = categoryws.toInteger("VolumeID"); lObjID = categoryws.toInteger("ID");} doc.ListObjects(lVolumeID,lObjID,"","",doc.PERM_SEE,children); // doc.ListObjects(lVolumeID,lObjID,"","",doc.PERM_SEE,children); enumeration = children.enumerateValues();
Find more posts tagged with
Comments
Steve_Piatt_(spiatt_(Delete)_891610)
Attached is a sample that completes your program. I threw in a utility to dump the LLValues as well.
CatWS.java============/** *
@author
spiatt * */import com.opentext.api.*;public class CatWS{ public static void main(String[] args) { LLSession session = new LLSession("localhost", 2099, "", "Admin", "livelink", null); LLValueEnumeration enumeration; LAPI_DOCUMENTS doc = new LAPI_DOCUMENTS(session); LLValue categoryws = (new LLValue()).setAssocNotSet(); LLValue children = (new LLValue()).setAssocNotSet(); int lVolumeID = 0; int lObjID = 0; if (doc.AccessCategoryWS(categoryws) != 0) { // handleError(session); return; } else { lVolumeID = categoryws.toInteger("VolumeID"); lObjID = categoryws.toInteger("ID"); } doc.ListObjects(lVolumeID, lObjID, "", "", doc.PERM_SEE, children); // doc.ListObjects(lVolumeID,lObjID,"","",doc.PERM_SEE,children); lapi_utils utils = new lapi_utils(); utils.output = System.out; utils.DisplayLLValue(children, 0); enumeration = children.enumerateValues(); while ( enumeration.hasMoreElements() ) { LLValue currentRec = enumeration.nextValue(); System.out.println( "Name = " + currentRec.toString( "Name" ) ); System.out.println( "VolumeID = " + currentRec.toString( "VolumeID" ) ); System.out.println( "ID = " + currentRec.toString( "ID" ) ); } }lapi_utils.java===================import com.opentext.api.*;import java.io.*;import java.util.*;public class lapi_utils{ // Instance Variables public PrintStream output; // Generic constructor public lapi_utils() { } ///////////////////////////////////////////////////////////////////////////// // // NAME: DisplayLLValue // // PURPOSE: LAPI convenience routine that displays the type and // contents of any LLVALUE as formatted output. // // USAGE: status = DisplayLLValue( // LLVALUE value, // int level, // PrintStream output ); // // where: // // value INPUT The value to be displayed. // // level INPUT The nesting level of the value to be // displayed. Controls the indentation // preceding the display of the value. // // NOTES: This function may be called recursively. // /////////////////////////////////////////////////////////////////////////// public int DisplayLLValue( LLValue value, int level ) { String type; int status = 0; switch ( value.type() ) { case LLValue.LL_ASSOC: type = "Assoc"; break; case LLValue.LL_BOOLEAN: type = "Boolean"; break; case LLValue.LL_DATE: type = "Date"; break; case LLValue.LL_ERROR: type = "Error"; break; case LLValue.LL_INTEGER: type = "Integer"; break; case LLValue.LL_LIST: type = "List"; break; case LLValue.LL_NOTSET: type = "Not Set"; break; case LLValue.LL_RECORD: type = "Record"; break; case LLValue.LL_DOUBLE: type = "Real"; break; case LLValue.LL_STRING: type = "String"; break; case LLValue.LL_TABLE: type = "RecArray"; break; case LLValue.LL_UNDEFINED: type = "Undefined"; break; default: type = "Unknown"; } // Display the type output.print("(" + type + ")"); // Display the data switch ( value.type() ) { case LLValue.LL_ASSOC: status = DisplayAssoc( value, level+1 ); break; case LLValue.LL_BOOLEAN: output.print( value.toBoolean() ); break; case LLValue.LL_DATE: output.print( value.toDate() ); break; case LLValue.LL_DOUBLE: output.print( value.toDouble() ); break; case LLValue.LL_INTEGER: output.print( value.toInteger() ); break; case LLValue.LL_LIST: status = DisplayList( value, level+1 ); break; case LLValue.LL_RECORD: status = DisplayRecord( value, level+1 ); break; case LLValue.LL_STRING: output.print( value.toString() ); break; case LLValue.LL_TABLE: status = DisplayRecArray( value, level+1 ); break; case LLValue.LL_ERROR: case LLValue.LL_NOTSET: case LLValue.LL_UNDEFINED: break; default: ; } output.println( "" ); return status; } ///////////////////////////////////////////////////////////////////////////// // // NAME: DisplayAssoc // // PURPOSE: LAPI convenience routine that displays the type and // contents of an Assoc LLValue as formatted output. // // USAGE: status = DisplayAssoc( // LLVALUE value, // int level, // PrintStream output ); // // where: // // value INPUT The assoc to be displayed. // // level INPUT The nesting level of the assoc to be // displayed. Controls the indentation // preceeding the display of the contents. // // NOTES: This function is called by DisplayLLValue and also calls // DisplayLLValue. // /////////////////////////////////////////////////////////////////////////// private int DisplayAssoc( LLValue value, int level ) { String indent; Vector keywords; int status = 0; int length = 0; // num of elements in Assoc indent = SetIndent( level ); length = value.size(); keywords = new Vector( length ); // Display the length output.println( "" ); output.println( indent + "Length=" + length ); // Enumerate the column names LLNameEnumeration columns = value.enumerateNames(); // Add the first column name to the vector keywords.addElement( columns.nextName() ); while ( columns.hasMoreElements() ) { // Insert column name into proper sorted location within vector InsertColumn( columns.nextName(), keywords ); } // Loop thru keywords vector and display the column name and // its associated LLValue for ( int i = 0; i < length; i++ ) { String columnName = (String)keywords.elementAt( i ); output.print( indent + columnName + "=" ); status = DisplayLLValue( value.toValue( columnName ), level+1 ); } return status; } ///////////////////////////////////////////////////////////////////////////// // // NAME: DisplayList // // PURPOSE: LAPI convenience routine that displays the type and // contents of a List LLValue as formatted output. // // USAGE: status = DisplayList( // LLVALUE value, // int level, // PrintStream output ); // // where: // // value INPUT The list to be displayed. // // level INPUT The nesting level of the list to be // displayed. Controls the indentation // preceeding the display of the contents. // // NOTES: This function is called by DisplayLLValue and also calls // DisplayLLValue. // /////////////////////////////////////////////////////////////////////////// private int DisplayList( LLValue value, int level ) { String indent; int status = 0; int length = 0; // num of elements in List int i = 1; indent = SetIndent( level ); length = value.size(); // Display the length output.println( "" ); output.println( indent + "Length=" + length ); // Display the index and its corresponding value LLValueEnumeration cols = value.enumerateValues() ; while ( cols.hasMoreElements() ) { output.print( indent + "Item " + i + "=" ); status = DisplayLLValue( cols.nextValue(), level+1 ); i++; } return status; } ///////////////////////////////////////////////////////////////////////////// // // NAME: DisplayRecArray // // PURPOSE: LAPI convenience routine that displays the type and // contents of a RecArray LLValue as formatted output. // // USAGE: status = DisplayRecArray( // LLVALUE value, // int level, // PrintStream output ); // // where: // // value INPUT The RecArray to be displayed. // // level INPUT The nesting level of the recarray to be // displayed. Controls the indentation // preceeding the display of the contents. // // NOTES: This function is called by DisplayLLValue and also calls // DisplayLLValue. // /////////////////////////////////////////////////////////////////////////// private int DisplayRecArray( LLValue value, int level ) { String indent; int i = 1; int status = 0; int length = 0; // num of records in RecArray int width = 0; // num of fields in each record LLValue record = null; indent = SetIndent( level ); // Get the length and width length = value.size(); width = value.width(); // Display the length and width output.println( "" ); output.println( indent + "Length=" + length +" Width=" + width ); // Get each field and corresponding value and display the pair together LLValueEnumeration rows = value.enumerateValues(); while ( rows.hasMoreElements() ) { indent = SetIndent( level+1 ); output.print( indent + "Record #" + i + " "); status = DisplayLLValue( rows.nextValue(), level+1 ); i++; } return status; } ///////////////////////////////////////////////////////////////////////////// // // NAME: DisplayRecord // // PURPOSE: LAPI convenience routine that displays the type and // contents of a Record LLValue as formatted output. // // USAGE: status = DisplayRecord( // LLVALUE value, // int level, // PrintStream output ); // // where: // // value INPUT The record to be displayed. // // level INPUT The nesting level of the record to be // displayed. Controls the indentation // preceeding the display of the contents. // // NOTES: This function is called by DisplayLLValue and also calls // DisplayLLValue. // /////////////////////////////////////////////////////////////////////////// private int DisplayRecord( LLValue value, int level ) { int i; String indent; int status = 0; int width = 0; // num of elements in Assoc indent = SetIndent( level ); width = value.size(); // Display the length output.println( "" ); output.println( indent + "Width=" + width ); // Get each field and corresponding value and display the pair together LLNameEnumeration columns = value.enumerateNames(); LLValueEnumeration cols = value.enumerateValues() ; while ( columns.hasMoreElements() && cols.hasMoreElements() ) { output.print( indent + columns.nextName() + "="); status = DisplayLLValue( cols.nextValue(), level+1 ); } return status; } ///////////////////////////////////////////////////////////////////////////// // // NAME: SetIndent // // PURPOSE: LAPI convenience routine that determines the number of // spaces to set the indent string to. // // USAGE: indent = SetIndent( int level ); // // where: // // level INPUT The nesting level for which the number // of spaces is to be computed. // // indent OUTPUT The string that will hold the // appropriate number of spaces. // // NOTES: The number of spaces is computed as level * 5. // /////////////////////////////////////////////////////////////////////////// private String SetIndent( int level ) { int numSpaces = level * 5; StringBuffer sb = new StringBuffer( numSpaces ); for( int i = 1; i <= numSpaces; i++) { sb.append( ' ' ); } return sb.toString(); } ///////////////////////////////////////////////////////////////////////////// // // NAME: InsertColumn // // PURPOSE: LAPI convenience routine that inserts a column name into // an ordered vector. // // USAGE: InsertColumn( String columnName, Vector keywords ); // // where: // // columnName INPUT The string to be added to the vector. // // keywords MODIFY The vector that contains the sorted // strings. // /////////////////////////////////////////////////////////////////////////// private void InsertColumn( String columnName, Vector keywords ) { boolean inserted = false; int max = keywords.size(); for ( int i = 0; i < max && !inserted; i++ ) { String s = (String)keywords.elementAt( i ); // If the keyword from the vector is greater lexically than the // columnName, insert the columnName into the vector at that location if ( s.compareTo( columnName ) > 0 ) { keywords.insertElementAt( columnName, i ); inserted = true; } } // If columnName was not inserted, it must be greater lexically than // all elements in the vector, so add it to the end of the vector. if (!inserted) keywords.addElement(columnName); } ///////////////////////////////////////////////////////////////////////////// // // NAME: ShowError // // PURPOSE: LAPI convenience routine that displays Livelink // error information. // // USAGE: ShowError( // LLSession session, // int status ); // // where: // // session INPUT The session object that defines the // Livelink session. This object can be // undefined. // // status INPUT The status code to be interpreted. // /////////////////////////////////////////////////////////////////////////// public void ShowError( LLSession session, int status ) { if ( output instanceof PrintStream ) { // Display status code in both integer and hex output.println( "Status=" + status + " (0x" + Integer.toHexString( status ) +")" ); output.flush(); // If the session handle is valid, get the session's error information if ( session instanceof LLSession ) { // Get the error information int stat = session.getStatus(); String message = session.getStatusMessage(); String errMsg = session.getErrMsg(); String apiError = session.getApiError(); output.println ( "Session failure status is " + stat + " (0x" + Integer.toHexString( stat ) + ")" ); if ( message != "" || errMsg != "" || apiError != "" ) { output.println( "Message=" + message ); output.println( "errMsg=" + errMsg ); output.println( "apiError=" + apiError ); } output.flush(); } } }}
Brenda_Boelter_(kofaxuser2_-_(deleted))
Do you have to be an Admin user to retrieve categories defined in categories volume?
Steve_Piatt_(spiatt_(Delete)_891610)
The default ACLs limit access to the administrator, but these can be changed.