]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-7079: Changes for Botantical Garden profile.
authorremillet <remillet@yahoo.com>
Mon, 8 May 2017 17:55:25 +0000 (10:55 -0700)
committerremillet <remillet@yahoo.com>
Mon, 8 May 2017 17:55:25 +0000 (10:55 -0700)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/co2.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-adv-search.xml
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java
services/authentication/service/pom.xml
services/authentication/service/src/main/java/org/collectionspace/authentication/TomcatShutdownListener.java [new file with mode: 0644]
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/BotGardenCollectionObjectValidatorHandler.java [new file with mode: 0644]
services/common/src/main/cspace/config/services/tenants/botgarden/botgarden-tenant-bindings.delta.xml
services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java
services/common/src/main/resources/db/postgresql/load_botgarden_id_generators.sql [new file with mode: 0644]

index cad749b69c0cd1a4d70dcda66f2a50d2cef9102a..1099f4c297ff484ce2ea73ca492726aea9a20ed6 100644 (file)
@@ -6,9 +6,9 @@
     <objectNumber>6.0221415</objectNumber>
   </ns2:collectionobjects_common>
 
-  <ns3:collectionobjects_naturalhistory
-    xmlns:ns3="http://collectionspace.org/services/collectionobject/domain/naturalhistory">
+    <ns3:collectionobjects_testsci
+      xmlns:ns3="http://collectionspace.org/services/collectionobject/domain/testsci">
     <fieldLocVerbatim>jlmbsoqjlmbsoq</fieldLocVerbatim>
-  </ns3:collectionobjects_naturalhistory>
+  </ns3:collectionobjects_testsci>
 
 </document>
index 674dc371d078d67eaef32bbd0b533b5012a85a39..79e18b11d46fe87ccf1c71ee83bcb986f59ea59a 100644 (file)
@@ -48,7 +48,7 @@
         <!-- expected text within a single field in the extension schema part. -->
         <test ID="co2advsearch">
             <method>GET</method>
-            <uri>/cspace-services/collectionobjects?as=collectionobjects_naturalhistory%3AfieldLocVerbatim%3D'jlmbsoqjlmbsoq'</uri>
+            <uri>/cspace-services/collectionobjects?as=collectionobjects_testsci%3AfieldLocVerbatim%3D'jlmbsoqjlmbsoq'</uri>
             <response>
                 <expected level="TEXT" />
                 <label>abstract-common-list</label>
index 3a9f2b540836e1d419dee9b2080b47451dad2487..0781ac4f458ba95f8e30a86f1b56fb4a8a9aeb08 100644 (file)
@@ -9,6 +9,7 @@ import java.util.Date;
 
 public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
        
+       @Override
        public void  contextInitialized(ServletContextEvent event) {
                try {
                        //
@@ -23,6 +24,7 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
                System.out.println(String.format("%tc [INFO] CollectionSpace Services' JAX-RS application started.", new Date()));
                } catch (Throwable e) {
                        e.printStackTrace();
+                       throw e;
                }
        }
        
index 96219ad3c73af2b105b456a86aec87868ef609a1..1d5bb0e8fecc409f864bb67c64c2cacaa8dbbffe 100644 (file)
             <artifactId>jboss-logging</artifactId>
             <version>3.1.4.GA</version>
         </dependency>
