在露天存储库中如何使用 java api 为一个文件夹创建 link 到另一个文件夹

In alfresco repository how to create link for one folder to another folder using java api

大家好,我是 alfresco.I 的初学者,已经完成了许多服务,例如创建文件夹、子文件夹、上传文档、下载文档、使用 cmis 创建权限。 但是我无法使用 cmis 将一个文件夹的 link 创建到另一个文件夹。 有人告诉我使用 cmis 是不可能的。 不知何故我得到了这个linkhttp://basanagowdapatil.blogspot.in/2011/01/code-for-creating-links-in-alfresco.html。 但是这段代码不在cmis中。 我从来没有做过这种编程。 有人可以建议我如何在 Maven 中执行此程序。 我应该添加什么依赖项或罐子。 最好有人一步一步地向我解释(从某种意义上说如何进行身份验证)。 提前致谢

我得到了答案,我们可以使用 CMIS API。

import java.util.HashMap;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

import com.bizruntime.alfresco.session.CreateSession;
import com.bizruntime.alfresco.util.Config;

public class CreateLink {
    static Logger log = Logger.getLogger(CreateLink.class);

    public static void getLink() {
        // creating Session
        Session cmiSession = new CreateSession().getSession();
        log.debug("Session Created...");
        Map<String,Object> properties = new HashMap<>();
        properties.put(PropertyIds.BASE_TYPE_ID, BaseTypeId.CMIS_ITEM.value());

        // Define a name and description for the link
        properties.put(PropertyIds.NAME, Config.getConfig().getProperty("nameOfLink"));
        properties.put("cmis:description", Config.getConfig().getProperty("linkDescription"));
        properties.put(PropertyIds.OBJECT_TYPE_ID, "I:app:filelink");

        // Define the destination node reference
        properties.put("cm:destination", Config.getConfig().getProperty("destination-nodRef"));

        // Choose the folder where the link to be create
        Folder rootFoler = cmiSession.getRootFolder();
        Folder targerFolder = (Folder) cmiSession.getObjectByPath(rootFoler.getPath() + Config.getConfig().getProperty("targetFolder"));
        cmiSession.createItem(properties, targerFolder);
        log.info("Link Created Successfully....");
    }

    public static void main(String[] args) {
        BasicConfigurator.configure();
        CreateLink cl = new CreateLink();
        cl.getLink();               
    }
}

创建文件夹的代码link:

import java.util.HashMap;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

import com.bizruntime.alfresco.session.CreateSession;
import com.bizruntime.alfresco.util.Config;

public class CreateLink {
    static Logger log = Logger.getLogger(CreateLink.class);
    public static void getLink() {
        // creating Session
        Session cmiSession = new CreateSession().getSession();
        log.debug("Session Created...");
        Map<String,Object> properties = new HashMap<>();
        properties.put(PropertyIds.BASE_TYPE_ID, BaseTypeId.CMIS_ITEM.value());

        // Define a name and description for the link
        properties.put(PropertyIds.NAME, Config.getConfig().getProperty("nameOfLink"));
        properties.put("cmis:description", Config.getConfig().getProperty("linkDescription"));
        properties.put(PropertyIds.OBJECT_TYPE_ID, "I:app:filelink");

        // Define the destination node reference
        properties.put("cm:destination", Config.getConfig().getProperty("destination-nodRef"));

        // Choose the folder where the link to be create
        Folder rootFoler = cmiSession.getRootFolder();
        Folder targerFolder = (Folder) cmiSession.getObjectByPath(rootFoler.getPath() + Config.getConfig().getProperty("targetFolder"));
        cmiSession.createItem(properties, targerFolder);
        log.info("Link Created Successfully....");
    }

    public static void main(String[] args) {
        BasicConfigurator.configure();
        CreateLink cl = new CreateLink();
        cl.getLink();
    }
}