package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
+import org.collectionspace.services.description.ServiceDescription;
/**
* A AccountClient.
* @return response
* @see org.collectionspace.hello.client.AccountProxy#readList()
*/
+ @Override
public Response readList() {
return getProxy().readList();
}
* @return response
* @see org.collectionspace.hello.client.AccountProxy#getAccount(java.lang.String)
*/
+ @Override
public Response read(String csid) {
return getProxy().read(csid);
}
* @return response
* @see org.collectionspace.hello.client.AccountProxy#create(org.collectionspace.services.account.AccountsCommon)
*/
+ @Override
public Response create(AccountsCommon multipart) {
return getProxy().create(multipart);
}
* @return response
* @see org.collectionspace.hello.client.AccountProxy#updateAccount(java.lang.Long, org.collectionspace.services.account.AccountsCommon)
*/
+ @Override
public Response update(String csid, AccountsCommon multipart) {
return getProxy().update(csid, multipart);
}
+
+ /**
+ *
+ */
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.AccountRole;
+import org.collectionspace.services.description.ServiceDescription;
import org.collectionspace.services.jaxb.AbstractCommonList;
/**
* @param arcsid the arcsid
* @return the client response
*/
+ @Override
public Response read(String csid) {
return getProxy().read(csid);
}
public Response delete(String csid, AccountRole accRole) {
return getProxy().delete(csid, "delete", accRole);
}
+
+ /**
+ *
+ */
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
/*
* Not supported.
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.account.Tenant;
import org.collectionspace.services.account.TenantsList;
+import org.collectionspace.services.description.ServiceDescription;
/**
* A TenantClient.
* @return response
* @see org.collectionspace.hello.client.TenantProxy#readList()
*/
+ @Override
public Response readList() {
return getProxy().readList();
}
* @return response
* @see org.collectionspace.hello.client.TenantProxy#getTenant(java.lang.String)
*/
+ @Override
public Response read(String id) {
return getProxy().read(id);
}
* @return response
* @see org.collectionspace.hello.client.TenantProxy#create(org.collectionspace.services.account.Tenant)
*/
+ @Override
public Response create(Tenant multipart) {
return getProxy().create(multipart);
}
* @return response
* @see org.collectionspace.hello.client.TenantProxy#updateTenant(java.lang.Long, org.collectionspace.services.account.Tenant)
*/
+ @Override
public Response update(String id, Tenant multipart) {
return getProxy().update(id, multipart);
}
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
+import org.collectionspace.services.description.ServiceDescription;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentModelList;
uriRegistryEntriesMap.putAll(getUriRegistryEntries(tenantId, getItemDocType(tenantId), UriTemplateFactory.ITEM));
}
return uriRegistryEntriesMap;
- }
+ }
+
+ /**
+ *
+ */
+ public ServiceDescription getDescription(ServiceContext ctx) {
+ ServiceDescription result = super.getDescription(ctx);
+ result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId()));
+ return result;
+ }
+
}
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.perms.Permission;
import org.collectionspace.services.authorization.perms.PermissionsList;
+import org.collectionspace.services.description.ServiceDescription;
/**
* A PermissionClient.
* @return
* @see org.collectionspace.hello.client.PermissionProxy#readList()
*/
+ @Override
public Response readList() {
return getProxy().readList();
* @return
* @see org.collectionspace.hello.client.PermissionProxy#getAccount(java.lang.String)
*/
+ @Override
public Response read(String csid) {
return getProxy().read(csid);
}
* @return
* @see org.collectionspace.hello.client.PermissionProxy#create(org.collectionspace.services.permission.Permission)
*/
+ @Override
public Response create(Permission permission) {
return getProxy().create(permission);
}
* @return
* @see org.collectionspace.hello.client.PermissionProxy#updateAccount(java.lang.Long, org.collectionspace.services.permission.Permission)
*/
+ @Override
public Response update(String csid, Permission permission) {
return getProxy().update(csid, permission);
}
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.PermissionRole;
+import org.collectionspace.services.description.ServiceDescription;
/**
* A PermissionRoleClient.
* @return the client response
* @see
*/
+ @Override
public Response read(String csid) {
return getProxy().read(csid);
}
public Response readList() {
throw new UnsupportedOperationException(); //method not supported nor needed
}
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
+
+
+import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.Role;
import org.collectionspace.services.authorization.RolesList;
+import org.collectionspace.services.description.ServiceDescription;
/**
* A RoleClient.
public Class<RoleProxy> getProxyClass() {
return RoleProxy.class;
}
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.PermissionRole;
+import org.collectionspace.services.description.ServiceDescription;
// TODO: Auto-generated Javadoc
/**
public Response readList() {
throw new UnsupportedOperationException(); //method not supported nor needed
}
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
<target name="import-windows" if="osfamily-windows" depends="setup_hibernate.cfg">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
- <arg value="mvn.bat" /> <!-- To debug, change command here to be 'mvnDebug.bat' -->
+ <arg value=" .bat" /> <!-- To debug, change command here to be 'mvnDebug.bat' -->
<arg value="exec:java" />
<arg value="-f" />
<arg value="${basedir}/pom.xml" />
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
+import org.apache.http.HttpStatus;
+import org.collectionspace.services.description.ServiceDescription;
import org.collectionspace.services.jaxb.AbstractCommonList;
/*
super();
}
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
+
@Override
public Response create(PoxPayloadOut xmlPayload) {
return getProxy().create(xmlPayload.getBytes());
import javax.ws.rs.core.Response;
import org.apache.commons.httpclient.HttpClient;
-import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.description.ServiceDescription;
/**
* LT - List Type
public static final String URL_PROPERTY = "cspace.url";
public static final String USER_PROPERTY = "cspace.user";
public static final String TENANT_PROPERTY = "cspace.tenant";
+
+ // JAX-RS path for getting service description meta information
+ public static final String SERVICE_DESCRIPTION_PATH = "description";
/**
* Gets the proxy.
* Common proxied service calls
*/
+ public ServiceDescription getServiceDescription();
+
public Response create(REQUEST_TYPE payload);
public Response read(String csid);
public Response keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted);
- public Response advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted);
+ public Response advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted);
}
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
-
-import org.jboss.resteasy.client.ClientResponse;
/**
* The Interface CollectionSpaceProxy.
@Consumes({"application/xml"})
@Path("{csid}" + WorkflowClient.SERVICE_PATH + "/" + "{transition}")
Response updateWorkflowWithTransition(@PathParam("csid") String csid, @PathParam("transition") String transition);
-
+
+ /**
+ * Return a payload of meta info about the service
+ * @return
+ */
+ @GET
+ @Produces({"application/xml"})
+ @Path("/" + CollectionSpaceClient.SERVICE_DESCRIPTION_PATH)
+ public Response getServiceDescription();
+
/*
* (R)read List operations
*/
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
+import org.collectionspace.services.description.ServiceDescription;
import org.collectionspace.services.jaxb.AbstractCommonList;
/**
@Override
public Response readList() {
throw new UnsupportedOperationException();
- }
+ }
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
package org.collectionspace.services.client.test;
-import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
-import org.collectionspace.services.client.AuthorityClientImpl;
-import org.collectionspace.services.client.AuthorityProxy;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.client.RelationClient;
import org.collectionspace.services.client.XmlTools;
import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.description.ServiceDescription;
import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.relation.RelationsCommon;
+import org.collectionspace.services.relation.RelationshipType;
+
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected String knownAuthorityWithItemsIdentifier = null;
protected static final String SAS_IDENTIFIER = "SAS";
+ protected static final String SAS_WITH_RELATIONS = "_RELATIONS_";
+
+ private static final int SAS_ITEMLIST_SIZE = 5;
- private static final int SAS_ITEMLIST_SIZE = 5;
protected String knownSASAuthorityResourceId = null;
- protected String knownSASAuthorityResourceIdentifier = null;
+ protected String knownSASAuthorityResourceShortId = null;
protected List<String> knownSASItemIdentifiersList = new ArrayList<String>();
protected String knownSASItemResourceId = null;
protected HashMap<String, String> allSASResourceItemIdsCreated = new HashMap<String, String>(); /* itemURN, parentURN */;
protected int nItemsToCreateInList = 5;
protected String TEST_SHORTID = "johnWayneActor";
+ protected String knownSASAuthorityResourceWithRelationsId = null;
+ protected String knownSASAuthorityResourceWithRelationsShortId = null;
+
/*
* Abstract methods that subclasses must override/implement
*/
* @return
*/
protected String getSASAuthorityIdentifier() {
- // TODO Auto-generated method stub
return this.getKnowResourceIdentifier() + SAS_IDENTIFIER;
}
+ /**
+ *
+ * @return
+ */
+ protected String getSASAuthorityWithRelationsIdentifier() {
+ return this.getKnowResourceIdentifier() + SAS_WITH_RELATIONS + SAS_IDENTIFIER;
+ }
+
/**
*
* @param shortId
//
String localAuthorityId = null;
try {
- localAuthorityId = createResource(client, testName, knownSASAuthorityResourceIdentifier, false);
+ localAuthorityId = createResource(client, testName, knownSASAuthorityResourceShortId, false);
} catch (Exception e) {
Assert.assertNotNull(localAuthorityId);
}
// Now we can try to sync the SAS authority with the local one we just created.
//
setupSync();
- Response response = client.syncByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+ Response response = client.syncByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
try {
int statusCode = response.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
// Check to see if the parent authority (local) is in the "Replicated" state.
//
setupRead();
- response = client.readByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+ response = client.readByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
try {
int statusCode = response.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
// Submit the request to the service and store the response.
Response res = null;
- res = client.readItemListForNamedAuthority(knownSASAuthorityResourceIdentifier, null, null);
+ res = client.readItemListForNamedAuthority(knownSASAuthorityResourceShortId, null, null);
try {
int statusCode = res.getStatus();
+ nItemsToCreateInList + " items; got: " + nItemsReturned + " of: " + nItemsTotal);
}
Assert.assertEquals(nItemsTotal, SAS_ITEMLIST_SIZE);
-
+ //
+ // Verify that each of our local items has a corresponding remote item
+ //
for (AbstractCommonList.ListItem item : items) {
String shortId = AbstractCommonListUtils.ListItemGetElementValue(
item, AuthorityClient.SHORT_IDENTIFIER);
try {
String newID = createResource(getSASClientInstance(), testName, getSASAuthorityIdentifier(), true);
knownSASAuthorityResourceId = newID;
- knownSASAuthorityResourceIdentifier = getShortId(getSASClientInstance(), knownSASAuthorityResourceId);
+ knownSASAuthorityResourceShortId = getShortId(getSASClientInstance(), knownSASAuthorityResourceId);
if (logger.isDebugEnabled()) {
String.format("Created SAS authority '%s' with CSID=%s.", getSASAuthorityIdentifier(), newID);
}
logger.info(String.format("Failed to create SAS authority '%s'.", getSASAuthorityIdentifier()));
}
}
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"deleteLocalItemWithSync", "CRUDTests"})
+ public void createSASAuthorityWithRelations(String testName) {
+ //
+ // First check to see if the authority supports synchronization.
+ //
+ AuthorityClient client = (AuthorityClient) getClientInstance();
+ if (client.supportsSync() == false) {
+ return; // Exit the test since this authority doesn't support synchronization
+ }
+
+ // Perform setup.
+ setupCreate();
+ //
+ // Create a new authority on the remote server
+ //
+ try {
+ String newID = createResource(getSASClientInstance(), testName, getSASAuthorityWithRelationsIdentifier(), true);
+ knownSASAuthorityResourceWithRelationsId = newID;
+ knownSASAuthorityResourceWithRelationsShortId = getShortId(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId);
+ } catch (Exception e) {
+ logger.info(String.format("Failed to create SAS authority with relations '%s'.", getSASAuthorityWithRelationsIdentifier()));
+ }
+ //
+ // Add three items to the remote authority
+ //
+ String continentShortId = "Continent" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
+ String continentCSID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId, continentShortId);
+ this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(continentShortId), getUrnIdentifier(getSASAuthorityWithRelationsIdentifier()));
+
+ String countryShortId = "Country" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
+ String countryCSID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId, countryShortId);
+ this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(countryShortId), getUrnIdentifier(getSASAuthorityWithRelationsIdentifier()));
+
+ String cityShortId = "City" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
+ String cityCSID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId, cityShortId);
+ this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(cityShortId), getUrnIdentifier(getSASAuthorityWithRelationsIdentifier()));
+ //
+ // Create a set of hierarchical relationships between the items
+ //
+ ServiceDescription serviceDescription = client.getServiceDescription();
+ final String authorityItemDocumentType = serviceDescription == null ? "unknown" : serviceDescription.getSubresourceDocumentType();
+
+ RelationsCommon relationCommon = new RelationsCommon();
+ relationCommon.setSubjectCsid(countryCSID);
+ relationCommon.setSubjectDocumentType(authorityItemDocumentType);
+ relationCommon.setObjectCsid(continentCSID);
+ relationCommon.setObjectDocumentType(authorityItemDocumentType);
+ relationCommon.setRelationshipType(RelationshipType.HAS_BROADER.value());
+ relationCommon.setPredicateDisplayName(RelationshipType.HAS_BROADER.value());
+
+ RelationClient relationClient = new RelationClient(CollectionSpaceClient.SAS_CLIENT_PROPERTIES_FILENAME); // Get a Relation service client to the SAS
+ PoxPayloadOut payloadOut = relationClient.createRequestTypeInstance(relationCommon);
+ Response res = relationClient.create(payloadOut);
+ if (res.getStatus() != HttpStatus.SC_CREATED) {
+ logger.error("Could not create Relationship.");
+ }
+
+}
/**
* SAS - Create an item in the SAS authority on the SAS server.
// the *local* authority after we perform a sync operation. We need to keep track
// of the URN (not the CSID) since the CSIDs will differ on the SAS vs local.
//
- this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(shortId), getUrnIdentifier(getSASAuthorityIdentifier()));
+ this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(shortId), getUrnIdentifier(knownSASAuthorityResourceShortId));
}
}
// Delete an item from the SAS server
AuthorityClient sasClient = (AuthorityClient) this.getSASClientInstance();
- Response res = sasClient.deleteNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(itemIndexToDelete));
+ Response res = sasClient.deleteNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(itemIndexToDelete));
try {
Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
} finally {
// to the SAS takes place locally after the sync -i.e., the local item should be deleted as well.
setupSync();
AuthorityClient localClient = (AuthorityClient) this.getClientInstance();
- Response response = localClient.syncByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+ Response response = localClient.syncByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
try {
int statusCode = response.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode));
// Verify that the local item has been deleted.
setupReadNonExistent();
- res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(itemIndexToDelete));
+ res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(itemIndexToDelete));
try {
Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
knownSASItemIdentifiersList.remove(0); // remove it from our known set now that we've deleted it
// Retrieve the contents of a shared authority item that we're going to update.
AUTHORITY_ITEM_TYPE sasAuthorityItem = null;
AuthorityClient sasClient = (AuthorityClient) this.getSASClientInstance();
- Response res = sasClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(0));
+ Response res = sasClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(0));
try {
if (logger.isDebugEnabled()) {
logger.debug(testName + ": read status = " + res.getStatus());
// Submit the updated authority item and check the response.
PoxPayloadOut output = this.createItemRequestTypeInstance(theUpdate);
- res = sasClient.updateNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(0), output);
+ res = sasClient.updateNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(0), output);
AUTHORITY_ITEM_TYPE updatedSASAuthorityItem = null;
try {
int statusCode = res.getStatus();
// to the SAS item appears locally after the sync
setupSync();
AuthorityClient localClient = (AuthorityClient) this.getClientInstance();
- Response response = localClient.syncByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+ Response response = localClient.syncByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
try {
int statusCode = response.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode));
}
setupRead();
- res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(0));
+ res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(0));
try {
Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
AUTHORITY_ITEM_TYPE syncedAuthorityItem = extractItemCommonPartValue(res);
*/
package org.collectionspace.services.common;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.common.CSWebApplicationException;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
+import org.collectionspace.services.common.context.MultipartServiceContext;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.context.ServiceContextProperties;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.storage.StorageClient;
import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;
import org.collectionspace.services.config.service.ServiceBindingType;
-import org.jboss.resteasy.core.ResourceMethodInvoker;
-//import org.jboss.resteasy.core.ResourceMethod;
+import org.collectionspace.services.description.ServiceDescription;
import org.jboss.resteasy.spi.HttpRequest;
-import org.jboss.resteasy.spi.metadata.ResourceMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return result;
}
+
+ /*
+ * Get the service description
+ */
+ @GET
+ @Path(CollectionSpaceClient.SERVICE_DESCRIPTION_PATH)
+ public ServiceDescription getDescription(@Context UriInfo uriInfo) {
+ ServiceDescription result = null;
+
+ ServiceContext ctx = null;
+ try {
+ ctx = createServiceContext(uriInfo);
+ result = getDescription(ctx);
+ } catch (Exception e) {
+ String errMsg = String.format("Request to get service description information for the '%s' service failed.",
+ this.getServiceContextFactory());
+ throw bigReThrow(e, errMsg);
+ }
+
+ return result;
+ }
+
+ /**
+ * Each resource can override this method if they need to.
+ *
+ * @param ctx
+ * @return
+ */
+ public ServiceDescription getDescription(ServiceContext ctx) {
+ ServiceDescription result = new ServiceDescription();
+
+ result.setDocumentType(getDocType(ctx.getTenantId()));
+
+ return result;
+ }
public void checkResult(Object resultToCheck, String csid, String serviceMessage) throws CSWebApplicationException {
if (resultToCheck == null) {
import org.collectionspace.services.lifecycle.Lifecycle;
import org.collectionspace.services.lifecycle.TransitionDef;
import org.collectionspace.services.workflow.WorkflowCommon;
+
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return docHandler;
}
-
- /*
- * JAX-RS Annotated methods
+
+ /**
+ * Get the workflow lifecycle description of a resource
+ * @param uriInfo
+ * @return
*/
@GET
@Path(WorkflowClient.SERVICE_PATH)
return result;
}
-
- /*
- * JAX-RS Annotated methods
- */
-
+
/*
* We should change this method. The RepositoryClient (from call to getRepositoryClient) should support a call getWorkflowTransition() instead.
*/
*/
package org.collectionspace.services.common;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.common.config.ServiceConfigUtils;
-import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
import org.collectionspace.services.common.context.RemoteServiceContext;
import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.DocumentException;
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.config.ClientType;
import org.collectionspace.services.config.service.DocHandlerParams;
import org.collectionspace.services.config.service.ListResultField;
-import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.description.ServiceDescription;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
return result;
}
+
+ @Override
+ public ServiceDescription getDescription(ServiceContext ctx) {
+ ServiceDescription result = new ServiceDescription();
+
+ result.setDocumentType(getDocType(ctx.getTenantId()));
+
+ return result;
+ }
/*
* ResourceBase create and update calls will set the resourceMap into the service context
import org.collectionspace.services.authorization.AuthZ;
import org.collectionspace.services.authorization.CSpaceResource;
import org.collectionspace.services.authorization.URIResourceImpl;
+import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.index.IndexClient;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.config.service.ServiceBindingType;
String pathSegment = null;
while (strTok.hasMoreTokens() == true) {
pathSegment = strTok.nextToken();
- if (pathSegment.equals("*") == true || pathSegment.equals("index") == true) {
+ if (pathSegment.equals("*") ||
+ pathSegment.equals("index") || pathSegment.equals(CollectionSpaceClient.SERVICE_DESCRIPTION_PATH)) { // Strip off subresource paths since they inherit their parent's permissions
//
// leave the loop if we hit a wildcard character or the "index" subresource
//
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
+import org.collectionspace.services.description.ServiceDescription;
+
/**
* IDClient.
*
// Operations on ID Generators
+ @Override
public Response create(String xmlPayload) {
return getProxy().create(xmlPayload);
}
+ @Override
public Response read(String csid) {
return getProxy().read(csid);
}
+ @Override
public Response readList() {
return getProxy().readList();
}
@Override
public Response update(String csid, String payload) {
- throw new UnsupportedOperationException("ID client does not support an update operation."); }
+ throw new UnsupportedOperationException("ID client does not support an update operation.");
+ }
+
+ @Override
+ public ServiceDescription getServiceDescription() {
+ ServiceDescription result = null;
+
+ Response res = getProxy().getServiceDescription();
+ if (res.getStatus() == HttpStatus.SC_OK) {
+ result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+ }
+
+ return result;
+ }
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ Service Description Schema (XSD)
+
+ Entity : ServiceDescription
+ Used for: JAXB binding between XML and Java objects
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="1.0" elementFormDefault="unqualified"
+ xmlns:ns="http://collectionspace.org/services/description"
+ xmlns="http://collectionspace.org/services/description"
+ targetNamespace="http://collectionspace.org/services/description"
+ version="0.1">
+<!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->
+ <!-- ServiceDescription -->
+ <xs:element name="service_description">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="documentType" type="xs:string"/>
+ <xs:element name="subresourceDocumentType" type="xs:string"/>
+ <xs:element name="serviceVersion" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
+