]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4875 Adding support for keyword search across a range of services. This has...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Tue, 28 Feb 2012 20:09:58 +0000 (12:09 -0800)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Tue, 28 Feb 2012 20:09:58 +0000 (12:09 -0800)
14 files changed:
services/servicegroup/build.xml [new file with mode: 0644]
services/servicegroup/client/pom.xml [new file with mode: 0644]
services/servicegroup/client/src/main/java/org/collectionspace/services/client/ServiceGroupClient.java [new file with mode: 0644]
services/servicegroup/client/src/main/java/org/collectionspace/services/client/ServiceGroupProxy.java [new file with mode: 0644]
services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java [new file with mode: 0644]
services/servicegroup/client/src/test/resources/log4j.properties [new file with mode: 0644]
services/servicegroup/jaxb/pom.xml [new file with mode: 0644]
services/servicegroup/jaxb/src/main/java/org/collectionspace/services/ServiceGroupJAXBSchema.java [new file with mode: 0644]
services/servicegroup/jaxb/src/main/java/org/collectionspace/services/ServiceGroupListItemJAXBSchema.java [new file with mode: 0644]
services/servicegroup/pom.xml [new file with mode: 0644]
services/servicegroup/service/pom.xml [new file with mode: 0644]
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java [new file with mode: 0644]
services/servicegroup/service/src/test/java/org/collectionspace/services/test/ServiceGroupServiceTest.java [new file with mode: 0644]
services/servicegroup/service/src/test/resources/log4j.xml [new file with mode: 0644]

