mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,106 +1,106 @@
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.repo.web.scripts.TenantWebScriptServletRuntime;
|
||||
import org.springframework.extensions.config.ServerProperties;
|
||||
import org.springframework.extensions.surf.util.URLDecoder;
|
||||
import org.springframework.extensions.webscripts.Match;
|
||||
import org.springframework.extensions.webscripts.RuntimeContainer;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory;
|
||||
|
||||
public class PublicApiTenantWebScriptServletRuntime extends TenantWebScriptServletRuntime
|
||||
{
|
||||
private static final Pattern CMIS_URI_PATTERN = Pattern.compile(".*/cmis/versions/[0-9]+\\.[0-9]+/.*");
|
||||
|
||||
public PublicApiTenantWebScriptServletRuntime(RuntimeContainer container, ServletAuthenticatorFactory authFactory, HttpServletRequest req,
|
||||
HttpServletResponse res, ServerProperties serverProperties)
|
||||
{
|
||||
super(container, authFactory, req, res, serverProperties);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptRuntime#getScriptUrl()
|
||||
*/
|
||||
@Override
|
||||
protected String getScriptUrl()
|
||||
{
|
||||
// NOTE: Don't use req.getPathInfo() - it truncates the path at first semi-colon in Tomcat
|
||||
final String requestURI = req.getRequestURI();
|
||||
final String serviceContextPath = req.getContextPath() + req.getServletPath();
|
||||
String pathInfo;
|
||||
|
||||
if (serviceContextPath.length() > requestURI.length())
|
||||
{
|
||||
// NOTE: assume a redirect has taken place e.g. tomcat welcome-page
|
||||
// NOTE: this is unlikely, and we'll take the hit if the path contains a semi-colon
|
||||
pathInfo = req.getPathInfo();
|
||||
}
|
||||
// MNT-13057 fix, do not decode CMIS uris.
|
||||
else if (CMIS_URI_PATTERN.matcher(requestURI).matches())
|
||||
{
|
||||
pathInfo = requestURI.substring(serviceContextPath.length());
|
||||
}
|
||||
else
|
||||
{
|
||||
pathInfo = URLDecoder.decode(requestURI.substring(serviceContextPath.length()));
|
||||
}
|
||||
|
||||
// NOTE: must contain at least root / and single character for tenant name
|
||||
if (pathInfo.length() < 2 || pathInfo.equals("/"))
|
||||
{
|
||||
// url path has no tenant id -> get networks request
|
||||
pathInfo = PublicApiTenantWebScriptServletRequest.NETWORKS_PATH;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!pathInfo.substring(0, 6).toLowerCase().equals("/cmis/"))
|
||||
{
|
||||
// remove tenant
|
||||
int idx = pathInfo.indexOf('/', 1);
|
||||
pathInfo = pathInfo.substring(idx == -1 ? pathInfo.length() : idx);
|
||||
if(pathInfo.equals("") || pathInfo.equals("/"))
|
||||
{
|
||||
// url path is just a tenant id -> get network request
|
||||
pathInfo = PublicApiTenantWebScriptServletRequest.NETWORK_PATH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pathInfo;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptRuntime#createRequest(org.alfresco.web.scripts.WebScriptMatch)
|
||||
*/
|
||||
@Override
|
||||
protected WebScriptRequest createRequest(Match match)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// make the request input stream a BufferedInputStream so that the first x bytes can be reused.
|
||||
// PublicApiHttpServletRequest wrapped = new PublicApiHttpServletRequest(req);
|
||||
|
||||
// TODO: construct org.springframework.extensions.webscripts.servlet.WebScriptServletResponse when
|
||||
// org.alfresco.web.scripts.WebScriptServletResponse (deprecated) is removed
|
||||
servletReq = new PublicApiTenantWebScriptServletRequest(this, req, match, serverProperties);
|
||||
return servletReq;
|
||||
// }
|
||||
// catch(IOException e)
|
||||
// {
|
||||
// throw new AlfrescoRuntimeException("", e);
|
||||
// }
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptContainer#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return "PublicApiTenantServletRuntime";
|
||||
}
|
||||
}
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.repo.web.scripts.TenantWebScriptServletRuntime;
|
||||
import org.springframework.extensions.config.ServerProperties;
|
||||
import org.springframework.extensions.surf.util.URLDecoder;
|
||||
import org.springframework.extensions.webscripts.Match;
|
||||
import org.springframework.extensions.webscripts.RuntimeContainer;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory;
|
||||
|
||||
public class PublicApiTenantWebScriptServletRuntime extends TenantWebScriptServletRuntime
|
||||
{
|
||||
private static final Pattern CMIS_URI_PATTERN = Pattern.compile(".*/cmis/versions/[0-9]+\\.[0-9]+/.*");
|
||||
|
||||
public PublicApiTenantWebScriptServletRuntime(RuntimeContainer container, ServletAuthenticatorFactory authFactory, HttpServletRequest req,
|
||||
HttpServletResponse res, ServerProperties serverProperties)
|
||||
{
|
||||
super(container, authFactory, req, res, serverProperties);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptRuntime#getScriptUrl()
|
||||
*/
|
||||
@Override
|
||||
protected String getScriptUrl()
|
||||
{
|
||||
// NOTE: Don't use req.getPathInfo() - it truncates the path at first semi-colon in Tomcat
|
||||
final String requestURI = req.getRequestURI();
|
||||
final String serviceContextPath = req.getContextPath() + req.getServletPath();
|
||||
String pathInfo;
|
||||
|
||||
if (serviceContextPath.length() > requestURI.length())
|
||||
{
|
||||
// NOTE: assume a redirect has taken place e.g. tomcat welcome-page
|
||||
// NOTE: this is unlikely, and we'll take the hit if the path contains a semi-colon
|
||||
pathInfo = req.getPathInfo();
|
||||
}
|
||||
// MNT-13057 fix, do not decode CMIS uris.
|
||||
else if (CMIS_URI_PATTERN.matcher(requestURI).matches())
|
||||
{
|
||||
pathInfo = requestURI.substring(serviceContextPath.length());
|
||||
}
|
||||
else
|
||||
{
|
||||
pathInfo = URLDecoder.decode(requestURI.substring(serviceContextPath.length()));
|
||||
}
|
||||
|
||||
// NOTE: must contain at least root / and single character for tenant name
|
||||
if (pathInfo.length() < 2 || pathInfo.equals("/"))
|
||||
{
|
||||
// url path has no tenant id -> get networks request
|
||||
pathInfo = PublicApiTenantWebScriptServletRequest.NETWORKS_PATH;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!pathInfo.substring(0, 6).toLowerCase().equals("/cmis/"))
|
||||
{
|
||||
// remove tenant
|
||||
int idx = pathInfo.indexOf('/', 1);
|
||||
pathInfo = pathInfo.substring(idx == -1 ? pathInfo.length() : idx);
|
||||
if(pathInfo.equals("") || pathInfo.equals("/"))
|
||||
{
|
||||
// url path is just a tenant id -> get network request
|
||||
pathInfo = PublicApiTenantWebScriptServletRequest.NETWORK_PATH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pathInfo;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptRuntime#createRequest(org.alfresco.web.scripts.WebScriptMatch)
|
||||
*/
|
||||
@Override
|
||||
protected WebScriptRequest createRequest(Match match)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// make the request input stream a BufferedInputStream so that the first x bytes can be reused.
|
||||
// PublicApiHttpServletRequest wrapped = new PublicApiHttpServletRequest(req);
|
||||
|
||||
// TODO: construct org.springframework.extensions.webscripts.servlet.WebScriptServletResponse when
|
||||
// org.alfresco.web.scripts.WebScriptServletResponse (deprecated) is removed
|
||||
servletReq = new PublicApiTenantWebScriptServletRequest(this, req, match, serverProperties);
|
||||
return servletReq;
|
||||
// }
|
||||
// catch(IOException e)
|
||||
// {
|
||||
// throw new AlfrescoRuntimeException("", e);
|
||||
// }
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptContainer#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return "PublicApiTenantServletRuntime";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user