]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
PAHMA-963: Adding CSWebApplicationException class that extends WebApplicationExceptio...
authorRichard Millet <remillet@berkeley.edu>
Wed, 29 Jan 2014 20:51:23 +0000 (12:51 -0800)
committerRichard Millet <remillet@berkeley.edu>
Wed, 29 Jan 2014 20:51:23 +0000 (12:51 -0800)
21 files changed:
3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/default-repo-config.xml
3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/lifesci_domain-repo-config.xml
build.properties
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/RoleResource.java
services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java
services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java
services/common/src/main/java/org/collectionspace/services/common/profile/CSpaceFilter.java
services/common/src/main/java/org/collectionspace/services/common/relation/RelationResource.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java
services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java
services/query/service/src/main/java/org/collectionspace/services/query/QueryResource.java
services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java
services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java

index 2c1b6d4b4953b34fe2fde3dce2ff92e4c457fcfc..58f420c599c4c6ce62f8c9dca9a944f44e9adc92 100644 (file)
@@ -5,6 +5,8 @@
                <repository name="default"
                        factory="org.nuxeo.ecm.core.storage.sql.ra.PoolingRepositoryFactory">
                        <repository name="default">
+                               <pool minPoolSize="0" maxPoolSize="20"
+                               blockingTimeoutMillis="100" idleTimeoutMinutes="10" />
                        <clustering enabled="false" delay="1000" />
                        <binaryStore path="" />
                                <!-- The transactional datasource for Nuxeo -->
index 2f835f1f89edc5d74ae3586fdf94a63a9dfdd544..1e09a526f99d2aef142ae4295928d3ff0efd3fd6 100644 (file)
@@ -5,6 +5,8 @@
                <repository name="lifesci_domain"
                        factory="org.nuxeo.ecm.core.storage.sql.ra.PoolingRepositoryFactory">
                        <repository name="lifesci_domain">
+                               <pool minPoolSize="0" maxPoolSize="20"
+                               blockingTimeoutMillis="100" idleTimeoutMinutes="10" />
                        <clustering enabled="false" delay="1000" />
                        <binaryStore path="" />
                                <!-- The transactional datasource for Nuxeo -->
index 980c446514446c35ad001786259935afbfefc50a..245a592365d04cc3946794425c7a25f0d368b908 100644 (file)
@@ -120,7 +120,10 @@ db.nuxeo.user=nuxeo
 db.nuxeo.user.password=${env.DB_PASSWORD_NUXEO}\r
 db.cspace.user=cspace\r
 db.cspace.user.password=${env.DB_PASSWORD_CSPACE}\r
-db.host=dba-postgres-qa-21.ist.berkeley.edu\r
+#db.host=dba-postgres-qa-21.ist.berkeley.edu\r
+#db.host=173.255.228.202\r
+db.host=169.229.248.106\r
+#db.host=169.229.199.44\r
 db.jdbc.baseurl=jdbc:${db}://${db.host}:${db.port}\r
 \r
 #\r
index d18fa32d3f65e03a0b18defd650ef8cd740610e3..95693d7382c25ee6c30857248e227702f1e392bc 100644 (file)
@@ -25,6 +25,7 @@ package org.collectionspace.services.common.vocabulary;
 
 import java.util.List;
 import java.util.Map;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -40,11 +41,13 @@ import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+
 import org.collectionspace.services.client.IClientQueryParams;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.ServiceMain;
@@ -140,7 +143,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         }
     }
 
