Passes *ALL* current tests and merged with the latest set of sources.
import org.collectionspace.services.account.storage.AccountStorageClient;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
-import org.collectionspace.services.common.context.RemoteServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class AccountResource.
+ */
@Path("/accounts")
@Consumes("application/xml")
@Produces("application/xml")
public class AccountResource
- extends AbstractCollectionSpaceResourceImpl {
+ extends AbstractCollectionSpaceResourceImpl<AccountsCommon, AccountsCommon> {
+ /** The service name. */
final private String serviceName = "accounts";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(AccountResource.class);
+
+ /** The storage client. */
final StorageClient storageClient = new AccountStorageClient();
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceName;
}
+
+ @Override
+ public Class<AccountsCommon> getCommonPartClass() {
+ return AccountsCommon.class;
+ }
- private <T> ServiceContext createServiceContext(T obj) throws Exception {
- ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
- ctx.setInput(obj);
- ctx.setDocumentType(AccountsCommon.class.getPackage().getName()); //persistence unit
- ctx.setProperty("entity-name", AccountsCommon.class.getName());
- return ctx;
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getServiceContextFactory()
+ */
+ @Override
+ public ServiceContextFactory<AccountsCommon, AccountsCommon> getServiceContextFactory() {
+ return (ServiceContextFactory<AccountsCommon, AccountsCommon>)RemoteServiceContextFactory.get();
}
+
+// private <T> ServiceContext createServiceContext(T obj) throws Exception {
+// ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
+// ctx.setInput(obj);
+// ctx.setDocumentType(AccountsCommon.class.getPackage().getName()); //persistence unit
+// ctx.setProperty("entity-name", AccountsCommon.class.getName());
+// return ctx;
+// }
- @Override
- public StorageClient getStorageClient(ServiceContext ctx) {
- //FIXME use ctx to identify storage client
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getStorageClient(org.collectionspace.services.common.context.ServiceContext)
+ */
+@Override
+ public StorageClient getStorageClient(ServiceContext<AccountsCommon, AccountsCommon> ctx) {
+ //FIXME use ctx to identify storage client
return storageClient;
}
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- docHandler.setCommonPart(ctx.getInput());
- return docHandler;
- }
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// docHandler.setCommonPart(ctx.getInput());
+// return docHandler;
+// }
- @POST
+ /**
+ * Creates the account.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+@POST
public Response createAccount(AccountsCommon input) {
try {
- ServiceContext ctx = createServiceContext(input);
+ ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext(input, AccountsCommon.class);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getStorageClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(AccountResource.class);
}
}
+ /**
+ * Gets the account.
+ *
+ * @param csid the csid
+ *
+ * @return the account
+ */
@GET
@Path("{csid}")
public AccountsCommon getAccount(
}
AccountsCommon result = null;
try {
- ServiceContext ctx = createServiceContext((AccountsCommon) null);
+ ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext((AccountsCommon) null, AccountsCommon.class);
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).get(ctx, csid, handler);
result = (AccountsCommon) ctx.getOutput();
return result;
}
+ /**
+ * Gets the account list.
+ *
+ * @param ui the ui
+ *
+ * @return the account list
+ */
@GET
@Produces("application/xml")
public AccountsCommonList getAccountList(
@Context UriInfo ui) {
AccountsCommonList accountList = new AccountsCommonList();
try {
- ServiceContext ctx = createServiceContext((AccountsCommonList) null);
+ ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext((AccountsCommon) null, AccountsCommon.class);
DocumentHandler handler = createDocumentHandler(ctx);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx);
+ DocumentFilter myFilter = handler.createDocumentFilter();
myFilter.setPagination(queryParams);
myFilter.setQueryParams(queryParams);
handler.setDocumentFilter(myFilter);
return accountList;
}
+ /**
+ * Update account.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the accounts common
+ */
@PUT
@Path("{csid}")
public AccountsCommon updateAccount(
}
AccountsCommon result = null;
try {
- ServiceContext ctx = createServiceContext(theUpdate);
+ ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext(theUpdate, AccountsCommon.class);
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).update(ctx, csid, handler);
result = (AccountsCommon) ctx.getOutput();
return result;
}
+ /**
+ * Delete account.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deleteAccount(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = createServiceContext((AccountsCommon) null);
+ ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext((AccountsCommon) null,
+ AccountsCommon.class);
getStorageClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
}
@Override
- public DocumentFilter createDocumentFilter(ServiceContext ctx) {
- DocumentFilter filter = new AccountJpaFilter();
- filter.setPageSize(
- ctx.getServiceBindingPropertyValue(
- DocumentFilter.PAGE_SIZE_DEFAULT_PROPERTY));
+ public DocumentFilter createDocumentFilter() {
+ DocumentFilter filter = new AccountJpaFilter(this.getServiceContext());
return filter;
}
account.setPassword(null);
account.setTenants(new ArrayList<AccountTenant>(0));
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.document.DocumentHandler#initializeDocumentFilter(org.collectionspace.services.common.context.ServiceContext)
+ */
+ public void initializeDocumentFilter(ServiceContext ctx) {
+ // set a default document filter in this method
+ }
}
import java.util.ArrayList;
import java.util.List;
import org.collectionspace.services.common.storage.jpa.JpaDocumentFilter;
+import org.collectionspace.services.common.context.ServiceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final Logger logger = LoggerFactory.getLogger(AccountJpaFilter.class);
+ public AccountJpaFilter(ServiceContext ctx) {
+ super(ctx);
+ }
+
@Override
public List<ParamBinding> buildWhereForSearch(StringBuilder queryStrBldr) {
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.MultipartServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentFilter;
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
public class AcquisitionResource
- extends AbstractCollectionSpaceResourceImpl {
+ extends AbstractMultiPartCollectionSpaceResourceImpl {
/** The service name. */
final private String serviceName = "acquisitions";
public String getServiceName() {
return serviceName;
}
+
+ @Override
+ public Class<AcquisitionsCommon> getCommonPartClass() {
+ return AcquisitionsCommon.class;
+ }
/* (non-Javadoc)
* @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
*/
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), AcquisitionsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((AcquisitionsCommon) obj);
- }
- }
- return docHandler;
- }
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), AcquisitionsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((AcquisitionsCommon) obj);
+// }
+// }
+// return docHandler;
+// }
/**
* Instantiates a new acquisition resource.
public Response createAcquisition(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(AcquisitionResource.class);
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
private AcquisitionsCommonList getAcquisitionsList() {
AcquisitionsCommonList acquisitionObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).getAll(ctx, handler);
acquisitionObjectList = (AcquisitionsCommonList) handler.getCommonPartList();
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
private AcquisitionsCommonList searchAcquisitions(String keywords) {
AcquisitionsCommonList acquisitionObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
// perform a keyword search
if (keywords != null && !keywords.isEmpty()) {
String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
- DocumentFilter documentFilter = handler.createDocumentFilter(ctx);
+ DocumentFilter documentFilter = handler.getDocumentFilter();
documentFilter.setWhereClause(whereClause);
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
@Context UriInfo ui) {
AuthorityRefList authRefList = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
RemoteDocumentModelHandlerImpl handler
import javax.ws.rs.core.UriInfo;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
-import org.collectionspace.services.common.context.RemoteServiceContextImpl;
+//import org.collectionspace.services.common.context.RemoteServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
+import org.collectionspace.services.common.context.ServiceContextFactory;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class PermissionResource.
+ */
@Path("/authorization/permissions")
@Consumes("application/xml")
@Produces("application/xml")
public class PermissionResource
- extends AbstractCollectionSpaceResourceImpl {
+ extends AbstractCollectionSpaceResourceImpl<Permission, Permission> {
+ /** The service name. */
final private String serviceName = "authorization/permissions";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(PermissionResource.class);
+
+ /** The storage client. */
final StorageClient storageClient = new JpaStorageClientImpl(Permission.class);
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceName;
}
-
- private <T> ServiceContext createServiceContext(T obj) throws Exception {
- ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
- ctx.setInput(obj);
- ctx.setDocumentType(Permission.class.getPackage().getName()); //persistence unit
- ctx.setProperty("entity-name", Permission.class.getName());
- return ctx;
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
+ @Override
+ public Class<Permission> getCommonPartClass() {
+ return Permission.class;
}
-
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getServiceContextFactory()
+ */
+ @Override
+ public ServiceContextFactory<Permission, Permission> getServiceContextFactory() {
+ return RemoteServiceContextFactory.get();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getStorageClient(org.collectionspace.services.common.context.ServiceContext)
+ */
@Override
public StorageClient getStorageClient(ServiceContext ctx) {
//FIXME use ctx to identify storage client
return storageClient;
}
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- docHandler.setCommonPart(ctx.getInput());
- return docHandler;
- }
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// docHandler.setCommonPart(ctx.getInput());
+// return docHandler;
+// }
- @POST
+ /**
+ * Creates the permission.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+@POST
public Response createPermission(Permission input) {
try {
- ServiceContext ctx = createServiceContext(input);
+ ServiceContext<Permission, Permission> ctx = createServiceContext(input, Permission.class);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getStorageClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(PermissionResource.class);
}
}
+ /**
+ * Gets the permission.
+ *
+ * @param csid the csid
+ *
+ * @return the permission
+ */
@GET
@Path("{csid}")
public Permission getPermission(
}
Permission result = null;
try {
- ServiceContext ctx = createServiceContext((Permission) null);
+ ServiceContext<Permission, Permission> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).get(ctx, csid, handler);
result = (Permission) ctx.getOutput();
return result;
}
+ /**
+ * Gets the permission list.
+ *
+ * @param ui the ui
+ *
+ * @return the permission list
+ */
@GET
@Produces("application/xml")
public PermissionsList getPermissionList(
@Context UriInfo ui) {
PermissionsList permissionList = new PermissionsList();
try {
- ServiceContext ctx = createServiceContext((PermissionsList) null);
+ ServiceContext<Permission, Permission> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx);
+ DocumentFilter myFilter = handler.createDocumentFilter();
myFilter.setPagination(queryParams);
myFilter.setQueryParams(queryParams);
handler.setDocumentFilter(myFilter);
return permissionList;
}
+ /**
+ * Update permission.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the permission
+ */
@PUT
@Path("{csid}")
public Permission updatePermission(
}
Permission result = null;
try {
- ServiceContext ctx = createServiceContext(theUpdate);
+ ServiceContext<Permission, Permission> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).update(ctx, csid, handler);
result = (Permission) ctx.getOutput();
return result;
}
+ /**
+ * Delete permission.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deletePermission(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = createServiceContext((Permission) null);
+ ServiceContext<Permission, Permission> ctx = createServiceContext();
getStorageClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
import org.collectionspace.services.authorization.storage.PermissionRoleStorageClient;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
import org.collectionspace.services.common.context.RemoteServiceContextImpl;
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.storage.StorageClient;
* @author
*/
public class PermissionRoleSubResource
- extends AbstractCollectionSpaceResourceImpl {
+ extends AbstractCollectionSpaceResourceImpl<PermissionRole, PermissionRole> {
//this service is never exposed as standalone RESTful service...just use unique
//service name to identify binding
+ /** The service name. */
final private String serviceName = "authorization/permroles";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(PermissionRoleSubResource.class);
+
+ /** The storage client. */
final StorageClient storageClient = new PermissionRoleStorageClient();
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceName;
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
+ @Override
+ public Class<PermissionRole> getCommonPartClass() {
+ return PermissionRole.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getServiceContextFactory()
+ */
+ @Override
+ public ServiceContextFactory<PermissionRole, PermissionRole> getServiceContextFactory() {
+ return RemoteServiceContextFactory.get();
+ }
- private <T> ServiceContext createServiceContext(T obj, SubjectType subject) throws Exception {
- ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
- ctx.setInput(obj);
+ /**
+ * Creates the service context.
+ *
+ * @param input the input
+ * @param subject the subject
+ *
+ * @return the service context< permission role, permission role>
+ *
+ * @throws Exception the exception
+ */
+ private ServiceContext<PermissionRole, PermissionRole> createServiceContext(PermissionRole input,
+ SubjectType subject) throws Exception {
+ ServiceContext<PermissionRole, PermissionRole> ctx = createServiceContext(input);
+// ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
+// ctx.setInput(input);
ctx.setDocumentType(PermissionRole.class.getPackage().getName()); //persistence unit
ctx.setProperty("entity-name", PermissionRoleRel.class.getName());
//subject name is necessary to indicate if role or permission is a subject
return ctx;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getStorageClient(org.collectionspace.services.common.context.ServiceContext)
+ */
@Override
- public StorageClient getStorageClient(ServiceContext ctx) {
+ public StorageClient getStorageClient(ServiceContext<PermissionRole, PermissionRole> ctx) {
//FIXME use ctx to identify storage client
return storageClient;
}
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- docHandler.setCommonPart(ctx.getInput());
- return docHandler;
- }
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// docHandler.setCommonPart(ctx.getInput());
+// return docHandler;
+// }
/**
* createPermissionRole creates one or more permission-role relationships
public String createPermissionRole(PermissionRole input, SubjectType subject)
throws Exception {
- ServiceContext ctx = createServiceContext(input, subject);
+ ServiceContext<PermissionRole, PermissionRole> ctx = createServiceContext(input, subject);
DocumentHandler handler = createDocumentHandler(ctx);
return getStorageClient(ctx).create(ctx, handler);
}
logger.debug("getPermissionRole with csid=" + csid);
}
PermissionRole result = null;
- ServiceContext ctx = createServiceContext((PermissionRole) null, subject);
+ ServiceContext<PermissionRole, PermissionRole> ctx = createServiceContext((PermissionRole) null, subject);
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).get(ctx, csid, handler);
result = (PermissionRole) ctx.getOutput();
if (logger.isDebugEnabled()) {
logger.debug("deletePermissionRole with csid=" + csid);
}
- ServiceContext ctx = createServiceContext((PermissionRole) null, subject);
+ ServiceContext<PermissionRole, PermissionRole> ctx = createServiceContext((PermissionRole) null, subject);
getStorageClient(ctx).delete(ctx, csid);
}
}
import javax.ws.rs.core.UriInfo;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
-import org.collectionspace.services.common.context.RemoteServiceContextImpl;
+//import org.collectionspace.services.common.context.RemoteServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.slf4j.LoggerFactory;
+/**
+ * The Class RoleResource.
+ */
@Path("/authorization/roles")
@Consumes("application/xml")
@Produces("application/xml")
public class RoleResource
extends AbstractCollectionSpaceResourceImpl {
+ /** The service name. */
final private String serviceName = "authorization/roles";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(RoleResource.class);
+
+ /** The storage client. */
final StorageClient storageClient = new JpaStorageClientImpl();
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceName;
}
-
- private <T> ServiceContext createServiceContext(T obj) throws Exception {
- ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
- ctx.setInput(obj);
- ctx.setDocumentType(Role.class.getPackage().getName()); //persistence unit
- ctx.setProperty("entity-name", Role.class.getName());
- return ctx;
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
+ @Override
+ public Class<RoleResource> getCommonPartClass() {
+ return RoleResource.class;
}
-
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getServiceContextFactory()
+ */
@Override
+ public ServiceContextFactory getServiceContextFactory() {
+ return RemoteServiceContextFactory.get();
+ }
+
+
+// private <T> ServiceContext createServiceContext(T obj) throws Exception {
+// ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
+// ctx.setInput(obj);
+// ctx.setDocumentType(Role.class.getPackage().getName()); //persistence unit
+// ctx.setProperty("entity-name", Role.class.getName());
+// return ctx;
+// }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getStorageClient(org.collectionspace.services.common.context.ServiceContext)
+ */
+@Override
public StorageClient getStorageClient(ServiceContext ctx) {
//FIXME use ctx to identify storage client
return storageClient;
}
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- docHandler.setCommonPart(ctx.getInput());
- return docHandler;
- }
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// docHandler.setCommonPart(ctx.getInput());
+// return docHandler;
+// }
- @POST
+ /**
+ * Creates the role.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+@POST
public Response createRole(Role input) {
try {
- ServiceContext ctx = createServiceContext(input);
+ ServiceContext ctx = createServiceContext(input, Role.class);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getStorageClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(RoleResource.class);
}
}
+ /**
+ * Gets the role.
+ *
+ * @param csid the csid
+ *
+ * @return the role
+ */
@GET
@Path("{csid}")
public Role getRole(
}
Role result = null;
try {
- ServiceContext ctx = createServiceContext((Role) null);
+ ServiceContext ctx = createServiceContext((Role) null, Role.class);
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).get(ctx, csid, handler);
result = (Role) ctx.getOutput();
return result;
}
+ /**
+ * Gets the role list.
+ *
+ * @param ui the ui
+ *
+ * @return the role list
+ */
@GET
@Produces("application/xml")
public RolesList getRoleList(
@Context UriInfo ui) {
RolesList roleList = new RolesList();
try {
- ServiceContext ctx = createServiceContext((RolesList) null);
+ ServiceContext ctx = createServiceContext((RolesList) null, Role.class);
DocumentHandler handler = createDocumentHandler(ctx);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx);
+ DocumentFilter myFilter = handler.createDocumentFilter();
myFilter.setPagination(queryParams);
myFilter.setQueryParams(queryParams);
handler.setDocumentFilter(myFilter);
return roleList;
}
+ /**
+ * Update role.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the role
+ */
@PUT
@Path("{csid}")
public Role updateRole(
}
Role result = null;
try {
- ServiceContext ctx = createServiceContext(theUpdate);
+ ServiceContext ctx = createServiceContext(theUpdate, Role.class);
DocumentHandler handler = createDocumentHandler(ctx);
getStorageClient(ctx).update(ctx, csid, handler);
result = (Role) ctx.getOutput();
return result;
}
+ /**
+ * Delete role.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deleteRole(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = createServiceContext((Role) null);
+ ServiceContext ctx = createServiceContext((Role) null, Role.class);
((JpaStorageClientImpl)getStorageClient(ctx)).deleteWhere(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
}
@Override
- public DocumentFilter createDocumentFilter(ServiceContext ctx) {
- DocumentFilter filter = new PermissionJpaFilter();
- filter.setPageSize(
- ctx.getServiceBindingPropertyValue(
- DocumentFilter.PAGE_SIZE_DEFAULT_PROPERTY));
+ public DocumentFilter createDocumentFilter() {
+ DocumentFilter filter = new PermissionJpaFilter(this.getServiceContext());
return filter;
}
import java.util.ArrayList;
import java.util.List;
+import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.storage.jpa.JpaDocumentFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final Logger logger = LoggerFactory.getLogger(PermissionJpaFilter.class);
+ /**
+ * Instantiates a new permission jpa filter.
+ *
+ * @param ctx the ctx
+ */
+ public PermissionJpaFilter(ServiceContext ctx) {
+ super(ctx);
+ }
+
@Override
public List<ParamBinding> buildWhereForSearch(StringBuilder queryStrBldr) {
}
@Override
- public DocumentFilter createDocumentFilter(ServiceContext ctx) {
- return new DocumentFilter();
+ public DocumentFilter createDocumentFilter() {
+ return new DocumentFilter(this.getServiceContext());
}
}
}
DocumentFilter docFilter = handler.getDocumentFilter();
if (docFilter == null) {
- docFilter = handler.createDocumentFilter(ctx);
+ docFilter = handler.createDocumentFilter();
}
EntityManagerFactory emf = null;
EntityManager em = null;
}
@Override
- public DocumentFilter createDocumentFilter(ServiceContext ctx) {
- DocumentFilter filter = new RoleJpaFilter();
- filter.setPageSize(
- ctx.getServiceBindingPropertyValue(
- DocumentFilter.PAGE_SIZE_DEFAULT_PROPERTY));
+ public DocumentFilter createDocumentFilter() {
+ DocumentFilter filter = new RoleJpaFilter(this.getServiceContext());
return filter;
}
import java.util.ArrayList;
import java.util.List;
import org.collectionspace.services.common.storage.jpa.JpaDocumentFilter;
+import org.collectionspace.services.common.context.ServiceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final Logger logger = LoggerFactory.getLogger(RoleJpaFilter.class);
+ public RoleJpaFilter(ServiceContext ctx) {
+ super(ctx);
+ }
+
@Override
public List<ParamBinding> buildWhereForSearch(StringBuilder queryStrBldr) {
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.ServiceContextFactory;
+//import org.collectionspace.services.common.context.MultipartServiceContext;
import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.MultipartServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
public class CollectionObjectResource
- extends AbstractCollectionSpaceResourceImpl {
+ extends AbstractMultiPartCollectionSpaceResourceImpl {
/** The Constant serviceName. */
static final public String serviceName = "collectionobjects";
public String getServiceName() {
return serviceName;
}
-
+
/* (non-Javadoc)
- * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
*/
@Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(),
- CollectionobjectsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((CollectionobjectsCommon) obj);
- }
- }
- return docHandler;
+ public Class<CollectionobjectsCommon> getCommonPartClass() {
+ return CollectionobjectsCommon.class;
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(),
+// CollectionobjectsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((CollectionobjectsCommon) obj);
+// }
+// }
+// return docHandler;
+// }
/**
* Creates the collection object.
@POST
public Response createCollectionObject(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input); //
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(CollectionObjectResource.class);
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Gets the collection object list.
+ *
+ * @param ui the ui
+ * @param keywords the keywords
+ *
+ * @return the collection object list
+ */
@GET
@Produces("application/xml")
public CollectionobjectsCommonList getCollectionObjectList(@Context UriInfo ui,
private CollectionobjectsCommonList getCollectionObjectList() {
CollectionobjectsCommonList collectionObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).getAll(ctx, handler);
collectionObjectList = (CollectionobjectsCommonList) handler.getCommonPartList();
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
return result;
}
+ /**
+ * Gets the authority refs.
+ *
+ * @param csid the csid
+ * @param ui the ui
+ *
+ * @return the authority refs
+ */
@GET
@Path("{csid}/authorityrefs")
@Produces("application/xml")
@Context UriInfo ui) {
AuthorityRefList authRefList = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
RemoteDocumentModelHandlerImpl handler
return searchCollectionObjects(keywords);
}
+ /**
+ * Search collection objects.
+ *
+ * @param keywords the keywords
+ *
+ * @return the collectionobjects common list
+ */
private CollectionobjectsCommonList searchCollectionObjects(String keywords) {
CollectionobjectsCommonList collectionObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
// perform a keyword search
if (keywords != null && !keywords.isEmpty()) {
String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
- DocumentFilter documentFilter = handler.createDocumentFilter(ctx);
+ //DocumentFilter documentFilter = handler.createDocumentFilter(ctx);
+ DocumentFilter documentFilter = handler.getDocumentFilter();
documentFilter.setWhereClause(whereClause);
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
import javax.ws.rs.GET;\r
import javax.ws.rs.Path;\r
import javax.ws.rs.Produces;\r
+import javax.ws.rs.core.MultivaluedMap;\r
\r
+import org.collectionspace.services.common.context.RemoteServiceContext;\r
import org.collectionspace.services.common.context.ServiceContext;\r
+import org.collectionspace.services.common.context.ServiceContextFactory;\r
import org.collectionspace.services.common.document.DocumentHandler;\r
import org.collectionspace.services.common.repository.RepositoryClient;\r
import org.collectionspace.services.common.repository.RepositoryClientFactory;\r
/**\r
* The Class AbstractCollectionSpaceResource.\r
*/\r
-public abstract class AbstractCollectionSpaceResourceImpl\r
- implements CollectionSpaceResource {\r
+public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>\r
+ implements CollectionSpaceResource<IT, OT> {\r
\r
// Fields for default client factory and client\r
/** The repository client factory. */\r
* @see org.collectionspace.services.common.CollectionSpaceResource#getRepositoryClient(org.collectionspace.services.common.context.ServiceContext)\r
*/\r
@Override\r
- synchronized public RepositoryClient getRepositoryClient(ServiceContext ctx) {\r
+ synchronized public RepositoryClient getRepositoryClient(ServiceContext<IT, OT> ctx) {\r
if(repositoryClient != null){\r
return repositoryClient;\r
}\r
* @see org.collectionspace.services.common.CollectionSpaceResource#getStorageClient(org.collectionspace.services.common.context.ServiceContext)\r
*/\r
@Override\r
- synchronized public StorageClient getStorageClient(ServiceContext ctx) {\r
+ synchronized public StorageClient getStorageClient(ServiceContext<IT, OT> ctx) {\r
if(storageClient != null) {\r
return storageClient;\r
}\r
storageClient = new JpaStorageClientImpl();\r
return storageClient;\r
}\r
-\r
+ \r
/* (non-Javadoc)\r
* @see org.collectionspace.services.common.CollectionSpaceResource#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)\r
*/\r
@Override\r
- abstract public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception ;\r
+ public DocumentHandler createDocumentHandler(ServiceContext<IT, OT> ctx) throws Exception {\r
+ DocumentHandler docHandler = createDocumentHandler(ctx, ctx.getInput());\r
+ return docHandler;\r
+ }\r
+ \r
+ /**\r
+ * Creates the document handler.\r
+ * \r
+ * @param ctx the ctx\r
+ * @param commonPart the common part\r
+ * \r
+ * @return the document handler\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ public DocumentHandler createDocumentHandler(ServiceContext<IT, OT> ctx,\r
+ Object commonPart) throws Exception {\r
+ DocumentHandler docHandler = ctx.getDocumentHandler();\r
+ docHandler.setCommonPart(commonPart);\r
+ return docHandler;\r
+ } \r
+ \r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext() throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(this.getServiceName(),\r
+ (IT)null, //inputType\r
+ (MultivaluedMap<String, String>)null, /*queryParams*/\r
+ this.getCommonPartClass());\r
+ return ctx;\r
+ } \r
+ \r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param serviceName the service name\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ serviceName,\r
+ (IT)null, /*input*/\r
+ (MultivaluedMap<String, String>)null, /*queryParams*/\r
+ (Class<?>)null /*input type's Class*/);\r
+ return ctx;\r
+ }\r
\r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param serviceName the service name\r
+ * @param input the input\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(String serviceName,\r
+ IT input) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(serviceName, input,\r
+ (MultivaluedMap<String, String>)null, /*queryParams*/\r
+ (Class<?>)null /*input type's Class*/);\r
+ return ctx;\r
+ }\r
+ \r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param serviceName the service name\r
+ * @param input the input\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(String serviceName,\r
+ MultivaluedMap<String, String> queryParams) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(serviceName,\r
+ (IT)null,\r
+ queryParams,\r
+ (Class<?>)null /*input type's Class*/);\r
+ return ctx;\r
+ } \r
+\r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param queryParams the query params\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(MultivaluedMap<String, String> queryParams) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ (IT)null, /*input*/\r
+ queryParams,\r
+ (Class<?>)null /*input type's Class*/);\r
+ return ctx;\r
+ } \r
+ \r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param input the input\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(IT input) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ input,\r
+ (Class<?>)null /*input type's Class*/);\r
+ return ctx;\r
+ }\r
+ \r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param input the input\r
+ * @param theClass the the class\r
+ * \r
+ * @return the service context\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(IT input, Class<?> theClass) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ input,\r
+ (MultivaluedMap<String, String>)null, //queryParams,\r
+ theClass);\r
+ return ctx;\r
+ }\r
+ \r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param input the input\r
+ * @param queryParams the query params\r
+ * @param theClass the the class\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ protected ServiceContext<IT, OT> createServiceContext(\r
+ IT input,\r
+ MultivaluedMap<String, String> queryParams,\r
+ Class<?> theClass) throws Exception {\r
+ return createServiceContext(this.getServiceName(),\r
+ input,\r
+ queryParams,\r
+ theClass);\r
+ }\r
+\r
+ /**\r
+ * Creates the service context.\r
+ * \r
+ * @param serviceName the service name\r
+ * @param input the input\r
+ * @param queryParams the query params\r
+ * @param theClass the the class\r
+ * \r
+ * @return the service context< i t, o t>\r
+ * \r
+ * @throws Exception the exception\r
+ */\r
+ private ServiceContext<IT, OT> createServiceContext(\r
+ String serviceName,\r
+ IT input,\r
+ MultivaluedMap<String, String> queryParams,\r
+ Class<?> theClass) throws Exception {\r
+ ServiceContext<IT, OT> ctx = getServiceContextFactory().createServiceContext(\r
+ serviceName,\r
+ input,\r
+ queryParams,\r
+ theClass != null ? theClass.getPackage().getName() : null,\r
+ theClass != null ? theClass.getName() : null);\r
+ return ctx;\r
+ }\r
+ \r
/**\r
* Gets the version string.\r
* \r
\r
return result;\r
}\r
- \r
}\r
package org.collectionspace.services.common;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.context.ServiceContextFactory;
import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.common.storage.StorageClient;
* CollectionSpaceResource is a resource interface implemented by every
* entity/service in CollectionSpace
*/
-public interface CollectionSpaceResource {
+public interface CollectionSpaceResource<IT, OT> {
/**
* getServiceName returns the name of the service
*/
public String getServiceName();
-
+
+ /**
+ * Gets the common class.
+ *
+ * @return the common class
+ */
+ public Class getCommonPartClass();
/**
* getRepositoryClient
* @param ctx service context
*/
- public RepositoryClient getRepositoryClient(ServiceContext ctx);
+ public RepositoryClient getRepositoryClient(ServiceContext<IT, OT> ctx);
/**
* getStorageClient
* @param ctx service context
*/
- public StorageClient getStorageClient(ServiceContext ctx);
+ public StorageClient getStorageClient(ServiceContext<IT, OT> ctx);
/**
* createDocumentHandler creates a document handler and populates it with given
* @param ctx
* @return
*/
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception;
+ public DocumentHandler createDocumentHandler(ServiceContext<IT, OT> ctx) throws Exception;
+
+
+ public ServiceContextFactory<IT, OT> getServiceContextFactory();
+
}
import javax.security.auth.Subject;
import javax.security.jacc.PolicyContext;
import javax.security.jacc.PolicyContextException;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.collectionspace.authentication.AuthN;
import org.collectionspace.authentication.CSpaceTenant;
import org.collectionspace.services.common.config.PropertyItemUtils;
import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.ValidatorHandler;
import org.collectionspace.services.common.security.UnauthorizedException;
import org.collectionspace.services.common.service.ObjectPartType;
public abstract class AbstractServiceContextImpl<IT, OT>
implements ServiceContext<IT, OT> {
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(AbstractServiceContextImpl.class);
+
+ /** The properties. */
Map<String, Object> properties = new HashMap<String, Object>();
+
+ /** The object part map. */
Map<String, ObjectPartType> objectPartMap = new HashMap<String, ObjectPartType>();
+
+ /** The service binding. */
private ServiceBindingType serviceBinding;
+
+ /** The tenant binding. */
private TenantBindingType tenantBinding;
+
+ /** The override document type. */
private String overrideDocumentType = null;
+
+ /** The val handlers. */
private List<ValidatorHandler> valHandlers = null;
+
+ /** The doc handler. */
private DocumentHandler docHandler = null;
- public AbstractServiceContextImpl(String serviceName) throws UnauthorizedException {
+ private AbstractServiceContextImpl() {} // private constructor for singleton pattern
+
+ // request query params
+ private MultivaluedMap<String, String> queryParams;
+
+ /**
+ * Instantiates a new abstract service context impl.
+ *
+ * @param serviceName the service name
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected AbstractServiceContextImpl(String serviceName) throws UnauthorizedException {
TenantBindingConfigReaderImpl tReader =
ServiceMain.getInstance().getTenantBindingConfigReader();
//FIXME retrieveTenantId is not working consistently in non-auth mode
return schemaName.toLowerCase() + PART_LABEL_SEPERATOR + PART_COMMON_LABEL;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getPartsMetadata()
+ */
@Override
public Map<String, ObjectPartType> getPartsMetadata() {
if (objectPartMap.size() != 0) {
return objectPartMap;
}
+ /**
+ * Gets the properties for part.
+ *
+ * @param partLabel the part label
+ *
+ * @return the properties for part
+ */
public List<PropertyItemType> getPropertiesForPart(String partLabel) {
Map<String, ObjectPartType> partMap = getPartsMetadata();
ObjectPartType part = partMap.get(partLabel);
return propNodeList.isEmpty()?null:propNodeList.get(0).getItem();
}
+ /**
+ * Gets the property values for part.
+ *
+ * @param partLabel the part label
+ * @param propName the prop name
+ *
+ * @return the property values for part
+ */
public List<String> getPropertyValuesForPart(String partLabel, String propName) {
List<PropertyItemType> allProps = getPropertiesForPart(partLabel);
return PropertyItemUtils.getPropertyValuesByName(allProps, propName);
}
+ /**
+ * Gets the all parts property values.
+ *
+ * @param propName the prop name
+ *
+ * @return the all parts property values
+ */
public List<String> getAllPartsPropertyValues(String propName) {
return ServiceBindingUtils.getAllPartsPropertyValues(getServiceBinding(), propName);
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getServiceBindingPropertyValue(java.lang.String)
+ */
public String getServiceBindingPropertyValue(String propName) {
return ServiceBindingUtils.getPropertyValue(getServiceBinding(), propName);
}
+ /**
+ * Gets the common part properties.
+ *
+ * @return the common part properties
+ */
public List<PropertyItemType> getCommonPartProperties() {
return getPropertiesForPart(getCommonPartLabel());
}
+ /**
+ * Gets the common part property values.
+ *
+ * @param propName the prop name
+ *
+ * @return the common part property values
+ */
public List<String> getCommonPartPropertyValues(String propName) {
return getPropertyValuesForPart(getCommonPartLabel(), propName);
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getQualifiedServiceName()
+ */
@Override
public String getQualifiedServiceName() {
return TenantBindingConfigReaderImpl.getTenantQualifiedServiceName(getTenantId(), getServiceName());
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryClientName()
+ */
@Override
public String getRepositoryClientName() {
if (serviceBinding.getRepositoryClient() == null) {
return serviceBinding.getRepositoryClient().trim();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryClientType()
+ */
@Override
public ClientType getRepositoryClientType() {
//assumption: there is only one repository client configured
return ServiceMain.getInstance().getClientType();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryDomainName()
+ */
@Override
public String getRepositoryDomainName() {
return tenantBinding.getRepositoryDomain();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceId()
+ */
@Override
public String getRepositoryWorkspaceId() {
TenantBindingConfigReaderImpl tbConfigReader = ServiceMain.getInstance().getTenantBindingConfigReader();
return tbConfigReader.getWorkspaceId(getTenantId(), getServiceName());
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceName()
+ */
@Override
public String getRepositoryWorkspaceName() {
//service name is workspace name by convention
return serviceBinding.getName();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getServiceBinding()
+ */
@Override
public ServiceBindingType getServiceBinding() {
return serviceBinding;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceBinding.getName();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getDocumentType()
+ */
@Override
public String getDocumentType() {
// If they have not overridden the setting, use the type of the service
return (overrideDocumentType != null) ? overrideDocumentType : serviceBinding.getObject().getName();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#setDocumentType(java.lang.String)
+ */
@Override
public void setDocumentType(String docType) {
overrideDocumentType = docType;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getTenantId()
+ */
@Override
public String getTenantId() {
return tenantBinding.getId();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getTenantName()
+ */
@Override
public String getTenantName() {
return tenantBinding.getName();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getInput()
+ */
@Override
public abstract IT getInput();
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#setInput(java.lang.Object)
+ */
@Override
public abstract void setInput(IT input);
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getOutput()
+ */
@Override
public abstract OT getOutput();
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#setOutput(java.lang.Object)
+ */
@Override
public abstract void setOutput(OT output);
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getProperties()
+ */
@Override
public Map<String, Object> getProperties() {
return properties;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#setProperties(java.util.Map)
+ */
@Override
public void setProperties(Map<String, Object> props) {
properties.putAll(props);
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getProperty(java.lang.String)
+ */
public Object getProperty(String name) {
return properties.get(name);
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#setProperty(java.lang.String, java.lang.Object)
+ */
public void setProperty(String name, Object o) {
properties.put(name, o);
}
+ /**
+ * Retrieve tenant id.
+ *
+ * @return the string
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
private String retrieveTenantId() throws UnauthorizedException {
String[] tenantIds = AuthN.get().getTenantIds();
//id should be matched with the one sent over the wire
return tenantIds[0];
}
-
- @Override
- public DocumentHandler getDocumentHandler() throws Exception {
- if (docHandler != null) {
- return docHandler;
- }
+
+ /**
+ * Creates the document handler instance.
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
+ private DocumentHandler createDocumentHandlerInstance() throws Exception {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
Class c = tccl.loadClass(getDocumentHandlerClass());
if (DocumentHandler.class.isAssignableFrom(c)) {
throw new IllegalArgumentException("Not of type "
+ DocumentHandler.class.getCanonicalName());
}
+ //
+ // create a default document filter with pagination if the context
+ // was created with query params
+ //
docHandler.setServiceContext(this);
- return docHandler;
+ DocumentFilter docFilter = docHandler.createDocumentFilter();
+ docFilter.setPagination(this.getQueryParams());
+ docHandler.setDocumentFilter(docFilter);
+
+ return docHandler;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getDocumentHandler()
+ */
+ @Override
+ public DocumentHandler getDocumentHandler() throws Exception {
+ DocumentHandler result = docHandler;
+ // create a new instance if one does not yet exist
+ if (result == null) {
+ result = createDocumentHandlerInstance();
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getDocumentHanlder(javax.ws.rs.core.MultivaluedMap)
+ */
+ @Override
+ public DocumentHandler getDocumentHandler(MultivaluedMap<String, String> queryParams) throws Exception {
+ DocumentHandler result = getDocumentHandler();
+ DocumentFilter documentFilter = result.getDocumentFilter(); //to see results in debugger variables view
+ documentFilter.setPagination(queryParams);
+ return result;
+ }
+
+ /**
+ * Gets the document handler class.
+ *
+ * @return the document handler class
+ */
private String getDocumentHandlerClass() {
if (serviceBinding.getDocumentHandler() == null
|| serviceBinding.getDocumentHandler().isEmpty()) {
return serviceBinding.getDocumentHandler().trim();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getValidatorHandlers()
+ */
@Override
public List<ValidatorHandler> getValidatorHandlers() throws Exception {
if (valHandlers != null) {
return valHandlers;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
StringBuilder msg = new StringBuilder();
msg.append("]");
return msg.toString();
}
+
+ @Override
+ public MultivaluedMap<String, String> getQueryParams() {
+ return this.queryParams;
+ }
+
+ @Override
+ public void setQueryParams(MultivaluedMap<String, String> queryParams) {
+ this.queryParams = queryParams;
+ }
}
*/
package org.collectionspace.services.common.context;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
/**
*
*
*/
public class MultipartServiceContextFactory
- implements ServiceContextFactory<MultipartInput> {
+ implements ServiceContextFactory<MultipartInput, MultipartOutput> {
+ /** The Constant self. */
final private static MultipartServiceContextFactory self = new MultipartServiceContextFactory();
- private MultipartServiceContextFactory() {
- }
+ /**
+ * Instantiates a new multipart service context factory.
+ */
+ private MultipartServiceContextFactory() {} // private constructor as part of the singleton pattern
+ /**
+ * Gets the.
+ *
+ * @return the multipart service context factory
+ */
public static MultipartServiceContextFactory get() {
return self;
}
- /**
- * createServiceContext is a factory method to create a service context
- * a service context is created on every service request call
- * @param input
- * @param serviceName which service/repository context to use
- * @return
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String)
*/
@Override
- public ServiceContext createServiceContext(MultipartInput input, String serviceName) throws Exception {
+ public ServiceContext<MultipartInput, MultipartOutput> createServiceContext(String serviceName) throws Exception {
MultipartServiceContext ctx = new MultipartServiceContextImpl(serviceName);
- ctx.setInput(input);
return ctx;
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object)
+ */
+ @Override
+ public ServiceContext<MultipartInput, MultipartOutput> createServiceContext(String serviceName,
+ MultipartInput input) throws Exception {
+ MultipartServiceContext ctx = new MultipartServiceContextImpl(serviceName, input);
+ return ctx;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap)
+ */
+ @Override
+ public ServiceContext<MultipartInput, MultipartOutput> createServiceContext(String serviceName,
+ MultipartInput input,
+ MultivaluedMap<String, String> queryParams)
+ throws Exception {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = new MultipartServiceContextImpl(serviceName,
+ input,
+ queryParams);
+ return ctx;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap, java.lang.String, java.lang.String)
+ */
+ @Override
+ public ServiceContext<MultipartInput, MultipartOutput> createServiceContext(String serviceName,
+ MultipartInput input,
+ MultivaluedMap<String, String> queryParams,
+ String documentType,
+ String entityName) throws Exception {
+ return this.createServiceContext(serviceName, input, queryParams);
+ }
}
import java.io.InputStream;
import java.lang.reflect.Constructor;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.collectionspace.services.common.document.DocumentUtils;
import org.collectionspace.services.common.security.UnauthorizedException;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
extends RemoteServiceContextImpl<MultipartInput, MultipartOutput>
implements MultipartServiceContext {
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(MultipartServiceContextImpl.class);
- public MultipartServiceContextImpl(String serviceName) throws UnauthorizedException {
- super(serviceName);
+ /**
+ * Instantiates a new multipart service context impl.
+ *
+ * @param serviceName the service name
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected MultipartServiceContextImpl(String serviceName)
+ throws UnauthorizedException {
+ super(serviceName);
+ setOutput(new MultipartOutput());
+ }
+
+ /**
+ * Instantiates a new multipart service context impl.
+ *
+ * @param serviceName the service name
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected MultipartServiceContextImpl(String serviceName, MultipartInput theInput)
+ throws UnauthorizedException {
+ super(serviceName, theInput);
setOutput(new MultipartOutput());
}
+ /**
+ * Instantiates a new multipart service context impl.
+ *
+ * @param serviceName the service name
+ * @param queryParams the query params
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected MultipartServiceContextImpl(String serviceName,
+ MultipartInput theInput,
+ MultivaluedMap<String, String> queryParams) throws UnauthorizedException {
+ super(serviceName, theInput, queryParams);
+ setOutput(new MultipartOutput());
+ }
+ /**
+ * Gets the input part.
+ *
+ * @param label the label
+ *
+ * @return the input part
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
private InputPart getInputPart(String label) throws IOException {
if (getInput() != null) {
MultipartInput fdip = getInput();
return null;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.MultipartServiceContext#getInputPart(java.lang.String, java.lang.Class)
+ */
@Override
public Object getInputPart(String label, Class clazz) throws IOException {
Object obj = null;
return obj;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.MultipartServiceContext#getInputPartAsString(java.lang.String)
+ */
@Override
public String getInputPartAsString(String label) throws IOException {
InputPart part = getInputPart(label);
return null;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.MultipartServiceContext#getInputPartAsStream(java.lang.String)
+ */
@Override
public InputStream getInputPartAsStream(String label) throws IOException {
InputPart part = getInputPart(label);
return null;
}
-
-
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.MultipartServiceContext#addOutputPart(java.lang.String, org.w3c.dom.Document, java.lang.String)
+ */
@Override
public void addOutputPart(String label, Document doc, String contentType) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
}
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.RemoteServiceContextImpl#getLocalContext(java.lang.String)
+ */
@Override
public ServiceContext getLocalContext(String localContextClassName) throws Exception {
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
*/
package org.collectionspace.services.common.context;
+import javax.ws.rs.core.MultivaluedMap;
+
/**
* RemoteServiceContext is used to encapsulate the service context of a
* remotely invokable service
* @return local service context
*/
public ServiceContext getLocalContext(String localContextClassName) throws Exception;
+
+ /**
+ * Gets the query params.
+ *
+ * @return the query params
+ */
+ public MultivaluedMap<String, String> getQueryParams();
+
+ /**
+ * Gets the query params.
+ *
+ * @return the query params
+ */
+ public void setQueryParams(MultivaluedMap<String, String> queryParams);
}
+
package org.collectionspace.services.common.context;
import java.lang.reflect.Constructor;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.security.UnauthorizedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
extends AbstractServiceContextImpl<IT, OT>
implements RemoteServiceContext<IT, OT> {
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(RemoteServiceContextImpl.class);
//input stores original content as received over the wire
+ /** The input. */
private IT input;
+
+ /** The output. */
private OT output;
- public RemoteServiceContextImpl(String serviceName) throws UnauthorizedException {
+ /**
+ * Instantiates a new remote service context impl.
+ *
+ * @param serviceName the service name
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected RemoteServiceContextImpl(String serviceName) throws UnauthorizedException {
super(serviceName);
}
+ /**
+ * Instantiates a new remote service context impl. (This is "package" protected for the Factory class)
+ *
+ * @param serviceName the service name
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected RemoteServiceContextImpl(String serviceName, IT theInput) throws UnauthorizedException {
+ this(serviceName);
+ this.input = theInput;
+ }
+
+ /**
+ * Instantiates a new remote service context impl. (This is "package" protected for the Factory class)
+ *
+ * @param serviceName the service name
+ * @param theInput the the input
+ * @param queryParams the query params
+ *
+ * @throws UnauthorizedException the unauthorized exception
+ */
+ protected RemoteServiceContextImpl(String serviceName,
+ IT theInput,
+ MultivaluedMap<String, String> queryParams) throws UnauthorizedException {
+ this(serviceName, theInput);
+ this.setQueryParams(queryParams);
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.AbstractServiceContextImpl#getInput()
+ */
@Override
public IT getInput() {
return input;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.AbstractServiceContextImpl#setInput(java.lang.Object)
+ */
@Override
public void setInput(IT input) {
//for security reasons, do not allow to set input again (from handlers)
this.input = input;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.AbstractServiceContextImpl#getOutput()
+ */
@Override
public OT getOutput() {
return output;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.AbstractServiceContextImpl#setOutput(java.lang.Object)
+ */
@Override
public void setOutput(OT output) {
this.output = output;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.RemoteServiceContext#getLocalContext(java.lang.String)
+ */
@Override
public ServiceContext getLocalContext(String localContextClassName) throws Exception {
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
Constructor ctor = ctxClass.getConstructor(java.lang.String.class);
ServiceContext ctx = (ServiceContext) ctor.newInstance(getServiceName());
return ctx;
- }
+ }
}
import java.util.List;
import java.util.Map;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.document.ValidatorHandler;
* The character used to separate the words in a part label
*/
public static final String PART_LABEL_SEPERATOR = "_";
+
+ /** The Constant PART_COMMON_LABEL. */
public static final String PART_COMMON_LABEL = "common";
/**
*/
public String getServiceBindingPropertyValue(String propName);
-
-
/**
* getDocumentHanlder returns document handler configured in the the binding
* it creates the handler if necessary.
* @return document handler
*/
public DocumentHandler getDocumentHandler() throws Exception;
+
+ /**
+ * Gets the document hanlder.
+ *
+ * @param queryParams the query params
+ *
+ * @return the document hanlder
+ *
+ * @throws Exception the exception
+ */
+ public DocumentHandler getDocumentHandler(MultivaluedMap<String, String> queryParams) throws Exception;
/**
* getValidatorHandlers returns registered (from binding) validtor handlers
* @return validation handlers
*/
public List<ValidatorHandler> getValidatorHandlers() throws Exception;
-
+
+ /**
+ * Gets the query params.
+ *
+ * @return the query params
+ */
+ public MultivaluedMap<String, String> getQueryParams();
+
+ /**
+ * Sets the query params.
+ *
+ * @param queryParams the query params
+ */
+ public void setQueryParams(MultivaluedMap<String, String> queryParams);
}
*/
package org.collectionspace.services.common.context;
+import javax.ws.rs.core.MultivaluedMap;
+
/**
*
* ServiceContextFactory creates a service context
*
*/
-public interface ServiceContextFactory<T> {
-
+public interface ServiceContextFactory<IT, OT> {
/**
- * createServiceContext is a factory method to create a service context
- * a service context is created on every service request call
- * @param input
- * @param serviceName which service/repository context to use
- * @return
+ * Creates a new ServiceContext object.
+ *
+ * @param serviceName the service name
+ * @param input the input
+ *
+ * @return the service context
+ *
+ * @throws Exception the exception
+ */
+ public ServiceContext<IT, OT> createServiceContext(String serviceName, IT input) throws Exception;
+
+ /**
+ * Creates a new ServiceContext object.
+ *
+ * @param serviceName the service name
+ *
+ * @return the service context< i t, o t>
+ *
+ * @throws Exception the exception
*/
- public ServiceContext createServiceContext(T input, String serviceName) throws Exception;
+ public ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception;
+ /**
+ * Creates a new ServiceContext object.
+ *
+ * @param serviceName the service name
+ * @param input the input
+ * @param queryParams the query params
+ *
+ * @return the service context
+ *
+ * @throws Exception the exception
+ */
+ public ServiceContext<IT, OT> createServiceContext(String serviceName,
+ IT input,
+ MultivaluedMap<String, String> queryParams) throws Exception;
+
+ /**
+ * Creates a new ServiceContext object.
+ *
+ * @param serviceName the service name
+ * @param input the input
+ * @param queryParams the query params
+ * @param documentType the document type
+ * @param entityName the entity name
+ *
+ * @return the service context
+ *
+ * @throws Exception the exception
+ */
+ public ServiceContext<IT, OT> createServiceContext(
+ String serviceName,
+ IT input,
+ MultivaluedMap<String, String> queryParams,
+ String documentType,
+ String entityName) throws Exception;
}
this.properties = properties;
}
+// public void initializeDocumentFilter(ServiceContext ctx) {
+// DocumentFilter docFilter = this.createDocumentFilter(ctx);
+// this.setDocumentFilter(docFilter);
+// }
+
@Override
- public abstract DocumentFilter createDocumentFilter(ServiceContext ctx);
+ public abstract DocumentFilter createDocumentFilter();
/**
* @return the DocumentFilter
import java.util.List;\r
import javax.ws.rs.core.MultivaluedMap;\r
import org.collectionspace.services.common.query.IQueryManager;\r
+import org.collectionspace.services.common.context.ServiceContext;\r
\r
//TODO: would be great to not rely on resteasy directly\r
import org.jboss.resteasy.specimpl.MultivaluedMapImpl;\r
protected String whereClause; // Filtering clause. Omit the "WHERE".\r
protected int startPage; // Pagination offset for list results\r
protected int pageSize; // Pagination limit for list results\r
- private MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl<String, String>();\r
+ private boolean pageSizeDirty = false; // True if default page size explicitly set/overridden\r
+ private MultivaluedMap<String, String> queryParams = null;\r
\r
\r
/**\r
}\r
}\r
\r
+ /**\r
+ * Instantiates a new document filter.\r
+ * \r
+ * @param ctx the ctx\r
+ */\r
+ public DocumentFilter(ServiceContext ctx) {\r
+ this.setPageSize(ctx.getServiceBindingPropertyValue(\r
+ DocumentFilter.PAGE_SIZE_DEFAULT_PROPERTY));\r
+ }\r
+ \r
public DocumentFilter() {\r
this("", 0, defaultPageSize); // Use empty string for easy concatenation\r
}\r
this.pageSize = (pageSize > 0) ? pageSize : defaultPageSize;\r
}\r
\r
- public void setPagination(MultivaluedMap<String, String> queryParams) {\r
-\r
- String startPageStr = null;\r
- String pageSizeStr = null;\r
+ /**\r
+ * Sets the pagination.\r
+ * \r
+ * @param queryParams the query params\r
+ */\r
+ public void setPagination(MultivaluedMap<String, String> queryParams) { \r
+ //\r
+ // Bail if there are no params\r
+ //\r
+ if (queryParams == null) return;\r
+ \r
+ //\r
+ // Set the page size\r
+ //\r
+ String pageSizeStr = null;\r
List<String> list = queryParams.remove(PAGE_SIZE_PARAM);\r
if (list != null) {\r
pageSizeStr = list.get(0);\r
}\r
setPageSize(pageSizeStr);\r
+\r
+ //\r
+ // Set the start page\r
+ //\r
+ String startPageStr = null;\r
list = queryParams.remove(START_PAGE_PARAM);\r
if (list != null) {\r
startPageStr = list.get(0);\r
}\r
- if (startPageStr != null) {\r
- try {\r
- startPage = Integer.valueOf(startPageStr);\r
- } catch (NumberFormatException e) {\r
- throw new NumberFormatException("Bad value for: " + START_PAGE_PARAM);\r
- }\r
- }\r
+ setStartPage(startPageStr);\r
}\r
\r
/**\r
public int getPageSize() {\r
return pageSize;\r
}\r
+ \r
+ public boolean getPageSizeDirty() {\r
+ return this.getPageSizeDirty();\r
+ }\r
\r
/**\r
* @param pageSize the max number of items to return for list requests\r
*/\r
public void setPageSize(int pageSize) {\r
this.pageSize = pageSize;\r
+ this.pageSizeDirty = true; // page size explicity set/overriden\r
}\r
\r
/**\r
* @param pageSize the max number of items to return for list requests\r
*/\r
public void setPageSize(String pageSizeStr) {\r
+ int pageSize = this.defaultPageSize;\r
if (pageSizeStr != null) {\r
try {\r
- pageSize = Integer.valueOf(pageSizeStr);\r
+ pageSize = Integer.valueOf(pageSizeStr);\r
} catch (NumberFormatException e) {\r
+ //FIXME This should cause a warning in the log file and should result in the\r
+ //FIXME page size being set to the default. We don't need to throw an exception here.\r
throw new NumberFormatException("Bad value for: " + PAGE_SIZE_PARAM);\r
}\r
}\r
+ \r
+ setPageSize(pageSize);\r
+ }\r
+\r
+ /**\r
+ * Sets the start page.\r
+ * \r
+ * @param startPageStr the new start page\r
+ */\r
+ protected void setStartPage(String startPageStr) {\r
+ if (startPageStr != null) {\r
+ try {\r
+ startPage = Integer.valueOf(startPageStr);\r
+ } catch (NumberFormatException e) {\r
+ throw new NumberFormatException("Bad value for: " + START_PAGE_PARAM);\r
+ }\r
+ }\r
}\r
\r
/**\r
* @param properties
*/
public void setProperties(Map<String, Object> properties);
-
+
/**
* createDocumentFilter is a factory method to create a document
* filter that is relevant to be used with this document handler
* @param ctx ServiceContext used to fetch default pagination, etc.
* @return
*/
- public DocumentFilter createDocumentFilter(ServiceContext ctx);
+ public DocumentFilter createDocumentFilter();
/**
* getDocumentFilter
package org.collectionspace.services.common.storage.jpa;
import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.context.ServiceContext;
+
/**
* JPA query specific document filter
*/
public class JpaDocumentFilter extends DocumentFilter {
-
-
+ public JpaDocumentFilter(ServiceContext ctx) {
+ super(ctx);
+ }
}
}
DocumentFilter docFilter = handler.getDocumentFilter();
if (docFilter == null) {
- docFilter = handler.createDocumentFilter(ctx);
+ docFilter = handler.createDocumentFilter();
}
EntityManagerFactory emf = null;
EntityManager em = null;
}
DocumentFilter docFilter = handler.getDocumentFilter();
if (docFilter == null) {
- docFilter = handler.createDocumentFilter(ctx);
+ docFilter = handler.createDocumentFilter();
}
EntityManagerFactory emf = null;
EntityManager em = null;
@Override
public abstract void setCommonPartList(TL obj);
-
+
@Override
- public DocumentFilter createDocumentFilter(ServiceContext ctx) {
- DocumentFilter filter = new NuxeoDocumentFilter();
- filter.setPageSize(
- ctx.getServiceBindingPropertyValue(
- DocumentFilter.PAGE_SIZE_DEFAULT_PROPERTY));
+ public DocumentFilter createDocumentFilter() {
+ DocumentFilter filter = new NuxeoDocumentFilter(this.getServiceContext());
return filter;
}
package org.collectionspace.services.nuxeo.client.java;
import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.context.ServiceContext;
/**
* NXQL specific document filter
*/
public class NuxeoDocumentFilter extends DocumentFilter {
+ public NuxeoDocumentFilter(ServiceContext ctx) {
+ super(ctx);
+ }
}
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.context.MultipartServiceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class ContactResource.
+ */
@Path("/contacts")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class ContactResource extends AbstractCollectionSpaceResourceImpl {
+public class ContactResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
+ /** The Constant serviceName. */
private final static String serviceName = "contacts";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(ContactResource.class);
//FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+ /**
+ * Instantiates a new contact resource.
+ */
public ContactResource() {
// do nothing
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceName;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
@Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext)ctx).getInputPart(ctx.getCommonPartLabel(), ContactsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((ContactsCommon) obj);
- }
- }
- return docHandler;
+ public Class<ContactsCommon> getCommonPartClass() {
+ return ContactsCommon.class;
}
+
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext)ctx).getInputPart(ctx.getCommonPartLabel(), ContactsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((ContactsCommon) obj);
+// }
+// }
+// return docHandler;
+// }
- @POST
+ /**
+ * Creates the contact.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+@POST
public Response createContact(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//contactObject.setCsid(csid);
}
}
+ /**
+ * Gets the contact.
+ *
+ * @param csid the csid
+ *
+ * @return the contact
+ */
@GET
@Path("{csid}")
public MultipartOutput getContact(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Gets the contact list.
+ *
+ * @param ui the ui
+ *
+ * @return the contact list
+ */
@GET
@Produces("application/xml")
public ContactsCommonList getContactList(@Context UriInfo ui) {
ContactsCommonList contactObjectList = new ContactsCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).getAll(ctx, handler);
contactObjectList = (ContactsCommonList) handler.getCommonPartList();
return contactObjectList;
}
+ /**
+ * Update contact.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}")
public MultipartOutput updateContact(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete contact.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deleteContact(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (DocumentNotFoundException dnfe) {
import javax.ws.rs.PathParam;
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.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
-import org.collectionspace.services.dimension.DimensionsCommonList.*;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
+//import org.collectionspace.services.dimension.DimensionsCommonList.*;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class DimensionResource.
+ */
@Path("/dimensions")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class DimensionResource extends AbstractCollectionSpaceResourceImpl {
+public class DimensionResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
+ /** The Constant serviceName. */
private final static String serviceName = "dimensions";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(DimensionResource.class);
//FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+ /**
+ * Instantiates a new dimension resource.
+ */
public DimensionResource() {
// do nothing
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return serviceName;
}
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext)ctx).getInputPart(ctx.getCommonPartLabel(), DimensionsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((DimensionsCommon) obj);
- }
- }
- return docHandler;
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext)ctx).getInputPart(ctx.getCommonPartLabel(), DimensionsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((DimensionsCommon) obj);
+// }
+// }
+// return docHandler;
+// }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
+@Override
+ public Class<DimensionsCommon> getCommonPartClass() {
+ return DimensionsCommon.class;
}
+ /**
+ * Creates the dimension.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
@POST
public Response createDimension(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//dimensionObject.setCsid(csid);
}
}
+ /**
+ * Gets the dimension.
+ *
+ * @param csid the csid
+ *
+ * @return the dimension
+ */
@GET
@Path("{csid}")
public MultipartOutput getDimension(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Gets the dimension list.
+ *
+ * @param ui the ui
+ *
+ * @return the dimension list
+ */
@GET
@Produces("application/xml")
public DimensionsCommonList getDimensionList(@Context UriInfo ui) {
DimensionsCommonList dimensionObjectList = new DimensionsCommonList();
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).getAll(ctx, handler);
dimensionObjectList = (DimensionsCommonList) handler.getCommonPartList();
return dimensionObjectList;
}
+ /**
+ * Update dimension.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}")
public MultipartOutput updateDimension(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete dimension.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deleteDimension(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (DocumentNotFoundException dnfe) {
import javax.ws.rs.QueryParam;
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.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+//import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+//import org.collectionspace.services.common.context.MultipartServiceContext;
+//import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.MultipartServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentFilter;
@Path("/intakes")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class IntakeResource extends AbstractCollectionSpaceResourceImpl {
+public class IntakeResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
/** The Constant serviceName. */
private final static String serviceName = "intakes";
}
/* (non-Javadoc)
- * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
*/
@Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), IntakesCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((IntakesCommon) obj);
- }
- }
- return docHandler;
+ public Class<IntakesCommon> getCommonPartClass() {
+ return IntakesCommon.class;
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), IntakesCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((IntakesCommon) obj);
+// }
+// }
+// return docHandler;
+// }
/**
* Creates the intake.
@POST
public Response createIntake(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//intakeObject.setCsid(csid);
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
public IntakesCommonList getIntakeList(@Context UriInfo ui,
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) {
IntakesCommonList result = null;
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
if (keywords != null) {
- result = searchIntakes(keywords);
+ result = searchIntakes(queryParams, keywords);
} else {
- result = getIntakeList();
+ result = getIntakeList(queryParams);
}
return result;
*
* @return the intake list
*/
- private IntakesCommonList getIntakeList() {
+ private IntakesCommonList getIntakeList(MultivaluedMap<String, String> queryParams) {
IntakesCommonList intakeObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).getAll(ctx, handler);
intakeObjectList = (IntakesCommonList) handler.getCommonPartList();
@Context UriInfo ui) {
AuthorityRefList authRefList = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
RemoteDocumentModelHandlerImpl handler
*
* @return the intake list
*/
+ @Deprecated
public IntakesCommonList getIntakeList(List<String> csidList) {
IntakesCommonList intakeObjectList = new IntakesCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csidList, handler);
intakeObjectList = (IntakesCommonList) handler.getCommonPartList();
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
@GET
@Path("/search")
@Produces("application/xml")
+ @Deprecated
public IntakesCommonList keywordsSearchIntakes(@Context UriInfo ui,
@QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) {
- return searchIntakes(keywords);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return searchIntakes(queryParams, keywords);
}
/**
*
* @return the intakes common list
*/
- private IntakesCommonList searchIntakes(String keywords) {
+ private IntakesCommonList searchIntakes(MultivaluedMap<String, String> queryParams,
+ String keywords) {
IntakesCommonList intakesObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
// perform a keyword search
if (keywords != null && !keywords.isEmpty()) {
String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
- DocumentFilter documentFilter = handler.createDocumentFilter(ctx);
+ DocumentFilter documentFilter = handler.getDocumentFilter();
documentFilter.setWhereClause(whereClause);
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
throw new WebApplicationException(response);
}
return intakesObjectList;
- }
-
+ }
}
import javax.ws.rs.QueryParam;
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.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
@Path("/loansin")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class LoaninResource extends AbstractCollectionSpaceResourceImpl {
+public class LoaninResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
/** The Constant serviceName. */
private final static String serviceName = "loansin";
}
/* (non-Javadoc)
- * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
*/
@Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), LoansinCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((LoansinCommon) obj);
- }
- }
- return docHandler;
+ public Class<LoansinCommon> getCommonPartClass() {
+ return LoansinCommon.class;
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), LoansinCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((LoansinCommon) obj);
+// }
+// }
+// return docHandler;
+// }
/**
* Creates the loanin.
@POST
public Response createLoanin(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//loaninObject.setCsid(csid);
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
public LoansinCommonList getLoaninList(@Context UriInfo ui,
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) {
LoansinCommonList result = null;
-
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
if (keywords != null) {
- result = searchLoansin(keywords);
+ result = searchLoansin(queryParams, keywords);
} else {
- result = getLoaninList();
+ result = getLoaninList(queryParams);
}
return result;
*
* @return the loanin list
*/
- private LoansinCommonList getLoaninList() {
+ private LoansinCommonList getLoaninList(MultivaluedMap<String, String> queryParams) {
LoansinCommonList loaninObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).getAll(ctx, handler);
loaninObjectList = (LoansinCommonList) handler.getCommonPartList();
@Context UriInfo ui) {
AuthorityRefList authRefList = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
RemoteDocumentModelHandlerImpl handler
*
* @return the loanin list
*/
+ @Deprecated
public LoansinCommonList getLoaninList(List<String> csidList) {
LoansinCommonList loaninObjectList = new LoansinCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csidList, handler);
loaninObjectList = (LoansinCommonList) handler.getCommonPartList();
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
throw new WebApplicationException(response);
}
}
-
- /**
- * Keywords search loansin.
- *
- * @param ui the ui
- * @param keywords the keywords
- *
- * @return the loansin common list
- */
- @GET
- @Path("/search")
- @Produces("application/xml")
- public LoansinCommonList keywordsSearchLoansin(@Context UriInfo ui,
- @QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) {
- return searchLoansin(keywords);
- }
-
+
/**
* Search loansin.
*
*
* @return the loansin common list
*/
- private LoansinCommonList searchLoansin(String keywords) {
+ private LoansinCommonList searchLoansin(MultivaluedMap<String, String> queryParams,
+ String keywords) {
LoansinCommonList loansinObjectList;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
// perform a keyword search
throw new WebApplicationException(response);
}
return loansinObjectList;
- }
-
+ }
}
import org.collectionspace.services.OrgAuthorityJAXBSchema;
import org.collectionspace.services.OrganizationJAXBSchema;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+//import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class OrgAuthorityResource.
+ */
@Path("/orgauthorities")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class OrgAuthorityResource extends AbstractCollectionSpaceResourceImpl {
+public class OrgAuthorityResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
+ /** The Constant orgAuthorityServiceName. */
private final static String orgAuthorityServiceName = "orgauthorities";
+
+ /** The Constant organizationServiceName. */
private final static String organizationServiceName = "organizations";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(OrgAuthorityResource.class);
//FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+ /** The contact resource. */
private ContactResource contactResource = new ContactResource();
+ /**
+ * Instantiates a new org authority resource.
+ */
public OrgAuthorityResource() {
// do nothing
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return orgAuthorityServiceName;
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
+ @Override
+ public Class<OrgauthoritiesCommon> getCommonPartClass() {
+ return OrgauthoritiesCommon.class;
+ }
+ /**
+ * Gets the item service name.
+ *
+ * @return the item service name
+ */
public String getItemServiceName() {
return organizationServiceName;
}
+ /**
+ * Gets the contact service name.
+ *
+ * @return the contact service name
+ */
public String getContactServiceName() {
return contactResource.getServiceName();
}
return ctx;
}
*/
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler =ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), OrgauthoritiesCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((OrgauthoritiesCommon) obj);
- }
- }
- return docHandler;
- }
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler =ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), OrgauthoritiesCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((OrgauthoritiesCommon) obj);
+// }
+// }
+// return docHandler;
+// }
+ /**
+ * Creates the item document handler.
+ *
+ * @param ctx the ctx
+ * @param inAuthority the in authority
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
private DocumentHandler createItemDocumentHandler(
- ServiceContext ctx,
- String inAuthority) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- ((OrganizationDocumentModelHandler) docHandler).setInAuthority(inAuthority);
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(getItemServiceName()),
- OrganizationsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((OrganizationsCommon) obj);
- }
- }
+ ServiceContext<MultipartInput, MultipartOutput> ctx,
+ String inAuthority) throws Exception {
+ OrganizationDocumentModelHandler docHandler = (OrganizationDocumentModelHandler)createDocumentHandler(
+ ctx,
+ ctx.getCommonPartLabel(getItemServiceName()),
+ OrganizationsCommon.class);
+ docHandler.setInAuthority(inAuthority);
+
+
+// ((OrganizationDocumentModelHandler) docHandler).setInAuthority(inAuthority);
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(getItemServiceName()),
+// OrganizationsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((OrganizationsCommon) obj);
+// }
+// }
+
return docHandler;
}
+ /**
+ * Creates the contact document handler.
+ *
+ * @param ctx the ctx
+ * @param inAuthority the in authority
+ * @param inItem the in item
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
private DocumentHandler createContactDocumentHandler(
- ServiceContext ctx, String inAuthority,
+ ServiceContext<MultipartInput, MultipartOutput> ctx, String inAuthority,
String inItem) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- // Set the inAuthority and inItem values, which specify the
- // parent authority (e.g. PersonAuthority, OrgAuthority) and the item
- // (e.g. Person, Organization) with which the Contact is associated.
- ((ContactDocumentModelHandler) docHandler).setInAuthority(inAuthority);
- ((ContactDocumentModelHandler) docHandler).setInItem(inItem);
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx)
- .getInputPart(ctx.getCommonPartLabel(getContactServiceName()),
- ContactsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((ContactsCommon) obj);
- }
- }
+
+ ContactDocumentModelHandler docHandler = (ContactDocumentModelHandler)createDocumentHandler(
+ ctx,
+ ctx.getCommonPartLabel(getContactServiceName()),
+ ContactsCommon.class);
+ docHandler.setInAuthority(inAuthority);
+ docHandler.setInItem(inItem);
+
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// // Set the inAuthority and inItem values, which specify the
+// // parent authority (e.g. PersonAuthority, OrgAuthority) and the item
+// // (e.g. Person, Organization) with which the Contact is associated.
+// ((ContactDocumentModelHandler) docHandler).setInAuthority(inAuthority);
+// ((ContactDocumentModelHandler) docHandler).setInItem(inItem);
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx)
+// .getInputPart(ctx.getCommonPartLabel(getContactServiceName()),
+// ContactsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((ContactsCommon) obj);
+// }
+// }
return docHandler;
}
+ /**
+ * Creates the org authority.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
@POST
public Response createOrgAuthority(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//orgAuthorityObject.setCsid(csid);
}
}
-
+ /**
+ * Gets the org authority by name.
+ *
+ * @param specifier the specifier
+ *
+ * @return the org authority by name
+ */
@GET
@Path("urn:cspace:name({specifier})")
public MultipartOutput getOrgAuthorityByName(@PathParam("specifier") String specifier) {
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
handler.setDocumentFilter(myFilter);
return result;
}
+ /**
+ * Gets the org authority.
+ *
+ * @param csid the csid
+ *
+ * @return the org authority
+ */
@GET
@Path("{csid}")
public MultipartOutput getOrgAuthority(@PathParam("csid") String csid) {
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Gets the org authority list.
+ *
+ * @param ui the ui
+ *
+ * @return the org authority list
+ */
@GET
@Produces("application/xml")
public OrgauthoritiesCommonList getOrgAuthorityList(@Context UriInfo ui) {
OrgauthoritiesCommonList orgAuthorityObjectList = new OrgauthoritiesCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
DocumentHandler handler = createDocumentHandler(ctx);
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
myFilter.setPagination(queryParams);
String nameQ = queryParams.getFirst("refName");
if (nameQ != null) {
return orgAuthorityObjectList;
}
+ /**
+ * Update org authority.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}")
public MultipartOutput updateOrgAuthority(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete org authority.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deleteOrgAuthority(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
@Path("{csid}/items")
public Response createOrganization(@PathParam("csid") String parentcsid, MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ input);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
}
}
+ /**
+ * Gets the organization.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the organization
+ */
@GET
@Path("{csid}/items/{itemcsid}")
public MultipartOutput getOrganization(
MultipartOutput result = null;
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
getRepositoryClient(ctx).get(ctx, itemcsid, handler);
// TODO should we assert that the item is in the passed orgAuthority?
return result;
}
+ /**
+ * Gets the organization list.
+ *
+ * @param parentcsid the parentcsid
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the organization list
+ */
@GET
@Path("{csid}/items")
@Produces("application/xml")
@Context UriInfo ui) {
OrganizationsCommonList organizationObjectList = new OrganizationsCommonList();
try {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
// Note that docType defaults to the ServiceName, so we're fine with that.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ queryParams);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
myFilter.setWhereClause(OrganizationJAXBSchema.ORGANIZATIONS_COMMON +
":" + OrganizationJAXBSchema.IN_AUTHORITY + "=" +
"'" + parentcsid + "'");
return organizationObjectList;
}
+ /**
+ * Gets the organization list by auth name.
+ *
+ * @param parentSpecifier the parent specifier
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the organization list by auth name
+ */
@GET
@Path("urn:cspace:name({specifier})/items")
@Produces("application/xml")
@Context UriInfo ui) {
OrganizationsCommonList personObjectList = new OrganizationsCommonList();
try {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String whereClause =
OrgAuthorityJAXBSchema.ORGAUTHORITIES_COMMON+
":"+OrgAuthorityJAXBSchema.DISPLAY_NAME+
"='"+parentSpecifier+"'";
// Need to get an Authority by name
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
- String parentcsid =
- getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
+ String parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
- ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ctx = createServiceContext(getItemServiceName(), queryParams);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx);// new DocumentFilter();
- myFilter.setPagination(queryParams);
+ DocumentFilter myFilter = handler.createDocumentFilter();// new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
// Add the where clause "organizations_common:inAuthority='" + parentcsid + "'"
myFilter.setWhereClause(OrganizationJAXBSchema.ORGANIZATIONS_COMMON + ":" +
return personObjectList;
}
+ /**
+ * Update organization.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}/items/{itemcsid}")
public MultipartOutput updateOrganization(
MultipartOutput result = null;
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ theUpdate);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
getRepositoryClient(ctx).update(ctx, itemcsid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete organization.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}/items/{itemcsid}")
public Response deleteOrganization(
}
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
getRepositoryClient(ctx).delete(ctx, itemcsid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
try {
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(), input);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
String csid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
}
+ /**
+ * Gets the contact list.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param ui the ui
+ *
+ * @return the contact list
+ */
@GET
@Produces({"application/xml"})
@Path("{parentcsid}/items/{itemcsid}/contacts/")
@Context UriInfo ui) {
ContactsCommonList contactObjectList = new ContactsCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getContactServiceName());
- DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(),
+ queryParams);
+ DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
myFilter.setWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" +
ContactJAXBSchema.IN_AUTHORITY +
"='" + parentcsid + "'" +
return contactObjectList;
}
+ /**
+ * Gets the contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ *
+ * @return the contact
+ */
@GET
@Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
public MultipartOutput getContact(
try {
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName());
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
}
+ /**
+ * Update contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
public MultipartOutput updateContact(
try {
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(theUpdate, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(), theUpdate);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
public Response deleteContact(
try {
// Note that we have to create the service context for the
// Contact service, not the main service.
- ServiceContext ctx =
- MultipartServiceContextFactory.get().createServiceContext(null, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName());
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
*/
package org.collectionspace.services.person;
-import java.net.URI;
+//import java.net.URI;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
+//import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import org.collectionspace.services.PersonAuthorityJAXBSchema;
import org.collectionspace.services.PersonJAXBSchema;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
-import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+//import org.collectionspace.services.common.context.MultipartServiceContext;
+//import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.BadRequestException;
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.document.DocumentWrapper;
+//import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.security.UnauthorizedException;
-import org.collectionspace.services.common.vocabulary.RefNameUtils;
+//import org.collectionspace.services.common.vocabulary.RefNameUtils;
import org.collectionspace.services.common.query.IQueryManager;
import org.collectionspace.services.contact.ContactResource;
import org.collectionspace.services.contact.ContactsCommon;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.util.HttpResponseCodes;
-import org.nuxeo.ecm.core.api.DocumentModel;
+//import org.nuxeo.ecm.core.api.DocumentModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class PersonAuthorityResource.
+ */
@Path("/personauthorities")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class PersonAuthorityResource extends AbstractCollectionSpaceResourceImpl {
+public class PersonAuthorityResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
+ /** The Constant personAuthorityServiceName. */
private final static String personAuthorityServiceName = "personauthorities";
+
+ /** The Constant personServiceName. */
private final static String personServiceName = "persons";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(PersonAuthorityResource.class);
//FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+ /** The contact resource. */
private ContactResource contactResource = new ContactResource();
+ /**
+ * Instantiates a new person authority resource.
+ */
public PersonAuthorityResource() {
// do nothing
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return personAuthorityServiceName;
}
+ @Override
+ public Class<PersonauthoritiesCommon> getCommonPartClass() {
+ return PersonauthoritiesCommon.class;
+ }
+
+ /**
+ * Gets the item service name.
+ *
+ * @return the item service name
+ */
public String getItemServiceName() {
return personServiceName;
}
+ /**
+ * Gets the contact service name.
+ *
+ * @return the contact service name
+ */
public String getContactServiceName() {
return contactResource.getServiceName();
}
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), PersonauthoritiesCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((PersonauthoritiesCommon) obj);
- }
- }
- return docHandler;
- }
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), PersonauthoritiesCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((PersonauthoritiesCommon) obj);
+// }
+// }
+// return docHandler;
+// }
- private DocumentHandler createItemDocumentHandler(
- ServiceContext ctx,
- String inAuthority) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- ((PersonDocumentModelHandler) docHandler).setInAuthority(inAuthority);
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(getItemServiceName()),
- PersonsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((PersonsCommon) obj);
- }
- }
+ /**
+ * Creates the item document handler.
+ *
+ * @param ctx the ctx
+ * @param inAuthority the in authority
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
+ private DocumentHandler createItemDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx,
+ String inAuthority) throws Exception {
+ PersonDocumentModelHandler docHandler = (PersonDocumentModelHandler)createDocumentHandler(ctx,
+ ctx.getCommonPartLabel(getItemServiceName()),
+ PersonsCommon.class);
+ docHandler.setInAuthority(inAuthority);
+
return docHandler;
}
+ /**
+ * Creates the contact document handler.
+ *
+ * @param ctx the ctx
+ * @param inAuthority the in authority
+ * @param inItem the in item
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
private DocumentHandler createContactDocumentHandler(
- ServiceContext ctx, String inAuthority,
+ ServiceContext<MultipartInput, MultipartOutput> ctx, String inAuthority,
String inItem) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- // Set the inAuthority and inItem values, which specify the
- // parent authority (e.g. PersonAuthority, OrgAuthority) and the item
- // (e.g. Person, Organization) with which the Contact is associated.
- ((ContactDocumentModelHandler) docHandler).setInAuthority(inAuthority);
- ((ContactDocumentModelHandler) docHandler).setInItem(inItem);
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx)
- .getInputPart(ctx.getCommonPartLabel(getContactServiceName()),
- ContactsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((ContactsCommon) obj);
- }
- }
+ ContactDocumentModelHandler docHandler = (ContactDocumentModelHandler)createDocumentHandler(ctx,
+ ctx.getCommonPartLabel(getContactServiceName()),
+ ContactsCommon.class);
+ docHandler.setInAuthority(inAuthority);
+ docHandler.setInItem(inItem);
+
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// // Set the inAuthority and inItem values, which specify the
+// // parent authority (e.g. PersonAuthority, OrgAuthority) and the item
+// // (e.g. Person, Organization) with which the Contact is associated.
+// ((ContactDocumentModelHandler) docHandler).setInAuthority(inAuthority);
+// ((ContactDocumentModelHandler) docHandler).setInItem(inItem);
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx)
+// .getInputPart(ctx.getCommonPartLabel(getContactServiceName()),
+// ContactsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((ContactsCommon) obj);
+// }
+// }
return docHandler;
}
+ /**
+ * Creates the person authority.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
@POST
public Response createPersonAuthority(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//personAuthorityObject.setCsid(csid);
}
}
+ /**
+ * Gets the person authority by name.
+ *
+ * @param specifier the specifier
+ *
+ * @return the person authority by name
+ */
@GET
@Path("urn:cspace:name({specifier})")
public MultipartOutput getPersonAuthorityByName(@PathParam("specifier") String specifier) {
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
handler.setDocumentFilter(myFilter);
return result;
}
+ /**
+ * Gets the person authority.
+ *
+ * @param csid the csid
+ *
+ * @return the person authority
+ */
@GET
@Path("{csid}")
public MultipartOutput getPersonAuthority(@PathParam("csid") String csid) {
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Gets the person authority list.
+ *
+ * @param ui the ui
+ *
+ * @return the person authority list
+ */
@GET
@Produces("application/xml")
public PersonauthoritiesCommonList getPersonAuthorityList(@Context UriInfo ui) {
PersonauthoritiesCommonList personAuthorityObjectList = new PersonauthoritiesCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
DocumentHandler handler = createDocumentHandler(ctx);
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME
String nameQ = queryParams.getFirst("refName");
if (nameQ != null) {
myFilter.setWhereClause("personauthorities_common:refName='" + nameQ + "'");
return personAuthorityObjectList;
}
+ /**
+ * Update person authority.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}")
public MultipartOutput updatePersonAuthority(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete person authority.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deletePersonAuthority(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
@Path("{csid}/items")
public Response createPerson(@PathParam("csid") String parentcsid, MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(), input);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(PersonAuthorityResource.class);
}
}
+ /**
+ * Gets the person.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the person
+ */
@GET
@Path("{csid}/items/{itemcsid}")
public MultipartOutput getPerson(
MultipartOutput result = null;
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
getRepositoryClient(ctx).get(ctx, itemcsid, handler);
// TODO should we assert that the item is in the passed personAuthority?
return result;
}
+ /**
+ * Gets the person list.
+ *
+ * @param parentcsid the parentcsid
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the person list
+ */
@GET
@Path("{csid}/items")
@Produces("application/xml")
PersonsCommonList personObjectList = new PersonsCommonList();
try {
// Note that docType defaults to the ServiceName, so we're fine with that.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ queryParams);
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
// Add the where clause "persons_common:inAuthority='" + parentcsid + "'"
myFilter.setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" +
return personObjectList;
}
+ /**
+ * Gets the person list by auth name.
+ *
+ * @param parentSpecifier the parent specifier
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the person list by auth name
+ */
@GET
@Path("urn:cspace:name({specifier})/items")
@Produces("application/xml")
@Context UriInfo ui) {
PersonsCommonList personObjectList = new PersonsCommonList();
try {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String whereClause =
PersonAuthorityJAXBSchema.PERSONAUTHORITIES_COMMON+
":"+PersonAuthorityJAXBSchema.DISPLAY_NAME+
"='"+parentSpecifier+"'";
// Need to get an Authority by name
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
String parentcsid =
getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
- ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ctx = createServiceContext(getItemServiceName(), queryParams);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME
// Add the where clause "persons_common:inAuthority='" + parentcsid + "'"
myFilter.setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" +
return personObjectList;
}
+ /**
+ * Update person.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}/items/{itemcsid}")
public MultipartOutput updatePerson(
MultipartOutput result = null;
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ theUpdate);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
getRepositoryClient(ctx).update(ctx, itemcsid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete person.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}/items/{itemcsid}")
public Response deletePerson(
}
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
getRepositoryClient(ctx).delete(ctx, itemcsid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
try {
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(), input);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
String csid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(PersonAuthorityResource.class);
}
+ /**
+ * Gets the contact list.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param ui the ui
+ *
+ * @return the contact list
+ */
@GET
@Produces({"application/xml"})
@Path("{parentcsid}/items/{itemcsid}/contacts/")
@Context UriInfo ui) {
ContactsCommonList contactObjectList = new ContactsCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getContactServiceName());
- DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(),
+ queryParams);
+ DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
myFilter.setWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" +
ContactJAXBSchema.IN_AUTHORITY +
"='" + parentcsid + "'" +
return contactObjectList;
}
+ /**
+ * Gets the contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ *
+ * @return the contact
+ */
@GET
@Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
public MultipartOutput getContact(
try {
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName());
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
}
+ /**
+ * Update contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
public MultipartOutput updateContact(
try {
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(theUpdate, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(),
+ theUpdate);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
public Response deleteContact(
try {
// Note that we have to create the service context for the
// Contact service, not the main service.
- ServiceContext ctx =
- MultipartServiceContextFactory.get().createServiceContext(null, getContactServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName());
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
-import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
+//import org.collectionspace.services.common.context.MultipartServiceContext;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.relation.IRelationsManager;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.security.UnauthorizedException;
+
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.util.HttpResponseCodes;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/relations")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class NewRelationResource extends AbstractCollectionSpaceResourceImpl {
+public class NewRelationResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
/** The Constant serviceName. */
public final static String serviceName = "relations";
}
/* (non-Javadoc)
- * @see org.collectionspace.services.common.AbstractCollectionSpaceResource#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
*/
@Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx)
- throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx
- .getCommonPartLabel(), RelationsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((RelationsCommon) obj);
- }
- }
- return docHandler;
- }
+ public Class<RelationsCommon> getCommonPartClass() {
+ return RelationsCommon.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResource#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx)
+// throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx
+// .getCommonPartLabel(), RelationsCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((RelationsCommon) obj);
+// }
+// }
+// return docHandler;
+// }
/**
* Creates the relation.
*/
@POST
public Response createRelation(MultipartInput input) {
-
try {
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
String predicate, String objectCsid) throws WebApplicationException {
RelationsCommonList relationList = new RelationsCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get()
- .createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
- Map propsFromPath = handler.getProperties();
+ Map<String, Object> propsFromPath = handler.getProperties();
propsFromPath.put(IRelationsManager.SUBJECT, subjectCsid);
propsFromPath.put(IRelationsManager.PREDICATE, predicate);
propsFromPath.put(IRelationsManager.OBJECT, objectCsid);
import javax.ws.rs.core.UriInfo;
import org.collectionspace.services.VocabularyItemJAXBSchema;
-import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.context.MultipartServiceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class VocabularyResource.
+ */
@Path("/vocabularies")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class VocabularyResource extends AbstractCollectionSpaceResourceImpl {
+public class VocabularyResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
+ /** The Constant vocabularyServiceName. */
private final static String vocabularyServiceName = "vocabularies";
+
+ /** The Constant vocabularyItemServiceName. */
private final static String vocabularyItemServiceName = "vocabularyitems";
+
+ /** The logger. */
final Logger logger = LoggerFactory.getLogger(VocabularyResource.class);
//FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+ /**
+ * Instantiates a new vocabulary resource.
+ */
public VocabularyResource() {
// do nothing
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
@Override
protected String getVersionString() {
/** The last change revision. */
return lastChangeRevision;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
@Override
public String getServiceName() {
return vocabularyServiceName;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+ */
+ @Override
+ public Class<VocabulariesCommon> getCommonPartClass() {
+ return VocabulariesCommon.class;
+ }
+
+ /**
+ * Gets the item service name.
+ *
+ * @return the item service name
+ */
public String getItemServiceName() {
return vocabularyItemServiceName;
}
return ctx;
}
*/
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), VocabulariesCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((VocabulariesCommon) obj);
- }
- }
- return docHandler;
- }
-
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+// DocumentHandler docHandler = ctx.getDocumentHandler();
+// if (ctx.getInput() != null) {
+// Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), VocabulariesCommon.class);
+// if (obj != null) {
+// docHandler.setCommonPart((VocabulariesCommon) obj);
+// }
+// }
+// return docHandler;
+// }
+
+// @Override
+// public DocumentHandler createDocumentHandler(ServiceContext ctx)
+// throws Exception {
+// DocumentHandler docHandler = createDocumentHandler(ctx, VocabulariesCommon.class);
+// return docHandler;
+// }
+
+ /**
+ * Creates the item document handler.
+ *
+ * @param ctx the ctx
+ * @param inVocabulary the in vocabulary
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
private DocumentHandler createItemDocumentHandler(
- ServiceContext ctx,
- String inVocabulary) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- ((VocabularyItemDocumentModelHandler) docHandler).setInVocabulary(inVocabulary);
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(getItemServiceName()),
- VocabularyitemsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((VocabularyitemsCommon) obj);
- }
- }
+ ServiceContext<MultipartInput, MultipartOutput> ctx,
+ String inVocabulary)
+ throws Exception {
+ VocabularyItemDocumentModelHandler docHandler;
+
+ docHandler = (VocabularyItemDocumentModelHandler)createDocumentHandler(ctx,
+ ctx.getCommonPartLabel(getItemServiceName()),
+ VocabularyitemsCommon.class);
+ docHandler.setInVocabulary(inVocabulary);
+
return docHandler;
}
+ /**
+ * Creates the vocabulary.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
@POST
public Response createVocabulary(MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getRepositoryClient(ctx).create(ctx, handler);
//vocabularyObject.setCsid(csid);
}
}
+ /**
+ * Gets the vocabulary.
+ *
+ * @param csid the csid
+ *
+ * @return the vocabulary
+ */
@GET
@Path("{csid}")
public MultipartOutput getVocabulary(@PathParam("csid") String csid) {
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
throw new WebApplicationException(response);
}
+
if (result == null) {
Response response = Response.status(Response.Status.NOT_FOUND).entity(
"Get failed, the requested Vocabulary CSID:" + csid + ": was not found.").type(
"text/plain").build();
throw new WebApplicationException(response);
}
+
return result;
}
+ /**
+ * Gets the vocabulary list.
+ *
+ * @param ui the ui
+ *
+ * @return the vocabulary list
+ */
@GET
@Produces("application/xml")
public VocabulariesCommonList getVocabularyList(@Context UriInfo ui) {
VocabulariesCommonList vocabularyObjectList = new VocabulariesCommonList();
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+// DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ DocumentFilter myFilter = handler.getDocumentFilter();
+// myFilter.setPagination(queryParams);
String nameQ = queryParams.getFirst("refName");
if (nameQ != null) {
myFilter.setWhereClause("vocabularies_common:refName='" + nameQ + "'");
}
- handler.setDocumentFilter(myFilter);
+// handler.setDocumentFilter(myFilter);
getRepositoryClient(ctx).getFiltered(ctx, handler);
vocabularyObjectList = (VocabulariesCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
return vocabularyObjectList;
}
+ /**
+ * Update vocabulary.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}")
public MultipartOutput updateVocabulary(
}
MultipartOutput result = null;
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete vocabulary.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}")
public Response deleteVocabulary(@PathParam("csid") String csid) {
throw new WebApplicationException(response);
}
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
@Path("{csid}/items")
public Response createVocabularyItem(@PathParam("csid") String parentcsid, MultipartInput input) {
try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ input);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(VocabularyResource.class);
}
}
+ /**
+ * Gets the vocabulary item.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the vocabulary item
+ */
@GET
@Path("{csid}/items/{itemcsid}")
public MultipartOutput getVocabularyItem(
MultipartOutput result = null;
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
getRepositoryClient(ctx).get(ctx, itemcsid, handler);
// TODO should we assert that the item is in the passed vocab?
return result;
}
+ /**
+ * Gets the vocabulary item list.
+ *
+ * @param parentcsid the parentcsid
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the vocabulary item list
+ */
@GET
@Path("{csid}/items")
@Produces("application/xml")
@Context UriInfo ui) {
VocabularyitemsCommonList vocabularyItemObjectList = new VocabularyitemsCommonList();
try {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
// Note that docType defaults to the ServiceName, so we're fine with that.
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ queryParams);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentFilter myFilter = handler.createDocumentFilter(ctx); //new DocumentFilter();
- myFilter.setPagination(queryParams);
+// DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ DocumentFilter myFilter = handler.getDocumentFilter(); //new DocumentFilter();
+// myFilter.setPagination(queryParams);
// "vocabularyitems_common:inVocabulary='" + parentcsid + "'");
myFilter.setWhereClause(
VocabularyItemJAXBSchema.VOCABULARYITEMS_COMMON + ":"
return vocabularyItemObjectList;
}
+ /**
+ * Update vocabulary item.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
@PUT
@Path("{csid}/items/{itemcsid}")
public MultipartOutput updateVocabularyItem(
MultipartOutput result = null;
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ theUpdate);
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
getRepositoryClient(ctx).update(ctx, itemcsid, handler);
result = (MultipartOutput) ctx.getOutput();
return result;
}
+ /**
+ * Delete vocabulary item.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the response
+ */
@DELETE
@Path("{csid}/items/{itemcsid}")
public Response deleteVocabularyItem(
}
try {
// Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
getRepositoryClient(ctx).delete(ctx, itemcsid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {