mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
OpenSearch
- improve logging - support for specifying search locale - fix some minor authentication issues git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4713 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -68,43 +68,45 @@ public class APIServlet extends BaseServlet
|
||||
*/
|
||||
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
APIRequest request = new APIRequest(req);
|
||||
APIResponse response = new APIResponse(res);
|
||||
|
||||
//
|
||||
// Execute appropriate service
|
||||
//
|
||||
// TODO: Handle errors (with appropriate HTTP error responses)
|
||||
|
||||
APIRequest.HttpMethod method = request.getHttpMethod();
|
||||
String uri = request.getPathInfo();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Processing request (" + request.getHttpMethod() + ") " + request.getRequestURL() + (request.getQueryString() != null ? "?" + request.getQueryString() : ""));
|
||||
|
||||
APIService service = apiServiceRegistry.get(method, uri);
|
||||
if (service != null)
|
||||
try
|
||||
{
|
||||
//
|
||||
// Execute appropriate service
|
||||
//
|
||||
// TODO: Handle errors (with appropriate HTTP error responses)
|
||||
|
||||
APIRequest.HttpMethod method = request.getHttpMethod();
|
||||
String uri = request.getPathInfo();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Mapped to service " + service.getName());
|
||||
logger.debug("Processing request (" + request.getHttpMethod() + ") " + request.getRequestURL() + (request.getQueryString() != null ? "?" + request.getQueryString() : ""));
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
service.execute(request, response);
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Service " + service.getName() + " executed in " + (end - start) + "ms");
|
||||
APIService service = apiServiceRegistry.get(method, uri);
|
||||
if (service != null)
|
||||
{
|
||||
// TODO: Wrap in single transaction
|
||||
service.execute(request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Request does not map to service.");
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
// TODO: add appropriate error detail
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Request does not map to service.");
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
// TODO: add appropriate error detail
|
||||
}
|
||||
|
||||
// TODO: exception handling
|
||||
finally
|
||||
{
|
||||
long end = System.currentTimeMillis();
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Processed request (" + request.getHttpMethod() + ") " + request.getRequestURL() + (request.getQueryString() != null ? "?" + request.getQueryString() : "") + " in " + (end - start) + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user