-    protected Specifier getSpecifier(String specifierIn, String method, String op) throws WebApplicationException {
+    protected Specifier getSpecifier(String specifierIn, String method, String op) throws CSWebApplicationException {
         if (logger.isDebugEnabled()) {
             logger.debug("getSpecifier called by: " + method + " with specifier: " + specifierIn);
         }
@@ -168,7 +171,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         Response response = Response.status(Response.Status.BAD_REQUEST).entity(
                 op + " failed on bad or missing Authority specifier").type(
                 "text/plain").build();
-        throw new WebApplicationException(response);
+        throw new CSWebApplicationException(response);
     }
 
     /**
@@ -416,7 +419,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             Response response = Response.status(Response.Status.NOT_FOUND).entity(
                     "Get failed, the requested Authority specifier:" + specifier + ": was not found.").type(
                     "text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(response);
         }
 
         return result.getBytes();
@@ -657,12 +660,14 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.GET_FAILED);
         }
+        
         if (result == null) {
             Response response = Response.status(Response.Status.NOT_FOUND).entity(
                     "Get failed, the requested AuthorityItem specifier:" + itemspecifier + ": was not found.").type(
                     "text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(response);
         }
+        
         return result.getBytes();
     }
 
@@ -808,7 +813,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             Response response = Response.status(Response.Status.NOT_FOUND).entity(
                     "Get failed, the requested Item CSID:" + itemspecifier + ": was not found.").type(
                     "text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(response);
         }
         return authRefDocList;
     }
index 8bbd027a9703e6821a9ffd6ea4cc9a9dcfeae8ac..96a948c08d5dea4fa10c90224cb522e2fdc45d3f 100644 (file)
@@ -32,6 +32,8 @@ import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.context.ServiceContextFactory;
 import org.collectionspace.services.common.storage.StorageClient;
 import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;
+import org.collectionspace.services.common.CSWebApplicationException;
+
 import org.jboss.resteasy.util.HttpResponseCodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -133,7 +135,7 @@ public class RoleResource extends SecurityResourceBase {
                if(RoleClient.IMMUTABLE.equals(role.getMetadataProtection())) {
                    Response response = 
                        Response.status(Response.Status.FORBIDDEN).entity("Role: "+csid+" is immutable.").type("text/plain").build();
-                throw new WebApplicationException(response);
+                throw new CSWebApplicationException(response);
                }
                return (Role)update(csid, theUpdate, Role.class);
         } catch (Exception e) {
index 576d3bf8dd463f9364b6d0e8e2ff206a5699f08d..5e182268de4a6342dbf2a60b7e2fa51514e3a53f 100644 (file)
@@ -38,6 +38,8 @@ import org.collectionspace.services.common.blob.BlobUtil;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.publicitem.PublicItemUtil;
 import org.collectionspace.services.nuxeo.client.java.CommonList;
+import org.collectionspace.services.common.CSWebApplicationException;
+
 import org.jboss.resteasy.plugins.providers.multipart.InputPart;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
 
@@ -122,7 +124,7 @@ public class BlobResource extends ResourceBase {
     private InputStream getBlobContent(ServiceContext ctx,
                String csid, 
                String derivativeTerm, 
-               StringBuffer outMimeType) throws WebApplicationException {
+               StringBuffer outMimeType) throws CSWebApplicationException {
        InputStream result = null;
        
        try {
@@ -152,7 +154,7 @@ public class BlobResource extends ResourceBase {
                Response response = Response.status(
                        Response.Status.INTERNAL_SERVER_ERROR).entity(
                                        "Index failed. Could not get the contents for the Blob.").type("text/plain").build();
-               throw new WebApplicationException(response);
+               throw new CSWebApplicationException(response);
        }
        
        return result;
@@ -366,7 +368,7 @@ public class BlobResource extends ResourceBase {
             if (result == null) {
                 Response response = Response.status(Response.Status.NOT_FOUND).entity(
                     ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build();
-                throw new WebApplicationException(response);
+                throw new CSWebApplicationException(response);
             }
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.READ_FAILED, csid);
@@ -387,7 +389,7 @@ public class BlobResource extends ResourceBase {
             if (result == null) {
                 Response response = Response.status(Response.Status.NOT_FOUND).entity(
                     ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build();
-                throw new WebApplicationException(response);
+                throw new CSWebApplicationException(response);
             }
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.READ_FAILED, csid);
index c04368c1c934ded52b938a7012845939dff1c818..d85062628179ea2aff12a9427da4613c89ddd587 100644 (file)
@@ -33,6 +33,7 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;\r
 import javax.ws.rs.core.UriInfo;\r
 \r
+import org.collectionspace.services.common.CSWebApplicationException;\r
 import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.common.context.ServiceContext;\r
 import org.collectionspace.services.common.context.ServiceContextProperties;\r
@@ -46,6 +47,7 @@ import org.collectionspace.services.common.repository.RepositoryClientFactory;
 import org.collectionspace.services.common.security.UnauthorizedException;\r
 import org.collectionspace.services.common.storage.StorageClient;\r
 import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;\r
+\r
 import org.jboss.resteasy.core.ResourceMethod;\r
 import org.jboss.resteasy.spi.HttpRequest;\r
 \r
@@ -404,45 +406,45 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
        return result;\r
     }\r
 \r
-    public void checkResult(Object resultToCheck, String csid, String serviceMessage) throws WebApplicationException {\r
+    public void checkResult(Object resultToCheck, String csid, String serviceMessage) throws CSWebApplicationException {\r
         if (resultToCheck == null) {\r
             Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
                     serviceMessage + "csid=" + csid\r
                     + ": was not found.").type(\r
                     "text/plain").build();\r
-            throw new WebApplicationException(response);\r
+            throw new CSWebApplicationException(response);\r
         }\r
     }\r
 \r
-    protected void ensureCSID(String csid, String crudType) throws WebApplicationException {\r
+    protected void ensureCSID(String csid, String crudType) throws CSWebApplicationException {\r
         ensureCSID(csid, crudType, "csid");\r
     }\r
 \r
-    protected void ensureCSID(String csid, String crudType, String whichCsid) throws WebApplicationException {\r
+    protected void ensureCSID(String csid, String crudType, String whichCsid) throws CSWebApplicationException {\r
            if (logger.isDebugEnabled()) {\r
                logger.debug(crudType + " for " + getClass().getName() + " with csid=" + csid);\r
            }\r
            if (csid == null || "".equals(csid)) {\r
                logger.error(crudType + " for " + getClass().getName() + " missing csid!");\r
                Response response = Response.status(Response.Status.BAD_REQUEST).entity(crudType + " failed on " + getClass().getName() + ' '+whichCsid+'=' + csid).type("text/plain").build();\r
-               throw new WebApplicationException(response);\r
+               throw new CSWebApplicationException(response);\r
            }\r
        }\r
 \r
-    protected WebApplicationException bigReThrow(Exception e, String serviceMsg) throws WebApplicationException {\r
+    protected CSWebApplicationException bigReThrow(Exception e, String serviceMsg) throws CSWebApplicationException {\r
         return bigReThrow(e, serviceMsg, "");\r
     }\r
 \r
-    protected WebApplicationException bigReThrow(Exception e, String serviceMsg, String csid) throws WebApplicationException {\r
+    protected CSWebApplicationException bigReThrow(Exception e, String serviceMsg, String csid) throws CSWebApplicationException {\r
        boolean logException = true;\r
-       WebApplicationException result = null;\r
+       CSWebApplicationException result = null;\r
         Response response;\r
-        \r
         String detail = Tools.errorToString(e, true);\r
         String detailNoTrace = Tools.errorToString(e, true, 3);\r
+        \r
         if (e instanceof UnauthorizedException) {\r
             response = Response.status(Response.Status.UNAUTHORIZED).entity(serviceMsg + e.getMessage()).type("text/plain").build();\r
-            result = new WebApplicationException(response);\r
+            result = new CSWebApplicationException(e, response);\r
 \r
         } else if (e instanceof DocumentNotFoundException) {\r
                //\r
@@ -450,12 +452,12 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
                //\r
                logException = false;\r
             response = Response.status(Response.Status.NOT_FOUND).entity(serviceMsg + " on " + getClass().getName() + " csid=" + csid).type("text/plain").build();\r
-            result = new WebApplicationException(response);\r
+            result = new CSWebApplicationException(e, response);\r
             \r
         } else if (e instanceof TransactionException) {\r
             int code = ((TransactionException) e).getErrorCode();\r
             response = Response.status(code).entity(e.getMessage()).type("text/plain").build();\r
-            result = new WebApplicationException(response);\r
+            result = new CSWebApplicationException(e, response);\r
 \r
         } else if (e instanceof BadRequestException) {\r
             int code = ((BadRequestException) e).getErrorCode();\r
@@ -465,7 +467,7 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
             // CSPACE-1110\r
             response = Response.status(code).entity(serviceMsg + e.getMessage()).type("text/plain").build();\r
             // return new WebApplicationException(e, code);\r
-            result = new WebApplicationException(response);\r
+            result = new CSWebApplicationException(e, response);\r
 \r
         } else if (e instanceof DocumentException) {\r
             int code = ((DocumentException) e).getErrorCode();\r
@@ -475,16 +477,16 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
             // CSPACE-1110\r
             response = Response.status(code).entity(serviceMsg + e.getMessage()).type("text/plain").build();\r
             // return new WebApplicationException(e, code);\r
-            result = new WebApplicationException(response);\r
+            result = new CSWebApplicationException(e, response);\r
            \r
-        } else if (e instanceof WebApplicationException) {\r
+        } else if (e instanceof CSWebApplicationException) {\r
             // subresource may have already thrown this exception\r
             // so just pass it on\r
-            result = (WebApplicationException) e;\r
+            result = (CSWebApplicationException) e;\r
 \r
         } else { // e is now instanceof Exception\r
             response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(serviceMsg + " detail: " + detailNoTrace).type("text/plain").build();\r
-            result = new WebApplicationException(response);\r
+            result = new CSWebApplicationException(e, response);\r
         }\r
         //\r
         // Some exceptions like DocumentNotFoundException won't be logged unless we're in 'trace' mode\r
index 2d1dcb27f1e33072076be644943d376918d2016a..58117049fac9a6d1e0865717fef396d5e8e73466 100644 (file)
@@ -253,7 +253,7 @@ public abstract class ResourceBase
             if (result == null) {\r
                 Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
                         ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build();\r
-                throw new WebApplicationException(response);\r
+                throw new CSWebApplicationException(response);\r
             }\r
         } catch (Exception e) {\r
             throw bigReThrow(e, ServiceMessages.READ_FAILED, csid);\r
index 989e647111645dfffc3a2198e301fa8bea35ed89..459cb4193d0adb6d6a8c06a63842dcc607489e53 100644 (file)
@@ -17,6 +17,8 @@
 package org.collectionspace.services.common.profile;\r
 \r
 import java.io.IOException;\r
+import java.net.SocketException;\r
+\r
 import javax.servlet.Filter;\r
 import javax.servlet.FilterChain;\r
 import javax.servlet.FilterConfig;\r
@@ -26,9 +28,9 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;\r
 //import javax.servlet.ServletContext;\r
 \r
+\r
 import org.collectionspace.services.client.Profiler;\r
 import org.collectionspace.services.common.ServletTools;\r
-\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -51,6 +53,8 @@ public class CSpaceFilter implements Filter {
     FilterConfig filterConfig = null;\r
 \r
     private final String CLASS_NAME = this.getClass().getSimpleName();\r
+       private static final int MAX_RETRY_SECONDS = 5;\r
+\r
 \r
     /* (non-Javadoc)\r
      * @see javax.servlet.Filter#destroy()\r
@@ -96,7 +100,13 @@ public class CSpaceFilter implements Filter {
            profiler.log(csvMsg, FORMAT_LOG_MESSAGE);\r
 \r
             // Process the request.\r
-            chain.doFilter(request, response);\r
+            //chain.doFilter(request, response);\r
+                       try {\r
+                               invoke(request, response, chain);\r
+                       } catch (Throwable e) {\r
+                               // TODO Auto-generated catch block\r
+                               e.printStackTrace();\r
+                       }\r
 \r
             // Stop timing and log performance-related metrics.\r
             profiler.stop();\r
@@ -116,6 +126,61 @@ public class CSpaceFilter implements Filter {
             profiler.reset();\r
         }\r
     }\r
+    \r
+       public void invoke(ServletRequest request, ServletResponse response,\r
+            FilterChain chain) throws Throwable {\r
+               Throwable lastException = null;\r
+               int attempt = 0;\r
+\r
+               long quittingTime = System.currentTimeMillis() + MAX_RETRY_SECONDS * 1000;\r
+               do {\r
+                       try {\r
+                               // proceed to original method call\r
+                               chain.doFilter(request, response);\r
+                               String contentType = response.getContentType();\r
+                               lastException = null;\r
+                               break;\r
+                       } catch (Exception e) {\r
+                               lastException = e;\r
+                               if (exceptionChainContains(lastException, SocketException.class) == false) {\r
+                                       // Break if the exception chain does not contain a\r
+                                       // SocketException.\r
+                                       break;\r
+                               }\r
+                               attempt++;\r
+                               System.out\r
+                                               .println(String\r
+                                                               .format("'%s' URL request failed with exception '%s' at attemp '%d'",\r
+                                                                               ServletTools.getURL((HttpServletRequest) request),\r
+                                                                               lastException.getClass().getName(),\r
+                                                                               attempt));\r
+                       }\r
+               } while (System.currentTimeMillis() < quittingTime);\r
+\r
+               if (lastException != null) {\r
+                       throw lastException;\r
+               }\r
+\r
+               System.out.println("Success!");\r
+       }\r
+       \r
+       private boolean exceptionChainContains(Throwable exceptionChain,\r
+                       Class<?> target) {\r
+               boolean result = false;\r
+               Throwable top = exceptionChain;\r
+\r
+               while (top != null) {\r
+                       System.out.println(top.getClass().getCanonicalName());\r
+                       if (target.isInstance(top) == true) {\r
+                               result = true;\r
+                               break;\r
+                       }\r
+                       top = top.getCause();\r
+               }\r
+\r
+               return result;\r
+       }\r
+    \r
 \r
     /* (non-Javadoc)\r
      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)\r
index 02d3d8b7b3ed6b16cabfd4e22a59bfef6b3f651b..ee137fe93402cb0642038e103d4023d1d8564014 100644 (file)
@@ -29,6 +29,7 @@ package org.collectionspace.services.common.relation;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ServiceMessages;
 import org.collectionspace.services.common.context.ServiceContext;
@@ -38,7 +39,6 @@ import org.collectionspace.services.client.IRelationsManager;
 import org.collectionspace.services.common.relation.nuxeo.RelationsUtils;
 import org.collectionspace.services.relation.RelationsCommon;
 import org.collectionspace.services.relation.RelationsCommonList;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -101,7 +101,7 @@ public class RelationResource extends ResourceBase {
                String subjectCsid, String subjectType,
                String predicate,
                String objectCsid,
-               String objectType) throws WebApplicationException {
+               String objectType) throws CSWebApplicationException {
         try {
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
             if (parentCtx != null) { // If the parent context has an open repository session then use it
index 49752e4858d48d52e5a0ea1940e672ea0662c6f7..ce5189c65937a10847b5ad386110a4083cb26129 100644 (file)
@@ -53,11 +53,11 @@ import org.collectionspace.services.authorization.AuthZ;
 import org.collectionspace.services.authorization.CSpaceResource;
 import org.collectionspace.services.authorization.URIResourceImpl;
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.CollectionSpaceResource;
 import org.collectionspace.services.common.document.JaxbUtils;
 import org.collectionspace.services.common.storage.jpa.JpaStorageUtils;
 import org.collectionspace.services.common.security.SecurityUtils;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -123,7 +123,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
         */
        @Override
        public ServerResponse preProcess(HttpRequest request, ResourceMethod resourceMethod)
-       throws Failure, WebApplicationException {
+                       throws Failure, CSWebApplicationException {
                ServerResponse result = null; // A null value essentially means success for this method
                
                if (isAnonymousRequest(request, resourceMethod) == true) {
@@ -138,13 +138,15 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                final int servicesResourceLen = servicesResource.length();
                String httpMethod = request.getHttpMethod();
                String uriPath = request.getUri().getPath();
+               
                if (logger.isDebugEnabled()) {
                        String fullRequest = request.getUri().getRequestUri().toString();
                        int servicesResourceIdx = fullRequest.indexOf(servicesResource);
                        String relativeRequest = (servicesResourceIdx<=0)? fullRequest
-                                                                                               :fullRequest.substring(servicesResourceIdx+servicesResourceLen);
+                                                                                               : fullRequest.substring(servicesResourceIdx+servicesResourceLen);
                        logger.debug("received " + httpMethod + " on " + relativeRequest);
                }
+               
                String resName = SecurityUtils.getResourceName(request.getUri());
                String resEntity = SecurityUtils.getResourceEntity(resName);
                
@@ -172,7 +174,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                                        + " user=" + AuthN.get().getUserId());
                                        Response response = Response.status(
                                                        Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
-                                       throw new WebApplicationException(response);
+                                       throw new CSWebApplicationException(response);
                        } else {
                                //
                                // They passed the first round of security checks, so now let's check to see if they're trying
@@ -186,7 +188,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                                                + " user=" + AuthN.get().getUserId());
                                                Response response = Response.status(
                                                                Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
-                                               throw new WebApplicationException(response);
+                                               throw new CSWebApplicationException(response);
                                        }
                                }
                        }
@@ -218,10 +220,14 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
 
        /**
         * checkActive check if account is active
-        * @throws WebApplicationException
+        * @throws CSWebApplicationException
         */
-       private void checkActive() throws WebApplicationException {
+       private void checkActive() throws CSWebApplicationException {
                String userId = AuthN.get().getUserId();
+               
+               if (true)
+                       throw new CSWebApplicationException(new java.net.SocketException("An faux exception thrown for testing."));
+               
                try {
                        // Need to ensure that user is associated to a tenant
                        String tenantId = AuthN.get().getCurrentTenantId();
@@ -232,8 +238,9 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                        // indicates that authorization has been refused for those credentials.
                        Response response = Response.status(
                                        Response.Status.UNAUTHORIZED).entity(msg).type("text/plain").build();
-                       throw new WebApplicationException(ise, response);
+                       throw new CSWebApplicationException(ise, response);
                }
+               
                try {
                        //can't use JAXB here as this runs from the common jar which cannot
                        //depend upon the account service
@@ -247,7 +254,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                String msg = "User's account not found, userId=" + userId;
                                Response response = Response.status(
                                                Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
-                               throw new WebApplicationException(response);
+                               throw new CSWebApplicationException(response);
                        }
                        Object status = JaxbUtils.getValue(account, "getStatus");
                        if (status != null) {
@@ -256,7 +263,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                        String msg = "User's account is inactive, userId=" + userId;
                                        Response response = Response.status(
                                                        Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
-                                       throw new WebApplicationException(response);
+                                       throw new CSWebApplicationException(response);
                                }
                        }
 
@@ -264,14 +271,14 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                        String msg = "User's account is in invalid state, userId=" + userId;
                        Response response = Response.status(
                                        Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
-                       throw new WebApplicationException(response);
+                       throw new CSWebApplicationException(e, response);
                }
        }
        //
        // Nuxeo login support
        //
        public ServerResponse nuxeoPreProcess(HttpRequest request, ResourceMethod resourceMethod)
-                       throws Failure, WebApplicationException {
+                       throws Failure, CSWebApplicationException {
                try {
                        nuxeoLogin();
                } catch (LoginException e) {
@@ -279,7 +286,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                        logger.error(msg, e);
                        Response response = Response.status(
                                        Response.Status.INTERNAL_SERVER_ERROR).entity(msg).type("text/plain").build();
-                       throw new WebApplicationException(response);
+                       throw new CSWebApplicationException(e, response);
                }
                
                return null;
index c515451a6943d294b2166a0ac2ae3fadec08f3eb..069d9451602991c8a661479ba11bb59a6baad09e 100644 (file)
@@ -542,7 +542,7 @@ public class JpaStorageUtils {
             if (logger.isDebugEnabled()) {
                 logger.debug("could not find entity (2) with where=" + whereClause, e);
             }
-            //returns null
+            throw e;
         } finally {
             if (em != null) {
                 releaseEntityManagerFactory(emf);
index 0577780311c3fc88cbd396a9f56a3f2d011d7c53..1323e9c1a5196ba8e8ebb35423a2d7f331dd55b6 100644 (file)
@@ -49,6 +49,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.Profiler;
 import org.collectionspace.services.client.RelationClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.config.ServiceConfigUtils;
@@ -80,12 +81,10 @@ import org.collectionspace.services.relation.RelationsCommonList;
 import org.collectionspace.services.relation.RelationsDocListItem;
 import org.collectionspace.services.relation.RelationshipType;
 import org.dom4j.Element;
-
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.model.PropertyException;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -664,7 +663,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                     Response.Status.INTERNAL_SERVER_ERROR).entity(
                     "Failed to retrieve authority references").type(
                     "text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(e, response);
         }
 
         return authRefList;
index cebbb47db2e1d1d04438bea3a49b6be6a2d67aaf..e44ad6ee03dfd861a34bb19061d3aed5bb9a1458 100644 (file)
@@ -28,8 +28,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-import javax.sql.rowset.CachedRowSet;
 
+import javax.sql.rowset.CachedRowSet;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
 
@@ -46,7 +46,6 @@ import org.collectionspace.services.common.storage.JDBCTools;
 import org.collectionspace.services.common.storage.PreparedStatementSimpleBuilder;
 import org.collectionspace.services.lifecycle.TransitionDef;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-
 import org.collectionspace.services.common.document.BadRequestException;
 import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentFilter;
@@ -57,7 +56,6 @@ import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.document.DocumentWrapperImpl;
 import org.collectionspace.services.common.document.TransactionException;
 import org.collectionspace.services.config.tenant.RepositoryDomainType;
-
 import org.nuxeo.common.utils.IdUtils;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -76,6 +74,7 @@ import org.nuxeo.runtime.transaction.TransactionRuntimeException;
 //
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.config.ConfigUtils;
@@ -85,7 +84,6 @@ import org.collectionspace.services.common.storage.PreparedStatementBuilder;
 import org.collectionspace.services.config.tenant.TenantBindingType;
 import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService;
 import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoRepository;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -910,7 +908,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw de;
         } catch (Exception e) {
             if (logger.isDebugEnabled()) {
-                logger.debug("Caught exception ", e);
+                logger.debug("Caught exception ", e); // REM - 1/17/2014: Check for org.nuxeo.ecm.core.api.ClientException and re-attempt
             }
             throw new DocumentException(e);
         } finally {
@@ -1354,7 +1352,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw bre;
         } catch (DocumentException de) {
             throw de;
-        } catch (WebApplicationException wae) {
+        } catch (CSWebApplicationException wae) {
             throw wae;
         } catch (Exception e) {
             if (logger.isDebugEnabled()) {
index 74947ec458952c4b0ccf34b55865cedc0b516087..b0fe84eddbf6497a1f1c11e3caafb1d6be89022b 100644 (file)
@@ -26,6 +26,7 @@ package org.collectionspace.services.contact;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -40,7 +41,9 @@ 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.client.*;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.StoredValuesUriTemplate;
 import org.collectionspace.services.common.UriTemplateFactory;
 import org.collectionspace.services.common.UriTemplateRegistryKey;
@@ -222,7 +225,7 @@ public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler>
         }
         if (result == null) {
             Response response = Response.status(Response.Status.NOT_FOUND).entity("Get failed, the requested Contact CSID:" + csid + ": was not found.").type("text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(response);
         }
         return result.toXML();
     }
index 7d1eb95230450d1d925a70371358aaae200588c0..9c575b8f1ee1352f44add95a4366771a566d677b 100644 (file)
@@ -33,6 +33,8 @@ import javax.ws.rs.core.Response;
 //import javax.xml.bind.JAXBContext;\r
 //import javax.xml.bind.Marshaller;\r
 \r
+\r
+import org.collectionspace.services.common.CSWebApplicationException;\r
 import org.collectionspace.services.common.query.QueryManager;\r
 //import org.collectionspace.services.common.NuxeoClientType;\r
 /*import org.collectionspace.services.common.ServiceMain;\r
@@ -66,12 +68,12 @@ public class QueryResource {
         if(logger.isDebugEnabled()){\r
             verbose("getQuery with csid=" + csid);\r
         }\r
-        if(csid == null || "".equals(csid)){\r
+        if (csid == null || "".equals(csid)){\r
             logger.error("getQuery: missing csid!");\r
             Response response = Response.status(Response.Status.BAD_REQUEST).entity(\r
                     "get failed on getQuery csid=" + csid).type(\r
                     "text/plain").build();\r
-            throw new WebApplicationException(response);\r
+            throw new CSWebApplicationException(response);\r
         }\r
 \r
         try {\r
@@ -83,14 +85,14 @@ public class QueryResource {
             Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
                     "Get failed on query csid=" + csid).type(\r
                     "text/plain").build();\r
-            throw new WebApplicationException(response);\r
+            throw new CSWebApplicationException(e, response);\r
         }\r
 \r
-        if(false){\r
+        if (false) {  // REM - 1/29/2014 : Huh? Why is this essentially commented out?  Should probably clean up.\r
             Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
                     "Get failed, the requested CSID:" + csid + ": was not found.").type(\r
                     "text/plain").build();\r
-            throw new WebApplicationException(response);\r
+            throw new CSWebApplicationException(response);\r
         }\r
 \r
 //        return intakeObject;\r
index 3eccdc81c5c1a2877a3fa1521e4892b0b1790ae2..566d4e3b9f216e43cdca0d0ee4137f20117e0a08 100644 (file)
@@ -32,6 +32,7 @@ import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ReportClient;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.ServiceMessages;
@@ -228,7 +229,7 @@ public class ReportResource extends ResourceBase {
             Response response = Response.status(Response.Status.BAD_REQUEST).entity(
                     "invoke failed on Report csid=" + csid).type(
                     "text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(response);
         }
         
         if (logger.isTraceEnabled()) {
index f7a4eaf694abbe8d161668258cc05216a1a8cd0e..104f33d685669f435414fac2c908ab89c68d9214 100644 (file)
@@ -36,7 +36,6 @@ import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.core.MediaType;
-
 import javax.naming.NamingException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
@@ -64,6 +63,7 @@ import org.collectionspace.services.report.ReportsCommon;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ReportClient;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.collectionspace.services.common.api.FileTools;
@@ -358,7 +358,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
             Response response = Response.status(
                     Response.Status.INTERNAL_SERVER_ERROR).entity(
                                "Invoke failed (SQL problem) on Report csid=" + reportCSID).type("text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(sqle, response);
         } catch (JRException jre) {
             if (logger.isDebugEnabled()) {
                logger.debug("JR Exception: " + jre.getLocalizedMessage() + " Cause: "+jre.getCause());
@@ -366,7 +366,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
             Response response = Response.status(
                     Response.Status.INTERNAL_SERVER_ERROR).entity(
                                "Invoke failed (Jasper problem) on Report csid=" + reportCSID).type("text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(jre, response);
         } catch (FileNotFoundException fnfe) {
             if (logger.isDebugEnabled()) {
                logger.debug("FileNotFoundException: " + fnfe.getLocalizedMessage());
@@ -374,11 +374,11 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
             Response response = Response.status(
                     Response.Status.INTERNAL_SERVER_ERROR).entity(
                                "Invoke failed (SQL problem) on Report csid=" + reportCSID).type("text/plain").build();
-            throw new WebApplicationException(response);
+            throw new CSWebApplicationException(fnfe, response);
                } finally {
-               if(conn!=null) {
+               if (conn!=null) {
                        try {
-                       conn.close();
+                               conn.close();
                 } catch (SQLException sqle) {
                     // SQLExceptions can be chained. We have at least one exception, so
                     // set up a loop to make sure we let the user know about all of them
index 14cf99225bbd54e5bd295fe3944bf9ba3c394753..3b6d27ab5134d92ca930ff91b7441c8379b25aa2 100644 (file)
@@ -34,6 +34,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ServiceGroupClient;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.ServiceMessages;
@@ -183,7 +184,7 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
                // 404 if there are no mappings.
                 Response response = Response.status(Response.Status.NOT_FOUND).entity(
                         ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(groupname)).type("text/plain").build();
-                throw new WebApplicationException(response);
+                throw new CSWebApplicationException(response);
             }
                //Otherwise, build the response with a list
             ServicegroupsCommon common = new ServicegroupsCommon();
index 8e74d700311b9bc835dfd9b3da115d35b17ce608..874ad09952265ab60025df9ade27f0b18b98a72f 100644 (file)
@@ -41,6 +41,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.ServiceMessages;
 import org.collectionspace.services.common.StoredValuesUriTemplate;
@@ -113,7 +114,7 @@ public class ServiceGroupDocumentModelHandler
                     Response response = Response.status(Response.Status.NOT_FOUND).entity(
                             ServiceMessages.READ_FAILED + 
                             ServiceMessages.resourceNotFoundMsg(implode(serviceGroupNames, ","))).type("text/plain").build();
-                    throw new WebApplicationException(response);
+                    throw new CSWebApplicationException(response);
                }
                servicebindings = SecurityUtils.getReadableServiceBindingsForCurrentUser(servicebindings);
                // Build the list of docTypes for allowed serviceBindings
@@ -161,7 +162,8 @@ public class ServiceGroupDocumentModelHandler
                        logger.debug("Caught exception ", e);
                }
                throw new DocumentException(e);
-       }               
+       }
+       
         return list;
     }
     
index b0ec10880e9250db30adff9140727868020b27ca..19a8af56286daa55c102ab10ae4185191753f5a0 100644 (file)
@@ -24,6 +24,7 @@
 package org.collectionspace.services.workflow;
 
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.ServiceMessages;
@@ -101,7 +102,7 @@ public class WorkflowResource extends ResourceBase {
                Response response = Response.status(Response.Status.BAD_REQUEST)
                                .entity(ServiceMessages.GET_LIST_UNSUPPORTED).type("text/plain")
                                .build();
-               throw new WebApplicationException(response);
+               throw new CSWebApplicationException(response);
        }
     
 }