+        <dependency>
+                       <groupId>org.apache.tomcat</groupId>
+                       <artifactId>tomcat-catalina</artifactId>
+                       <version>7.0.64</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.tomcat</groupId>
+                       <artifactId>tomcat-dbcp</artifactId>
+                       <version>7.0.64</version>
+                       <scope>provided</scope>
+               </dependency>
         <dependency>
         <!--
             <groupId>jboss</groupId>
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/TomcatShutdownListener.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/TomcatShutdownListener.java
new file mode 100644 (file)
index 0000000..eba6ea5
--- /dev/null
@@ -0,0 +1,98 @@
+package org.collectionspace.authentication;
+
+import static org.apache.catalina.Lifecycle.AFTER_INIT_EVENT;
+import static org.apache.catalina.Lifecycle.AFTER_START_EVENT;
+import static org.apache.catalina.LifecycleState.INITIALIZED;
+import static org.apache.catalina.LifecycleState.NEW;
+import static org.apache.catalina.LifecycleState.STARTED;
+
+import java.util.logging.Level;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Executor;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleState;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
+import org.apache.catalina.connector.Connector;
+
+/**
+ * Checks to see if any of the webapps in the Tomcat container failed during startup.  If so,
+ * we ask Tomcat to shutdown.
+ * 
+ * @author remillet
+ *
+ */
+public class TomcatShutdownListener implements LifecycleListener {
+       
+       java.util.logging.Logger logger = java.util.logging.Logger.getAnonymousLogger();
+
+       @Override
+       public void lifecycleEvent(final LifecycleEvent event) {
+               boolean isInit = AFTER_INIT_EVENT.equals(event.getType());
+               if (isInit || AFTER_START_EVENT.equals(event.getType())) {
+                       Server server = (Server) event.getLifecycle();
+                       boolean failed = checkServer(isInit, server);
+                       if (failed) {
+                               triggerShutdown(isInit, server);
+                       } else if (!isInit) {
+                               logger.log(Level.INFO, "CollectionSpace Startup successful.");
+                       }
+               }
+       }
+
+       private boolean checkServer(final boolean isInit, final Server server) {
+               boolean failed = checkState(isInit, server);
+               for (Service service : server.findServices()) {
+                       failed |= checkService(isInit, service);
+               }
+               return failed;
+       }
+
+       private boolean checkService(final boolean isInit, final Service service) {
+               boolean failed = checkState(isInit, service);
+               failed |= checkContainer(isInit, service.getContainer());
+               for (Connector connector : service.findConnectors()) {
+                       failed |= checkState(isInit, connector);
+               }
+               for (Executor executor : service.findExecutors()) {
+                       failed |= checkState(isInit, executor);
+               }
+               return failed;
+       }
+
+       private boolean checkContainer(final boolean isInit, final Container container) {
+               boolean failed = checkState(isInit, container);
+               for (Container child : container.findChildren()) {
+                       failed |= checkContainer(isInit, child);
+               }
+               return failed;
+       }
+
+       private boolean checkState(final boolean isInit, final Lifecycle lifecycle) {
+               LifecycleState state = lifecycle.getState();
+               if (isInit ? state != NEW && state != INITIALIZED : state != STARTED) {
+                       logger.log(Level.SEVERE, "CollectionSpace Startup Failure\n###\n### - CollectionSpace Startup failure, initiating Tomcat shutdown...\n###");
+                       logger.log(Level.SEVERE, String.format("Required CollectionSpace Component {%s} failed to {%s}: state {%s}.", lifecycle.toString(),
+                                       isInit ? "initialize" : "start", state.toString()));
+                       logger.log(Level.SEVERE, "See other Tomcat log files for possible failure reasons and details.\n");
+                       return true;
+               }
+               return false;
+       }
+
+       private void triggerShutdown(final boolean isInit, final Server server) {
+               if (isInit) {
+                       throw new RuntimeException("One or more required Tomcat components failed to initialize.");
+               }
+               try {
+                       server.stop();
+                       server.destroy();
+               } catch (LifecycleException e) {
+                       e.printStackTrace();
+               }
+       }
+}
diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/BotGardenCollectionObjectValidatorHandler.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/BotGardenCollectionObjectValidatorHandler.java
new file mode 100644 (file)
index 0000000..9ed2b87
--- /dev/null
@@ -0,0 +1,12 @@
+package org.collectionspace.services.collectionobject.nuxeo;
+
+import org.collectionspace.services.common.document.InvalidDocumentException;
+
+public class BotGardenCollectionObjectValidatorHandler extends CollectionObjectValidatorHandler {
+
+       @Override
+       protected void handleUpdate() throws InvalidDocumentException {
+               // Disable non-empty objectNumber requirement, so that updates don't need to retrieve the current objectNumber.
+
+       }
+}
\ No newline at end of file
index 65f3b3d50932189c79d857080c2b664e4ce53da7..f08ee43fe86497ae51aa3896d0094ba9d22a5d57 100644 (file)
@@ -8,11 +8,42 @@
     <!-- value in cspace/config/services/tenants/testsci-tenant-bindings-proto.xml -->
 
     <tenant:tenantBinding id="3500">
