AnsweredAssumed Answered

FirstFoundationClient - InvalidNodeRefException

Question asked by sturner on Nov 14, 2006
Still working on the FirstFoundationClient sample code, against WCM preview on Win XP. I've switched to a mysql database, and run into trouble with the following code.


       //
        // locate the company home node
        //
        SearchService searchService = serviceRegistry.getSearchService();
        StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
        ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home\"");
        NodeRef companyHome = resultSet.getNodeRef(0);
        System.out.println(companyHome.toString());
        System.out.println(companyHome.getId());

        //
        // create new content node within company home
        //

        // assign name
        String name = "Foundation API sample (" + System.currentTimeMillis() + ")";
        Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
        contentProps.put(ContentModel.PROP_NAME, name);

        // create content node
        NodeService nodeService = serviceRegistry.getNodeService();
        ChildAssociationRef association = nodeService.createNode(companyHome,
              ContentModel.ASSOC_CONTAINS,
              QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, name),
                ContentModel.TYPE_CONTENT,
                contentProps);

The createNode call throws an exception:

org.alfresco.service.cmr.repository.InvalidNodeRefException: Node does not exist: workspace://SpacesStore/2a2a1453-6430-11db-88ba-c940ee47bf6b

According to the Javadoc, this indicates that the parent node (company home) does not exist. The print statements after I locate company home show this url for the node:

workspace://SpacesStore/2a2a1453-6430-11db-88ba-c940ee47bf6b

I'm wondering why the 'locate the company home node' code should give me a node that doesn't exist.

Outcomes