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
This commit is contained in:
Alex Mukha
2014-09-26 08:30:15 +00:00
parent 827140a35d
commit 10f1d71f6e
2 changed files with 48 additions and 17 deletions

View File

@@ -57,7 +57,6 @@ public class CMISHttpServletRequest implements HttpServletRequest
protected WebScriptRequest req; protected WebScriptRequest req;
protected HttpServletRequest httpReq; protected HttpServletRequest httpReq;
protected String networkId; protected String networkId;
protected String repositoryId;
protected String operation; protected String operation;
protected String id; // object id (or path for browser binding) protected String id; // object id (or path for browser binding)
protected String serviceName; protected String serviceName;
@@ -80,14 +79,8 @@ public class CMISHttpServletRequest implements HttpServletRequest
this.networkId = servletReq.getTenant(); this.networkId = servletReq.getTenant();
if(TenantUtil.DEFAULT_TENANT.equals(this.networkId) || TenantUtil.SYSTEM_TENANT.equals(this.networkId)) 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(); Match match = req.getServiceMatch();
@@ -117,9 +110,9 @@ public class CMISHttpServletRequest implements HttpServletRequest
protected void addAttributes() 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); httpReq.setAttribute("serviceName", serviceName);
} }
@@ -129,7 +122,7 @@ public class CMISHttpServletRequest implements HttpServletRequest
{ {
if(arg0.equals(Dispatcher.BASE_URL_ATTRIBUTE)) if(arg0.equals(Dispatcher.BASE_URL_ATTRIBUTE))
{ {
return baseUrlGenerator.getBaseUrl(this, repositoryId, binding); return baseUrlGenerator.getBaseUrl(this, networkId, binding);
} }
else else
{ {
@@ -223,7 +216,7 @@ public class CMISHttpServletRequest implements HttpServletRequest
{ {
if(arg0.equals(Constants.PARAM_REPOSITORY_ID)) if(arg0.equals(Constants.PARAM_REPOSITORY_ID))
{ {
return repositoryId; return networkId;
} }
return httpReq.getParameter(arg0); return httpReq.getParameter(arg0);
} }
@@ -234,9 +227,9 @@ public class CMISHttpServletRequest implements HttpServletRequest
{ {
Map map = httpReq.getParameterMap(); Map map = httpReq.getParameterMap();
Map ret = new HashedMap(map); 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; return ret;
} }
@@ -251,7 +244,7 @@ public class CMISHttpServletRequest implements HttpServletRequest
{ {
l.add(e.nextElement()); l.add(e.nextElement());
} }
if(repositoryId != null) if(networkId != null)
{ {
l.add(Constants.PARAM_REPOSITORY_ID); l.add(Constants.PARAM_REPOSITORY_ID);
} }
@@ -442,7 +435,28 @@ public class CMISHttpServletRequest implements HttpServletRequest
@Override @Override
public String getQueryString() 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 @Override

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2012 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * 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 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_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 = "{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 static final String ATOM_PUB_URL = "{0}://{1}:{2}{3}cmisatom";
private String scheme = "http"; private String scheme = "http";
@@ -164,6 +165,22 @@ public class PublicApiHttpClient
return url.toString(); 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) public void setHost(String host)
{ {
this.host = host; this.host = host;