AnsweredAssumed Answered

Create multilingual container

Question asked by dcmg on Dec 5, 2010
Im using Alfresco 3.3 and Im trying to add a translation to an existing multilanguage content document of a custom type with just some new properties. All works fine using alfresco web ui "Add Translation" button, but I need to do the same using Web Services.

First I create a multilanguage document with a locale using Web Services, when I go to Alfresco UI all seems to be ok, only delete icon of the document is dissapeared. When Im traying to view the details or view Multilingual Content Info of the document I errors like this:

javax.faces.FacesException: org.apache.jasper.JasperException: javax.faces.el.EvaluationException: Cannot get value for expression '#{DialogManager.bean.documentMlContainer}'
caused by:
org.apache.jasper.JasperException: org.apache.jasper.JasperException: javax.faces.el.EvaluationException: Cannot get value for expression '#{DialogManager.bean.documentMlContainer}'
caused by:
org.apache.jasper.JasperException: javax.faces.el.EvaluationException: Cannot get value for expression '#{DialogManager.bean.documentMlContainer}'
caused by:
javax.faces.el.EvaluationException: Cannot get value for expression '#{DialogManager.bean.documentMlContainer}'
caused by:
javax.faces.el.EvaluationException: Exception getting value of property documentMlContainer of base of type : org.alfresco.web.bean.content.DocumentDetailsDialog
caused by:
javax.faces.el.EvaluationException: Bean: org.alfresco.web.bean.content.DocumentDetailsDialog, property: documentMlContainer
caused by:
java.lang.reflect.InvocationTargetException
caused by:
org.alfresco.error.AlfrescoRuntimeException: 11040026 No multilingual container exists for document node: workspace://SpacesStore/12b9dcba-e761-467d-a105-19dbb31f8e3d

Due to this errors I figure out that I need to create mlContainer for the documents.
I know that something is wrong. I get an error when I try to execute the first WebServiceFactory.getRepositoryService().update(cml) to create the mlContainer

This is my code to create the mlContainer

        ParentReference parentReference = new ParentReference(this.spacesStore, idPadre, null, Constants.ASSOC_CONTAINS, Constants.ASSOC_CONTAINS);
     
        String qname = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "mlContainer");
       
        CMLCreate create = new CMLCreate("1", parentReference, "2", Constants.ASSOC_CHILDREN, qname, qname, null);
        CML cml = new CML();
        cml.setCreate(new CMLCreate[]{create});
        UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
       
        CMLAddAspect aspect = new CMLAddAspect();
        aspect.setAspect(Constants.ASPECT_VERSIONABLE);
        aspect.setWhere(new Predicate(new Reference[]{results[0].getDestination()},   this.spacesStore, null));
       
       cml = new CML();
        cml.setAddAspect(new CMLAddAspect[]{aspect});
        results = WebServiceFactory.getRepositoryService().update(cml);
       
        Reference reference = results[0].getDestination();
   Predicate predicate = new Predicate(new Reference[]{reference}, this.spacesStore, null);
   
   ParentReference target = new ParentReference();
   target.setStore(this.spacesStore);
   target.setPath(reference.getPath());
   target.setPath(reference.getUuid());
   target.setAssociationType(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "mlChild"));
   target.setChildName(target.getAssociationType());
      
   CMLAddChild addChild = new CMLAddChild(target, idOriginal, target.getAssociationType(), target.getAssociationType(), predicate, idNodo);
      
   cml = new CML();
   cml.setAddChild(new CMLAddChild[]{addChild});
   results = WebServiceFactory.getRepositoryService().update(cml);

Im got this error:

org.alfresco.repo.node.integrity.IntegrityException: 11040027 Found 1 integrity violations:
The association child multiplicity has been violated:
   Source Node: workspace://SpacesStore/3c1670d5-6001-4f31-931b-fb3729a1f135
   Association: Association[ class=ClassDef[name={http://www.alfresco.org/model/content/1.0}mlContainer], name={http://www.alfresco.org/model/content/1.0}mlChild, target class={http://www.alfresco.org/model/content/1.0}mlDocument, source role=null, target role=null]
   Required child Multiplicity: 1..*
   Actual child Multiplicity: 0

can anyone help on this?
Im using Alfresco 3.3

Outcomes