Search in sources :

Example 1 with JcrRemotingServlet

use of org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet in project jackrabbit by apache.

the class RepositoryStubImpl method getRepository.

@Override
public Repository getRepository() throws RepositoryStubException {
    if (repository == null) {
        repository = super.getRepository();
    }
    if (connector == null) {
        connector = new SocketConnector();
        connector.setHost("localhost");
        String pvalue = System.getProperty("org.apache.jackrabbit.jcr2dav.RepositoryStubImpl.port", "0");
        int port = pvalue.equals("") ? 0 : Integer.parseInt(pvalue);
        connector.setPort(port);
    }
    if (server == null) {
        server = new Server();
        server.addConnector(connector);
        ServletHolder holder = new ServletHolder(new JcrRemotingServlet() {

            protected Repository getRepository() {
                return repository;
            }
        });
        holder.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, "");
        holder.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_MISSING_AUTH_MAPPING, "");
        holder.setInitParameter(JcrRemotingServlet.INIT_PARAM_PROTECTED_HANDLERS_CONFIG, protectedRemoveImplClass);
        Context context = new Context(server, "/");
        context.addServlet(holder, "/*");
        server.addHandler(context);
        try {
            server.start();
        } catch (Exception e) {
            throw new RepositoryStubException(e);
        }
    }
    if (client == null) {
        try {
            Map<String, String> parameters = new HashMap<String, String>();
            String uri = "http://localhost:" + connector.getLocalPort() + "/";
            String parmName = System.getProperty(this.getClass().getName() + ".REPURIPARM", JcrUtils.REPOSITORY_URI);
            parameters.put(parmName, uri);
            parameters.put(PROP_ACCESSCONTROL_PROVIDER_CLASS, acProviderImplClass);
            client = JcrUtils.getRepository(parameters);
        } catch (Exception e) {
            throw new RepositoryStubException(e);
        }
    }
    return client;
}
Also used : Context(org.mortbay.jetty.servlet.Context) Repository(javax.jcr.Repository) Server(org.mortbay.jetty.Server) HashMap(java.util.HashMap) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) RepositoryStubException(org.apache.jackrabbit.test.RepositoryStubException) SocketConnector(org.mortbay.jetty.bio.SocketConnector) JcrRemotingServlet(org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet) RepositoryStubException(org.apache.jackrabbit.test.RepositoryStubException) RepositoryException(javax.jcr.RepositoryException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 2 with JcrRemotingServlet

use of org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet in project jackrabbit-oak by apache.

the class RemotingInitializer method remotingServlet.

@Bean
public ServletRegistrationBean remotingServlet() {
    ServletRegistrationBean bean = new ServletRegistrationBean(new JcrRemotingServlet() {

        @Override
        public Repository getRepository() {
            return repository;
        }

        @Override
        public ServletContext getServletContext() {
            return RemotingInitializer.this.getServletContext();
        }
    }, "/server/*");
    bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, "/server");
    bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_BATCHREAD_CONFIG, "/remoting/batchread.properties");
    bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_PROTECTED_HANDLERS_CONFIG, "/remoting/protectedHandlersConfig.xml");
    bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_HOME, davHome);
    return bean;
}
Also used : Repository(javax.jcr.Repository) ServletRegistrationBean(org.springframework.boot.context.embedded.ServletRegistrationBean) ServletContext(javax.servlet.ServletContext) JcrRemotingServlet(org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet) ServletRegistrationBean(org.springframework.boot.context.embedded.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Repository (javax.jcr.Repository)2 JcrRemotingServlet (org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet)2 HashMap (java.util.HashMap)1 RepositoryException (javax.jcr.RepositoryException)1 ServletContext (javax.servlet.ServletContext)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1 RepositoryStubException (org.apache.jackrabbit.test.RepositoryStubException)1 Server (org.mortbay.jetty.Server)1 SocketConnector (org.mortbay.jetty.bio.SocketConnector)1 Context (org.mortbay.jetty.servlet.Context)1 ServletHolder (org.mortbay.jetty.servlet.ServletHolder)1 ServletRegistrationBean (org.springframework.boot.context.embedded.ServletRegistrationBean)1 Bean (org.springframework.context.annotation.Bean)1