mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
127571 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 126242 gjames: RA-878:All api errors should return the standard error object git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127665 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,27 +25,29 @@
|
||||
*/
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.repo.web.scripts.TenantWebScriptServletRuntime;
|
||||
import org.alfresco.rest.framework.tools.ApiAssistant;
|
||||
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.*;
|
||||
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]+/.*");
|
||||
|
||||
private ApiAssistant apiAssistant;
|
||||
|
||||
public PublicApiTenantWebScriptServletRuntime(RuntimeContainer container, ServletAuthenticatorFactory authFactory, HttpServletRequest req,
|
||||
HttpServletResponse res, ServerProperties serverProperties)
|
||||
HttpServletResponse res, ServerProperties serverProperties, ApiAssistant apiAssistant)
|
||||
{
|
||||
super(container, authFactory, req, res, serverProperties);
|
||||
this.apiAssistant = apiAssistant;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -128,4 +130,24 @@ public class PublicApiTenantWebScriptServletRuntime extends TenantWebScriptServl
|
||||
{
|
||||
return "PublicApiTenantServletRuntime";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderErrorResponse(Match match, Throwable exception, WebScriptRequest request, WebScriptResponse response) {
|
||||
|
||||
//If its cmis or not an exception then use the default behaviour
|
||||
if (CMIS_URI_PATTERN.matcher(req.getRequestURI()).matches() || !(exception instanceof Exception))
|
||||
{
|
||||
super.renderErrorResponse(match, exception, request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
apiAssistant.renderException((Exception)exception, response);
|
||||
} catch (IOException e) {
|
||||
logger.error("Internal error", e);
|
||||
throw new WebScriptException("Internal error", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user