Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
"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."

above shows my erro. here is my source code which tries to create space in alfresco

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

Please help me to sort out this issue. thanks

share|improve this question
1  
What line is the exception triggering on? –  Gagravarr Oct 9 '13 at 8:58
1  
you cannot create a NodeRef aka Reference using the path. this line does not work: space = new Reference(STORE, null, parent.getPath() + "/cm:" + ISO9075.encode(spacename)); use RepositoryService.queryChildren(...) or RepositoryService.query(...) to check if your space exists (wiki.alfresco.com/wiki/Repository_Web_Service) –  alfrescian Oct 9 '13 at 12:07
2  
consider to use REST or CMIS if possible - Alfresco CML is a little bit outdated –  alfrescian Oct 9 '13 at 12:11
    
thanks Gagravarr & alfrescian :-) –  Priyan RockZ Oct 10 '13 at 3:59

1 Answer 1

up vote 2 down vote accepted

Use this one instead:

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

Check the sample in your Alfresco SDK: samples\WebServiceSamples\source\org\alfresco\sample\webservice\CMLUpdates.java

In this sample it gets the parent ref with path, and creates an extra file in the folder.

share|improve this answer
    
thanks Dear Tahir :-) –  Priyan RockZ Oct 10 '13 at 3:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.