From 10f1d71f6e4ed63e5da0c13fb8a7b0e52c0ce766 Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Fri, 26 Sep 2014 08:30:15 +0000 Subject: [PATCH] Merged DEV (5.0.0.BF) to HEAD (5.0/Cloud) 85527: ACE-2355 : Can't access sites' of Cloud networks other than 'alfresco.com' on Android mobile device with Alfresco mobile app Added repositoryId as an url parameter for CMIS requests. 85721: ACE-2355 : Can't access sites' of Cloud networks other than 'alfresco.com' on Android mobile device with Alfresco mobile app Implemented a test to simulate the issue. 85759: ACE-2355 : Can't access sites' of Cloud networks other than 'alfresco.com' on Android mobile device with Alfresco mobile app Extended the test to use both 1.0 and 1.1 end points. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85766 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../opencmis/CMISHttpServletRequest.java | 46 ++++++++++++------- .../api/tests/client/PublicApiHttpClient.java | 19 +++++++- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/source/java/org/alfresco/opencmis/CMISHttpServletRequest.java b/source/java/org/alfresco/opencmis/CMISHttpServletRequest.java index 0d911c3198..a60ec2bb7b 100644 --- a/source/java/org/alfresco/opencmis/CMISHttpServletRequest.java +++ b/source/java/org/alfresco/opencmis/CMISHttpServletRequest.java @@ -57,7 +57,6 @@ public class CMISHttpServletRequest implements HttpServletRequest protected WebScriptRequest req; protected HttpServletRequest httpReq; protected String networkId; - protected String repositoryId; protected String operation; protected String id; // object id (or path for browser binding) protected String serviceName; @@ -80,14 +79,8 @@ public class CMISHttpServletRequest implements HttpServletRequest this.networkId = servletReq.getTenant(); if(TenantUtil.DEFAULT_TENANT.equals(this.networkId) || TenantUtil.SYSTEM_TENANT.equals(this.networkId)) { - this.repositoryId = TenantService.DEFAULT_DOMAIN; + this.networkId = TenantService.DEFAULT_DOMAIN; } - -// if(TenantUtil.DEFAULT_TENANT.equals(this.repositoryId) || TenantUtil.SYSTEM_TENANT.equals(this.repositoryId)) -// { -//// this.repositoryId = currentDescriptor.getId()/*TenantUtil.getCurrentDomain()*/; -// this.repositoryId = TenantUtil.getCurrentDomain(); -// } } Match match = req.getServiceMatch(); @@ -117,9 +110,9 @@ public class CMISHttpServletRequest implements HttpServletRequest protected void addAttributes() { - if(repositoryId != null) + if(networkId != null) { - httpReq.setAttribute(Constants.PARAM_REPOSITORY_ID, repositoryId); + httpReq.setAttribute(Constants.PARAM_REPOSITORY_ID, networkId); } httpReq.setAttribute("serviceName", serviceName); } @@ -129,7 +122,7 @@ public class CMISHttpServletRequest implements HttpServletRequest { if(arg0.equals(Dispatcher.BASE_URL_ATTRIBUTE)) { - return baseUrlGenerator.getBaseUrl(this, repositoryId, binding); + return baseUrlGenerator.getBaseUrl(this, networkId, binding); } else { @@ -223,7 +216,7 @@ public class CMISHttpServletRequest implements HttpServletRequest { if(arg0.equals(Constants.PARAM_REPOSITORY_ID)) { - return repositoryId; + return networkId; } return httpReq.getParameter(arg0); } @@ -234,9 +227,9 @@ public class CMISHttpServletRequest implements HttpServletRequest { Map map = httpReq.getParameterMap(); Map ret = new HashedMap(map); - if(repositoryId != null) + if(networkId != null) { - ret.put(Constants.PARAM_REPOSITORY_ID, new String[] { repositoryId }); + ret.put(Constants.PARAM_REPOSITORY_ID, new String[] { networkId }); } return ret; } @@ -251,7 +244,7 @@ public class CMISHttpServletRequest implements HttpServletRequest { l.add(e.nextElement()); } - if(repositoryId != null) + if(networkId != null) { l.add(Constants.PARAM_REPOSITORY_ID); } @@ -442,7 +435,28 @@ public class CMISHttpServletRequest implements HttpServletRequest @Override public String getQueryString() { - return httpReq.getQueryString(); + StringBuilder queryString = new StringBuilder(); + String reqQueryString = httpReq.getQueryString(); + + if(networkId != null) + { + if (reqQueryString == null) + { + queryString.append("repositoryId="); + queryString.append(networkId); + } + else + { + queryString.append(reqQueryString); + queryString.append("&repositoryId="); + queryString.append(networkId); + } + return queryString.toString(); + } + else + { + return null; + } } @Override diff --git a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java index 274f98b87b..7c12a47906 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2012 Alfresco Software Limited. + * Copyright (C) 2005-2014 Alfresco Software Limited. * * This file is part of Alfresco * @@ -74,6 +74,7 @@ public class PublicApiHttpClient private static final String BASE_URL = "{0}://{1}:{2}{3}{4}{5}/{6}/{7}/versions/1"; private static final String PUBLICAPI_CMIS_SERVICE_URL = "{0}://{1}:{2}{3}{4}cmis/versions/{5}/{6}"; private static final String PUBLICAPI_CMIS_URL = "{0}://{1}:{2}{3}{4}{5}/{6}/cmis/versions/{7}/{8}"; + private static final String PUBLICAPI_CMIS_URL_SUFFIX = "{0}/{1}/cmis/versions/{2}/{3}"; private static final String ATOM_PUB_URL = "{0}://{1}:{2}{3}cmisatom"; private String scheme = "http"; @@ -163,6 +164,22 @@ public class PublicApiHttpClient return url.toString(); } + + public String getPublicApiCmisUrlSuffix(String networkId, Binding binding, String version, String operation) + { + StringBuilder url = new StringBuilder(); + + url.append(MessageFormat.format(PUBLICAPI_CMIS_URL_SUFFIX, + new Object[] {networkId, "public", version, binding.toString().toLowerCase()})); + + if(operation != null) + { + url.append("/"); + url.append(operation); + } + + return url.toString(); + } public void setHost(String host) {