public static WTDocument newDocument(String container_name,
String doc_path, String doc_name,String fileName) throws Exception {
WTDocument document = null;
WTContainer container = getContainer(container_name);
ReferenceFactory rf = new ReferenceFactory();
String containerRef = rf.getReferenceString(ObjectReference
.newObjectReference(((Persistable) container).getPersistInfo()
.getObjectIdentifier()));
ReferenceFactory referenceFactory = new ReferenceFactory();
String[] directory = { doc_name };
WTContainerRef ref = WTContainerRef.newWTContainerRef(container);
createMultiLevelDirectory(directory, ref);
SubFolder folder = (SubFolder) FolderHelper.service.getFolder(
"/Default/"+doc_name, ref);
String folderRef = referenceFactory.getReferenceString(ObjectReference
.newObjectReference(folder.getPersistInfo()
.getObjectIdentifier()));
TypeIdentifier typeidentifier = FdnWTContainerHelper
.toTypeIdentifier("wt.doc.WTDocument");
HashMap<String, String> input_data = new HashMap<String, String>();
input_data.put("name", fileName);
input_data.put("folderRef", folderRef);
input_data.put("container", containerRef);
document = ApplicationIntegrationFactory.createDocument(typeidentifier,
input_data, false, SessionHelper.manager.getLocale(), "html");
ContentHolder ch = (ContentHolder) document;
ApplicationData ap = ApplicationData.newApplicationData(ch);
ap.setRole(ContentRoleType.PRIMARY);
String filePath = doc_path;
ap = ContentServerHelper.service.updateContent(ch, ap, filePath);
ap = (ApplicationData) PersistenceHelper.manager.save(ap);
return document;
}
newDocument
最新推荐文章于 2021-03-12 18:38:18 发布