IBM® Product Master provides three Java™ API interfaces, CMSInstance,
CMSManager, and CMSContentURN, that you can use to manage
content in the content management system.
When you run the
CMSInstance,
CMSManager, and
CMSContentURN
Java APIs, make sure that your JVM has the parameter
vbr.home set like
this:
vbr.home=cms_home
Where,
cms_home
is the installation directory of IBM Content Integrator.
For example, if you are running the APIs from a stand alone Java program in Linux®, you can add the parameter
vbr.home to
your classpath in this way:
export CLASSPATH=$CLASSPATH" -Dvbr.home=/opt/IBM/ContentIntegrator"
See IBM Javadoc Documentation to view all of
the available information on the parameters, returns, exceptions,
and syntax for all Java classes.
- Sample CMSManager interface usage
- Use the CMSManager interface to gather the data that is configured in the
content_management_system_properties.xml file. To use these methods, you do not
need to implement single sign-on to content management systems.
- This sample code shows how to retrieve the CMSManager object from the context
and use it to retrieve a list of configured repositories.
Context ctx = null;
try
{
ctx = PIMContextFactory.getContext("Admin", "xxx", "MyCompany");
CMSManager CMSMgr = ctx.getCMSManager();
Collection<String> listOfCMS = CMSMgr. getRepositoryNames();
}
catch (PIMAuthorizationException ae)
{
// Expected a failure
System.out.println("Authorization Failure");
return;
}
catch(PIMInternalException ie)
{
System.out.println(" Internal Error ");
return;
}
- Sample CMSInstance interface usage
- Use the CMSInstance interface to perform tasks needed to integrate the
content management system and validate any errors.
- This sample code populates the metadata attributes and adds a content to repository.
Context ctx = null;
try
{
ctx = PIMContextFactory.getContext("Admin", "xxx", "MyCompany");
CMSManager CMSMgr = ctx.getCMSManager();
CMSInstance CMSInst = CMSMgr.getCMSInstance();
CMSInst.logon();
String repositoryName = "DB2CM";
String itemClassName =
CMSMgr. getItemClassName(repositoryName);
String filename = Configuration.getValue("tmp_dir") + "/test.xml";
String folderUrn = CMSMgr. getFolderURN(repositoryName);
HashMap<String, String> metadataAttributesHM = new HashMap<String, String>();
Map<String, String> metaProps =
CMSInst. getMetaDataAttributes(repositoryName);
Iterator<String> it = metaProps.keySet().iterator();
while (it.hasNext())
{
// meta data attribute
String property = (String) it.next();
// meta data attribute value
String value = "val1";
metadataAttributesHM.put(property, value);
}
File file1 = new File(filename);
String addedContentURN = CMSInst. addContent(
repositoryName, file1,file1.getName(),
metadataAttributesHM);
}
catch (PIMAuthorizationException ae)
{
// Expected a failure
System.out.println("Authorization Failure");
return;
}
catch(IllegalArgumentException iae)
{
System.out.println(" Passed argument is null or empty ");
return;
}
catch(PIMInternalException ie)
{
System.out.println(" Internal Error ");
return;
}
- Sample CMSReadOnlyAttribs interface usage
- Use the CMSReadOnlyAttribs interface to assigns values and make those
attributes read only.
- This sample code assigns values to the CMS attribute and makes those attributes read only.
Option |
Sample code |
Java API |
Type
//script_execution_mode=java_api="japi:///javaapiclass:com.ibm.mdm.pim.CMSTest.class"
to call this API.
package com.ibm.mdm.pim;
import com.ibm.pim.extensionpoints.CMSEntryBuildFunction;
import com.ibm.pim.extensionpoints.CMSEntryBuildFunctionArguments;
import java.util.HashMap;
public class CMSTest implements CMSEntryBuildFunction
{
public void cmsEntryBuild(CMSEntryBuildFunctionArguments inArgs)
{
HashMap hmAttrs = (HashMap)inArgs.getCMSMetaData();
hmAttrs.put("ExpiryDate", "08/11/2011 16:45:00");
hmAttrs.put("MDM_DOC_AUTHOR", "isome");
// use inArgs.getCMSReadOnlyAttribs();
// for setting attributes to readonly
}
}
|
Script API |
Type res["<name of the attribute>"] = <value>; where <name of
the attribute> is the name of the CMS Item Class attribute, which shows up in
Add Content screen. And where <value> is the value which
you want to assign to that attribute. For
example, res["PIMItemnr"] = 1234; //assuming it takes numbers, or else enclose the value with double quotes
res["PIMTaal"] = "someText";
res["PIMDocType"] = "Text";
//Assigns value to CMS attribute. Provide the name of the attribute as seen in the UI
cmsMetadata["AuthorCode"] ="Ruth";
//Make CMS Attributes read only. Provide the name of the attribute as seen in the UI
cmsReadOnlyAttribs[0] = "AuthorCode";
|
- Sample CMSContentURN interface usage
- Use the CMSContentURN interface to validate and check for the existence of a
particular URN or external content management system document.
- This code sample retrieves the IBM Content Integrators
content object that is referring to the given URN. This code sample checks to see if the content
referenced by this URN object is existing and if so, returns the IBM Content Integrators content
object.
Context ctx = null;
try
{
ctx = PIMContextFactory.getContext("Admin", "xxx", "MyCompany");
CMSManager CMSMgr = ctx.getCMSManager();
CMSInstance CMSInst = CMSMgr.getCMSInstance();
String urn = "vbr:/DB2PAL/firstItemType.A1001001A09B24B35145B46524.A09B24B35145B46524.1022/1/CONTENT";
CMSContentURN contURN= CMSInst. getCMSContentURN(urn);
Content CIContent = null;
if( contURN.isExisting())
{
Content CIContent =
CMSInst.getContentIntegratorContent (contURN);
}
}
catch (PIMAuthorizationException ae)
{
// Expected a failure
System.out.println("Authorization Failure");
return;
}
catch(IllegalArgumentException iae)
{
System.out.println(" Passed argument is null or empty ");
return;
}
catch(PIMInternalException ie)
{
System.out.println(" Internal Error ");
return;
}