-<?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
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
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, "
<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"/>
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;
*/
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);
Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
throw new WebApplicationException(response);
}
+
+ profiler.stop();
return collectionObjectList;
}
*
* 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;
<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"/>
--- /dev/null
+/** \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
*/\r
public class Profiler {\r
\r
+ private int messageIndent = 0;\r
+ \r
/** The start time. */\r
private long startTime = 0;\r
\r
*\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
/**\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
message.append("<<<< Stopped <<<< [");\r
message.append(finalTime);\r
message.append("ms]");\r
- message.append('\n');\r
getLogger().debug(message.toString());\r
} \r
}\r
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, "*");
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;
@Override
public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ Profiler profiler = new Profiler(this, 2);
+ profiler.start();
setCommonPartList(extractCommonPartList(wrapDoc));
+ profiler.stop();
}
@Override
// 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)) {