-               <tenant:eventListenerConfigurations id="default" merge:matcher="id">
-                   <tenant:eventListenerConfig id="UpdateObjectLocationOnMove" merge:matcher="id">
-                       <tenant:paramList id="default" merge:matcher="id" merge:action="delete"/>
+        <tenant:eventListenerConfigurations id="default" merge:matcher="id">
+            <tenant:eventListenerConfig id="UpdateObjectLocationOnMove" merge:matcher="id">
+                <tenant:paramList id="default" merge:matcher="id" merge:action="delete"/>
             </tenant:eventListenerConfig>
             <tenant:eventListenerConfig id="UpdateObjectLocationAndCrateOnMove" merge:matcher="id" merge:action="delete"/>
         </tenant:eventListenerConfigurations>
+
+        <tenant:properties id="default">
+            <types:item xmlns:types="http://collectionspace.org/services/config/types" id="ptstartingwildcard" merge:matcher="id" merge:action="replace">
+                <types:key>ptStartingWildcard</types:key>
+                <types:value>false</types:value>
+            </types:item>
+            <types:item xmlns:types="http://collectionspace.org/services/config/types" id="maxlistitemsjdbc" merge:matcher="id" merge:action="replace">
+                <types:key>maxListItemsReturnedLimitOnJdbcQueries</types:key>
+                <types:value>425</types:value>
+            </types:item>
+        </tenant:properties>
+        
+        <tenant:serviceBindings merge:matcher="id" id="CollectionObjects">
+            <service:validatorHandler xmlns:service="http://collectionspace.org/services/config/service" merge:matcher="tag" merge:action="replace">org.collectionspace.services.collectionobject.nuxeo.BotGardenCollectionObjectValidatorHandler</service:validatorHandler>
+        </tenant:serviceBindings>
+        <tenant:serviceBindings merge:matcher="id" id="idgenerators">
+            <service:initHandler xmlns:service="http://collectionspace.org/services/config/service">
+                <service:params>
+                    <service:property merge:matcher="skip" merge:action="insert">
+                        <service:key>sqlScriptName</service:key>
+                        <service:value>load_botgarden_id_generators.sql</service:value>
+                    </service:property>
+                    <service:property merge:matcher="skip" merge:action="insert">
+                        <service:key>sqlScriptName</service:key>
+                        <service:value>grant_botgarden_reporters_privileges.sql</service:value>
+                    </service:property>
+                </service:params>
+            </service:initHandler>
+        </tenant:serviceBindings>
+        
     </tenant:tenantBinding>
 </tenant:TenantBindingConfig>
