* Dispatches to feed, entry or whatever.
*/
private void dispatch(CallContext context, HttpServletRequest request, HttpServletResponse response)
throws Exception {
CmisService service = null;
try {
// get services factory
CmisServiceFactory factory = (CmisServiceFactory) getServletContext().getAttribute(
CmisRepositoryContextListener.SERVICES_FACTORY);
if (factory == null) {
throw new CmisRuntimeException("Service factory not available! Configuration problem?");
}
// get the service
service = factory.getService(context);
// analyze the path
String[] pathFragments = HttpUtils.splitPath(request);
if (pathFragments.length < 2) {
// root -> service document
RepositoryService.getRepositories(context, service, request, response);
return;
}
String method = request.getMethod();
String repositoryId = pathFragments[0];
String resource = pathFragments[1];
// dispatch
boolean methodFound = dispatcher.dispatch(resource, method, context, service, repositoryId, request,
response);
// if the dispatcher couldn't find a matching method, return an
// error message
if (!methodFound) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Unknown operation");
}
} finally {
if (service != null) {
service.close();
}
}
}