创建空间时出现Alfresco java.lang.IllegalStateException错误

时间:2013-10-09 08:34:33

标签: java alfresco h2 alfresco-share

"java.lang.IllegalStateException: Failed to resolve to a single NodeRef with parameters (store=workspace:SpacesStore uuid=null path=/app:company_home/cm:DCSL_DOCS/cm:Scanned_Docs), found 0 nodes."

上面显示了我的错误。 这是我的源代码,试图在露天创建空间

protected Reference createSpace(Reference parentref, String spacename) throws Exception {
    Reference space = null;
    ParentReference parent = ReferenceToParent(parentref);
    try {
        System.out.println("Entering space:" + spacename+":");
        space = new Reference(STORE, null, parent.getPath() + "/cm:" + ISO9075.encode(spacename));
        WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[]{space}, STORE, null));
    } catch (Exception e1) {
        System.out.println("The space named " + spacename + " does not exist. Creating it.");
       parent.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, normilizeNodeName(spacename)));
        //Set the space's property name
        NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, spacename)};
        // Create the space using CML (Content Manipulation Language)
        CMLCreate create = new CMLCreate("1", parent, null, null, null, Constants.TYPE_FOLDER, properties);
        CML cml = new CML();
        cml.setCreate(new CMLCreate[]{create});

        //Execute the CML create statement
        try {
            getRepositoryService().update(cml);
        } catch (Exception e2) {
            e2.printStackTrace();
            System.err.println("Can not create the space.");
            throw e2;
        }
    }
    return space;
}

请帮我解决这个问题。 感谢

1 个答案:

答案 0 :(得分:2)

改为使用这个:

ParentReference parentReference = new ParentReference(STORE, null, parent.getPath() + "/cm:" + ISO9075.encode(spacename), Constants.ASSOC_CONTAINS, Constants.ASSOC_CONTAINS);

检查Alfresco SDK中的示例: samples \ WebServiceSamples \ source \ org \ alfresco \ sample \ webservice \ CMLUpdates.java

在此示例中,它获取带路径的父引用,并在文件夹中创建一个额外的文件。