/*******************[URL unfurl="true"]http://www.nairkn,com*************************************[/URL]
***The code albeit hard coded uses the livelink java api
***for creating a category and populating its contents
***Written for Dr LAPI series in
***[URL unfurl="true"]http://www.greggriffiths.org/livelink/development/lapi/drlapi/[/URL]
***java version "1.4.2_05"
***Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
***Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
***Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
***Oracle 32-bit Windows: Version 8.1.7.0.0
***Livelink 9.1.0 SP3
***@author K N Nair (appoos@hotmail.com) alias appnair
*** in tek-tips forum [URL unfurl="true"]http://www.tek-tips.com/tipmasters.cfm?pid=862[/URL]
***The published documentation of Opentext,livelink are proprietary
***software and given proper credits
*/
/*When using a package create a hierarchy called com/nairkn
and put the source file there and after compilation
execute it by calling java com.nairkn.addUserToGroup
Error traps at each stage should be done by looking at
the status of each LAPI call for clarity I have omitted those
*/
import com.opentext.api.*; //If you are ajar person the right jars
public class addUserToGroup
{
// Declare some constants for the user and group to add
// In production, your code would read a file where this information is stored.
public static final String USER_NAME = "Admin";
public static final String USER_PASS = "Admin";
public static void main( String[] args )
{
try
{
// Declare some local fields
LLSession session;
int status;
session = new LLSession( "localhost", 2099, "", "Admin", "Admin" );
LAPI_USERS users = new LAPI_USERS( session );
/*here is the user API prototype we will be using to do that
we need a user from the system ,their loginname(select name from kuaf where id=1000)
should give 'Admin'.In this case I am going to add a user called 'asha' to the
'DefaultGroup'.NOTE:the user 'asha is already existing in my system with
another base group
public int AddUserToGroup (
String user,
int toType,
String toName)
READ THE DOCUMENTATION OF THE API FOR THE CONSTANTS */
status = users.AddUserToGroup("asha",LAPI_USERS.GROUP,"DefaultGroup" );
//THIS IS ANOTHER WAY
//status = users.AddUserToGroup("asha",users.GROUP,"Controlled" );
if ( status != 0 )
{
String statustext = session.getStatusMessage();
String errtext = session.getErrMsg();
String apitext = session.getApiError();
System.out.println( "\nERROR: " + statustext + "\n" + errtext + "\n" + apitext );
} else {
System.out.println( "\nSUCCESS: New HARD CODED user " + " has been added" );
}
}
catch ( Throwable e )
{
String x = e.getClass().getName();
String s = e.getMessage();
e.printStackTrace();
}
} // end main
}