Uploaded by Jairo Fiorentino

Sample Records Manager Java code

advertisement
Sample – Declare Record with Java API – IBM Enterprise Records
Sample code for declaring a record using the RM Java API is available for you to use.
This sample demonstrates how a record is declared for a document that is stored in a Content Platform Engine
repository. It illustrates how the RM Java (TM) API interacts with the Content Java Compatiblity Layer API to
create a
RecordInfo object corresponding to the Document object.
During the declaration process, it validates whether the document can be declared as a record. In addition, it
validates whether the destination container object can hold the RecordInfo object.
package test;
// Import the required classes
import com.filenet.wcm.api.*;
import com.filenet.rm.api.*;
import com.filenet.rm.api.util.*;
import com.filenet.rm.api.impl.*;
import java.util.Date;
/**
* This class provides the methods that are required for declaring an Electronic
Record in an FPOS.
*/
public class TestDeclare
{
/*************************** MAIN ******************************************/
public static void main(String sdf[])
{
// Calls the method that declares an Electronic Record in a FPOS.
new TestDeclare().testDeclare_Electronic();
}
/*************************** MAIN ******************************************/
// Specify the Content Platform Engine server name
String lsServer = "??";
// Specify the user ID
String userId = "??";
// Specify the password
String password = "??";
String appId = "??"; // a fully-qualified class name is a good choice
String remoteServerUrl = "??";
String remoteServerDownloadUrl = "??";
String remoteServerUploadUrl = "??";
/*********************** PRIVATE COMMON METHOD *****************************/
ObjectStore os = null;
/**
* Initializes the session object and creates an RMObjectStore
* instance in which the declaration is to be done.
* The method returns an instance of RMObjectStore.
*/
private RMObjectStore common()
{
// Initializes a Session object to connect
// to the ObjectStore
Session session = ObjectFactory.getSession(appId, null, userId, password);
session.setRemoteServerUrl(remoteServerUrl);
// Creates an instance of the required FPOS where the record is to be
declared
os = ObjectFactory.getObjectStore("PRO21042004", session);
// Initializes an instance of RMObjectStore
RMObjectStore loRMOS = new RMObjectStoreImpl(os);
return loRMOS;
}
/***************************************************************************/
/**
* Declares an electronic RecordInfo object in an FPOS.
*/
public void testDeclare_Electronic()
{
RMObjectStore loRMOS = common();
/* Instantiates the RMRecordContainer that will contain the record, that
is,
* the the parent entity of the record.
*/
//Specify the GUID to retrieve the RMRecordContainer object.
RMRecordContainer moRecordContainer =
RecordContainer)loRMOS.getObject( RMType.RM_TYPE_VOLUME,
"??"); // Specify the GUID
// Calls the private method to create the Properties collection of the
RecordInfo object
Properties loProperties = getRecordProperties();
/*
Calls the declare method on RMRecordContainer and passes the following
parameters:
DocumentStore: Repository where the Document is located. Call the
RMUtil.getDocumentStore
method to instantiate it.
DocumentIds: String array that specifies the DocumentIds that are to be
declared.
Properties: Properties collection of RecordInfo.
ClassId: ClassId of RecordInfo.
Permissions: Permissions object that specifies the security permissions
of the RecordInfo object that is to be created.
AutoName: Specifies whether or not the record name is to be generated
automatically
The method also passes an optional parameter that specifies the folders
where the RecordInfo object is to be declared.
*/
RecordInfo loRecord = moRecordContainer.declare (
new RMUtil().getDocumentStore(loRMOS),
new String[]{"??"}, // < DocumentId >
null,
loProperties,
"??", // <RecordClassID>
null,
false);
System.out.println("RecordInfo id - " + loRecord.getId());
}
/**
* Creates a Properties collection to declare a RecordInfo object. This
collection
* contains all of the mandatory properties that are required for an
* ElectronicRecord object.
* The method returns a Properties collection.
*/
private Properties getRecordProperties()
{
/*
Defines all of the properties that need to be passed to the RM Java
API
to declare a RecordInfo object
*/
com.filenet.wcm.api.Properties loProps = ObjectFactory.getProperties();
Property loDate = ObjectFactory.getProperty(RMProperty.DATE_RECEIVED);
Property loMedia = ObjectFactory.getProperty(RMProperty.MEDIATYPE);
Property loFormat = ObjectFactory.getProperty(RMProperty.FORMAT);
Property loPubDate =
ObjectFactory.getProperty(RMProperty.PUBLICATIONDATE);
Property loAuthor = ObjectFactory.getProperty(RMProperty.AUTHOR);
Property loOrgn =
ObjectFactory.getProperty(RMProperty.ORIGINATING_Organization);
Property loSubjTitle = ObjectFactory.getProperty(RMProperty.SUBJECT);
Property lsTitle = ObjectFactory.getProperty(Property.DOCUMENT_TITLE);
// Sets the value of all of the properties defined above
loDate.setValue(new java.util.Date());
loMedia.setValue("??");
loFormat.setValue("??");
loPubDate.setValue(new java.util.Date());
loAuthor.setValue("??");
loOrgn.setValue("??");
loSubjTitle.setValue("??");
lsTitle.setValue("??");
// Adds all of the above-mentioned properties to the Properties
collection.
loProps.add(loDate);
loProps.add(loMedia);
loProps.add(loFormat);
loProps.add(loPubDate);
loProps.add(loAuthor);
loProps.add(loOrgn);
loProps.add(loSubjTitle);
loProps.add(lsTitle);
return loProps;
}
}
Download