<artifactId>org.collectionspace.services.dimension.service</artifactId>\r
<version>${project.version}</version>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.servicegroup.service</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.contact.service</artifactId>\r
import org.collectionspace.services.report.ReportResource;
import org.collectionspace.services.acquisition.AcquisitionResource;
import org.collectionspace.services.dimension.DimensionResource;
+import org.collectionspace.services.servicegroup.ServiceGroupResource;
import org.collectionspace.services.contact.ContactResource;
import org.collectionspace.services.vocabulary.VocabularyResource;
import org.collectionspace.services.organization.OrgAuthorityResource;
singletons.add(new AccountResource());
singletons.add(new RoleResource());
singletons.add(new PermissionResource());
+ singletons.add(new ServiceGroupResource());
addResourceToMapAndSingletons(new VocabularyResource());
addResourceToMapAndSingletons(new PersonAuthorityResource());
#\r
# CollectionSpace log levels\r
#\r
-log4j.logger.org.collectionspace=INFO\r
+log4j.logger.org.collectionspace=DEBUG\r
#log4j.logger.org.collectionspace.services.common.vocabulary.nuxeo=TRACE\r
+log4j.logger.org.collectionspace.services.authorization=TRACE\r
log4j.logger.perf.collectionspace=ERROR\r
\r
log4j.logger.org.nuxeo=INFO\r
<ant antfile="id/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="note/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="collectionobject/build.xml" target="deploy" inheritAll="false"/>\r
+ <ant antfile="servicegroup/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="group/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="imports/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="imports/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="group/build.xml" target="undeploy" inheritAll="false"/>\r
+ <ant antfile="servicegroup/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="collectionobject/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="note/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="id/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="relation/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="id/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="collectionobject/build.xml" target="dist" inheritAll="false"/>\r
+ <ant antfile="servicegroup/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="group/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="loanin/build.xml" target="dist" inheritAll="false"/>\r
</tenant:serviceBindings>
<!-- end id service meta-data -->
+ <!-- begin servicegroup service meta-data -->
+ <!-- Servicegroup is a task service that has no representation in the repo,
+ but provides tools like keyword search across many types of services.
+ -->
+ <tenant:serviceBindings id="servicegroups" name="servicegroups" type="utility" version="0.1">
+ <!-- other URI paths through which this service could be accessed -->
+ </tenant:serviceBindings>
+ <!-- end servicegroup service meta-data -->
+
<!-- begin collectionobject service meta-data -->
<tenant:serviceBindings id="CollectionObjects" name="CollectionObjects" type="object" version="0.1">
<service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/collectionobjects/*/workflow/</service:uriPath>
<module>person</module>
<module>id</module>
<module>collectionobject</module>
+ <module>servicegroup</module>
<module>group</module>
<module>intake</module>
<module>loanin</module>
<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>
<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>
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.ServiceGroupClient;
import org.collectionspace.services.client.ServiceGroupProxy;
import org.collectionspace.services.client.PayloadOutputPart;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class ServiceGroupServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ServicegroupsCommon> {
+public class ServiceGroupServiceTest extends BaseServiceTest<AbstractCommonList> {
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;
+ private String readGroupName = "procedure";
@Override
public String getServicePathComponent() {
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);
+ public ServicegroupsCommon extractCommonPartValue(CollectionSpaceClient client,
+ ClientResponse<String> res) throws Exception {
+
+ ServicegroupsCommon result = null;
+ PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());
+ if (payloadInputPart != null) {
+ result = (ServicegroupsCommon) payloadInputPart.getBody();
+ }
+ Assert.assertNotNull(result,
+ "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");
+
+ return result;
}
-
- 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;
+ protected PayloadInputPart extractPart(ClientResponse<String> res, String partLabel)
+ throws Exception {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Reading part " + partLabel + " ...");
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PayloadInputPart payloadInputPart = input.getPart(partLabel);
+ Assert.assertNotNull(payloadInputPart,
+ "Part " + partLabel + " was unexpectedly null.");
+ return payloadInputPart;
}
- @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;
- }
+ @Test(dataProvider = "testName", dependsOnMethods = {"readList"})
+ public void read(String testName) throws Exception {
+ // Perform setup.
+ setupRead();
- @Override
- protected void compareUpdatedInstances(ServicegroupsCommon original,
- ServicegroupsCommon updated) throws Exception {
- Assert.assertEquals(updated.getName(), original.getName());
- }
+ // Submit the request to the service and store the response.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<String> res = client.read(readGroupName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ ServicegroupsCommon output = extractCommonPartValue(client, res);
+ Assert.assertNotNull(output);
+
+ //
+ // Now compare with the expected field values
+ //
+ Assert.assertEquals(output.getName(), readGroupName,
+ "Display name in updated object did not match submitted data.");
+ }
+
+
+ @Test(dataProvider = "testName")
+ public void readList(String testName) throws Exception {
+ // Perform setup.
+ setupReadList();
+
+ // Submit the request to the service and store the response.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<AbstractCommonList> res = client.readList();
+ AbstractCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
+ }
+ }
+
+
}
import org.collectionspace.services.client.ServiceGroupClient;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ResourceBase;
import org.collectionspace.services.common.ServiceMessages;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.RemoteServiceContextFactory;
return ServiceGroupClient.SERVICE_NAME;
}
+ public String getServicePathComponent(){
+ return ServiceGroupClient.SERVICE_NAME.toLowerCase();
+ }
+
@Override
protected String getVersionString() {
final String lastChangeRevision = "$LastChangedRevision: 2108 $";
//======================= GET ====================================================
- /*
+ // NOTE that csid is not a good name for the specifier, but if we name it anything else,
+ // our AuthZ gets confused!!!
@GET
- @Path("{groupname}")
+ @Path("{csid}")
public byte[] get(
@Context UriInfo ui,
- @PathParam("csid") String csid) {
+ @PathParam("csid") String groupname) {
PoxPayloadOut result = null;
- ensureCSID(csid, READ);
+ ensureCSID(groupname, ResourceBase.READ);
try {
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
- result = Need to fetch info and prepare it.
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
+ ServicegroupsCommon common = new ServicegroupsCommon();
+ common.setName(groupname);
+ String uri = "/" + getServicePathComponent() + "/" + groupname;
+ common.setUri(uri);
+ result = new PoxPayloadOut(getServicePathComponent());
+ result.addPart("ServicegroupsCommon", common);
+
+ /* If we cannot get the result, then...
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);
+ throw bigReThrow(e, ServiceMessages.READ_FAILED, groupname);
}
return result.getBytes();
}
- */
//======================= GET without specifier: List =====================================