Message from David Slimmon via eLinkGood morning,Just a quick mail here to pass along some news of an additional new utilityadded to the Sample LAPI section of the KC. Static LAPI has been added tothe following area:Sample Tools and Applications: Static LAPI (SLAPI)
https://knowledge.opentext.com/knowledge/livelink.exe?func=ll&objId=2730318&objAction=browse&sort=namePlease feel free to download it and enjoy its use in your daily work.=========Features:=========SLAPI is intended to be a static, high-level API to Livelink's LAPI forJava. Its first and foremost purpose is to make doing the "usual" thingswith LAPI much easier, and more succinct.Some of SLAPI's features include:1. As much as possible, the Livelink "plumbing" is abstracted away from theSLAPI client, especially where it involves the use of the LLValue class2. Java classes that represent Livelink node types, such as Document,Folder, Workspace, CompoundDocument, etc.3. Easy-to-use factory methods for creating new objects4. A new SLAPIException type, to allow a more Java-oriented try/catcherror-handling approach than the C-style "return status" method.========Example:========In standard LAPI, to create a Folder named "my new folder" as a child ofone's personal workspace, and then place the contents of "c:/tmp/foo.txt"into that folder as a Document named "my new document", one might do this:--------------------------------------------------------------------------------import com.opentext.api.*;public class AddDocumentLAPI { public static void main (String [] args) { try { LLSession session = new LLSession("localhost", 2099,"Livelink91", "Admin", "livelink"); LAPI_DOCUMENTS doc = new LAPI_DOCUMENTS(session); LLValue ws = (new LLValue()).setAssocNotSet(); if(doc.AccessPersonalWS(ws) != 0) { handleError(session); return; } int wsVolId = ws.toInteger("VolumeID"); int wsObjId = ws.toInteger("ID"); LLValue folderCInfo = (new LLValue()).setAssocNotSet(); LLValue folderOInfo = (new LLValue()).setAssocNotSet(); if (doc.CreateObjectEx(wsVolId, wsObjId, LAPI_DOCUMENTS.OBJECTTYPE, LAPI_DOCUMENTS.FOLDERSUBTYPE, "my new folder", folderCInfo,folderOInfo) != 0) { handleError(session); return; } int folderVolId = folderOInfo.toInteger("VolumeID"); int folderObjId = folderOInfo.toInteger("ID"); LLValue objInfo = new LLValue(); LLValue verInfo = new LLValue(); if (doc.AddDocument(folderVolId, folderObjId, "my new document", "c:/tmp/foo.txt", objInfo, verInfo) == 0) { System.out.println("Document Added Successfully"); } else { System.out.println("Failed to Add Document"); } } catch (Exception e) { e.printStackTrace(); } } public static void handleError(LLSession session) { System.out.println("Failed to Access Workspace"); 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()); }}-----------------------------------------This is how you might do it using SLAPI:-----------------------------------------import slapi.Session;import slapi.SLAPIException;public class AddDocumentSLAPI { public static void main (String [] args) { try { Session session = new Session("localhost", 2099, "Livelink91","Admin", "livelink"); session .getPersonalWorkspace() .createFolder("my new folder") .createDocument("my new document", "c:/tmp/foo.txt"); System.out.println("Document Added Successfully"); } catch (SLAPIException e) { System.out.println("Failed to Add Document"); e.printStackTrace(); } }}----------------------------------------------------In the SLAPI case, the fact that both LAPI's "output parameters" and "returnstatus" values are abstracted away mean that we can use a more functionalstyle to chain the calls together, confident that if anything goes wrong aSLAPI Exception will be thrown.==========IMPORTANT:==========SLAPI is NOT production code, and is not meant to be anything but anexperiment in a new way to apply LAPI. It has not been rigorously tested,and is really not documented beyond this note. Open Text cannot open troubletickets based on SLAPI issues.As the saying goes, if it breaks, you get to keep both pieces. :)That being said, it is hoped that SLAPI gives Java programmers usingLivelink some ideas of different ways of to approach their task.Regards,David___________________________________________O P E N T E X T C O R P O R A T I O NDavid Slimmon, M.L.I.S.Supervisor - Customer Support
https://knowledge.opentext.comdslimmon@opentext.com