AnsweredAssumed Answered

Trouble creating associations with Alfresco WS

Question asked by isanalon on Aug 21, 2007
The following code is not working for me. Everything works fine until the line "WebServiceFactory.getRepositoryService().update(cml2);" is reached.


private void creaAsociaciones(Reference referFrom,Reference[] referesTo,String type)
       {       
            System.out.println("CreaAsociaciones");
            Predicate pred = new Predicate();
            Reference[] ref2 = new Reference[] { referFrom };
            pred.setNodes(ref2);
            pred.setStore(store);

            for (int i = 0; i < referesTo.length; i++) {
                Predicate pred2 = new Predicate();
                Reference[] ref3 = new Reference[] { referesTo[i] };
                pred2.setNodes(ref3);
                pred2.setStore(store);
                CMLCreateAssociation createAssoc = new CMLCreateAssociation(pred,null,pred2,null,type);
                CML cml2 = new CML();
                cml2.setCreateAssociation(new CMLCreateAssociation[] { createAssoc });
                try{
                    WebServiceFactory.getRepositoryService().update(cml2);
                } catch(Exception e) {System.out.println("Excepción en creaAsociaciones: "+e.getMessage());} //java.rmi.remoteException
            }
        } 

I think that the params that this method receives are correctly defined:


Reference refClausulaAsociada = new Reference(store,id_clausulaAsociacion,null); 
            Reference[] refNuevoTextoAsociadoClausula = new Reference[] { newDocumentNode };         
            String tipoAsociacion = "{my.new.model}TextosC";
creaAsociaciones(refClausulaAsociada,refNuevoTextoAsociadoClausula,tipoAsociacion);

I have debugged and no param is null.
One of the nodes I'm trying to associate is a new node I just created. Do I need to set any property of the node in order for it to be associated with another? Could that be the problem?

PLEASE HELP, I've been dealing quite a long time with this issue.

PS. I'm working with a relase of Alfresco previous to 2.0 I hope I don't have to deal with changing versions (I've already tried that and I got more problems than solutions) just to solve this little issue.

Outcomes