【问题标题】:In alfresco repository how to create link for one folder to another folder using java api在露天存储库中,如何使用 java api 为一个文件夹创建到另一个文件夹的链接
【发布时间】:2016-07-22 06:19:47
【问题描述】:

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

【问题讨论】:

    标签: alfresco alfresco-share opencmis apache-chemistry


    【解决方案1】:

    我得到了答案,我们可以使用 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();               
        }
    }
    

    创建文件夹链接的代码:

    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();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 2015-08-21
      • 2019-05-02
      • 2020-10-19
      • 1970-01-01
      相关资源
      最近更新 更多