cancel
Showing results for 
Search instead for 
Did you mean: 

Create a file in the repository: exception during update

sergio
Champ in-the-making
Champ in-the-making
Hi all.

I am not able to find the error in my code. The task is very simple: creating a file inside a node.

Here the code:

private void wsCreateNewContent(String nodeId)
   {
      String storeSchema = Constants.WORKSPACE_STORE;
     String storeAddress = "SpacesStore";
     final Store STORE = new Store(storeSchema, storeAddress);
     
     ParentReference parentRef = new ParentReference();
    parentRef.setStore(STORE);
    parentRef.setUuid("14c29a12-7be0-11db-83b6-f5ef9685f99e");
    parentRef.setAssociationType(Constants.ASSOC_CHILDREN);
    parentRef.setChildName(Constants.ASSOC_CHILDREN);
   
    CMLCreate create = new CMLCreate();
    create.setId("1");
    create.setParent(parentRef);
    create.setType(Constants.TYPE_CONTENT);
    NamedValue[] nv = new NamedValue[1];
    NamedValue n = new NamedValue(Constants.PROP_NAME, false, "readme.txt", null);
    nv[0] = n;
    create.setProperty(nv);
   
    CML cml = new CML();
    cml.setCreate(new CMLCreate[]{create});
    try
    {
         UpdateResult[] result = repositoryService.update(cml);
      }
    catch (RepositoryFault e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
    catch (RemoteException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }    
   } 

Please, could anyone help me in findind the problem. The code is apparently the same as the code provided with the testContentService() method for the ContentServiseSystemTest class from the SDK, but mine does not work.

Many thanks to all in advance.

All the best,

Sergio
1 REPLY 1

sergio
Champ in-the-making
Champ in-the-making
I solved the problem.

Instead of

parentRef.setAssociationType(Constants.ASSOC_CHILDREN);
parentRef.setChildName(Constants.ASSOC_CHILDREN);


it had to be used

parentRef.setAssociationType(Constants.ASSOC_CONTAINS);
parentRef.setChildName(Constants.ASSOC_CONTAINS);


But now my question is: in what caese should the ASSOC_CONTAINS values be used?

Sorry, but the documentation of WS APIs is not so clear and sometimes the examples are useful but not completely explained from the model  point of view.

Many thanks to everyone.

All the best,

Sergio