index 014c460e69f2cbdbe259dd0d4facccc60ebc1e69..5b246462804f0b48b5e668777dd1b3b5b628be6b 100644 (file)
@@ -1074,6 +1074,13 @@ public class AuthorizationCommon {
                        TenantBindingType tenantBinding = tenantBindings.get(tenantId);
                        Role adminRole = AuthorizationCommon.getRole(em, tenantBinding.getId(), ROLE_TENANT_ADMINISTRATOR);
                        Role readonlyRole = AuthorizationCommon.getRole(em, tenantBinding.getId(), ROLE_TENANT_READER);
+                       
+                       if (adminRole == null || readonlyRole == null) {
+                               String msg = String.format("One or more of the required default CollectionSpace administrator roles is missing or was never created.  If you're setting up a new instance of CollectionSpace, shutdown the Tomcat server and run the 'ant import' command from the root/top level CollectionSpace 'Services' source directory.  Then try restarting Tomcat.");
+                               logger.error(msg);
+                               throw new RuntimeException("One or more of the required default CollectionSpace administrator roles is missing or was never created.");
+                       }
+                       
                        for (ServiceBindingType serviceBinding : tenantBinding.getServiceBindings()) {
                                String prop = ServiceBindingUtils.getPropertyValue(serviceBinding, REFRESH_AUTZ_PROP);
                                if (prop == null ? true : Boolean.parseBoolean(prop)) {
index 3f7dbcff22e0fbbc2597bcda075833720ef8a5e1..3e1e6cc29793f1329d468afcb762e310fbe1d05e 100644 (file)
@@ -11,11 +11,15 @@ import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.collectionspace.services.config.RepositoryClientConfigType;
 import org.collectionspace.services.config.tenant.RepositoryDomainType;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-
+import org.nuxeo.ecm.core.api.CoreInstance;
+import org.nuxeo.ecm.core.api.CoreSession;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.nuxeo.ecm.core.api.SystemPrincipal;
+import org.nuxeo.ecm.core.api.repository.Repository;
+import org.nuxeo.ecm.core.api.repository.RepositoryManager;
 import org.nuxeo.osgi.application.FrameworkBootstrap;
-
+import org.nuxeo.runtime.api.Framework;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -109,10 +113,24 @@ public class NuxeoConnectorEmbedded {
                fb = new FrameworkBootstrap(NuxeoConnectorEmbedded.class.getClassLoader(),
                                nuxeoHomeDir);
                fb.setHostName("Tomcat");
-               fb.setHostVersion("7.0.57"); //FIXME: Should not be hard coded.
+               fb.setHostVersion("7.0.64"); //FIXME: Should not be hard coded.
                
                fb.initialize();
                fb.start();
+               
+               // Test to see if we can connect to the default repository
+               CoreSession coreSession = null;
+               try {
+                       Repository defaultRepo = Framework.getService(RepositoryManager.class).getDefaultRepository();
+                       coreSession = CoreInstance.openCoreSession(defaultRepo.getName(), new SystemPrincipal(null));
+               } catch (Throwable t) {
+                       logger.error(t.getMessage());
+                       throw new RuntimeException("Could not start the Nuxeo EP Framework", t);
+               } finally {
+                       if (coreSession != null) {
+                               CoreInstance.closeCoreSession(coreSession);
+                       }
+               }
        }
 
        /**
diff --git a/services/common/src/main/resources/db/postgresql/load_botgarden_id_generators.sql b/services/common/src/main/resources/db/postgresql/load_botgarden_id_generators.sql
new file mode 100644 (file)
index 0000000..a92b65b
--- /dev/null
@@ -0,0 +1,171 @@
+/*     
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright © 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
+
+/*
+ * load_botgarden_id_generators.sql
+ *
+ * Loads botgarden-specific data into the "id_generators" table,
+ * used by the ID Service.
+ *
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ */
+
+/*
+ * Note: in the priority column, values range from  '1' (highest)
+ * to '9' (lowest).
+ */
+
+/*
+ * NOTE: In the id_generator_state column, for numeric sequence parts
+ * whose first generated value should start at the initial value
+ * (such as '1'), enter '-1' for the <currentValue>
+ *
+ * Otherwise, the first generated value will be the next value
+ * in the sequence after the initial value (e.g. '2', if the
+ * initial value is '1').
+ */
+
+
+-- UC_ACCESSION_NUMBER
+
+INSERT INTO id_generators
+    (csid, displayname, description, priority, last_generated_id, id_generator_state)
+  SELECT 
+     'ed3c8578-cf01-4a05-b7fc-8e49b96273c6',
+     'UC Accession Number',
+     'Identifies individual collection objects formally
+acquired by the UC Herbarium. Used for collection objects
+without parts.',
+     '9',
+     '',
+'<org.collectionspace.services.id.SettableIDGenerator>
+  <parts>
+    <org.collectionspace.services.id.StringIDGeneratorPart>
+      <initialValue>UC</initialValue>
+      <currentValue>UC</currentValue>
+    </org.collectionspace.services.id.StringIDGeneratorPart>
+    <org.collectionspace.services.id.NumericIDGeneratorPart>
+      <maxLength>9</maxLength>
+      <initialValue>1</initialValue>
+      <currentValue>-1</currentValue>
+    </org.collectionspace.services.id.NumericIDGeneratorPart>
+  </parts>
+</org.collectionspace.services.id.SettableIDGenerator>'
+WHERE 'ed3c8578-cf01-4a05-b7fc-8e49b96273c6' NOT IN
+      (
+      SELECT  csid
+      FROM    id_generators
+      );
+
+
+
+-- JEPS_ACCESSION_NUMBER
+
+INSERT INTO id_generators
+    (csid, displayname, description, priority, last_generated_id, id_generator_state)
+  SELECT 
+     'd9eca382-23b7-47aa-8d9b-d7ff88f49e2b',
+     'JEPS Accession Number',
+     'Identifies individual collection objects formally
+acquired by the Jepson Herbarium. Used for collection objects
+without parts.',
+     '9',
+     '',
+'<org.collectionspace.services.id.SettableIDGenerator>
+  <parts>
+    <org.collectionspace.services.id.StringIDGeneratorPart>
+      <initialValue>JEPS</initialValue>
+      <currentValue>JEPS</currentValue>
+    </org.collectionspace.services.id.StringIDGeneratorPart>
+    <org.collectionspace.services.id.NumericIDGeneratorPart>
+      <maxLength>9</maxLength>
+      <initialValue>1</initialValue>
+      <currentValue>-1</currentValue>
+    </org.collectionspace.services.id.NumericIDGeneratorPart>
+  </parts>
+</org.collectionspace.services.id.SettableIDGenerator>'
+WHERE 'd9eca382-23b7-47aa-8d9b-d7ff88f49e2b' NOT IN
+      (
+      SELECT  csid
+      FROM    id_generators
+      );
+
+
+
+-- VOUCHER_NUMBER
+
+INSERT INTO id_generators
+    (csid, displayname, description, priority, last_generated_id, id_generator_state)
+  SELECT 
+     '940710aa-3df4-4bd4-8d6f-9bf6a92b35cc',
+     'Voucher Collection Number',
+     'Identifies Botanical Garden vouchers.',
+     '9',
+     '',
+'<org.collectionspace.services.id.SettableIDGenerator>
+  <parts>
+    <org.collectionspace.services.id.StringIDGeneratorPart>
+      <initialValue>V</initialValue>
+      <currentValue>V</currentValue>
+    </org.collectionspace.services.id.StringIDGeneratorPart>
+    <org.collectionspace.services.id.YearIDGeneratorPart>
+      <currentValue></currentValue>
+    </org.collectionspace.services.id.YearIDGeneratorPart>
+    <org.collectionspace.services.id.StringIDGeneratorPart>
+      <initialValue>.</initialValue>
+      <currentValue>.</currentValue>
+    </org.collectionspace.services.id.StringIDGeneratorPart>
+    <org.collectionspace.services.id.NumericIDGeneratorPart>
+      <maxLength>6</maxLength>
+      <initialValue>1</initialValue>
+      <currentValue>-1</currentValue>
+    </org.collectionspace.services.id.NumericIDGeneratorPart>
+  </parts>
+</org.collectionspace.services.id.SettableIDGenerator>'
+WHERE '940710aa-3df4-4bd4-8d6f-9bf6a92b35cc' NOT IN
+      (
+      SELECT  csid
+      FROM    id_generators
+      );
+
+
+-- PROP_NUMBER
+
+INSERT INTO id_generators
+    (csid, displayname, description, priority, last_generated_id, id_generator_state)
+  SELECT 
+     '81cf5a56-d43d-49e9-ac11-61cf4b0923d4',
+     'Propagation Number',
+     'Identifies activities in which accessions are
+propagated.',
+     '9',
+     '',
+'<org.collectionspace.services.id.SettableIDGenerator>
+  <parts>
+    <org.collectionspace.services.id.NumericIDGeneratorPart>
+      <maxLength>9</maxLength>
+      <initialValue>1</initialValue>
+      <currentValue>-1</currentValue>
+    </org.collectionspace.services.id.NumericIDGeneratorPart>
+  </parts>
+</org.collectionspace.services.id.SettableIDGenerator>'
+WHERE '81cf5a56-d43d-49e9-ac11-61cf4b0923d4' NOT IN
+      (
+      SELECT  csid
+      FROM    id_generators
+      );
\ No newline at end of file