/*
The code albeit hard coded uses the livelink java api combined
for getting task related info
In this example execute the Live report All late workflows
Written in answer for an functional_nam query in livelink Knowledge Base
tested java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
OJVM Client VM (build 9.0.2.572 cdov, Copyright (c) 1998-2002 Oracle Corp., nojit)
@author K N Nair (appoos@hotmail.com) alias appnair/samalayali
kn_nair@ssa-sa.sel.sony.com in tektips
Acknowledgement for using printTypeTree as a helper function
Fantastic object tree traversal
Glenn Heying (SCorUser8) Department: Sprint Corporate
SPRINT01 Title: Systems Developer V
E-mail: glenn.heying@mail.sprint.com Phone: (816) 665-9626
*/
//package com.nairkn;
import java.util.*;
import com.opentext.api.*;
public class listObjects{
private static String Server = "localhost"; //livelink host
private static int Port = 2099; //livelink server port see opentext.ini
private static String DFT = ""; //default database file or schema
private static String User = "Admin"; //username
private static String Pass = "Admin"; //passwd
public static void main (String [] args)
{
try
{
//variables
LLSession session;
LAPI_DOCUMENTS doc;//library object
LAPI_WORKFLOW flow;//workflow object
LLValue value=new LLValue();
session = new LLSession (Server, Port, DFT, User, Pass);
doc = new LAPI_DOCUMENTS (session);
flow= new LAPI_WORKFLOW (session);
LLValue LLvalueWP=new LLValue();
int volID, objID,versionID;
if (doc.AccessEnterpriseWS(value) == 0)
{
System.out.println("Enterprise accessed");
objID = value.toInteger("ID");
volID = value.toInteger("VolumeID");
System.out.println("Enterprise ID: " + objID);
System.out.println("Enterprise Volume: " + volID);
//PROVIDE a livelink Document with category that one is looking for
objID=11351;
LLValue children=new LLValue();
String viewName = "DTREE";
String queryStr="SUBTYPE=144 ";
if (doc.ListObjects(volID,objID,viewName,queryStr,LAPI_DOCUMENTS.PERM_FULL,children )==0)
{
printTypeTree(children,"|",":");
//now after running this if you would just like to enUmerate one RECORD inside that like name
System.out.println("I AM IMPATIENT SHOW ME JUST NAME***************");
printTypeTree(children.toValue("NAME"),"|",":");
System.out.println("I AM IMPATIENT SHOW ME JUST SUBTYPE***************");
printTypeTree(children.toValue("SUBTYPE"),"|",":");
//another way bad programming but since we know that all columns of dtree are lists we can do a shortcut
//if one of the enumerations are not LIST that si when you get unhandled exception errors such as
//getname not implemented.LAPI will return either success or failure and the return values may
//or maynot be enumeratable.In short handle your exceptions at the client yourself.
System.out.println("I AM IMPATIENT ALL I CARE IS THE NAME RECORD***************");
for(int i = 0; i < children.toValue("NAME").size(); i++) {
System.out.print("The name of this object is----"+children.toValue("NAME").toValue(i));
System.out.print("I THINK ITS SUBTYPE IS--"+children.toValue("SUBTYPE").toValue(i));
System.out.println("WHEN I AM A CONTAINER SUBTYPE(FOLDER,PROJECT,DISCUSSSION ETC) I SHOULD BE RECURSIVELY CALLED TO GET ITS CONTENTS");
}
}
else
{
//Error Checking
System.out.println("Failed to execute Document");
System.out.println("Status Code: " + session.getStatus());
System.out.println("Api Error: " + session.getApiError());
System.out.println("Error Message: " + session.getErrMsg());
System.out.println("Status Message: " + session.getStatusMessage());
}
}
else
{
//Error Checking
System.out.println("Failed to execute Document");
System.out.println("Status Code: " + session.getStatus());
System.out.println("Api Error: " + session.getApiError());
System.out.println("Error Message: " + session.getErrMsg());
System.out.println("Status Message: " + session.getStatusMessage());
}
}
catch (Throwable e)
{
System.err.println(e.getMessage() );
e.printStackTrace (System.err);
}
}
//Helper class which was published by another
//user in the LAPI discussion
private static void printTypeTree(LLValue inVal, String szSep, String szName) {
System.out.println(szSep + szName + " - " + printLLValueType(inVal.type()) + "\t" + printLLValue(inVal));
if(inVal.type() == LLValue.LL_ASSOC ||
inVal.type() == LLValue.LL_RECORD ||
inVal.type() == LLValue.LL_TABLE) {
LLNameEnumeration enumValue;
enumValue = inVal.enumerateNames();
while(enumValue.hasMoreElements()) {
String elValue = enumValue.nextElement().toString();
printTypeTree(inVal.toValue(elValue), "\t" + szSep, elValue);
}
}
else {
if(inVal.type() == LLValue.LL_LIST) {
for(int i = 0; i < inVal.size(); i++) {
printTypeTree(inVal.toValue(i), "\t" + szSep, "" + i);
}
}
}
}
private static String printLLValue(LLValue llVal)
{
String returnString = "";
switch (llVal.type()) {
case LLValue.LL_BOOLEAN :
returnString = "" + llVal.toBoolean();
break;
case LLValue.LL_DATE :
returnString = llVal.toDate().toString();
break;
case LLValue.LL_DOUBLE :
returnString = "" + llVal.toDouble();
break;
case LLValue.LL_INTEGER :
returnString = "" + llVal.toInteger();
break;
case LLValue.LL_STRING :
returnString = llVal.toString();
break;
default :
break;
}
return returnString;
}
private static String printLLValueType(int iType) {
String returnString = " ";
switch (iType) {
case LLValue.LL_ASSOC :
returnString = "Type is ASSOC";
break;
case LLValue.LL_BOOLEAN :
returnString = "Type is BOOLEAN";
break;
case LLValue.LL_DATE :
returnString = "Type is DATE";
break;
case LLValue.LL_DOUBLE :
returnString = "Type is DOUBLE";
break;
case LLValue.LL_ERROR :
returnString = "Type is ERROR";
break;
case LLValue.LL_INTEGER :
returnString = "Type is INTEGER";
break;
case LLValue.LL_LIST :
returnString = "Type is LIST";
break;
case LLValue.LL_NOTSET :
returnString = "Type is NOTSET";
break;
case LLValue.LL_RECORD :
returnString = "Type is RECORD";
break;
case LLValue.LL_STRING :
returnString = "Type is STRING";
break;
case LLValue.LL_TABLE :
returnString = "Type is TABLE";
break;
case LLValue.LL_UNDEFINED :
returnString = "Type is UNDEFINED";
break;
default :
returnString = "Type is Unknown";
break;
}
return returnString;
}//helper method ends
}//class ends here