//This simple code is actually commonly used, almost "as is" when connecting to an object store,
//there are still few improvements you could do, but it's OK to start testing your connection to a
//FileNet P8 domain. I almost took this code exactly from a training session that I
//had for FileNet P8 4.0 Content Engine development
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ObjectStoreSet;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
public class CEConnection{
public Connection getCEConnection(){
Connection connection = Factory.Connection.getConnection("iiop://myServer:2809/FileNet/Engine");
Subject subject = UserContext.createSubject(connection, "administrator", "password", null);
UserContext userContext = UserContext.get();
userContext.pushSubject(subject);
return connection;
}
public Domain getDomain(Connection connection){
String domainName = "P8domain";
Domain domain = Factory.Domain.fetchInstance(connection, domainName, null);
System.out.println("Domain name: "+domain.get_Name());
return domain;
}
public void getObjectStores(Domain domain){
ObjectStoreSet objectStoreSet = domain.get_ObjectStores();
ObjectStore objectStore;
Iterator objectStoreIterator = objectStoreSet.iterator();
System.out.println("Available object stores: ");
while(objectStoreIterator.hasNext()){
objectStore = (ObjectStore)objectStoreIterator.next();
System.out.println("*"+objectStore.get_DisplayName());
}
}
public ObjectStore getObjectStore(Domain domain, String objectStoreName){
ObjectStore objectStore = null;
objectStore = Factory.ObjectStore.fetchInstance(domain, objectStoreName, null);
return objectStore;
}
public static void main(String[] args) {
try {
CEConnectionEDU connectionEDU = new CEConnectionEDU();
Connection connection = connectionEDU.getCEConnectionEDU();
Domain domain = connectionEDU.getDomainEDU(connection);
connectionEDU.getObjectStoresEDU(domain);
System.out.println(connectionEDU.getObjectStoreEDU(domain, "MyObjectStore").get_DisplayName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Subscribe to:
Post Comments (Atom)
The review is nice. Thank you for useful tips. To protect yourself from unexpected losses try cheapest property insurance by zip code to save more on home insurance policies.
ReplyDelete