diff --git a/services/servicegroup/build.xml b/services/servicegroup/build.xml
new file mode 100644 (file)
index 0000000..90d068f
--- /dev/null
@@ -0,0 +1,118 @@
+
+<project name="servicegroup" default="package" basedir=".">
+    <description>
+        servicegroup service
+    </description>
+  <!-- set global properties for this build -->
+    <property name="services.trunk" value="../.."/>
+    <!-- environment should be declared before reading build.properties -->
+    <property environment="env" />
+    <property file="${services.trunk}/build.properties" />
+    <property name="mvn.opts" value="" />
+    <property name="src" location="src"/>
+
+    <condition property="osfamily-unix">
+        <os family="unix" />
+    </condition>
+    <condition property="osfamily-windows">
+        <os family="windows" />
+    </condition>
+
+    <target name="package" depends="package-unix,package-windows"
+  description="Package CollectionSpace Services" />
+  
+    <target name="package-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    
+    <target name="package-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+
+    <target name="install" depends="install-unix,install-windows"
+  description="Install" />
+    <target name="install-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="install-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="clean" depends="clean-unix,clean-windows"
+  description="Delete target directories" >
+        <delete dir="${build}"/>
+    </target>
+    <target name="clean-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="clean-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />
+    <target name="test-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="test-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="deploy" depends="install" description="deploy servicegroup service">
+    </target>
+
+    <target name="undeploy" description="undeploy servicegroup service">
+    </target>
+
+    <target name="dist" depends="package" description="distribute servicegroup service">
+    </target>
+
+</project>
diff --git a/services/servicegroup/client/pom.xml b/services/servicegroup/client/pom.xml
new file mode 100644 (file)
index 0000000..c4ff91d
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.servicegroup</artifactId>
+        <version>2.2-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.servicegroup.client</artifactId>
+    <name>services.servicegroup.client</name>
+    
+    <dependencies>
+        <!-- keep slf4j dependencies on the top -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+<!-- CollectionSpace dependencies -->
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
+            <optional>true</optional>
+            <version>${project.version}</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+            <optional>true</optional>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+         <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.servicegroup.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.person.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+<!-- External dependencies -->        
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <!-- filter out unwanted jars -->
+            <exclusions>
+                <exclusion>
+                    <groupId>tjws</groupId>
+                    <artifactId>webserver</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxb-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-multipart-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-servicegroup-client</finalName>
+    </build>
+</project>
diff --git a/services/servicegroup/client/src/main/java/org/collectionspace/services/client/ServiceGroupClient.java b/services/servicegroup/client/src/main/java/org/collectionspace/services/client/ServiceGroupClient.java
new file mode 100644 (file)
index 0000000..1359961
--- /dev/null
@@ -0,0 +1,48 @@
+/**    
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
+package org.collectionspace.services.client;
+
+/**
+ * ServiceGroupClient.java
+ *
+ * $LastChangedRevision: 2108 $
+ * $LastChangedDate: 2010-05-17 18:25:37 -0700 (Mon, 17 May 2010) $
+ *
+ */
+public class ServiceGroupClient extends AbstractCommonListPoxServiceClientImpl<ServiceGroupProxy> {
+       
+       public static final String SERVICE_NAME = "servicegroups";
+       public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
+       public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+       public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";     
+       public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; 
+
+       @Override
+       public String getServiceName() {
+               return SERVICE_NAME;
+       }
+       
+       @Override
+    public String getServicePathComponent() {
+        return SERVICE_PATH_COMPONENT;
+    }
+
+       @Override
+       public Class<ServiceGroupProxy> getProxyClass() {
+               return ServiceGroupProxy.class;
+       }
+}
diff --git a/services/servicegroup/client/src/main/java/org/collectionspace/services/client/ServiceGroupProxy.java b/services/servicegroup/client/src/main/java/org/collectionspace/services/client/ServiceGroupProxy.java
new file mode 100644 (file)
index 0000000..09a195f
--- /dev/null
@@ -0,0 +1,40 @@
+/**    
+ * ServiceGroupProxy.java
+ *
+ * {Purpose of This Class}
+ *
+ * {Other Notes Relating to This Class (Optional)}
+ *
+ * $LastChangedBy: $
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright © 2011 U.C. Berkeley
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
+package org.collectionspace.services.client;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+/**
+ * @version $Revision: 2108 $
+ */
+@Path(ServiceGroupClient.SERVICE_PATH_PROXY)
+@Produces({"application/xml"})
+@Consumes({"application/xml"})
+public interface ServiceGroupProxy extends CollectionSpaceCommonListPoxProxy {
+}
diff --git a/services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java b/services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java
new file mode 100644 (file)
index 0000000..26ef6c2
--- /dev/null
@@ -0,0 +1,130 @@
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright © 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.collectionspace.services.client.test;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.client.AbstractCommonListUtils;
+import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.ServiceGroupClient;
+import org.collectionspace.services.client.ServiceGroupProxy;
+import org.collectionspace.services.client.PayloadOutputPart;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.servicegroup.ServicegroupsCommon;
+
+import org.jboss.resteasy.client.ClientResponse;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceGroupServiceTest, carries out tests against a deployed and running ServiceGroup Service. <p/>
+ * $LastChangedRevision:  $
+ * $LastChangedDate:  $
+ */
+public class ServiceGroupServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ServicegroupsCommon> {
+
+    private final String CLASS_NAME = ServiceGroupServiceTest.class.getName();
+    private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+    final String SERVICE_PATH_COMPONENT = "servicegroups";
+    private String knownResourceId = null;
+
+    @Override
+       public String getServicePathComponent() {
+               return ServiceGroupClient.SERVICE_PATH_COMPONENT;
+       }
+
+       @Override
+       protected String getServiceName() {
+               return ServiceGroupClient.SERVICE_NAME;
+       }
+    
+    @Override
+    protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, ServiceGroupProxy> getClientInstance() {
+        return new ServiceGroupClient();
+    }
+
+    @Override
+    protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
+        return response.getEntity(AbstractCommonList.class);
+    }
+
+    // ---------------------------------------------------------------
+    // Utility methods used by tests above
+    // ---------------------------------------------------------------
+    
+    @Override
+    protected PoxPayloadOut createInstance(String identifier) {
+       ServiceGroupClient client = new ServiceGroupClient();
+       return createInstance(client.getCommonPartName(), identifier);
+    }
+    
+       @Override
+       protected PoxPayloadOut createInstance(String commonPartName,
+                       String identifier) {
+               return createServiceGroupInstance(identifier);
+       }
+    
+    private PoxPayloadOut createServiceGroupInstance(String uid) {
+        String identifier = "name-" + uid;
+        ServicegroupsCommon servicegroup = new ServicegroupsCommon();
+        servicegroup.setName(identifier);
+        PoxPayloadOut multipart = new PoxPayloadOut(ServiceGroupClient.SERVICE_PAYLOAD_NAME);
+        PayloadOutputPart commonPart = multipart.addPart(servicegroup, MediaType.APPLICATION_XML_TYPE);
+        commonPart.setLabel(new ServiceGroupClient().getCommonPartName());
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("to be created, servicegroup common");
+            logger.debug(objectAsXmlString(servicegroup, ServicegroupsCommon.class));
+        }
+
+        return multipart;
+    }
+
+       @Override
+       public void CRUDTests(String testName) {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       protected ServicegroupsCommon updateInstance(ServicegroupsCommon servicegroupsCommon) {
+               ServicegroupsCommon result = new ServicegroupsCommon();
+               
+        result.setName("updated-" + servicegroupsCommon.getName());
+               
+               return result;
+       }
+
+       @Override
+       protected void compareUpdatedInstances(ServicegroupsCommon original,
+                       ServicegroupsCommon updated) throws Exception {
+               Assert.assertEquals(updated.getName(), original.getName());
+       }
+}
diff --git a/services/servicegroup/client/src/test/resources/log4j.properties b/services/servicegroup/client/src/test/resources/log4j.properties
new file mode 100644 (file)
index 0000000..148a3e8
--- /dev/null
@@ -0,0 +1,23 @@
+log4j.rootLogger=debug, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=target/test-client.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+#packages
+log4j.logger.org.collectionspace=DEBUG
+log4j.logger.org.apache=INFO
+log4j.logger.httpclient=INFO
+log4j.logger.org.jboss.resteasy=INFO
diff --git a/services/servicegroup/jaxb/pom.xml b/services/servicegroup/jaxb/pom.xml
new file mode 100644 (file)
index 0000000..a20b404
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <parent>
+        <artifactId>org.collectionspace.services.servicegroup</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>2.2-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.servicegroup.jaxb</artifactId>
+    <name>services.servicegroup.jaxb</name>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-servicegroup-jaxb</finalName>
+        <defaultGoal>install</defaultGoal>
+        <plugins>
+            <plugin>
+                <groupId>org.jvnet.jaxb2.maven2</groupId>
+                <artifactId>maven-jaxb2-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+
diff --git a/services/servicegroup/jaxb/src/main/java/org/collectionspace/services/ServiceGroupJAXBSchema.java b/services/servicegroup/jaxb/src/main/java/org/collectionspace/services/ServiceGroupJAXBSchema.java
new file mode 100644 (file)
index 0000000..58ef4e2
--- /dev/null
@@ -0,0 +1,9 @@
+/**
+ * 
+ */
+package org.collectionspace.services;
+
+public interface ServiceGroupJAXBSchema {
+    final static String SERVICE_CLASS_NAME = "name";
+    final static String SERVICE_CLASS_URI = "uri";
+}
diff --git a/services/servicegroup/jaxb/src/main/java/org/collectionspace/services/ServiceGroupListItemJAXBSchema.java b/services/servicegroup/jaxb/src/main/java/org/collectionspace/services/ServiceGroupListItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..48fd0e1
--- /dev/null
@@ -0,0 +1,6 @@
+package org.collectionspace.services;
+
+public interface ServiceGroupListItemJAXBSchema {
+       final static String NAME = "name";
+       final static String URI = "url";
+}
diff --git a/services/servicegroup/pom.xml b/services/servicegroup/pom.xml
new file mode 100644 (file)
index 0000000..00e1bf1
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A comment. -->
+<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">
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.main</artifactId>
+        <version>2.2-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.servicegroup</artifactId>
+    <name>services.servicegroup</name>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>jaxb</module>
+        <module>service</module>
+        <module>client</module>
+    </modules>
+
+</project>
+
diff --git a/services/servicegroup/service/pom.xml b/services/servicegroup/service/pom.xml
new file mode 100644 (file)
index 0000000..1a87ab7
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.servicegroup</artifactId>        
+        <version>2.2-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.servicegroup.service</artifactId>
+    <name>services.servicegroup.service</name>
+    <packaging>jar</packaging>       
+
+    <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.servicegroup.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.servicegroup.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <!-- External dependencies -->        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+        </dependency>
+        
+      <!-- javax -->
+
+        <dependency>
+            <groupId>javax.security</groupId>
+            <artifactId>jaas</artifactId>
+            <version>1.0.01</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>1.6.1</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <!-- jboss -->
+
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>tjws</groupId>
+                    <artifactId>webserver</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxb-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-multipart-provider</artifactId>
+        </dependency>
+        
+        <!-- nuxeo -->
+
+        <dependency>
+            <groupId>org.nuxeo.ecm.core</groupId>
+            <artifactId>nuxeo-core-api</artifactId>
+            <version>${nuxeo.core.version}</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>jboss-remoting</artifactId>
+                    <groupId>jboss</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-servicegroup</finalName>
+    </build>
+</project>
+
diff --git a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java
new file mode 100644 (file)
index 0000000..b8f7a08
--- /dev/null
@@ -0,0 +1,160 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.servicegroup;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.collectionspace.services.ServiceGroupListItemJAXBSchema;
+import org.collectionspace.services.client.IQueryManager;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.client.ServiceGroupClient;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.common.api.Tools;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.DocumentNotFoundException;
+import org.collectionspace.services.common.query.QueryManager;
+import org.collectionspace.services.nuxeo.client.java.CommonList;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+@Path(ServiceGroupClient.SERVICE_PATH)
+@Produces({"application/xml"})
+@Consumes({"application/xml"})
+public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
+       
+    @Override
+    public String getServiceName(){
+        return ServiceGroupClient.SERVICE_NAME;
+    }
+
+    @Override
+    protected String getVersionString() {
+       final String lastChangeRevision = "$LastChangedRevision: 2108 $";
+       return lastChangeRevision;
+    }
+
+    @Override
+    //public Class<ServicegroupsCommon> getCommonPartClass() {
+    public Class getCommonPartClass() {
+       try {
+            return Class.forName("org.collectionspace.services.servicegroup.ServicegroupsCommon");//.class;
+        } catch (ClassNotFoundException e){
+            return null;
+        }
+    }
+
+    @Override
+    public ServiceContextFactory<PoxPayloadIn, PoxPayloadOut> getServiceContextFactory() {
+        return RemoteServiceContextFactory.get();
+    }
+
+
+    //======================= GET ====================================================
+    /*
+    @GET
+    @Path("{groupname}")
+    public byte[] get(
+            @Context UriInfo ui,
+            @PathParam("csid") String csid) {
+        PoxPayloadOut result = null;
+        ensureCSID(csid, READ);
+        try {
+            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            result = Need to fetch info and prepare it.
+            if (result == null) {
+                Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                        ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build();
+                throw new WebApplicationException(response);
+            }
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.READ_FAILED, csid);
+        }
+
+        return result.getBytes();
+    }
+    */
+
+
+    //======================= GET without specifier: List  =====================================
+    @GET
+    public AbstractCommonList getList(@Context UriInfo ui) {
+        try {
+            CommonList commonList = new CommonList();
+            AbstractCommonList list = (AbstractCommonList)commonList;
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
+               String commonSchema = ctx.getCommonPartLabel();
+               ArrayList<String> svcGroups = new ArrayList<String>();
+               svcGroups.add("procedure");
+               svcGroups.add("object");
+               svcGroups.add("authority");
+               // Fetch the list of groups from the tenant-bindings config, and prepare a list item
+               // for each one.
+               // We always declare this a full list, of the size that we are returning. 
+               // Not quite in the spirit of what paging means, but tells callers not to ask for more.
+               list.setPageNum(0);
+               list.setPageSize(svcGroups.size());
+               list.setItemsInPage(svcGroups.size());
+               list.setTotalItems(svcGroups.size());
+               String fields[] = new String[2];
+               fields[0] = ServiceGroupListItemJAXBSchema.NAME;
+               fields[1] = ServiceGroupListItemJAXBSchema.URI;
+               commonList.setFieldsReturned(fields);
+                       HashMap<String,String> item = new HashMap<String,String>();
+               for(String groupName:svcGroups){
+                   item.put(ServiceGroupListItemJAXBSchema.NAME, groupName);
+                   String uri = "/" + getServiceName().toLowerCase() + "/" + groupName;
+                   item.put(ServiceGroupListItemJAXBSchema.URI, uri);
+                   commonList.addItem(item);
+                   item.clear();
+               }
+               return list;
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.LIST_FAILED);
+        }
+        
+    }
+
+    
+}
diff --git a/services/servicegroup/service/src/test/java/org/collectionspace/services/test/ServiceGroupServiceTest.java b/services/servicegroup/service/src/test/java/org/collectionspace/services/test/ServiceGroupServiceTest.java
new file mode 100644 (file)
index 0000000..307ed28
--- /dev/null
@@ -0,0 +1,13 @@
+package org.collectionspace.services.test;
+
+//import org.collectionspace.services.servicegroup.ServiceGroup;
+//import org.collectionspace.services.servicegroup.ServiceGroupList;
+
+/**
+ * Placeholder for server-side testing of ServiceGroup service code.
+ * 
+ * @version $Revision: 2108 $
+ */
+public class ServiceGroupServiceTest {
+       //empty
+}
diff --git a/services/servicegroup/service/src/test/resources/log4j.xml b/services/servicegroup/service/src/test/resources/log4j.xml
new file mode 100644 (file)
index 0000000..52121cb
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+       <appender name="console" class="org.apache.log4j.ConsoleAppender">
+               <param name="Target" value="System.out" />
+               <layout class="org.apache.log4j.TTCCLayout">
+                       <param name="DateFormat" value="ISO8601" />
+               </layout>
+       </appender>
+
+
+       <appender name="unit-tests"
+               class="org.apache.log4j.RollingFileAppender">
+               <param name="File" value="./target/unit-tests.log" />
+               <param name="MaxFileSize" value="10240KB" />
+               <param name="MaxBackupIndex" value="6" />
+               <layout class="org.apache.log4j.TTCCLayout">
+                       <param name="DateFormat" value="ISO8601" />
+               </layout>
+       </appender>
+
+       <logger name="org.apache.commons.httpclient" additivity="false">
+               <level value="warn" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </logger>
+
+       <logger name="httpclient.wire" additivity="false">
+               <level value="info" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </logger>
+
+       <root>
+               <priority value="debug" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </root>
+
+</log4j:configuration>
+
+
+
+