The following code indicates how to use the document management API. The method initialize() is used to position a certain number of parameters.
The document management module has the particularity to use a COM layer that requires the call of methods Ole32.CoInitialize() and Ole32.CoUninitialize(). The class DocumentManagementHelper simplifies the writing and hides the calls to the COM initialization methods.
public void general_useModule() { try { // retrieving an object from the document management module DocumentManagementHelper module = DocumentManagementHelper.getInstance(); try { // positioning the connection parameters module.AddParameter( module.getPROTOCOL(), "http://" ); module.AddParameter( module.getHOST(), "host-name" ); module.AddParameter( module.getPORT(), "80" ); module.AddParameter( module.getAPPLICATION(), "vdocopenweb" ); module.AddParameter( module.getDATABASE(), "database-name" ); module.AddParameter( module.getCHECK_BUNDLE_TIMEOUT(), "250" ); // initialization of the module module.Initialize(); // do something here... } catch( Exception e ) {} finally { module.UnInitialize(); } } catch( Exception e ) { try { if ( module.getHasLastError() ) System.out.println( module.getLastError().getmessage() ); } catch( COMException error ) { error.printStackTrace(); } } }
The context notion enables to run processing with a user account. Several cases are displayed. Their using depends on the execution context and the available objects.
public void general_getContext( IDocumentManagementModule module ) throws Exception { // 1st case : retrieving the context from a user object IUser user = module.GetUserByLogin( "sysadmin" ); IContext userContext = module.GetContext( user ); // 2nd case: retrieving the context by login IContext loginContext = module.GetContextByLogin( "sysadmin" ); // 3rd case: retrieving the context by authentication IContext authenticationContext = module.GetContextByAuthentication( "adm", "admin" ); }