Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LAPI communication efficiency

Status
Not open for further replies.

joeggi

MIS
Joined
Jan 12, 2005
Messages
1
Location
CH
The java code below recursively lists all docs under a given project/folder. Although it produces the expected result, it seems very inefficient in terms of communication: in one example I listed 26 files in 11 folders, which generated 163 IP packets in 12 TCP connections in 6.3 secs. If I make the code more complex, e.g. by adding GetVersionInfo or other calls, it gets worse. Bottom line: execution is slow.

Is there any way to make this more efficient, e.g. can LAPI be instructed to continue using an existing TCP connection ?

I can't run code on the Livelink server and would like to use the code to work over slow speed WANs.

thanks !
joerg



import com.opentext.api.*;

import java.io.*;
import java.util.*;
import java.text.*;


public class ListDir4s {
static LAPI_DOCUMENTS documents = null;

public static void main( String[] args ) {
try {
LLSession session = null;


int status = 0;
int nodeID = 0;
int EWSID = 0;
int nodeVol = 0;
int VolID = 0;
int RootID = 10751181;

session = new LLSession( ...);

documents = new LAPI_DOCUMENTS( session );

LLValue objInfo = ( new LLValue() ).setAssocNotSet();

status = documents.GetObjectInfo(0, RootID, objInfo );
if ( status == 0 ) {
if (objInfo.toInteger("SubType")==documents.PROJECTSUBTYPE ||
objInfo.toInteger("SubType")==documents.FOLDERSUBTYPE ) recurse(objInfo,".");

if (objInfo.toInteger("SubType")==documents.DOCUMENTSUBTYPE ) {
System.out.println ("doc name is "+ objInfo.toString("Name"));
System.exit(status);
}
}


if ( status != 0 ) {
// Display status code in both integer and hex
System.out.println( "Status=" + status +
" (0x" + Integer.toHexString( status ) +")" );

// 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();


System.err.println ("Session failure status is " + stat +
" (0x" + Integer.toHexString( stat ) + ")" );

if ( message != "" || errMsg != "" || apiError != "" ) {
System.out.println( "Message=" + message );
System.out.println( "errMsg=" + errMsg );
System.out.println( "apiError=" + apiError );
}
}
System.exit( status );
}

}

catch ( Throwable e ) {
// Display exception
System.err.println( "Application encountered an exception:" );
System.err.println( e.getMessage() );
e.printStackTrace( System.err );
} // catch
} // main


private static void recurse(LLValue objInfo, String path) {
int obj=objInfo.toInteger("ID");
int vol=objInfo.toInteger("VolumeID");

path=path+"\\"+objInfo.toString("Name");

listcont (vol, obj,path);
if (objInfo.toInteger("SubType")==documents.PROJECTSUBTYPE) listcont (obj, -obj, path);
} // recurse


private static void listcont(int vol, int obj, String path) {
LLValue children = ( new LLValue() );
int i;

int status=(documents.ListObjects(vol, obj,
null, null, documents.PERM_SEECONTENTS, children));
int size=0;
if (children.isRecord()) size=1;
if (children.isTable()) size=children.size();
for (i = 0; i < size; i++) {
// date=( year,month,day,hour,minute,second );
if (children.toInteger(i,"SubType")==documents.FOLDERSUBTYPE ) recurse(children.toValue(i),path);
if (children.toInteger(i,"SubType")==documents.PROJECTSUBTYPE) recurse(children.toValue(i),path);
if (children.toInteger(i,"SubType")==documents.DOCUMENTSUBTYPE)
System.out.println (children.toString(i, "Name"));
} // for
} // listcont

}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top