How to set charset in Apache Chemistry CMIS API?

2019-07-14 20:26发布

问题:

I'm trying to get a folder ID by path like:

Folder folder = (Folder) getCmisSession().getObjectByPath(folderPath);

and the path that I'm requesting is:

/SIGAP/2011/DIRECCIÓN GENERAL DE PRUEBAS/SIN EXPEDIENTE/2010001231

and as you can see there's a special character Ó in the string,

the error that throws chemistry is:

STACK TRACE:
org.cmis.ws.CmisException: Not found an object for the specific path: /SIGAP/2011/DIRECCIÃ?N GENERAL DE PRUEBAS/OFICIOS
    at com.emc.documentum.fs.cmis.impl.dfs.utils.CmisExceptionFactory.create(CmisExceptionFactory.java:24)
    at com.emc.documentum.fs.cmis.impl.dfs.utils.CmisExceptionBuilder.build(CmisExceptionBuilder.java:31)
    at com.emc.documentum.fs.cmis.impl.dfs.action.GetObjectByPathAction.getNonCabinetObjectByPath(GetObjectByPathAction.java:170)

it changes the string from DIRECCIÓN to DIRECCIÃ?N,

how can I set to the session the charset to be utf-8? or how do I have to encode the path?

Update 1:

as @FlorianMüller sugested, with help of SoapUI, I try requesting the same folder by path like this:

 <soapenv:Body>
      <ns:getObjectByPath>
         <ns:repositoryId>LHD_ECM</ns:repositoryId>
         <ns:path>/SIGAP/2011/DIRECCIÓN GENERAL DE PRUEBAS/SIN EXPEDIENTE/2010001231</ns:path>
      </ns:getObjectByPath>
   </soapenv:Body>

and got the server got it rigth:

<S:Body>
      <ns2:getObjectByPathResponse xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:ns2="http://docs.oasis-open.org/ns/cmis/messaging/200908/">
         <ns2:object>
            <properties>
               <propertyString queryName="cmis:name" displayName="Name" localName="object_name" propertyDefinitionId="cmis:name">
                  <value>2010001231</value>
               </propertyString>
               <propertyId queryName="cmis:objectTypeId" displayName="Object Type ID" localName="r_object_type" propertyDefinitionId="cmis:objectTypeId">
                  <value>sigapfolio</value>
               </propertyId>
               <propertyId queryName="cmis:baseTypeId" displayName="Base Type Id" localName="" propertyDefinitionId="cmis:baseTypeId">
                  <value>cmis:folder</value>
               </propertyId>
               <propertyId queryName="cmis:objectId" displayName="Object Id" localName="r_object_id" propertyDefinitionId="cmis:objectId">
                  <value>0b00020280080815</value>
               </propertyId>
               <propertyString queryName="cmis:createdBy" displayName="Created By" localName="r_creator_name" propertyDefinitionId="cmis:createdBy">
                  <value>dmadmin</value>
               </propertyString>
               <propertyDateTime queryName="cmis:creationDate" displayName="Creation Date" localName="r_creation_date" propertyDefinitionId="cmis:creationDate">
                  <value>2016-04-05T04:54:44.000-05:00</value>
               </propertyDateTime>
               <propertyString queryName="cmis:lastModifiedBy" displayName="Last Modified By" localName="r_modifier" propertyDefinitionId="cmis:lastModifiedBy">
                  <value>dmadmin</value>
               </propertyString>
               <propertyDateTime queryName="cmis:lastModificationDate" displayName="Last Modification Date" localName="r_modify_date" propertyDefinitionId="cmis:lastModificationDate">
                  <value>2016-04-05T04:54:44.000-05:00</value>
               </propertyDateTime>
               <propertyString queryName="cmis:changeToken" displayName="Change Token" localName="i_vstamp" propertyDefinitionId="cmis:changeToken">
                  <value>1</value>
               </propertyString>
               <propertyId queryName="cmis:parentId" displayName="Parent Id" localName="i_folder_id" propertyDefinitionId="cmis:parentId">
                  <value>0b00020280005a3b</value>
               </propertyId>
               <propertyString queryName="cmis:path" displayName="Folder Path" localName="r_folder_path" propertyDefinitionId="cmis:path">
                  <value>/SIGAP/2011/DIRECCIÓN GENERAL DE PRUEBAS/SIN EXPEDIENTE/2010001231</value>
               </propertyString>
               <propertyId queryName="cmis:allowedChildObjectTypeIds" displayName="Allowed Child Object Type IDs" localName="" propertyDefinitionId="cmis:allowedChildObjectTypeIds">
                  <value>cmis:folder</value>
                  <value>cmis:document</value>
               </propertyId>
            </properties>
         </ns2:object>
      </ns2:getObjectByPathResponse>
   </S:Body>
</S:Envelope>

so it's definitly something wrong with Apache Chemistry :(

回答1:

So the problem IS the binding, switch from AtomPub to Webservices and the problem went away.

parameter.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());