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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java and LAPI

Status
Not open for further replies.

TomBarrand

Programmer
Aug 9, 2000
162
GB
Hi,

I am using the Livelink API's to connect to Livelink via Java. I have written a simple class that calls the LLSession method. It doesn't look like my call is even getting to the Livelink server.

I have installed the Livelink API program on the server and have added the bin directory to the LAPI stuff on my class path on my laptop where I am writing the code from.

Please can some who has used Java and LAPI explain what I am missing?

I have detailed my code below

Thanks

Tom

-----------------------------------------------------------

//Specify import directives
import com.opentext.api.*;

public class CreateNewLLSession
{

//class member functions
public static void main (String args[]) throws Exception
{
try
{
//Create a new Livelink Session
LLSession session;
session = new LLSession ("10.10.0.88", 2099, "", "Admin", "livelink", null);

//Initialize any LAPI Objects
LAPI_USERS user = new LAPI_USERS(session);

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

//////////////////////////////////////////////////////////////////////
//Code to Update a User's Info
//////////////////////////////////////////////////////////////////////

//Define the user's login name
//String userName = "kward";


//////////////////////////////////////////////////////////////////////

}
catch (Throwable e)
{
System.err.println(e.getMessage());
e.printStackTrace(System.err);
}
}

//This function outputs any errors from the session
public static void GetErrors(LLSession session)
{
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());
}
}
 
to answer this qn simply if you open up a browser and type
you should get the livelink login screen and when you type in Admin and password you should get in there.Does your program compile.Also from your code all you are doing is creating a session,you have not used any methods.Try accessing eneterprise,personal or one of the UAPI functions.the lapi jar or class files should be on the classpath and it doesnot hurt to put . for the current directory.

Lapi is client software and should be installed on the machine you are working and trying to connect to a particular llserver,it need not necessarily be on the server.Your api calls will hit the livelink server and it knows how to handle it.

If you do not get the login screen then it tells me that the llserver you are running has dir svcs of some sort and it needs a different kind of session constructor.

You might also want to check this site
or even the Ot SDK devZone




Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
You can verify if your call is getting to the Livelink server by turning on logging and checking the thread.out files in the opentext\logs directory. It will show the LAPI call coming into the server with the username and some other basic LAPI parameters regardless of if the login is successful or not.

LAPI doesn't validate your login until you try something. Most people try accessing the Enterprise workspace as part of the login process and checking for an error. If they get an error it means the login failed.
 
Syntergy,

I think the issue was that LAPI doesn't validate your login until you try and do something. I have tried accessing the Enterprise workspace and got the following error, so I guess I am communicating to the server then.

Please can you be a bit more specific on how I enable logging on the server?

I am only concerning with creating new users, modifying user attributes and doing the same for groups. Do you have any examples or resources that you gould point me to?

I have no previous experience of Livelink and my first task is to use LAPI, I'm sure you appreciate my difficulties.

Many thanks for your comments

Tom

Enterprise Volume-2000Enterprise ObjID2000
Failed to Add Document
Status Code: 100401
Api Error:
Error Message:
Status Message: Could not get results.
 
The above error typically means that you got into the enterprise workspace.If you can add a document using the login /id and password then that is what lapi can do as well,that is I mean you need to check it thru a browser.For adding users the userid should have user addition privileges.Talk to your syasadmins first.
The error 100401 is thrown when you called the AddDocument method but it could be for a variety of reasons such as

a)The ParentNode does not exist
b)the Document exists already .In this case you want to add a version
c)Your livelink may need a mandatory node category filled
d)Your livelink may need additional node attributes.
I deliberately did not say permissions because I asw you using the 'admin' constructor so you are a super user to the system.
Unfortunately lapi does not say well about livelink business rules,so please use the browser first to get a feel of the land.


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
To enable logging on the server you do the following:

With a web browser navigate to /livelink/livelink.exe?func=admin.index (This is the Administration page)

In the Search Administration section of the page select "Configure Debug Settings". On this page set the Debug Level to 1 to get the thread.out files in the opentext\logs directory. These files (one for each thread executing in Livelink) will show the LAPI requests as they come in. It might be useful to check the Log Connections" setting too. The will produce a connect.log (one for each thread executing in Livelink) that shows all the database activity in Livelink. This could be useful for determing why the LAPI call is not working.

Here is a snippet of Java code that does a Livelink login and checks access to the Enterprise workspace to see if the login was successful.

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

try
{
// Initialize Session

String ip = props.getProperty("llIpAddress");
int port = Integer.parseInt(props.getProperty("llPort"));
String acct = props.getProperty("llDbAcct");
String uname = props.getProperty("llDbUser");
String upwd = props.getProperty("llDbPswd");
String udomain = props.getProperty("llDbDomain");

config.add( "DomainName", udomain );
session = new LLSession( ip,
port,
acct,
uname,
upwd,
config);

doc = new LAPI_DOCUMENTS( session );

// Access the Workbin
doc.AccessLibrary( libInfo );

// Get parent volume and node
volumeID = libInfo.toInteger( "VolumeID");
pNodeID = libInfo.toInteger( "ID" );

if(volumeID == 0 && pNodeID == 0) return(false);
 
Thanks for that.

Do you have any example Java code for doing things with users and groups or can you point me to a resource as I can't seem to find much on the web?

e.g. Create a new user, update user attributes, disable a user, create a new group, add users to a group, remove users from a group

Many Thanks

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top