exo-jcr SVN: r56 - parent/trunk.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-08-28 10:18:58 -0400 (Fri, 28 Aug 2009)
New Revision: 56
Modified:
parent/trunk/pom.xml
Log:
EXOJCR-2: exo.dev.resources.version=1.2.0 (was 1.1.0)
Modified: parent/trunk/pom.xml
===================================================================
--- parent/trunk/pom.xml 2009-08-28 14:08:33 UTC (rev 55)
+++ parent/trunk/pom.xml 2009-08-28 14:18:58 UTC (rev 56)
@@ -111,7 +111,7 @@
<exo.projects.app.jboss.version>jboss-4.2.3.GA</exo.projects.app.jboss.version>
<exo.projects.app.jonas.version>JONAS_4_8_5</exo.projects.app.jonas.version>
- <exo.dev.resources.version>1.1.0</exo.dev.resources.version>
+ <exo.dev.resources.version>1.2.0</exo.dev.resources.version>
<exo.product.name>eXo Platform</exo.product.name>
<exo.product.specification>N/A</exo.product.specification>
16 years, 8 months
exo-jcr SVN: r55 - parent/trunk.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-08-28 10:08:33 -0400 (Fri, 28 Aug 2009)
New Revision: 55
Modified:
parent/trunk/pom.xml
Log:
EXOJCR-1: deps on jboss-4.2.3.GA (was jboss-4.2.0.GA)
Modified: parent/trunk/pom.xml
===================================================================
--- parent/trunk/pom.xml 2009-08-28 13:57:35 UTC (rev 54)
+++ parent/trunk/pom.xml 2009-08-28 14:08:33 UTC (rev 55)
@@ -108,7 +108,7 @@
<exo.projects.app.mvn.repo>${exo.projects.directory.dependencies}/repository</exo.projects.app.mvn.repo>
<exo.projects.app.tomcat.version>tomcat-6.0.16</exo.projects.app.tomcat.version>
- <exo.projects.app.jboss.version>jboss-4.2.0.GA</exo.projects.app.jboss.version>
+ <exo.projects.app.jboss.version>jboss-4.2.3.GA</exo.projects.app.jboss.version>
<exo.projects.app.jonas.version>JONAS_4_8_5</exo.projects.app.jonas.version>
<exo.dev.resources.version>1.1.0</exo.dev.resources.version>
16 years, 8 months
exo-jcr SVN: r54 - dev-resources/trunk and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-08-28 09:57:35 -0400 (Fri, 28 Aug 2009)
New Revision: 54
Added:
dev-resources/
dev-resources/trunk/pom.xml
dev-resources/trunk/src/
dev-resources/trunk/src/main/resources/code-samples/
dev-resources/trunk/src/main/resources/code-samples/java/
Removed:
dev-resources/trunk/code-sample/
dev-resources/trunk/dev-resources/
dev-tools/
Log:
EXOJCR-16: reorganization of dev-resources
Copied: dev-resources (from rev 50, dev-tools)
Copied: dev-resources/trunk/pom.xml (from rev 50, dev-tools/trunk/dev-resources/pom.xml)
===================================================================
--- dev-resources/trunk/pom.xml (rev 0)
+++ dev-resources/trunk/pom.xml 2009-08-28 13:57:35 UTC (rev 54)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform</groupId>
+ <artifactId>foundation-parent</artifactId>
+ <version>1</version>
+ </parent>
+
+ <groupId>org.exoplatform.tools</groupId>
+ <artifactId>dev-resources</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <name>eXo JBoss Dev Resources</name>
+ <description>Development Resources for eXo Jboss</description>
+
+</project>
Copied: dev-resources/trunk/src (from rev 50, dev-tools/trunk/dev-resources/src)
Copied: dev-resources/trunk/src/main/resources/code-samples (from rev 52, dev-tools/trunk/dev-resources/src/main/resources/code-samples)
Copied: dev-resources/trunk/src/main/resources/code-samples/java (from rev 53, dev-tools/trunk/dev-resources/src/main/resources/code-samples/java)
16 years, 8 months
exo-jcr SVN: r53 - in dev-tools/trunk: dev-resources/src/main/resources/code-samples and 1 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-08-28 09:50:52 -0400 (Fri, 28 Aug 2009)
New Revision: 53
Added:
dev-tools/trunk/dev-resources/src/main/resources/code-samples/java/
dev-tools/trunk/dev-resources/src/main/resources/code-samples/java/x/
Removed:
dev-tools/trunk/code-sample/src/main/java/x/
Log:
EXOJCR-16: reorganization of code-samples
Copied: dev-tools/trunk/dev-resources/src/main/resources/code-samples/java/x (from rev 50, dev-tools/trunk/code-sample/src/main/java/x)
16 years, 8 months
exo-jcr SVN: r51 - jcr/trunk and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-08-28 09:30:38 -0400 (Fri, 28 Aug 2009)
New Revision: 51
Modified:
core/trunk/pom.xml
jcr/trunk/pom.xml
kernel/trunk/pom.xml
ws/trunk/pom.xml
Log:
EXOJCR-15 {projectname-parent} pattern used for root POMs
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-08-28 13:12:43 UTC (rev 50)
+++ core/trunk/pom.xml 2009-08-28 13:30:38 UTC (rev 51)
@@ -28,7 +28,7 @@
</parent>
<groupId>org.exoplatform.core</groupId>
- <artifactId>config</artifactId>
+ <artifactId>core-parent</artifactId>
<version>2.3-SNAPSHOT</version>
<packaging>pom</packaging>
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2009-08-28 13:12:43 UTC (rev 50)
+++ jcr/trunk/pom.xml 2009-08-28 13:30:38 UTC (rev 51)
@@ -29,7 +29,7 @@
</parent>
<groupId>org.exoplatform.jcr</groupId>
- <artifactId>config</artifactId>
+ <artifactId>jcr-parent</artifactId>
<version>1.12-SNAPSHOT</version>
<packaging>pom</packaging>
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2009-08-28 13:12:43 UTC (rev 50)
+++ kernel/trunk/pom.xml 2009-08-28 13:30:38 UTC (rev 51)
@@ -29,7 +29,7 @@
</parent>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>config</artifactId>
+ <artifactId>kernel-parent</artifactId>
<version>2.2-SNAPSHOT</version>
<packaging>pom</packaging>
Modified: ws/trunk/pom.xml
===================================================================
--- ws/trunk/pom.xml 2009-08-28 13:12:43 UTC (rev 50)
+++ ws/trunk/pom.xml 2009-08-28 13:30:38 UTC (rev 51)
@@ -29,7 +29,7 @@
</parent>
<groupId>org.exoplatform.ws</groupId>
- <artifactId>config</artifactId>
+ <artifactId>ws-parent</artifactId>
<version>2.1-SNAPSHOT</version>
<packaging>pom</packaging>
16 years, 8 months
exo-jcr SVN: r49 - in jcr/trunk/component/ext/src: main/java/org/exoplatform/services/jcr/ext/repository and 3 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-08-28 09:12:40 -0400 (Fri, 28 Aug 2009)
New Revision: 49
Added:
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/NamesList.java
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RepositoryServiceConf.java
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/repository/
jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java
Modified:
jcr/trunk/component/ext/src/test/java/conf/standalone/test-configuration.xml
Log:
EXOJCR-13 : Add RestRepositoryService and test for this service.
Added: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/NamesList.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/NamesList.java (rev 0)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/NamesList.java 2009-08-28 13:12:40 UTC (rev 49)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.ext.repository;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>
+ * Date: 27.08.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id: NamesList.java 111 2008-11-11 11:11:11Z rainf0x $
+ */
+public class NamesList
+{
+
+ /**
+ * List with names.
+ */
+ protected List<String> names = new ArrayList<String>();
+
+ /**
+ * Empty constructor.
+ */
+ public NamesList()
+ {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param names
+ * List, the list with names
+ */
+ public NamesList(List<String> names)
+ {
+ this.names = names;
+ }
+
+ /**
+ * @return List
+ * return the list of name
+ */
+ public List<String> getNames()
+ {
+ return names;
+ }
+
+ /**
+ * @param names
+ * List, the list with names
+ */
+ public void setNames(List<String> names)
+ {
+ this.names = names;
+ }
+
+}
Property changes on: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/NamesList.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RepositoryServiceConf.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RepositoryServiceConf.java (rev 0)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RepositoryServiceConf.java 2009-08-28 13:12:40 UTC (rev 49)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.ext.repository;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.exoplatform.services.jcr.config.AbstractRepositoryServiceConfiguration;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:vitaly.parfonov@gmail.com">Vitaly Parfonov</a>
+ * @version $Id: $
+ */
+public class RepositoryServiceConf
+ extends AbstractRepositoryServiceConfiguration
+{
+
+ /**
+ * @param defaultRepositoryName
+ * String, the default repository name
+ * @param repositories
+ * List of RepositoryEntry-s
+ */
+ public RepositoryServiceConf(List<RepositoryEntry> repositories, String defaultRepositoryName)
+ {
+ this.defaultRepositoryName = defaultRepositoryName;
+ this.repositoryConfigurations = repositories;
+ }
+
+ /**
+ * The empty constructor.
+ */
+ public RepositoryServiceConf()
+ {
+ this.repositoryConfigurations = new ArrayList<RepositoryEntry>();
+ }
+
+ /**
+ * @param repositories
+ * List of RepositoryEntry
+ */
+ public RepositoryServiceConf(List<RepositoryEntry> repositories)
+ {
+ this.repositoryConfigurations = repositories;
+ }
+
+ /**
+ * @return List
+ * return the list of RepositoryEntry
+ */
+ public List<RepositoryEntry> getRepositories()
+ {
+ return repositoryConfigurations;
+ }
+
+ /**
+ * @param repositories
+ * List of RepositoryEntry
+ */
+ public void setRepositories(List<RepositoryEntry> repositories)
+ {
+ this.repositoryConfigurations = repositories;
+ }
+
+ public RepositoryEntry getRepositoryEntry(String repositoryName)
+ {
+ for (RepositoryEntry repositoryEntry : this.repositoryConfigurations)
+ {
+ if (repositoryEntry.getName().equals(repositoryName))
+ return repositoryEntry;
+ }
+ return null;
+ }
+
+}
Property changes on: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RepositoryServiceConf.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java (rev 0)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2009-08-28 13:12:40 UTC (rev 49)
@@ -0,0 +1,501 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.ext.repository;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.security.RolesAllowed;
+import javax.jcr.RepositoryException;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.core.Response.Status;
+
+import org.exoplatform.common.http.HTTPStatus;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>
+ * Date: 27.08.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id: NamesList.java 111 2008-11-11 11:11:11Z rainf0x $
+ */
+
+@Path("/jcr-service")
+public class RestRepositoryService
+ implements ResourceContainer
+{
+
+ /**
+ * Definition the constants.
+ */
+ public static final class Constants
+ {
+
+ /**
+ * The base path to this service.
+ */
+ public static final String BASE_URL = "/jcr-service";
+
+ /**
+ * Definition the operation types.
+ */
+ public static final class OperationType
+ {
+ /**
+ * Repository service configuration operation.
+ */
+ public static final String REPOSITORY_SERVICE_CONFIGURATION = "/repository-service-configuration";
+
+ /**
+ * Default workspace configuration operations.
+ */
+ public static final String DEFAULT_WS_CONFIG = "/default-ws-config";
+
+ /**
+ * Create new repository operations.
+ */
+ public static final String NEW_REPOSITORY = "/new-repository";
+
+ /**
+ * Create new workspace.
+ */
+ public static final String NEW_WORKSPACE = "/new-workspace";
+
+ /**
+ * Remove repository operation.
+ */
+ public static final String REMOVE_REPOSITORY = "/remove-repository";
+
+ /**
+ * Remove workspace operation.
+ */
+ public static final String REMOVE_WORKSPACE = "/remove-workspace";
+
+ /**
+ * The list of repositories name operations.
+ */
+ public static final String REPOSITORIES_LIST = "/repositories";
+
+ /**
+ * The list of workspaces name operation.
+ */
+ public static final String WORKSPACES_LIST = "/workspaces";
+
+ /**
+ * Update workspace configuration operation.
+ */
+ public static final String UPDATE_WORKSPACE_CONFIG = "/update-workspace-config";
+
+ /**
+ * OperationType private constructor.
+ */
+ private OperationType()
+ {
+ }
+ }
+
+ /**
+ * Constants private constructor.
+ */
+ private Constants()
+ {
+ }
+ }
+
+ /**
+ * Class logger.
+ */
+ private final Log log = ExoLogger.getLogger("jcr.ext.RestRepositoryService");
+
+ /**
+ *
+ */
+ private final RepositoryService repositoryService;
+
+ /**
+ * To disable cache control.
+ */
+ private static final CacheControl NO_CACHE = new CacheControl();
+
+ static
+ {
+ // noCache = new CacheControl();
+ NO_CACHE.setNoCache(true);
+ NO_CACHE.setNoStore(true);
+ }
+
+ /**
+ * @param repositoryService
+ */
+ public RestRepositoryService(RepositoryService repositoryService)
+ {
+ this.repositoryService = repositoryService;
+ }
+
+ /**
+ * @return
+ * @throws RepositoryConfigurationException
+ * @throws RepositoryException
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/repository-service-configuration")
+ public Response getRepositoryServiceConfiguration()
+ {
+ RepositoryServiceConfiguration configuration = repositoryService.getConfig();
+ RepositoryServiceConf conf =
+ new RepositoryServiceConf(configuration.getRepositoryConfigurations(), configuration
+ .getDefaultRepositoryName());
+ return Response.ok(conf, MediaType.APPLICATION_JSON_TYPE).cacheControl(NO_CACHE).build();
+ }
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/default-ws-config/{repositoryName}")
+ public Response getDefaultWorkspaceConfig(@PathParam("repositoryName") String repositoryName)
+ {
+ String errorMessage = new String();
+ Status status;
+
+ try
+ {
+ String defaultWorkspaceName =
+ repositoryService.getRepository(repositoryName).getConfiguration().getDefaultWorkspaceName();
+
+ for (WorkspaceEntry wEntry : repositoryService.getRepository(repositoryName).getConfiguration()
+ .getWorkspaceEntries())
+ if (defaultWorkspaceName.equals(wEntry.getName()))
+ return Response.ok(wEntry).cacheControl(NO_CACHE).build();
+
+ return Response.status(Response.Status.NOT_FOUND).entity("Can not get default workspace configuration.").type(
+ MediaType.TEXT_PLAIN).cacheControl(NO_CACHE).build();
+ }
+ catch (RepositoryException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.NOT_FOUND;
+ }
+ catch (Throwable e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.INTERNAL_SERVER_ERROR;
+ }
+
+ return Response.status(status).entity(errorMessage).type(MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE)
+ .build();
+ }
+
+ /**
+ * @param uriInfo
+ * @param newRepository
+ * @return
+ * @throws URISyntaxException
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/new-repository")
+ public Response createRepository(@Context UriInfo uriInfo, RepositoryEntry newRepository) throws URISyntaxException
+ {
+ String errorMessage = new String();
+ Status status;
+ try
+ {
+ repositoryService.createRepository(newRepository);
+ URI location = new URI(uriInfo.getBaseUri().toString() + uriInfo.getPath() + "/" + newRepository.getName());
+ return Response.created(location).cacheControl(NO_CACHE).build();
+ }
+ catch (RepositoryException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.BAD_REQUEST;
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.BAD_REQUEST;
+ }
+ catch (Throwable e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.INTERNAL_SERVER_ERROR;
+ }
+
+ return Response.status(status).entity(errorMessage).type(MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE)
+ .build();
+ }
+
+ /**
+ * @param uriInfo
+ * @param repositoryName
+ * @param newWorkspace
+ * @return
+ * @throws URISyntaxException
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/new-workspace/{repositoryName}")
+ public Response createWorkspace(@Context UriInfo uriInfo, @PathParam("repositoryName") String repositoryName,
+ WorkspaceEntry newWorkspace) throws URISyntaxException
+ {
+ String errorMessage = new String();
+ Status status;
+ try
+ {
+ RepositoryImpl repository = (RepositoryImpl) repositoryService.getRepository(repositoryName);
+ repository.configWorkspace(newWorkspace);
+ repository.createWorkspace(newWorkspace.getName());
+ URI location = new URI(uriInfo.getBaseUri().toString() + uriInfo.getPath() + "/" + newWorkspace.getName());
+ return Response.created(location).build();
+ }
+ catch (RepositoryException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.NOT_FOUND;
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.BAD_REQUEST;
+ }
+ catch (Throwable e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.INTERNAL_SERVER_ERROR;
+ }
+ return Response.status(status).entity(errorMessage).type(MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE)
+ .build();
+ }
+
+ /**
+ * @param uriInfo
+ * @param repositoryName
+ * @return
+ * @throws URISyntaxException
+ */
+ @POST
+ @RolesAllowed("administrators")
+ @Path("/remove-repository/{repositoryName}")
+ public Response removeRepository(@Context UriInfo uriInfo, @PathParam("repositoryName") String repositoryName)
+ {
+ String errorMessage = new String();
+ Status status;
+
+ try
+ {
+ if (repositoryService.canRemoveRepository(repositoryName))
+ {
+ repositoryService.removeRepository(repositoryName);
+ return Response.noContent().build();
+ }
+ return Response.status(HTTPStatus.CONFLICT).entity("Can't remove repository " + repositoryName).cacheControl(
+ NO_CACHE).build();
+ }
+ catch (RepositoryException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.NOT_FOUND;
+ }
+ catch (Throwable e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.INTERNAL_SERVER_ERROR;
+ }
+
+ return Response.status(status).entity(errorMessage).type(MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE)
+ .build();
+ }
+
+ /**
+ * @param uriInfo
+ * @param repositoryName
+ * @return
+ * @throws URISyntaxException
+ */
+ @POST
+ @RolesAllowed("administrators")
+ @Path("/remove-workspace/{repositoryName}/{workspaceName}")
+ public Response removeWorkspace(@Context UriInfo uriInfo, @PathParam("repositoryName") String repositoryName,
+ @PathParam("workspaceName") String workspaceName)
+ {
+ String errorMessage = new String();
+ Status status;
+
+ try
+ {
+ ManageableRepository repository = repositoryService.getRepository(repositoryName);
+ if (repository.canRemoveWorkspace(workspaceName))
+ {
+ repository.removeWorkspace(workspaceName);
+ return Response.noContent().build();
+ }
+ return Response.status(Status.CONFLICT).entity(
+ "Can't remove workspace " + workspaceName + " in repository " + repositoryName)
+ .cacheControl(NO_CACHE).build();
+ }
+ catch (RepositoryException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.NOT_FOUND;
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.NOT_FOUND;
+ }
+ catch (Throwable e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.INTERNAL_SERVER_ERROR;
+ }
+
+ return Response.status(status).entity(errorMessage).type(MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE)
+ .build();
+ }
+
+ /**
+ * @return
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/repositories")
+ public Response getRepositoryNames()
+ {
+ List<String> repositories = new ArrayList<String>();
+
+ for (RepositoryEntry rEntry : repositoryService.getConfig().getRepositoryConfigurations())
+ {
+ repositories.add(rEntry.getName());
+ }
+
+ return Response.ok(new NamesList(repositories)).cacheControl(NO_CACHE).build();
+ }
+
+ /**
+ * @param repositoryName
+ * @return
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/workspaces/{repositoryName}")
+ public Response getWorkspaceNames(@PathParam("repositoryName") String repositoryName)
+ {
+ String errorMessage = new String();
+ Status status;
+
+ try
+ {
+ List<String> workspaces = new ArrayList<String>();
+
+ for (WorkspaceEntry wEntry : repositoryService.getRepository(repositoryName).getConfiguration()
+ .getWorkspaceEntries())
+ {
+ workspaces.add(wEntry.getName());
+ }
+
+ return Response.ok(new NamesList(workspaces)).cacheControl(NO_CACHE).build();
+
+ }
+ catch (RepositoryException e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.NOT_FOUND;
+ }
+ catch (Throwable e)
+ {
+ if (log.isDebugEnabled())
+ log.error(e.getMessage(), e);
+ errorMessage = e.getMessage();
+ status = Status.INTERNAL_SERVER_ERROR;
+ }
+
+ return Response.status(status).entity(errorMessage).type(MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE)
+ .build();
+ }
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/update-workspace-config/{repositoryName}/{workspaceName}")
+ public Response updateWorkspaceConfiguration(@PathParam("repositoryName") String repositoryName,
+ @PathParam("workspaceName") String workspaceName, WorkspaceEntry workspaceEntry)
+ {
+ return Response.status(Status.OK).entity("The method /update-workspace-config not implemented.").type(
+ MediaType.TEXT_PLAIN_TYPE).cacheControl(NO_CACHE).build();
+ }
+
+}
Property changes on: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: jcr/trunk/component/ext/src/test/java/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/component/ext/src/test/java/conf/standalone/test-configuration.xml 2009-08-28 13:04:12 UTC (rev 48)
+++ jcr/trunk/component/ext/src/test/java/conf/standalone/test-configuration.xml 2009-08-28 13:12:40 UTC (rev 49)
@@ -120,6 +120,10 @@
</value-param>
</init-params>
</component>
+
+ <component>
+ <type>org.exoplatform.services.jcr.ext.repository.RestRepositoryService</type>
+ </component>
<!-- backup -->
<component>
Added: jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java
===================================================================
--- jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java (rev 0)
+++ jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java 2009-08-28 13:12:40 UTC (rev 49)
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.ext.repository;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
+import org.exoplatform.services.jcr.ext.app.SessionProviderService;
+import org.exoplatform.services.jcr.ext.app.ThreadLocalSessionProviderService;
+import org.exoplatform.services.jcr.ext.backup.ContainerRequestUserRole;
+import org.exoplatform.services.jcr.ext.common.SessionProvider;
+import org.exoplatform.services.rest.RequestHandler;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.InputHeadersMap;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+import org.exoplatform.services.security.ConversationState;
+import org.exoplatform.services.security.Identity;
+import org.exoplatform.ws.frameworks.json.JsonHandler;
+import org.exoplatform.ws.frameworks.json.JsonParser;
+import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
+import org.exoplatform.ws.frameworks.json.impl.JsonDefaultHandler;
+import org.exoplatform.ws.frameworks.json.impl.JsonGeneratorImpl;
+import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
+import org.exoplatform.ws.frameworks.json.value.JsonValue;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>
+ * Date: 26.08.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id: RestRepositoryServiceTest.java 111 2008-11-11 11:11:11Z rainf0x $
+ */
+public class RestRepositoryServiceTest
+ extends BaseStandaloneTest
+{
+ private String REST_REPOSITORY_SERVICE_PATH = RestRepositoryService.Constants.BASE_URL;
+
+ private RequestHandler handler;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ handler = (RequestHandler) container.getComponentInstanceOfType(RequestHandler.class);
+
+ SessionProviderService sessionProviderService =
+ (SessionProviderService) container.getComponentInstanceOfType(ThreadLocalSessionProviderService.class);
+ assertNotNull(sessionProviderService);
+ sessionProviderService.setSessionProvider(null, new SessionProvider(new ConversationState(new Identity("root"))));
+ }
+
+ public void testRepositoriesList() throws Exception
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
+ + RestRepositoryService.Constants.OperationType.REPOSITORIES_LIST), new URI(""), null,
+ new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ NamesList repositories = (NamesList) getObject(NamesList.class, responseWriter.getBody());
+
+ assertNotNull(repositories);
+ assertEquals(repositoryService.getConfig().getRepositoryConfigurations().size(), repositories.getNames().size());
+ }
+
+ public void testWorkspacesList() throws Exception
+ {
+ String repoName = repositoryService.getConfig().getDefaultRepositoryName();
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
+ + RestRepositoryService.Constants.OperationType.WORKSPACES_LIST + "/" + repoName + "/"),
+ new URI(""), null, new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ NamesList workspaces = (NamesList) getObject(NamesList.class, responseWriter.getBody());
+
+ assertNotNull(workspaces);
+ assertEquals(repositoryService.getConfig().getRepositoryConfiguration(repoName).getWorkspaceEntries().size(),
+ workspaces.getNames().size());
+ }
+
+ public void testGetDefaultWorkspaceConfig() throws Exception
+ {
+ String repoName = repositoryService.getConfig().getDefaultRepositoryName();
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
+ + RestRepositoryService.Constants.OperationType.DEFAULT_WS_CONFIG + "/" + repoName + "/"),
+ new URI(""), null, new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ WorkspaceEntry workspaceEntry = (WorkspaceEntry) getObject(WorkspaceEntry.class, responseWriter.getBody());
+
+ assertNotNull(workspaceEntry);
+ assertEquals(repositoryService.getConfig().getRepositoryConfiguration(repoName).getDefaultWorkspaceName(),
+ workspaceEntry.getName());
+ }
+
+ public void testGetRepositoryServiceConfiguration() throws Exception
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
+ + RestRepositoryService.Constants.OperationType.REPOSITORY_SERVICE_CONFIGURATION), new URI(""),
+ null, new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ RepositoryServiceConf repositoryConf =
+ (RepositoryServiceConf) getObject(RepositoryServiceConf.class, responseWriter.getBody());
+
+ assertNotNull(repositoryConf);
+ assertEquals(repositoryService.getConfig().getDefaultRepositoryName(), repositoryConf.getDefaultRepositoryName());
+ assertEquals(repositoryService.getConfig().getRepositoryConfigurations().size(), repositoryConf.getRepositories()
+ .size());
+ }
+
+ public void testCreateRepository() throws Exception
+ {
+ String wsName = "ws_over_rest";
+ String rName = "repo_over_rest";
+
+ RepositoryEntry rDefault =
+ repositoryService.getConfig().getRepositoryConfiguration(
+ repositoryService.getConfig().getDefaultRepositoryName());
+ RepositoryEntry rEntry = new RepositoryEntry();
+
+ rEntry.setAccessControl(rDefault.getAccessControl());
+ rEntry.setAuthenticationPolicy(rDefault.getAuthenticationPolicy());
+ rEntry.setDefaultWorkspaceName("ws_over_rest");
+ rEntry.setName(rName);
+ rEntry.setSecurityDomain(rDefault.getSecurityDomain());
+ rEntry.setSessionTimeOut(rDefault.getSessionTimeOut());
+ rEntry.setSystemWorkspaceName(wsName);
+
+ WorkspaceEntry wEntry =
+ makeWorkspaceEntry(rDefault.getWorkspaceEntries().get(0), rName, wsName, "jdbcjcr_to_rest_repo");
+ rEntry.addWorkspace(wEntry);
+
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(rEntry);
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.putSingle("Content-Type", "application/json; charset=UTF-8");
+
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("POST", new URI(REST_REPOSITORY_SERVICE_PATH
+ + RestRepositoryService.Constants.OperationType.NEW_REPOSITORY), new URI(""),
+ new ByteArrayInputStream(json.toString().getBytes("UTF-8")), new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(201, cres.getStatus());
+
+ URI location = (URI) getObject(URI.class, responseWriter.getBody());
+
+ assertNotNull(location);
+ // assertEquals(repositoryService.getConfig().getDefaultRepositoryName(), repositoryConf.getDefaultRepositoryName());
+ // assertEquals(repositoryService.getConfig().getRepositoryConfigurations().size(), repositoryConf.getRepositories().size());
+ }
+
+ /**
+ * Will be created the Object from JSON binary data.
+ *
+ * @param cl
+ * Class
+ * @param data
+ * binary data (JSON)
+ * @return Object
+ * @throws Exception
+ * will be generated Exception
+ */
+ private Object getObject(Class cl, byte[] data) throws Exception
+ {
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ JsonParser jsonParser = new JsonParserImpl();
+ InputStream inputStream = new ByteArrayInputStream(data);
+ jsonParser.parse(inputStream, jsonHandler);
+ JsonValue jsonValue = jsonHandler.getJsonObject();
+
+ return new BeanBuilder().createObject(cl, jsonValue);
+ }
+
+ protected WorkspaceEntry makeWorkspaceEntry(WorkspaceEntry defWEntry, String repoNmae, String wsName,
+ String sourceName)
+ {
+ WorkspaceEntry ws1back = new WorkspaceEntry();
+ ws1back.setName(wsName);
+ ws1back.setUniqueName(repoNmae + "_" + wsName);
+
+ ws1back.setAccessManager(defWEntry.getAccessManager());
+ ws1back.setAutoInitializedRootNt(defWEntry.getAutoInitializedRootNt());
+ ws1back.setAutoInitPermissions(defWEntry.getAutoInitPermissions());
+ ws1back.setCache(defWEntry.getCache());
+ ws1back.setLockManager(defWEntry.getLockManager());
+
+ // Indexer
+ ArrayList qParams = new ArrayList();
+ qParams.add(new SimpleParameterEntry("indexDir", "target" + File.separator + wsName));
+ QueryHandlerEntry qEntry = new QueryHandlerEntry(defWEntry.getQueryHandler().getType(), qParams);
+
+ ws1back.setQueryHandler(qEntry);
+
+ ArrayList params = new ArrayList();
+ for (Iterator i = defWEntry.getContainer().getParameters().iterator(); i.hasNext();)
+ {
+ SimpleParameterEntry p = (SimpleParameterEntry) i.next();
+ SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(), p.getValue());
+
+ if (newp.getName().equals("source-name"))
+ newp.setValue(sourceName);
+ else if (newp.getName().equals("swap-directory"))
+ newp.setValue("target/temp/swap/" + wsName);
+ else if (newp.getName().equals("multi-db"))
+ newp.setValue("false");
+
+ params.add(newp);
+ }
+
+ ContainerEntry ce = new ContainerEntry(defWEntry.getContainer().getType(), params);
+ ws1back.setContainer(ce);
+
+ return ws1back;
+ }
+}
Property changes on: jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r47 - jcr/trunk/applications/product-patches/as/jboss.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-08-28 08:56:53 -0400 (Fri, 28 Aug 2009)
New Revision: 47
Modified:
jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml
Log:
EXOJCR-2: JCR-1071 fix merged.
Modified: jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml 2009-08-28 12:51:24 UTC (rev 46)
+++ jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml 2009-08-28 12:56:53 UTC (rev 47)
@@ -227,7 +227,7 @@
</value-param>
<value-param>
<name>cache-folder-name</name>
- <value>target/ftp_cache</value>
+ <value>../temp/ftp_cache</value>
</value-param>
<!-- bytes per second -->
16 years, 8 months