如何使用java委托创建文件夹并将文档保存到alfresco中

时间:2016-08-04 10:06:40

标签: java alfresco

我正在使用露天社区版,在活动工作流程中我必须自动生成文件保存到alfresco文件库文件夹中,我创建文件但是在使用时将文件保存到文件库我不能,请参考< / p>

1 个答案:

答案 0 :(得分:0)

试试这个对我来说很好

public static void main(String args[]) {
String serverUrl = args[0];
String username = args[1];
String password = args[2];
Session session = getSession(serverUrl, username, password);
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_
DOCUMENT.value());
String name = "New Document (" + System.currentTimeMillis() +
").txt";
properties.put(PropertyIds.NAME, name);
List<Ace> addAces = new LinkedList<Ace>();
List<Ace> removeAces = new LinkedList<Ace>();
List<Policy> policies = new LinkedList<Policy>();
String content = "The quick brown fox jumps over the lazy dog.";
ContentStream contentStream = new ContentStreamImpl("text.txt",
BigInteger.valueOf(content.length()),
"text/plain", new ByteArrayInputStream(content.
getBytes()));
Document newDocument = root.createDocument(properties,
contentStream, VersioningState.MAJOR, policies, addAces, removeAces,
session.getDefaultContext());
System.out.println(newDocument.getId());}