cancel
Showing results for 
Search instead for 
Did you mean: 

setting createFolder properties - Axis2 client

nikes
Champ on-the-rise
Champ on-the-rise
Dear friends,

I have developed Apache Axis2 client (ADB binding stubs) to talk to Alfresco using CMIS API.
I am able to fetch information from repository.

Now I am trying to create folder, document in alfresco, but dont know how to set properties for that.

Can anyone guide me for creating properties object.

Here is my incomplete code.


package cmis;


import java.math.BigInteger;
import java.util.Iterator;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.databinding.types.xsd.QName;
import org.apache.axis2.jaxws.description.xml.handler.ObjectFactory;
import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub;
import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisPropertiesType;
import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisProperty;
import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisPropertyString;
import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CreateFolder;
import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CreateFolderResponse;


import com.sun.org.apache.bcel.internal.Constants;

public class ObjectClient {
   
    public static void main(String[] args) throws Exception
    {
  
        ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("D:\\Softwares\\axis2-1.5.1-bin\\axis2-1.5.1\\repository","D:\\Softwares\\axis2-1.5.1-bin\\axis2-1.5.1\\repository\\modules\\client.axis2.xml");

        ObjectServiceStub stub = new ObjectServiceStub(ctx, "http://localhost:8080/alfresco/cmis/ObjectService");
      
        CreateFolder cf = new ObjectServiceStub.CreateFolder();
        cf.setRepositoryId("46f8b242-9f61-423b-b824-c6118f470f01");
        cf.setFolderId("workspace://SpacesStore/0fceb8de-fe45-439a-9ac4-30b32c7671e0");
       
        [b]// How to set property name and property values?[/b]
       
        CreateFolderResponse fr = stub.createFolder(cf);
          
    }//end main

}//end class

Thanks for any help.
6 REPLIES 6

rameshbelli
Champ in-the-making
Champ in-the-making
Hi Nikes,

This is how the properties are set

CmisPropertiesType docPropType = cf.addNewProperties();

CmisPropertyId docPropId1 = docPropType.addNewPropertyId();
docPropId1.addNewPropertyDefinitionId().setStringValue("cmisSmiley SurprisedbjectTypeId");
docPropId1.addValue("cmis:folder");
         
CmisPropertyId docPropId2 = docPropType.addNewPropertyId();
docPropId2.addNewPropertyDefinitionId().setStringValue("cmis:name");
docPropId2.addValue("whateverfoldername");
         
docPropType.setPropertyIdArray(new CmisPropertyId[]{docPropId1 , docPropId2});
cf.setProperties(propType);

Hope this helps,
Ramesh

rameshbelli
Champ in-the-making
Champ in-the-making
Sorry the last line should be

cf.setProperties(docPropType);

nikes
Champ on-the-rise
Champ on-the-rise
Hi Ramesh,

When I tried creating an object of CmisPropertiesType it doesnt have addNewProperties() method.

As in my previous code cf is and object of CreateFolder class.

I have generated stub classes from wsdl2java with ADB option.

CmisPropertiesType docPropType = cf.addNewProperties();

Thanks for any help.

nikes
Champ on-the-rise
Champ on-the-rise
I am still not getting how to set properties.

In my implementation CreateFolder class does not have addNewProperties() method.

Can any one guide me how to set property?

I have generated Axis2 stubs with ADB binding option.

Thanks for any help.

rameshbelli
Champ in-the-making
Champ in-the-making
Hi Nike, the code in my previous post was with Axis2 stub classes generated with xmlbeans as the binding.

This is just  a guidance to set the properties.

The properties should end up like this in the createFolder request.

<properties>
   <ns2Smiley TongueropertyId propertyDefinitionId="cmisSmiley SurprisedbjectTypeId">
       <ns2:value>cmis:folder</ns2:value>
   </ns2Smiley TongueropertyId>
   <ns2Smiley TongueropertyString propertyDefinitionId="cmis:name">
       <ns2:value>Your folder Name</ns2:value>
   </ns2Smiley TongueropertyString>
</properties>

Just try with this approach


ObjectServiceStub stub = new ObjectServiceStub(SERVICE_URL);

CreateFolder cf = new ObjectServiceStub.CreateFolder();

CmisPropertiesType  propsType = new ObjectServiceStub.CmisPropertiesType();

CmisPropertiesTypeChoice_type0 choiceType1 = new ObjectServiceStub.CmisPropertiesTypeChoice_type0();
CmisPropertiesTypeChoice_type0 choiceType2 = new ObjectServiceStub.CmisPropertiesTypeChoice_type0();


CmisPropertyId propId1 = new ObjectServiceStub.CmisPropertyId();
CmisPropertyString propId2 = new ObjectServiceStub.CmisPropertyString();


CmisPropertyDefinitionId propDefId1 = new ObjectServiceStub.CmisPropertyDefinitionId();
CmisChoiceIdType cIdType1 = new ObjectServiceStub.CmisChoiceIdType();
cIdType1.setValue("cmis:objectTypeId");

propDefId1.addDefaultValue(cIdType1);

propId1.setPropertyType(new EnumPropertyType.fromString("id");
propId1.setValue("cmis:folder");

choiceType1.setPropertyDefinitionId(propDefId1); //Not sure about this
choiceType1.setPropertyId(propId1);


CmisPropertyDefinitionId propDefId2 = new ObjectServiceStub.CmisPropertyDefinitionId();
CmisChoiceIdType cIdType2 = new ObjectServiceStub.CmisChoiceIdType();
cIdType2.setValue("cmis:name");

propDefId2.addDefaultValue(cIdType2);

propId2.setPropertyType(new EnumPropertyType.fromString("string");
propId2.setValue("YourFolderName");

choiceType2.setPropertyDefinitionId(propDefId2); //Not sure about this
choiceType2.setPropertyString(propId2);

propsType.setCmisPropertiesTypeChoice_type0(new CmisPropertiesTypeChoice_type0[]{ choiceType1 ,choiceType2});

cf.setRepositoryId("YourRepositoryId");
cf.setFolderId("YourFolderId");
cf.setProperties(propsType);

CreateFolderResponse resp = stub.createFolder(cf);


Hope this helps

Ramesh

nikes
Champ on-the-rise
Champ on-the-rise
I executed createFolder using XmlBeans binding, but still struggling with ADB binding since all other modules are
written usind ADB.

It would really a great help if you can try setting property using ADB binding and share your experience.

Thanks for any help.