1 package org.collectionspace.services.common.document;
\r
3 import java.lang.reflect.Field;
\r
4 import java.lang.reflect.ParameterizedType;
\r
5 import java.lang.reflect.Type;
\r
6 import java.lang.reflect.TypeVariable;
\r
7 import java.util.ArrayList;
\r
9 import org.collectionspace.services.common.context.MultipartServiceContext;
\r
10 import org.collectionspace.services.common.context.ServiceContext;
\r
11 import org.collectionspace.services.common.document.DocumentHandler.Action;
\r
12 import org.collectionspace.services.relation.RelationsCommon;
\r
13 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
\r
14 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
\r
15 import org.slf4j.Logger;
\r
16 import org.slf4j.LoggerFactory;
\r
18 // TODO: Auto-generated Javadoc
\r
20 * The Class ValidatorHandlerImpl.
\r
22 public abstract class ValidatorHandlerImpl<IT, OT> implements ValidatorHandler<IT, OT> {
\r
25 private final Logger logger = LoggerFactory.getLogger(ValidatorHandlerImpl.class);
\r
27 private ServiceContext<IT, OT> ctx;
\r
29 protected ServiceContext<IT, OT> getServiceContext() {
\r
33 protected void setServiceContext(ServiceContext<IT, OT> ctx) {
\r
38 * @see org.collectionspace.services.common.document.ValidatorHandler#validate(org.collectionspace.services.common.document.DocumentHandler.Action, org.collectionspace.services.common.context.ServiceContext)
\r
41 public void validate(Action action, ServiceContext<IT, OT> ctx)
\r
42 throws InvalidDocumentException {
\r
43 setServiceContext(ctx);
\r
61 throw new UnsupportedOperationException("ValidatorHandlerImpl: Unknow action = " +
\r
66 protected Object getCommonPart() {
\r
67 Object result = null;
\r
70 MultipartServiceContext multiPartCtx = (MultipartServiceContext) getServiceContext();
\r
71 result = multiPartCtx.getInputPart(ctx.getCommonPartLabel(),
\r
72 getCommonPartClass());
\r
73 } catch (Exception e) {
\r
74 if (logger.isDebugEnabled() == true) {
\r
75 logger.debug("Could not extract common part from multipart input.", e);
\r
82 abstract protected Class<?> getCommonPartClass();
\r
87 * @param ctx the ctx
\r
89 abstract protected void handleCreate() throws InvalidDocumentException;
\r
94 * @param ctx the ctx
\r
96 abstract protected void handleGet() throws InvalidDocumentException;
\r
101 * @param ctx the ctx
\r
103 abstract protected void handleGetAll() throws InvalidDocumentException;
\r
108 * @param ctx the ctx
\r
110 abstract protected void handleUpdate() throws InvalidDocumentException;
\r
115 * @param ctx the ctx
\r
117 abstract protected void handleDelete() throws InvalidDocumentException;
\r