[ 
https://issues.apache.org/jira/browse/CMIS-483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13164210#comment-13164210
 ] 

Marco Spasiano commented on CMIS-483:
-------------------------------------

Because if you try this code you have got an error

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
import 
org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;

public class TestEncoding {

        /**
         * @param args
         */
        public static void main(String[] args) {
                SessionFactory f = SessionFactoryImpl.newInstance();
                Map<String, String> parameter = new HashMap<String, String>();
                parameter.put(SessionParameter.USER, "admin");
                parameter.put(SessionParameter.PASSWORD, "admin");
                parameter.put(SessionParameter.ATOMPUB_URL, 
"http://cmis.alfresco.com/service/cmis";);
                parameter.put(SessionParameter.BINDING_TYPE, 
BindingType.ATOMPUB.value());
                parameter.put(SessionParameter.REPOSITORY_ID, 
f.getRepositories(parameter).get(0).getId());
                Session session = f.createSession(parameter);
                try{
                        Folder parent = (Folder) 
session.getObjectByPath("/_____a_marco");
                        try{
                                Folder newFolder = 
(Folder)session.getObjectByPath("/_____a_marco/carrè carla");
                                newFolder.deleteTree(true, null, true);
                        }catch (CmisObjectNotFoundException e) {
                                Map<String, Serializable> properties = new 
HashMap<String, Serializable>();
                                properties.put(PropertyIds.OBJECT_TYPE_ID,
                                                BaseTypeId.CMIS_FOLDER.value());
                                properties.put(PropertyIds.NAME, "carrè carla");
                                parent.createFolder(properties);
                                session.getObjectByPath("/_____a_marco/carrè 
carla");
                        }
                }catch (CmisBaseException e) {
                        e.printStackTrace();
                        System.err.println(e.getErrorContent());
                }               
        }

}
                
> URLEncoder for getObjectByPath with folder name like CARÈ CARLA
> ---------------------------------------------------------------
>
>                 Key: CMIS-483
>                 URL: https://issues.apache.org/jira/browse/CMIS-483
>             Project: Chemistry
>          Issue Type: Bug
>          Components: opencmis-client-bindings
>    Affects Versions: OpenCMIS 0.5.0
>            Reporter: Marco Spasiano
>              Labels: patch
>
> What do you think about this patch?
> {noformat}
> ### Eclipse Workspace Patch 1.0
> #P chemistry-opencmis-client-bindings
> Index: 
> src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
> ===================================================================
> --- 
> src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
>     (revisione 1124118)
> +++ 
> src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
>     (copia locale)
> @@ -68,6 +68,7 @@
>      private final Cache templateCache;
>      private final Cache repositoryLinkCache;
>  
> +    private final String encoding;
>      /**
>       * Constructor.
>       */
> @@ -87,6 +88,8 @@
>              objCount = CACHE_SIZE_OBJECTS;
>          }
>  
> +        encoding = (String) session.get(SessionParameter.LOCALE_VARIANT, 
> "UTF-8");
> +        
>          linkCache = new CacheImpl("Link Cache");
>          linkCache.initialize(new String[] {
>                  MapCacheLevelImpl.class.getName() + " " + 
> MapCacheLevelImpl.CAPACITY + "=" + repCount, // repository
> @@ -257,7 +260,7 @@
>                      String paramValue = 
> UrlBuilder.normalizeParameter(parameters.get(param.toString()));
>                      if (paramValue != null) {
>                          try {
> -                            result.append(URLEncoder.encode(paramValue, 
> "UTF-8"));
> +                            result.append(URLEncoder.encode(paramValue, 
> encoding));
>                          } catch (UnsupportedEncodingException e) {
>                              result.append(paramValue);
>                          }
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to