创建文档模板

package com.doshine.platform.transfer;


import com.filenet.api.admin.ClassDefinition;
import com.filenet.api.admin.LocalizedString;
import com.filenet.api.collection.LocalizedStringList;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.core.Factory;
import com.filenet.api.core.Folder;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
import com.pde.platform.ddc.searchengine.datasource.filenet.FileNetDataSource;


public class DocDefTransfer {


public void createSubClass(ObjectStore objObjectStore, String parentClassName, String strSubclassDisplayName,String subClassSymbolicName)
{




// Fetch selected class definition from the server
ClassDefinition objClassDef = Factory.ClassDefinition.fetchInstance(objObjectStore, parentClassName, null);
  


// Create subclass of the Folder class
ClassDefinition objClassDefNew = objClassDef.createSubclass();
objClassDefNew.set_SymbolicName(subClassSymbolicName);


// Set up locale
LocalizedString objLocStr = Factory.LocalizedString.createInstance();
objLocStr.set_LocalizedText(strSubclassDisplayName);
objLocStr.set_LocaleName(objObjectStore.get_LocaleName());


// Create LocalizedStringList collection
objClassDefNew.set_DisplayNames(Factory.LocalizedString.createList());
objClassDefNew.get_DisplayNames().add(objLocStr);


// Save new class definition to the server
objClassDefNew.save(RefreshMode.REFRESH);            
}

public static void main(String[] args) {
DocDefTransfer  defTransfer = new DocDefTransfer();
com.pde.platform.ddc.searchengine.datasource.filenet.FileNetDataSource fd =  new FileNetDataSource();
try {
ObjectStore os = fd.getObjectStore();
System.out.println(os.getConnection().getURI());

defTransfer.createSubClass(os, "Document","测试文档" ,"TestClass");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally{
UserContext.get().popSubject();
}

}
}

你可能感兴趣的:(exception,String,OS,Class,文档)