From 585007d258850c73ee9d0421251ced10030df70e Mon Sep 17 00:00:00 2001 From: remillet Date: Mon, 8 May 2017 10:55:25 -0700 Subject: [PATCH] CSPACE-7079: Changes for Botantical Garden profile. --- .../xmlreplay/collectionobject/co2.xml | 6 +- .../collectionobject-adv-search.xml | 2 +- .../jaxrs/CSpaceResteasyBootstrap.java | 2 + services/authentication/service/pom.xml | 12 ++ .../TomcatShutdownListener.java | 98 ++++++++++ ...ardenCollectionObjectValidatorHandler.java | 12 ++ .../botgarden-tenant-bindings.delta.xml | 37 +++- .../AuthorizationCommon.java | 7 + .../client/java/NuxeoConnectorEmbedded.java | 24 ++- .../load_botgarden_id_generators.sql | 171 ++++++++++++++++++ 10 files changed, 361 insertions(+), 10 deletions(-) create mode 100644 services/authentication/service/src/main/java/org/collectionspace/authentication/TomcatShutdownListener.java create mode 100644 services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/BotGardenCollectionObjectValidatorHandler.java create mode 100644 services/common/src/main/resources/db/postgresql/load_botgarden_id_generators.sql diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/co2.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/co2.xml index cad749b69..1099f4c29 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/co2.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/co2.xml @@ -6,9 +6,9 @@ 6.0221415 - + jlmbsoqjlmbsoq - + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-adv-search.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-adv-search.xml index 674dc371d..79e18b11d 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-adv-search.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-adv-search.xml @@ -48,7 +48,7 @@ GET - /cspace-services/collectionobjects?as=collectionobjects_naturalhistory%3AfieldLocVerbatim%3D'jlmbsoqjlmbsoq' + /cspace-services/collectionobjects?as=collectionobjects_testsci%3AfieldLocVerbatim%3D'jlmbsoqjlmbsoq' diff --git a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java index 3a9f2b540..0781ac4f4 100644 --- a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java @@ -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; } } diff --git a/services/authentication/service/pom.xml b/services/authentication/service/pom.xml index 96219ad3c..1d5bb0e8f 100644 --- a/services/authentication/service/pom.xml +++ b/services/authentication/service/pom.xml @@ -61,6 +61,18 @@ jboss-logging 3.1.4.GA + + org.apache.tomcat + tomcat-catalina + 7.0.64 + provided + + + org.apache.tomcat + tomcat-dbcp + 7.0.64 + provided + - - - + + + + + + + ptStartingWildcard + false + + + maxListItemsReturnedLimitOnJdbcQueries + 425 + + + + + org.collectionspace.services.collectionobject.nuxeo.BotGardenCollectionObjectValidatorHandler + + + + + + + sqlScriptName + load_botgarden_id_generators.sql + + + sqlScriptName + grant_botgarden_reporters_privileges.sql + + + + + diff --git a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java index 014c460e6..5b2464628 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java +++ b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java @@ -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)) { diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java index 3f7dbcff2..3e1e6cc29 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java @@ -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 index 000000000..a92b65b3a --- /dev/null +++ b/services/common/src/main/resources/db/postgresql/load_botgarden_id_generators.sql @@ -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 + * + * 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', + '', +' + + + UC + UC + + + 9 + 1 + -1 + + +' +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', + '', +' + + + JEPS + JEPS + + + 9 + 1 + -1 + + +' +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', + '', +' + + + V + V + + + + + + . + . + + + 6 + 1 + -1 + + +' +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', + '', +' + + + 9 + 1 + -1 + + +' +WHERE '81cf5a56-d43d-49e9-ac11-61cf4b0923d4' NOT IN + ( + SELECT csid + FROM id_generators + ); \ No newline at end of file -- 2.47.3