Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)

51903 to 54309 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Samuel Langlois
2013-08-20 17:17:31 +00:00
parent a91f6e2535
commit 788d3c9c89
777 changed files with 77820 additions and 23746 deletions

View File

@@ -38,6 +38,9 @@ import javax.servlet.http.HttpServletResponse;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.opencmis.CMISDispatcherRegistry.Binding;
import org.alfresco.opencmis.CMISDispatcherRegistry.Endpoint;
import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService;
import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
import org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet;
@@ -53,12 +56,25 @@ import org.springframework.extensions.webscripts.servlet.WebScriptServletRuntime
*/
public abstract class CMISServletDispatcher implements CMISDispatcher
{
private DescriptorService descriptorService;
private Descriptor currentDescriptor;
protected CmisServiceFactory cmisServiceFactory;
protected HttpServlet servlet;
protected CMISDispatcherRegistry registry;
protected String serviceName;
protected BaseUrlGenerator baseUrlGenerator;
protected String version;
public void setDescriptorService(DescriptorService descriptorService)
{
this.descriptorService = descriptorService;
}
public void setVersion(String version)
{
this.version = version;
}
public void setBaseUrlGenerator(BaseUrlGenerator baseUrlGenerator)
{
this.baseUrlGenerator = baseUrlGenerator;
@@ -83,6 +99,34 @@ public abstract class CMISServletDispatcher implements CMISDispatcher
{
return serviceName;
}
protected synchronized Descriptor getCurrentDescriptor()
{
if(this.currentDescriptor == null)
{
this.currentDescriptor = descriptorService.getCurrentRepositoryDescriptor();
}
return this.currentDescriptor;
}
public void init()
{
Endpoint endpoint = new Endpoint(getBinding(), version);
registry.registerDispatcher(endpoint, this);
try
{
// fake the CMIS servlet
ServletConfig config = getServletConfig();
this.servlet = getServlet();
servlet.init(config);
}
catch(ServletException e)
{
throw new AlfrescoRuntimeException("Failed to initialise CMIS servlet dispatcher", e);
}
}
/*
* Implement getBinding to provide the appropriate CMIS binding.
@@ -109,26 +153,11 @@ public abstract class CMISServletDispatcher implements CMISDispatcher
ServletConfig config = new CMISServletConfig();
return config;
}
public void init()
{
try
{
// fake the CMIS AtomPub servlet
ServletConfig config = getServletConfig();
this.servlet = getServlet();
servlet.init(config);
}
catch(ServletException e)
{
throw new AlfrescoRuntimeException("Failed to initialise CMIS webscript", e);
}
}
protected CMISHttpServletRequest getHttpRequest(WebScriptRequest req)
protected CMISHttpServletRequest getHttpRequest(WebScriptRequest req)
{
String serviceName = getServiceName();
CMISHttpServletRequest httpReqWrapper = new CMISHttpServletRequest(req, serviceName, baseUrlGenerator, getBinding());
CMISHttpServletRequest httpReqWrapper = new CMISHttpServletRequest(req, serviceName, baseUrlGenerator, getBinding(), currentDescriptor);
return httpReqWrapper;
}
@@ -138,8 +167,7 @@ public abstract class CMISServletDispatcher implements CMISDispatcher
{
HttpServletResponse httpResp = WebScriptServletRuntime.getHttpServletResponse(res);
// fake a servlet request. Note that getPathInfo is the only method that the servlet uses,
// hence the other methods are not implemented.
// fake a servlet request.
CMISHttpServletRequest httpReqWrapper = getHttpRequest(req);
servlet.service(httpReqWrapper, httpResp);
@@ -172,7 +200,11 @@ public abstract class CMISServletDispatcher implements CMISDispatcher
{
if(arg0.equals(CmisAtomPubServlet.PARAM_CALL_CONTEXT_HANDLER))
{
return "org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler";
return "org.alfresco.opencmis.PublicApiCallContextHandler";
}
else if(arg0.equals(CmisAtomPubServlet.PARAM_CMIS_VERSION))
{
return version;
}
return null;
}