AnsweredAssumed Answered

[help] added forum data by web service, but can not view

Question asked by leon on Apr 13, 2006
Latest reply on Apr 14, 2006 by leon
I use web service to add data to Alfresco as post of a topic in forum of a Node. there is sth unusal in the server, and I can not view the topic in the web client-UI of Alfresco
but I can not check where is  the error.
   the following section is some message of my application .I sincincely request your help…

server console prompts :

message when add the Node:

16:56:14,484 WARN  [org.alfresco.repo.node.integrity.IntegrityChecker] Found 1 integrity violations:
  The association child multiplicity has been violated:
   Association: Association[ class=ClassDef [ name={http://www.alfresco.org/model/forum/1.0}discussable], name={http://www.alfresco.org/model/forum/1.0}discussion, target class={http://www.alfresco.org/model/forum/1.0}forum, source role=null, target role=null]
   Required child Multiplicity: 1..1
   Actual child Multiplicity: 0
   AssocTypeQName = {http://www.alfresco.org/model/forum/1.0}discussion
   sourceNodeRef = 4c5b13ad-cacb-11da-95ba-993a183228c0
 

message when view in web client:

   javax.faces.el.EvaluationException: Exception while invoking expression #{ForumsBean.discuss}
   caused by:
   java.lang.IllegalStateException: Node has the discussable aspect but does not have 1 child, it has 0 children!


node structuct of
         Association association = new Association();
         association.setAssociationType(Constants.ASSOC_DISCUSSION);
         association.setDirection(AssociationDirectionEnum.target);
         children = repositoryService.queryAssociated(ref, new Association[] {association}); 
results is : 

   <?xml version="1.0" encoding="UTF-8" ?>
- <Node NodeType="{http://www.alfresco.org/model/content/1.0}content">
   - <Properties>
        <Property>modifier=admin</Property>
        <Property>editInline=true</Property>
        <Property>modified=2006-04-13T16:56:14.468+08:00</Property>
        <Property>description=</Property>
        <Property>node-uuid=4c5b13ad-cacb-11da-95ba-993a183228c0</Property>
        <Property>creator=admin</Property>
        <Property>store-protocol=workspace</Property>
        <Property>content=contentUrl=store://2006/4/13/16/4c623f9f-cacb-11da-95ba-993a183228c0.bin|mimetype=text/html|size=1318|encoding=UTF-8</Property>
        <Property>title=a.htm</Property>
        <Property>name=a.htm</Property>
        <Property>store-identifier=SpacesStore</Property>
        <Property>created=2006-04-13T16:55:46.921+08:00</Property>
     </Properties>
   - <Aspects>
        <Aspect>{http://www.alfresco.org/model/content/1.0}auditable</Aspect>
        <Aspect>{http://www.alfresco.org/model/content/1.0}titled</Aspect>
        <Aspect>{http://www.alfresco.org/model/system/1.0}referenceable</Aspect>
        <Aspect>{http://www.alfresco.org/model/forum/1.0}discussable</Aspect>
        <Aspect>{http://www.alfresco.org/model/application/1.0}inlineeditable</Aspect>
     </Aspects>
   - <Children>
      - <Node NodeType="{http://www.alfresco.org/model/forum/1.0}forum">
         - <Properties>
              <Property>modifier=admin</Property>
              <Property>modified=2006-04-13T16:56:16.187+08:00</Property>
              <Property>icon=forum_large</Property>
              <Property>node-uuid=5c3c04c6-cacb-11da-95ba-993a183228c0</Property>
              <Property>creator=admin</Property>
              <Property>store-protocol=workspace</Property>
              <Property>name=update.html discussion</Property>
              <Property>store-identifier=SpacesStore</Property>
              <Property>created=2006-04-13T16:56:13.593+08:00</Property>
           </Properties>
         - <Aspects>
              <Aspect>{http://www.alfresco.org/model/content/1.0}auditable</Aspect>
              <Aspect>{http://www.alfresco.org/model/application/1.0}uifacets</Aspect>
              <Aspect>{http://www.alfresco.org/model/system/1.0}referenceable</Aspect>
           </Aspects>
        </Node>
     </Children>
  </Node>

java code is

   // uuid is the id of resource.
   public String post(String uuid, String author, String title, String content) {
      String child_uuid = null;
      try {
         Node node=getNode(uuid);
         if(!hasAspect(node,Constants.ASPECT_DISCUSSABLE)) {
            makeDiscussable(uuid,title);
         }
         
         // get topic uuid ,if does not exit, create a topic child node
         String topic_id = getOrCreateTopic(repositoryService, uuid, title);
         //add a content node for title and cotent
         child_uuid = post_helper(topic_id, author, title, content);

      } catch (Exception e) {
         e.printStackTrace();
      }
      return child_uuid;
   }
   
   public void makeDiscussable(String uuid, String title) {
      try {
         // add discussable aspect
         addAspect(repositoryService, Constants.ASPECT_DISCUSSABLE, null,
               uuid);
         // add forum
         String forum_id = WebServiceUtil.createNode(Constants.TYPE_FORUM,
               uuid, "admin", title + "  discussion", null).getUuid();
         
         // add association
         addDiscussionAssociation(uuid,forum_id);

         // add uifacets aspect
         NamedValue[] props = new NamedValue[] { new NamedValue(
               Constants.PROP_ICON, "forum_large") };
         addAspect(repositoryService, Constants.ASPECT_UIFACETS, props,
               forum_id);

      } catch (Exception e) {
         e.printStackTrace();
      }
   }
   
   public void addDiscussionAssociation(String uuid uuid, String forum_id) throws Exception {
      // add DISCUSSION association from Forum to Discussable Node
      CML cml = new CML();
      CMLCreateAssociation discusstion = new CMLCreateAssociation();
      discusstion.setAssociation(Constants.ASSOC_DISCUSSION);
      discusstion.setFrom(WebServiceUtil.createPredicate(uuid));
      discusstion.setTo(WebServiceUtil.createPredicate(forum_id));
      cml.setCreateAssociation(new CMLCreateAssociation[] { discusstion });

      UpdateResult[] updateResults = repositoryService.update(cml);
      if(updateResults!=null) {
         for(UpdateResult r:updateResults) {
            Reference source=r.getSource();
            Reference target=r.getDestination();
            System.out.println("source = " + source.getUuid());
            System.out.println("target = " + target.getUuid());
         }
      }
   }
   

Outcomes