cancel
Showing results for 
Search instead for 
Did you mean: 

problem with NamedValue class(urgent)

pitti
Champ in-the-making
Champ in-the-making
Hi
         NamedValue class takes the properties name and value in string type.How can i use this class with all the types that are supported by the alfresco model
        How to store the date , int and other types without any parsing problems.


Help need immidietely
    Thanks in advance
3 REPLIES 3

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

All the property values are passed as strings and should be automatically converted back to the correct Alfresco recognised type before the value is stored on the server.

I'll add a unit test that shows this working, so it can be posted as an example here and will also serve to flush any issues out.

I'll get back to you,
Roy

pitti
Champ in-the-making
Champ in-the-making
Thank you very much
          waiting for your example

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Sorry it has taken so long to get back to about this.

When I tested setting various properties of different types via the web services it became evident there was a bug.

This has been fixed and the snipit below shows how different values can be set (Note:  this example can be found in RepositoryServiceSystemTest.java)



            // Now we can try and set all the various different types of properties
            NamedValue[] properties = new NamedValue[]{
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "textProp"), "some text"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "intProp"), "12"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "longProp"), "1234567890"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "floatProp"), "12.345"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "doubleProp"), "12.345"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "dateProp"), "2005-09-16T00:00:00.000+00:00"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "datetimeProp"), "2005-09-16T17:01:03.456+01:00"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "booleanProp"), "false"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "qnameProp"), "{http://www.alfresco.org/model/webservicetestmodel/1.0}testProperties"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "noderefProp"), "workspace://SpacesStore/123123123"),
                    Utils.createNamedValue(Constants.createQNameString("http://www.alfresco.org/model/webservicetestmodel/1.0", "textMultiProp"), new String[] {"firstValue", "secondValue", "thirdValue"}),                   
            };
            CMLUpdate cmlUpdate = new CMLUpdate(properties, new Predicate(new Reference[]{reference}, null, null), null);
            cml = new CML();
            cml.setUpdate(new CMLUpdate[]{cmlUpdate});
            WebServiceFactory.getRepositoryService().update(cml);


This example uses a custom model and the createNamedValue method is available in a Utils class.

Cheers,
Roy