]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2587: Add a separate log file for service profiling information. Also adding...
authorRichard Millet <richard.millet@berkeley.edu>
Thu, 12 Aug 2010 05:19:21 +0000 (05:19 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Thu, 12 Aug 2010 05:19:21 +0000 (05:19 +0000)
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java
services/common/src/main/config/log/jboss-log4j.xml
services/common/src/main/java/org/collectionspace/services/common/profile/CSpaceFilter.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/profile/Profiler.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java

index 3ed461b9a5cfa3bc86e8da7ed457c94e617c6ce4..c1395cf268e570c470d72ab4c00b6554e06c1483 100644 (file)
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!--
-    Document   : web.xml
-    Created on : May 19, 2009, 1:31 PM
-    Author     :
-    Copyright 2009 University of California at Berkeley
-    Description:
-        service layer web application
--->
-<web-app>
-    <display-name>CollectionSpace Services</display-name>
-    <env-entry>
-        <description>Sets the logging context for the Tiger web-app</description>
-        <env-entry-name>cspace-logging-context</env-entry-name>
-        <env-entry-value>CSpaceLoggingContext</env-entry-value>
-        <env-entry-type>java.lang.String</env-entry-type>
-    </env-entry>
-
-    <context-param>
-        <param-name>javax.ws.rs.Application</param-name>
-        <param-value>org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication</param-value>
-    </context-param>
-
-    <context-param>
-        <param-name>resteasy.servlet.mapping.prefix</param-name>
-        <param-value>/</param-value>
-    </context-param>
-
-    <!--
-      - Location of the XML file that defines the root application context
-      - Applied by ContextLoaderListener.
-      -->
-    <context-param>
-        <param-name>contextConfigLocation</param-name>
-        <param-value>
-            /WEB-INF/applicationContext-security.xml
-        </param-value>
-    </context-param>
-
-    <filter>
-        <filter-name>springSecurityFilterChain</filter-name>
-        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
-    </filter>
-
-    <filter-mapping>
-        <filter-name>springSecurityFilterChain</filter-name>
-        <url-pattern>/*</url-pattern>
-    </filter-mapping>
-
-    <!-- Listeners -->
-
-    <!--
-      - Loads the root application context of this web app at startup.
-      - The application context is then available via
-      - WebApplicationContextUtils.getWebApplicationContext(servletContext).
-    -->
-    <listener>
-        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
-    </listener>
-
-    <!--
-      - Publishes events for session creation and destruction through the application
-      - context. Optional unless concurrent session control is being used.
-      -->
-    <listener>
-        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
-    </listener>
-
-    <!--listener>
-        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
-    </listener-->
-
-    <listener>
-        <listener-class>
-            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
-        </listener-class>
-    </listener>
-
-    <listener>
-        <listener-class>
-            org.collectionspace.services.common.CollectionSpaceServiceContextListener
-        </listener-class>
-    </listener>
-
-    <servlet>
-        <servlet-name>Resteasy</servlet-name>
-        <servlet-class>
-            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
-        </servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>Resteasy</servlet-name>
-        <url-pattern>/*</url-pattern>
-    </servlet-mapping>
-
-</web-app>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">\r
+<!--\r
+    Document   : web.xml\r
+    Created on : May 19, 2009, 1:31 PM\r
+    Author     :\r
+    Copyright 2009 University of California at Berkeley\r
+    Description:\r
+        service layer web application\r
+-->\r
+<web-app>\r
+    <display-name>CollectionSpace Services</display-name>\r
+    <env-entry>\r
+        <description>Sets the logging context for the Tiger web-app</description>\r
+        <env-entry-name>cspace-logging-context</env-entry-name>\r
+        <env-entry-value>CSpaceLoggingContext</env-entry-value>\r
+        <env-entry-type>java.lang.String</env-entry-type>\r
+    </env-entry>\r
+\r
+    <context-param>\r
+        <param-name>javax.ws.rs.Application</param-name>\r
+        <param-value>org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication</param-value>\r
+    </context-param>\r
+\r
+    <context-param>\r
+        <param-name>resteasy.servlet.mapping.prefix</param-name>\r
+        <param-value>/</param-value>\r
+    </context-param>\r
+\r
+    <!--\r
+      - Location of the XML file that defines the root application context\r
+      - Applied by ContextLoaderListener.\r
+      -->\r
+    <context-param>\r
+        <param-name>contextConfigLocation</param-name>\r
+        <param-value>\r
+            /WEB-INF/applicationContext-security.xml\r
+        </param-value>\r
+    </context-param>\r
+\r
+    <filter>\r
+        <filter-name>springSecurityFilterChain</filter-name>\r
+        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>\r
+    </filter>\r
+\r
+    <filter>\r
+               <filter-name>CSpaceFilter</filter-name>\r
+        <filter-class>org.collectionspace.services.common.profile.CSpaceFilter</filter-class>\r
+       </filter>\r
+       <filter-mapping>\r
+               <filter-name>CSpaceFilter</filter-name>\r
+               <url-pattern>/*</url-pattern>\r
+       </filter-mapping>\r
+    \r
+    <filter-mapping>\r
+        <filter-name>springSecurityFilterChain</filter-name>\r
+        <url-pattern>/*</url-pattern>\r
+    </filter-mapping>\r
+\r
+    <!-- Listeners -->\r
+\r
+    <!--\r
+      - Loads the root application context of this web app at startup.\r
+      - The application context is then available via\r
+      - WebApplicationContextUtils.getWebApplicationContext(servletContext).\r
+    -->\r
+    <listener>\r
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\r
+    </listener>\r
+\r
+    <!--\r
+      - Publishes events for session creation and destruction through the application\r
+      - context. Optional unless concurrent session control is being used.\r
+      -->\r
+    <listener>\r
+        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>\r
+    </listener>\r
+\r
+    <!--listener>\r
+        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>\r
+    </listener-->\r
+\r
+    <listener>\r
+        <listener-class>\r
+            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap\r
+        </listener-class>\r
+    </listener>\r
+\r
+    <listener>\r
+        <listener-class>\r
+            org.collectionspace.services.common.CollectionSpaceServiceContextListener\r
+        </listener-class>\r
+    </listener>\r
+\r
+    <servlet>\r
+            <servlet-name>Resteasy</servlet-name>\r
+            <servlet-class>\r
+                org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher\r
+            </servlet-class>\r
+    </servlet>\r
+    \r
+    <servlet-mapping>\r
+        <servlet-name>Resteasy</servlet-name>\r
+        <url-pattern>/*</url-pattern>\r
+    </servlet-mapping>\r
+\r
+</web-app>\r
index 3c3319578b736f8227da58ae169e73510cb49a20..bd3efb56570c3fad61071498ea1d8430a2cbea2c 100644 (file)
@@ -17,6 +17,7 @@
     xmlns="http://collectionspace.org/collectionobject/"\r
     targetNamespace="http://collectionspace.org/collectionobject/" version="0.1">\r
 \r
+    <xs:element name="remNumber" type="ns:otherNumber"/>\r
     <!-- Object identification information -->\r
     <xs:element name="objectNumber" type="xs:string"/>\r
     <xs:element name="otherNumberList" type="ns:otherNumberList"/>\r
index 30beb96ca7bdf521673bf338da68ca6fff25bd66..392eed3cd7ba11e7d31f0819616c6137a002721e 100644 (file)
@@ -1122,6 +1122,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
             String objectNumber, String objectName) {
         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
 
+        //REM
+        OtherNumber remNumber = new OtherNumber();
+        remNumber.setNumberType("remNumber");
+        remNumber.setNumberValue("2271966-" + System.currentTimeMillis());
+        collectionObject.setRemNumber(remNumber);
+        
         BriefDescriptionList descriptionList = new BriefDescriptionList();
         List<String> descriptions = descriptionList.getBriefDescription();
         descriptions.add("Papier mache bird cow mask with horns, "
index 306361991424fbc0d70185c00d5c9d4887f27aa5..9ebf9ba1da01b5faa61c6e182128ecfe03f08cb8 100644 (file)
@@ -32,6 +32,7 @@
             <xs:sequence>
                 <xs:element name="csid" type="xs:string"/>
                 
+                <xs:element name="remNumber" type="ns:otherNumber"/>
                 <!-- Object Identification Information -->
                 <xs:element name="objectNumber" type="xs:string"/>
                 <xs:element name="otherNumberList" type="otherNumberList"/>
index 5b9b31bf823950e0551c9661e44d1e5dc57fc89c..553449cab05f8eb5235de4774a39ee7db5ba72f6 100644 (file)
@@ -69,10 +69,14 @@ import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
 import org.collectionspace.services.relation.NewRelationResource;
 import org.collectionspace.services.relation.RelationsCommonList;
 import org.collectionspace.services.relation.RelationshipType;
+import org.collectionspace.services.common.profile.Profiler;
+
 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -254,6 +258,9 @@ public class CollectionObjectResource
      */
     private CollectionobjectsCommonList getCollectionObjectList(MultivaluedMap<String, String> queryParams) {
         CollectionobjectsCommonList collectionObjectList;
+        Profiler profiler = new Profiler(this, 1);
+        profiler.start();
+        
         try {
             ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
             DocumentHandler handler = createDocumentHandler(ctx);
@@ -271,6 +278,8 @@ public class CollectionObjectResource
                     Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
             throw new WebApplicationException(response);
         }
+        
+        profiler.stop();
         return collectionObjectList;
     }
 
@@ -475,21 +484,17 @@ public class CollectionObjectResource
      * 
      * This is an intentionally empty method used for getting a rough time estimate
      * of the overhead required for a client->server request/response cycle.
+     * @param ms - milliseconds to delay
      * 
      * @return the response
      */
     @GET
-    @Path("/roundtrip")
+    @Path("/{ms}/roundtrip")
     @Produces("application/xml")
-    public Response roundtrip() {
+    public Response roundtrip(
+               @PathParam("ms") String ms) {
        Response result = null;
        
-               if (logger.isDebugEnabled()) {
-                       logger.debug("------------------------------------------------------------------------------");
-                       logger.debug("Client to server roundtrip called.");
-                       logger.debug("------------------------------------------------------------------------------");
-                       logger.debug("");
-               }
                result = Response.status(HttpResponseCodes.SC_OK).build();
                
                return result;
index 46e979dfe6af67e1d0219a887143f2c0c4ee5acf..c765e2831aac82e456d4be0598dc6365b4ffccfb 100644 (file)
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
       <param name="File" value="${jboss.server.log.dir}/collectionspace-perf.log"/>
       <layout class="org.apache.log4j.PatternLayout">
-         <param name="ConversionPattern" value="%d %-5p [%t] [%c:%L] %m%n"/>
+         <param name="ConversionPattern" value="%d [%t] %m%n"/>
       </layout>
             <!--filter class="org.jboss.logging.filter.TCLFilter">
          <param name="AcceptOnMatch" value="true"/>
diff --git a/services/common/src/main/java/org/collectionspace/services/common/profile/CSpaceFilter.java b/services/common/src/main/java/org/collectionspace/services/common/profile/CSpaceFilter.java
new file mode 100644 (file)
index 0000000..fa7b600
--- /dev/null
@@ -0,0 +1,84 @@
+/**    \r
+ * CSpaceFilter.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright © 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
+package org.collectionspace.services.common.profile;\r
+\r
+import java.io.IOException;\r
+import javax.servlet.Filter;\r
+import javax.servlet.FilterChain;\r
+import javax.servlet.FilterConfig;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.ServletRequest;\r
+import javax.servlet.ServletResponse;\r
+import javax.servlet.http.HttpServletRequest;\r
+//import javax.servlet.ServletContext;\r
+\r
+/**\r
+ * The Class CSpaceFilter.\r
+ */\r
+public class CSpaceFilter implements Filter {\r
+       \r
+       /** The filter config. */\r
+       FilterConfig filterConfig = null;\r
+\r
+       /* (non-Javadoc)\r
+        * @see javax.servlet.Filter#destroy()\r
+        */\r
+       @Override\r
+       public void destroy() {\r
+               // Empty method.\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)\r
+        */\r
+       @Override\r
+       public void doFilter(ServletRequest request, ServletResponse response,\r
+                       FilterChain chain) throws IOException, ServletException {               \r
+               if (request != null) {\r
+                       HttpServletRequest httpRequest = (HttpServletRequest)request;\r
+                       String uri = httpRequest.getRequestURI();\r
+                       Profiler profiler = new Profiler(uri, 0);\r
+                       profiler.start();\r
+                       chain.doFilter(request, response);\r
+//                     profiler.log(httpRequest.getRequestURI());\r
+                       profiler.stop();\r
+               }\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)\r
+        */\r
+       @Override\r
+       public void init(FilterConfig theFilterConfig) throws ServletException {\r
+               filterConfig = theFilterConfig;\r
+               if (filterConfig != null) {\r
+                       // We can initialize using the init-params here which we defined in\r
+                       // web.xml)\r
+               }\r
+       }\r
+\r
+}\r
index a628bf82e8ff0f60a49974e73f62972f45d3d49d..1a85859cd7fadd892eda470105dfc6c2fa9b784c 100644 (file)
@@ -35,6 +35,8 @@ import org.slf4j.LoggerFactory;
  */\r
 public class Profiler {\r
        \r
+       private int messageIndent = 0;\r
+       \r
        /** The start time. */\r
        private long startTime = 0;\r
        \r
@@ -63,8 +65,14 @@ public class Profiler {
      *\r
      * @param theMessagePrefix the new message prefix\r
      */\r
-    protected void setMessagePrefix(String theMessagePrefix) {\r
-       messagePrefix = theMessagePrefix + ":";\r
+    protected void setMessagePrefix(String theMessagePrefix, int indent) {\r
+       StringBuffer stringBuffer = new StringBuffer();\r
+       for (int i = 0; i < indent; i++) {\r
+               stringBuffer.append('\t');\r
+       }\r
+       stringBuffer.append(theMessagePrefix);\r
+       stringBuffer.append(':');\r
+       messagePrefix = stringBuffer.toString();\r
     }\r
     \r
     protected StringBuffer getMessagePrefix() {\r
@@ -74,21 +82,23 @@ public class Profiler {
     /**\r
      * Instantiates a new profiler.\r
      * @param theObject \r
+     * @param indent \r
      *\r
      * @param theClass the the class\r
      */\r
-    public Profiler(Object theObject) {\r
+    public Profiler(Object theObject, int indent) {\r
        if (theObject != null) {\r
-               this.setMessagePrefix(theObject.getClass().getSimpleName());\r
+               this.setMessagePrefix(theObject.getClass().getSimpleName(), indent);\r
        }\r
     }\r
        /**\r
         * Instantiates a new profiler.\r
         *\r
         * @param theMessagePrefix the the message prefix\r
+        * @param indent \r
         */\r
-       public Profiler(String theMessagePrefix) {\r
-               this.setMessagePrefix(theMessagePrefix);\r
+       public Profiler(String theMessagePrefix, int indent) {\r
+               this.setMessagePrefix(theMessagePrefix, indent);\r
        }\r
        \r
        /*\r
@@ -149,7 +159,6 @@ public class Profiler {
                        message.append("<<<< Stopped <<<< [");\r
                        message.append(finalTime);\r
                        message.append("ms]");\r
-                       message.append('\n');\r
                        getLogger().debug(message.toString());\r
                }               \r
        }\r
index 5010db2ba8c7c391f6311c28bd4ef0090912d8a1..152e4af677ea2d6f2b016a7ed4a402c574fd5616 100644 (file)
@@ -160,6 +160,10 @@ public class SecurityInterceptor implements PreProcessInterceptor {
                for (String pathParamName : pathParams.keySet()) {
                        //assumption : path params for csid for any entity has substring csid in name
                        String pathParamValue = pathParams.get(pathParamName).get(0);
+                       if ((pathParamName.toLowerCase().indexOf("ms") > -1)) {
+                               //replace csids with wildcard
+                               uriPath = uriPath.replace(pathParamValue, "*");
+                       }
                        if ((pathParamName.toLowerCase().indexOf("csid") > -1)) {
                                //replace csids with wildcard
                                uriPath = uriPath.replace(pathParamValue, "*");
index a99dec8594707e16d26ce5da0e6405175c672cfd..e46e751c3a8958cc69462c6e6ba528870a486889 100644 (file)
@@ -32,6 +32,8 @@ import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.document.DocumentHandler.Action;
 import org.collectionspace.services.nuxeo.client.*;
+import org.collectionspace.services.common.profile.Profiler;
+
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.model.PropertyException;
@@ -98,7 +100,10 @@ public abstract class DocumentModelHandler<T, TL>
 
     @Override
     public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+       Profiler profiler = new Profiler(this, 2);
+       profiler.start();
         setCommonPartList(extractCommonPartList(wrapDoc));
+        profiler.stop();
     }
 
     @Override
index 8e98d20fc80b20e7b947dc6a36477c8a3f1ecee3..5509569b2580cc661c0e37a0a5b8f3bae5288379 100644 (file)
@@ -643,7 +643,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
 
             // If we have limit and/or offset, then pass true to get totalSize
             // in returned DocumentModelList.
-               Profiler profiler = new Profiler(this);
+               Profiler profiler = new Profiler(this, 2);
                profiler.log("Executing NXQL query: " + query.toString());
                profiler.start();
             if ((queryContext.docFilter.getOffset() > 0) || (queryContext.docFilter.getPageSize() > 0)) {