Alfresco:创建链接后找不到该项

时间:2016-07-25 12:21:20

标签: alfresco alfresco-share opencmis apache-chemistry

我正在尝试使用apache-chemistry在Alfresco中创建文档的快捷方式或链接。使用下面的代码我试图创建链接或快捷方式

properties = new HashMap<String, Object>();
properties.put(PropertyIds.BASE_TYPE_ID, BaseTypeId.CMIS_ITEM.value()); 

// define a name and a description for the link
properties.put(PropertyIds.NAME, "Name_for_the.link");
properties.put("cmis:description", "test create link");            
properties.put(PropertyIds.OBJECT_TYPE_ID, "I:app:filelink"); 

//define the destination node reference
properties.put("cm:destination", "workspace://SpacesStore/41f43936-31c1-432e-bb33-438c05bcb26c");     

// choose a folder where the link is to be create
Folder destinationFolder = (Folder) session.getObjectByPath("/path/to/the/destination/folder");

session.createItem(properties, destinationFolder);

现在的问题是我能够从上面的代码创建链接,但每当我点击它显示我的链接

  

无法找到该项目。您无权查看该项目,该项目已被删除或从未存在过。

1 个答案:

答案 0 :(得分:0)

要修改现有对象的属性,首先需要检索它,然后可以调用setProperty方法 在对象本身上,传递ID和您的每个属性的新值 打算改变。最后,只需按如下方式调用updateProperties方法:

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());
newDocument.setProperty(PropertyIds.NAME, "Modified document (" +
System.currentTimeMillis() + ").txt");
newDocument.updateProperties();
session.save();
}

在这种方法中,我正在改变文档的属性,尝试做一些类似希望帮助你的事情