cancel
Showing results for 
Search instead for 
Did you mean: 

I do not see objects created with 'SimpleExampleWithCon

anweber
Champ in-the-making
Champ in-the-making
I launched the example  "SimpleExampleWithContent" and obtained following messages (until this point, all seems to be correct, I will explain my problem after) :

11:24:40,636 INFO  [admin.patch.PatchExecuter] Checking for patches to apply …
11:24:40,761 INFO  [admin.patch.PatchExecuter] No patches were required.
11:24:41,354 INFO  [service.descriptor.DescriptorService] Alfresco JVM - v1.5.0_06-b05; maximum heap size 63.563MB
11:24:41,370 WARN  [service.descriptor.DescriptorService] Alfresco JVM - WARNING - maximum heap size 63.563MB is less than recommended 512MB
11:24:41,370 INFO  [service.descriptor.DescriptorService] Alfresco started (Community Network): Current version 1.2.0 schema 6 - Installed version 1.2.0 schema 6
Node Store:
node: b014336c-be3c-11da-b32e-0fd5c57ae5ce (store_root, aspect_root)
   @store-protocol = workspace
   @name = b014336c-be3c-11da-b32e-0fd5c57ae5ce
   @node-uuid = b014336c-be3c-11da-b32e-0fd5c57ae5ce
   @store-identifier = SimpleExampleWithContent-b00f787b-be3c-11da-b32e-0fd5c57ae5ce
   -> {http://www.alfresco.org/test/SimpleExampleWithContent}My First Folder ({http://www.alfresco.org/test/SimpleExampleWithContent}My First Folder)
      node: b01b5f5e-be3c-11da-b32e-0fd5c57ae5ce (folder, auditable, referenceable)
         @modifier = admin
         @modified = Tue Mar 28 11:24:42 CEST 2006
         @node-uuid = b01b5f5e-be3c-11da-b32e-0fd5c57ae5ce
         @creator = admin
         @store-protocol = workspace
         @name = My First Folder
         @store-identifier = SimpleExampleWithContent-b00f787b-be3c-11da-b32e-0fd5c57ae5ce
         @created = Tue Mar 28 11:24:42 CEST 2006
         -> {http://www.alfresco.org/test/SimpleExampleWithContent}My First File ({http://www.alfresco.org/test/SimpleExampleWithContent}My First File)
            node: b02c012f-be3c-11da-b32e-0fd5c57ae5ce (content, auditable, referenceable)
               @modifier = admin
               @modified = Tue Mar 28 11:24:42 CEST 2006
               @node-uuid = b02c012f-be3c-11da-b32e-0fd5c57ae5ce
               @creator = admin
               @store-protocol = workspace
               @content = contentUrl=store://2006/3/28/11/b0359e20-be3c-11da-b32e-0fd5c57ae5ce.bin|mimetype=text/plain|size=43|encoding=UTF-8
               @name = My First File
               @store-identifier = SimpleExampleWithContent-b00f787b-be3c-11da-b32e-0fd5c57ae5ce
               @created = Tue Mar 28 11:24:42 CEST 2006


Then I tried to see the created objects with the web application (I use the enterprise version).  I executed "c:\Alfresco\alf_start.bat" and, with my web brower, I called http://localhost:8080/alfresco.  I logged as admin. The folder created by the application ("My First Folder") doesn't appear.

To be sure it exists, I had a look on the database content with MySql Query Browser. The created nodes are there.  For example, if we search on the last workspace created (SELECT * FROM alfresco.node n where guid='b01b5f5e-be3c-11da-b32e-0fd5c57ae5ce'Smiley Wink, we find a row.


Do you have any idea about the origin of this problem.  Is it matter of rights?  Is it because I use the enterprise version as web interface?  I saw that the nodes I created like that have not the field "title" (but a "name" field).  Is it a problem for the web interface?

   Thanks for your help,

             Andr
7 REPLIES 7

kevinr
Star Contributor
Star Contributor
The problem is that the web-client is setup to read from a single "store" - the SpacesStore. The example code creates example stores with names such as:

@store-identifier = SimpleExampleWithContent-b00f787b-be3c-11da-b32e-0fd5c57ae5ce

So the web-client knows nothing about the store.

A repository can contain multiple stores, we have a System, SpacesStore and LightWeightVersionStore by default. The stores created from your test app will not be visible.

You could change the NodeRef objects you create to point to the "SpacesStore" and you will also need to make sure you add the nodes underneath the "Company Home" node or you will not see them also.

Thanks,

Kevin

anweber
Champ in-the-making
Champ in-the-making
Kevin,

       Thanks for your help.  I am affraid, I still have a littel problem.

       I modified the "SimpleExampleWithContent.doExample" method as it :

    private static void doExample(ServiceRegistry serviceRegistry) throws Exception
    {
        // get individual, required services
        NodeService nodeService = serviceRegistry.getNodeService();
        ContentService contentService = serviceRegistry.getContentService();

        // authenticate
        AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
        authenticationService.authenticate("admin", "admin".toCharArray());
       
        // get the store
        StoreRef storeRef = new StoreRef(
                StoreRef.PROTOCOL_WORKSPACE,
                "SpacesStore"
                );
        if (!nodeService.exists(storeRef))
        {
            return;
        }
       
        // get the Company Home node from which to hang the next level of nodes
        NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
        List<ChildAssociationRef> rootChildren = nodeService.getChildAssocs(rootNodeRef);
        int nbRootChildren = rootChildren.size();
        int iRootChild;
        NodeRef rootChild = null;
        NodeRef companyHomeNode = null;
        String nodeId;
        for (iRootChild=0; iRootChild < nbRootChildren; iRootChild++){
           rootChild = rootChildren.get(iRootChild).getChildRef();
           nodeId = rootChild.getId();
          System.out.println(nodeId);
          Serializable prop = nodeService.getProperty(rootChild,ContentModel.PROP_NAME);
          System.out.println("|" + prop.toString() + "|");
             if ("Company Home".equals(prop.toString())){
                 companyHomeNode = rootChild;
                 break;
           }
        }
        if (companyHomeNode == null)return;
       
        Map<QName, Serializable> nodeProperties = new HashMap<QName, Serializable>(7);
       
        // add a simple folder to the "Company Home" node
        nodeProperties.clear();
        nodeProperties.put(ContentModel.PROP_NAME, "My First Folder");
        nodeProperties.put(ContentModel.PROP_TITLE,"My First Folder");
        ChildAssociationRef assocRef = nodeService.createNode(
              companyHomeNode,
                ContentModel.ASSOC_CHILDREN,
                QName.createQName(NAMESPACE, QName.createValidLocalName("My First Folder")),
                ContentModel.TYPE_FOLDER,
                nodeProperties);
        NodeRef folderRef = assocRef.getChildRef();
       
        // create a file
        nodeProperties.clear();
        nodeProperties.put(ContentModel.PROP_NAME, "My First File");
        assocRef = nodeService.createNode(
                folderRef,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName(NAMESPACE, QName.createValidLocalName("My First File")),
                ContentModel.TYPE_CONTENT,
                nodeProperties);
        NodeRef fileRef = assocRef.getChildRef();
       
        ContentWriter writer = contentService.getWriter(fileRef, ContentModel.PROP_CONTENT, true);
        // the mimetype will up pushed onto the node automatically once the stream closes
        writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        // store string content as UTF-8
        writer.setEncoding("UTF-8");
       
        // write some content - this API allows streaming and direct loading,
        // but for now we'll just upload a string
        // The writer, being updating, will take care of updating the node once the stream
        // closes.
        String content = "The quick brown fox jumps over the lazy dog";
        writer.putContent(content);
       
        // dump the content to a file
        File file = TempFileProvider.createTempFile("sample", ".txt");
        ContentReader reader = contentService.getReader(fileRef, ContentModel.PROP_CONTENT);
        reader.getContent(file);
       
    }
}


It can be executed without any exception but I still do not see created nodes with the web application (I see them in mysql).

          Thanks for your help,

               Andre (Damn, I do not find the way to write a "&eacute;").

kevinr
Star Contributor
Star Contributor
Hi Andre,

Can you try changing the association you are using to create the folder under Company Home from this:

ContentModel.ASSOC_CHILDREN,

to this:

ContentModel.ASSOC_CONTAINS,

Does that work?

Kevin

anweber
Champ in-the-making
Champ in-the-making
Hi Kevin,

I have done this modification but I still have the same problem : I do not see created objects with the "webClient".

Modified code :

       // add a simple folder to the root node
        nodeProperties.clear();
        nodeProperties.put(ContentModel.PROP_NAME, "My First Folder");
        ChildAssociationRef assocRef = nodeService.createNode(
                rootNodeRef,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName(NAMESPACE, QName.createValidLocalName("My First Folder")),
                ContentModel.TYPE_FOLDER,
                nodeProperties);
        NodeRef folderRef = assocRef.getChildRef();


   Regards,

          Andre

rwetherall
Confirmed Champ
Confirmed Champ
Hi Kevin,

I have done this modification but I still have the same problem : I do not see created objects with the "webClient".

Modified code :

       // add a simple folder to the root node
        nodeProperties.clear();
        nodeProperties.put(ContentModel.PROP_NAME, "My First Folder");
        ChildAssociationRef assocRef = nodeService.createNode(
                rootNodeRef,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName(NAMESPACE, QName.createValidLocalName("My First Folder")),
                ContentModel.TYPE_FOLDER,
                nodeProperties);
        NodeRef folderRef = assocRef.getChildRef();


   Regards,

          Andre

Hi,

Looking at the code posted here it looks like you are creating the folder under the root node.  Try creating it under the company home node and you should see it in the client.

Cheers,
Roy

anweber
Champ in-the-making
Champ in-the-making
Thank you very much Roy.  It works!  Sorry for the last error (for my tests, I made a copy of the "SimpleExampleWithContent.java"; it becames "MySimpleExampleWithContent.java".  Then I have done the last modification in the wrong class and sent you an extract of it).  It's stupid : I am confused to have bothered you with that!

    Regards,

           Andre

PS : For information the resulting method is :

    private static void doExample(ServiceRegistry serviceRegistry) throws Exception
    {
        // get individual, required services
        NodeService nodeService = serviceRegistry.getNodeService();
        ContentService contentService = serviceRegistry.getContentService();

        // authenticate
        AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
        authenticationService.authenticate("admin", "admin".toCharArray());
       
        // get the store
        StoreRef storeRef = new StoreRef(
                StoreRef.PROTOCOL_WORKSPACE,
                "SpacesStore"
                );
        if (!nodeService.exists(storeRef))
        {
            return;
        }
       
        // get the Company Home node from which to hang the next level of nodes
        NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
        List<ChildAssociationRef> rootChildren = nodeService.getChildAssocs(rootNodeRef);
        int nbRootChildren = rootChildren.size();
        int iRootChild;
        NodeRef rootChild = null;
        NodeRef companyHomeNode = null;
        String nodeId;
        for (iRootChild=0; iRootChild < nbRootChildren; iRootChild++){
           rootChild = rootChildren.get(iRootChild).getChildRef();
           nodeId = rootChild.getId();
          System.out.println(nodeId);
          Serializable prop = nodeService.getProperty(rootChild,ContentModel.PROP_NAME);
          System.out.println("|" + prop.toString() + "|");
             if ("Company Home".equals(prop.toString())){
                 companyHomeNode = rootChild;
                 break;
           }
        }
        if (companyHomeNode == null)return;
       
        Map<QName, Serializable> nodeProperties = new HashMap<QName, Serializable>(7);
       
        // add a simple folder to the "Company Home" node
        nodeProperties.clear();
        nodeProperties.put(ContentModel.PROP_NAME, "My First Folder");
        nodeProperties.put(ContentModel.PROP_TITLE,"My First Folder");
        ChildAssociationRef assocRef = nodeService.createNode(
              companyHomeNode,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName(NAMESPACE, QName.createValidLocalName("My First Folder")),
                ContentModel.TYPE_FOLDER,
                nodeProperties);
        NodeRef folderRef = assocRef.getChildRef();
       
        // create a file
        nodeProperties.clear();
        nodeProperties.put(ContentModel.PROP_NAME, "My First File");
        assocRef = nodeService.createNode(
                folderRef,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName(NAMESPACE, QName.createValidLocalName("My First File")),
                ContentModel.TYPE_CONTENT,
                nodeProperties);
        NodeRef fileRef = assocRef.getChildRef();
       
        ContentWriter writer = contentService.getWriter(fileRef, ContentModel.PROP_CONTENT, true);
        // the mimetype will up pushed onto the node automatically once the stream closes
        writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        // store string content as UTF-8
        writer.setEncoding("UTF-8");
       
        // write some content - this API allows streaming and direct loading,
        // but for now we'll just upload a string
        // The writer, being updating, will take care of updating the node once the stream
        // closes.
        String content = "The quick brown fox jumps over the lazy dog";
        writer.putContent(content);
       
        // dump the content to a file
        File file = TempFileProvider.createTempFile("sample", ".txt");
        ContentReader reader = contentService.getReader(fileRef, ContentModel.PROP_CONTENT);
        reader.getContent(file);
       
    }

kevinr
Star Contributor
Star Contributor
Glad to hear it's working now! Smiley Happy FYI if you put
[code]
tags around your code when you paste it into a forum message it's much easier for us to read (i've edited your post as an example! Smiley Happy )

Thanks,

Kevin