The following code shows how to initialize and release the portal API.
import com.axemble.vdoc.sdk.Modules; import com.axemble.vdoc.sdk.exceptions.SDKException; import com.axemble.vdoc.sdk.modules.IPortalModule; import com.axemble.vdp.utils.Logger; public class GeneralClass { protected final Logger log = Logger.getLogger( GeneralClass.class ); public void generalUseModule() { IPortalModule portalModule = Modules.getPortalModule(); try { // code here... } catch( Exception e ) { throw new SDKException( e ); } finally { Modules.releaseModule( portalModule ); } } }
To recover a list of connection definitions using their type name, you can use the method getConnectionDefinitionsByTypeName().
IConnectionDefinition.IType contains the list of standards types.
The following example shows how to recover connections to external data according to their type from an agent.
import java.util.Collection; import com.axemble.vdoc.sdk.agent.base.BaseAgent; import com.axemble.vdoc.sdk.exceptions.PortalModuleException; import com.axemble.vdoc.sdk.exceptions.SDKException; import com.axemble.vdoc.sdk.interfaces.IConnectionDefinition; import com.axemble.vdoc.sdk.interfaces.IContext; /** * this agent allows to get the names of external data connections according to their type * * @author bchapoton */ public class CountConnectionAgent extends BaseAgent { @Override protected void execute() { IContext adminContext = getPortalModule().getSysadminContext(); try { reportConnectionDefinition( adminContext, IConnectionDefinition.IType.CMIS ); reportConnectionDefinition( adminContext, IConnectionDefinition.IType.JDBC ); reportConnectionDefinition( adminContext, IConnectionDefinition.IType.MAIL ); reportConnectionDefinition( adminContext, IConnectionDefinition.IType.MY_SQL ); reportConnectionDefinition( adminContext, IConnectionDefinition.IType.SMS_CONNECTION ); reportConnectionDefinition( adminContext, IConnectionDefinition.IType.SQL_SERVER ); reportConnectionDefinition( adminContext, IConnectionDefinition.IType.TWITTER ); } catch( Exception e ) { throw new SDKException( e ); } } private void reportConnectionDefinition( IContext context, String type ) throws PortalModuleException { Collection<? extends IConnectionDefinition<?>> cmisCollection = getPortalModule().getConnectionDefinitionsByTypeName( context, type ); for ( IConnectionDefinition<?> cmisObject : cmisCollection ) getReport().addDebug( "type : " + type + " - connection name : " + cmisObject.getName() ); } }
To recover a list of connection definitions using their category name, you can use the method getConnectionDefinitionsByCategoryName().
IConnectionDefinition.ICategory contains the list of standards categories.
The following example shows how to recover the list of all Database connection definitions.
import java.util.Collection; import java.util.Iterator; import com.axemble.vdoc.sdk.Modules; import com.axemble.vdoc.sdk.agent.base.BaseAgent; import com.axemble.vdoc.sdk.exceptions.SDKException; import com.axemble.vdoc.sdk.interfaces.IConnectionDefinition; import com.axemble.vdoc.sdk.interfaces.IContext; import com.axemble.vdoc.sdk.modules.IPortalModule; public class CountConnectionAgent2 extends BaseAgent { /*** this agent allows to get the names of external data connections within the same category ****/ @Override protected void execute() { IPortalModule portalmodule = Modules.getPortalModule(); IContext adminContext = portalmodule.getSysadminContext(); try { // Retrieves all the connections definition of database category Collection<? extends IConnectionDefinition<?>> dbCollection = portalmodule.getConnectionDefinitionsByCategoryName( adminContext, IConnectionDefinition.ICategory.DATA_BASE ); for ( Iterator iterator = dbCollection.iterator() ; iterator.hasNext() ; ) { IConnectionDefinition<?> iConnectionDefinition = (IConnectionDefinition<?>)iterator.next(); LOGGER.error( " Database category - Name : " + iConnectionDefinition.getName() ); } // Retrieves all the connections definition of email category Collection<? extends IConnectionDefinition<?>> mailCollection = portalmodule.getConnectionDefinitionsByTypeName( adminContext, IConnectionDefinition.ICategory.MAIL ); for ( Iterator iterator = mailCollection.iterator() ; iterator.hasNext() ; ) { IConnectionDefinition<?> iConnectionDefinition = (IConnectionDefinition<?>)iterator.next(); LOGGER.error( " Email category - Name : " + iConnectionDefinition.getName() ); } } catch( Exception e ) { throw new SDKException( e ); } finally { Modules.releaseModule( portalmodule ); } } }