From: Richard Millet Date: Mon, 9 Apr 2012 06:51:44 +0000 (-0700) Subject: Changed Permission CSIDs from opaque UUID to something more refname-like. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=180c0cb06df3db1929e06caf660b16b9c4a4cf1e;p=tmp%2Fjakarta-migration.git Changed Permission CSIDs from opaque UUID to something more refname-like. --- diff --git a/pom.xml b/pom.xml index 40f641d74..a0bb1827c 100644 --- a/pom.xml +++ b/pom.xml @@ -384,7 +384,9 @@ javax.transaction jta 1.1 + diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java index ccde889b3..944a8aea6 100644 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java @@ -4,9 +4,7 @@ import org.apache.commons.cli.*; import org.apache.commons.io.FileUtils; import org.apache.commons.jexl2.JexlEngine; -import org.collectionspace.services.common.api.FileTools; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.service.ServiceBindingType; import org.dom4j.*; import org.dom4j.io.SAXReader; diff --git a/services/JaxRsServiceProvider/src/main/resources/log4j.properties b/services/JaxRsServiceProvider/src/main/resources/log4j.properties index 14cfac1f8..393c951da 100644 --- a/services/JaxRsServiceProvider/src/main/resources/log4j.properties +++ b/services/JaxRsServiceProvider/src/main/resources/log4j.properties @@ -45,7 +45,7 @@ log4j.appender.cspace_perf_appender.layout.ConversionPattern=%d %-5p [%t] [%c:%L # # This logger uses the "cspace_perf_appender" appender to log performance profiling information. # -log4j.logger.perf.collectionspace=ERROR, cspace_perf_appender, stdout +log4j.logger.perf.collectionspace=TRACE, cspace_perf_appender, stdout # send the logs only to our appender -no inheritence. log4j.additivity.perf.collectionspace=false diff --git a/services/authority/service/pom.xml b/services/authority/service/pom.xml index 0fb36cf38..83a83342b 100644 --- a/services/authority/service/pom.xml +++ b/services/authority/service/pom.xml @@ -9,13 +9,17 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.authority.service services.authority.service jar + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + org.collectionspace.services org.collectionspace.services.common-api diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index b5119587d..7035137bd 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -28,7 +28,6 @@ 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.ClientType; import org.collectionspace.services.common.ResourceBase; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMain; @@ -55,6 +54,7 @@ import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; import org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler; +import org.collectionspace.services.config.ClientType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; @@ -114,7 +114,7 @@ public abstract class AuthorityResource protected Class resourceClass; protected String authorityCommonSchemaName; protected String authorityItemCommonSchemaName; - final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); + final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); //FIXME: REM - 3 Why is this field needed? I see no references to it. final static String URN_PREFIX = "urn:cspace:"; final static int URN_PREFIX_LEN = URN_PREFIX.length(); final static String URN_PREFIX_NAME = "name("; diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index 7ddb66a17..e2b22a664 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -32,8 +32,8 @@ import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.context.MultipartServiceContext; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.service.ObjectPartType; import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; +import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index 0daa61835..c52ac6975 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -45,13 +45,13 @@ import org.collectionspace.services.common.document.DocumentWrapperImpl; import org.collectionspace.services.common.relation.IRelationsManager; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.repository.RepositoryClientFactory; -import org.collectionspace.services.common.service.ObjectPartType; import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; +import org.collectionspace.services.config.service.ListResultField; +import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; -import org.collectionspace.services.common.service.ListResultField; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.relation.RelationResource; import org.collectionspace.services.relation.RelationsCommon; diff --git a/services/authorization-common/build.xml b/services/authorization-common/build.xml new file mode 100644 index 000000000..3baaa1ede --- /dev/null +++ b/services/authorization-common/build.xml @@ -0,0 +1,132 @@ + + + + Collectionspace's common authorization classes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/authorization-common/pom.xml b/services/authorization-common/pom.xml new file mode 100644 index 000000000..c75ae42f7 --- /dev/null +++ b/services/authorization-common/pom.xml @@ -0,0 +1,64 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services.authorization-common + services.authorization-common + jar + + + + + org.collectionspace.services + org.collectionspace.services.authorization.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authorization.service + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.hyperjaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authorization-mgt.client + ${project.version} + + + + org.slf4j + slf4j-api + provided + + + org.slf4j + slf4j-log4j12 + provided + + + org.testng + testng + provided + + + + diff --git a/services/authorization-mgt/client/pom.xml b/services/authorization-mgt/client/pom.xml index fb964121e..8778a1d37 100644 --- a/services/authorization-mgt/client/pom.xml +++ b/services/authorization-mgt/client/pom.xml @@ -9,7 +9,6 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.authorization-mgt.client services.authorization-mgt.client diff --git a/services/authorization-mgt/import/pom.xml b/services/authorization-mgt/import/pom.xml index 46e537da3..030117a90 100644 --- a/services/authorization-mgt/import/pom.xml +++ b/services/authorization-mgt/import/pom.xml @@ -9,7 +9,6 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.authorization-mgt.import services.authorization-mgt.import @@ -17,6 +16,7 @@ 3.0.0.RELEASE 3.0.2.RELEASE + @@ -29,6 +29,13 @@ slf4j-log4j12 1.6.1 + + + org.collectionspace.services + org.collectionspace.services.authentication.service + ${project.version} + provided + org.collectionspace.services org.collectionspace.services.authorization.service @@ -57,6 +64,7 @@ org.collectionspace.services.authorization-mgt.client ${project.version} + org.testng testng diff --git a/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/driver/AuthorizationSeedDriver.java b/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/driver/AuthorizationSeedDriver.java index 37c9112f9..f69f8dc9f 100644 --- a/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/driver/AuthorizationSeedDriver.java +++ b/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/driver/AuthorizationSeedDriver.java @@ -28,6 +28,9 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + import org.collectionspace.services.authorization.AuthZ; import org.collectionspace.services.authorization.perms.Permission; import org.collectionspace.services.authorization.PermissionRole; @@ -37,7 +40,8 @@ import org.collectionspace.services.authorization.SubjectType; import org.collectionspace.services.authorization.importer.AuthorizationGen; import org.collectionspace.services.authorization.importer.AuthorizationSeed; import org.collectionspace.services.common.authorization_mgt.AuthorizationStore; -import org.collectionspace.services.authorization.storage.PermissionRoleUtil; +import org.collectionspace.services.common.authorization_mgt.PermissionRoleUtil; +import org.collectionspace.services.common.storage.jpa.JpaStorageUtils; import org.hibernate.exception.ConstraintViolationException; @@ -190,37 +194,59 @@ public class AuthorizationSeedDriver { } private void store() throws Exception { - AuthorizationStore authzStore = new AuthorizationStore(); - for (Role role : authzGen.getDefaultRoles()) { - try { - authzStore.store(role); - } catch (Exception e) { - // - // If the role already exists, read it in and replace the instance - // we're trying to import with the exist one. This will ensure that the rest - // of import uses the correct CSID. - if (e.getCause() instanceof ConstraintViolationException) { - Role existingRole = authzStore.getRoleByName(role.getRoleName(), role.getTenantId()); - // - role = existingRole; - } - } - } - - for (Permission perm : authzGen.getDefaultPermissions()) { //FIXME: REM - 3/27/2012 - If we change the CSID of permissions to something like a refname, then we need to check for existing perms just like we did above for roles - authzStore.store(perm); - } - - List permRoleRels = new ArrayList(); - for (PermissionRole pr : authzGen.getDefaultPermissionRoles()) { - PermissionRoleUtil.buildPermissionRoleRel(pr, SubjectType.ROLE, permRoleRels, false /*not for delete*/); - } - for (PermissionRoleRel permRoleRel : permRoleRels) { - authzStore.store(permRoleRel); - } + EntityManagerFactory emf = JpaStorageUtils.getEntityManagerFactory(JpaStorageUtils.CS_AUTHZ_PERSISTENCE_UNIT); + EntityManager em = null; - if (logger.isInfoEnabled()) { - logger.info("Authroization metata persisted."); + try { + em = emf.createEntityManager(); + em.getTransaction().begin(); + + AuthorizationStore authzStore = new AuthorizationStore(); + for (Role role : authzGen.getDefaultRoles()) { + try { + authzStore.store(em, role); + } catch (Exception e) { + // + // If the role already exists, read it in and replace the instance + // we're trying to import with the exist one. This will ensure that the rest + // of import uses the correct CSID. + if (e.getCause() instanceof ConstraintViolationException) { + Role existingRole = authzStore.getRoleByName(role.getRoleName(), role.getTenantId()); + // + role = existingRole; + } + } + } + + for (Permission perm : authzGen.getDefaultPermissions()) { //FIXME: REM - 3/27/2012 - If we change the CSID of permissions to something like a refname, then we need to check for existing perms just like we did above for roles + authzStore.store(em, perm); + } + + List permRoleRels = new ArrayList(); + for (PermissionRole pr : authzGen.getDefaultPermissionRoles()) { + PermissionRoleUtil.buildPermissionRoleRel(em, pr, SubjectType.ROLE, permRoleRels, false /*not for delete*/); + } + for (PermissionRoleRel permRoleRel : permRoleRels) { + authzStore.store(em, permRoleRel); + } + + em.getTransaction().commit(); + em.close(); + if (logger.isInfoEnabled()) { + logger.info("Authroization metata persisted."); + } + } catch (Exception e) { + if (em != null && em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + if (logger.isDebugEnabled()) { + logger.debug("Caught exception and rolling back permission creation: ", e); + } + throw e; + } finally { + if (em != null) { + JpaStorageUtils.releaseEntityManagerFactory(emf); + } } } diff --git a/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java b/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java index 3f5426a45..d21bebf39 100644 --- a/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java +++ b/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java @@ -49,9 +49,9 @@ import org.collectionspace.services.authorization.RolesList; import org.collectionspace.services.authorization.SubjectType; import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.tenant.TenantBindingType; import org.collectionspace.services.common.security.SecurityUtils; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.TenantBindingType; /** * AuthorizationGen generates authorizations (permissions and roles) @@ -184,7 +184,7 @@ public class AuthorizationGen { private Permission buildReaderPermission(String tenantId, String resourceName) { String description = "Generated read-only permission."; - return AuthorizationCommon.createPermission(tenantId, resourceName, description, AuthorizationCommon.ACTIONGROUP_CRUDL_NAME); + return AuthorizationCommon.createPermission(tenantId, resourceName, description, AuthorizationCommon.ACTIONGROUP_RL_NAME); } public List getDefaultPermissions() { @@ -251,8 +251,10 @@ public class AuthorizationGen { allRoleList = new ArrayList(); allRoleList.addAll(adminRoles); allRoleList.addAll(readerRoles); + // Finally, add the "super" role to the list + allRoleList.add(cspaceAdminRole); } - return allRoleList; //FIXME: REM - 3/27/2012, The super role "cspaceAdminRole" is not on this list. Intentional? + return allRoleList; } public void associateDefaultPermissionsRoles() { @@ -356,10 +358,14 @@ public class AuthorizationGen { private Role buildCSpaceAdminRole() { Role role = new Role(); + + role.setDescription("A generated super role that has permissions across tenancies."); role.setDisplayName(AuthorizationCommon.ROLE_ADMINISTRATOR); - role.setRoleName(AuthorizationCommon.ROLE_PREFIX + role.getDisplayName()); + role.setRoleName(AuthorizationCommon.getQualifiedRoleName( + AuthorizationCommon.ADMINISTRATOR_TENANT_ID, role.getDisplayName())); role.setCsid(AuthorizationCommon.ROLE_ADMINISTRATOR_ID); role.setTenantId(AuthorizationCommon.ADMINISTRATOR_TENANT_ID); + return role; } diff --git a/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationSeed.java b/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationSeed.java index 5a766a8ba..366530130 100644 --- a/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationSeed.java +++ b/services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationSeed.java @@ -26,7 +26,6 @@ package org.collectionspace.services.authorization.importer; import java.io.FileInputStream; import java.io.InputStream; -import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; @@ -35,17 +34,10 @@ import javax.xml.bind.Unmarshaller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.collectionspace.services.authorization.AuthZ; -import org.collectionspace.services.authorization.CSpaceAction; -import org.collectionspace.services.authorization.perms.EffectType; import org.collectionspace.services.authorization.perms.Permission; -import org.collectionspace.services.authorization.perms.PermissionAction; -import org.collectionspace.services.authorization.PermissionException; import org.collectionspace.services.authorization.PermissionRole; import org.collectionspace.services.authorization.perms.PermissionsList; import org.collectionspace.services.authorization.PermissionsRolesList; -import org.collectionspace.services.authorization.RoleValue; -import org.collectionspace.services.authorization.URIResourceImpl; import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon; /** diff --git a/services/authorization-mgt/pom.xml b/services/authorization-mgt/pom.xml index e0640d334..a436f35d3 100644 --- a/services/authorization-mgt/pom.xml +++ b/services/authorization-mgt/pom.xml @@ -7,7 +7,6 @@ 2.2-SNAPSHOT - org.collectionspace.services org.collectionspace.services.authorization-mgt services.authorization-mgt pom diff --git a/services/authorization-mgt/service/pom.xml b/services/authorization-mgt/service/pom.xml index 17229558d..ae303a055 100644 --- a/services/authorization-mgt/service/pom.xml +++ b/services/authorization-mgt/service/pom.xml @@ -6,7 +6,7 @@ org.collectionspace.services 2.2-SNAPSHOT - org.collectionspace.services + org.collectionspace.services.authorization-mgt.service jar services.authorization-mgt.service @@ -163,6 +163,12 @@ + + org.collectionspace.services + org.collectionspace.services.authentication.service + ${project.version} + provided + org.collectionspace.services org.collectionspace.services.authorization.jaxb diff --git a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/AuthorizationDelegate.java b/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/AuthorizationDelegate.java index 1b0f249b2..2f97a8a4c 100644 --- a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/AuthorizationDelegate.java +++ b/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/AuthorizationDelegate.java @@ -25,6 +25,8 @@ package org.collectionspace.services.authorization.storage; import java.util.ArrayList; import java.util.List; + +import org.collectionspace.authentication.AuthN; import org.collectionspace.services.authorization.perms.ActionType; import org.collectionspace.services.authorization.AuthZ; import org.collectionspace.services.authorization.CSpaceAction; @@ -39,6 +41,7 @@ import org.collectionspace.services.authorization.Role; import org.collectionspace.services.authorization.RoleValue; import org.collectionspace.services.authorization.SubjectType; import org.collectionspace.services.authorization.URIResourceImpl; +import org.collectionspace.services.common.authorization_mgt.PermissionRoleUtil; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.storage.jpa.JpaStorageUtils; @@ -228,7 +231,7 @@ public class AuthorizationDelegate { for (PermissionAction pa : p.getAction()) { CSpaceResource res = null; if (p.getTenantId() == null) { - res = new URIResourceImpl(p.getResourceName(), + res = new URIResourceImpl(AuthN.get().getCurrentTenantId(), p.getResourceName(), getAction(pa.getName())); } else { res = new URIResourceImpl(p.getTenantId(), p.getResourceName(), diff --git a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleDocumentHandler.java b/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleDocumentHandler.java index ba1871de1..d0914277f 100644 --- a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleDocumentHandler.java +++ b/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleDocumentHandler.java @@ -34,6 +34,8 @@ import org.collectionspace.services.authorization.RoleValue; import org.collectionspace.services.authorization.SubjectType; import org.collectionspace.services.common.authorization_mgt.AuthorizationRoleRel; +import org.collectionspace.services.common.authorization_mgt.PermissionRoleUtil; + import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler; diff --git a/services/authorization/service/pom.xml b/services/authorization/service/pom.xml index 4000e515b..018e205a5 100644 --- a/services/authorization/service/pom.xml +++ b/services/authorization/service/pom.xml @@ -8,7 +8,7 @@ org.collectionspace.services 2.2-SNAPSHOT - org.collectionspace.services + org.collectionspace.services.authorization.service jar services.authorization.service diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java index bc7dbe16f..68dff9c0e 100644 --- a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java +++ b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java @@ -24,12 +24,17 @@ */ package org.collectionspace.services.authorization; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.collectionspace.services.authorization.spi.CSpaceAuthorizationProvider; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.context.SecurityContextHolder; /** * AuthZ is the authorization service singleton used by the services runtime @@ -42,7 +47,7 @@ public class AuthZ { */ private static volatile AuthZ self = new AuthZ(); private CSpaceAuthorizationProvider provider; - final Log log = LogFactory.getLog(AuthZ.class); + final Log logger = LogFactory.getLog(AuthZ.class); private AuthZ() { setupProvider(); @@ -63,14 +68,14 @@ public class AuthZ { if (beanConfigProp != null && !beanConfigProp.isEmpty()) { beanConfig = beanConfigProp; } - if (log.isDebugEnabled()) { - log.debug("reading beanConfig=" + beanConfig); + if (logger.isDebugEnabled()) { + logger.debug("reading beanConfig=" + beanConfig); } ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( new String[]{beanConfig}); provider = (CSpaceAuthorizationProvider) appContext.getBean("cspaceAuthorizationProvider"); - if (log.isDebugEnabled()) { - log.debug("initialized the authz provider"); + if (logger.isDebugEnabled()) { + logger.debug("initialized the authz provider"); } } @@ -178,4 +183,18 @@ public class AuthZ { public boolean isAccessAllowed(CSpaceResource res, CSpaceAction action) { return provider.getPermissionEvaluator().hasPermission(res, action); } + + public void login() { + String user = "SPRING_ADMIN"; + String password = "SPRING_ADMIN"; + GrantedAuthority spring_security_admin = new GrantedAuthorityImpl("ROLE_SPRING_ADMIN"); //NOTE: Must match with value in applicationContext-authorization-test.xml (aka SPRING_SECURITY_METADATA) + HashSet gauths = new HashSet(); + gauths.add(spring_security_admin); + Authentication authRequest = new UsernamePasswordAuthenticationToken(user, password, gauths); + SecurityContextHolder.getContext().setAuthentication(authRequest); + if (logger.isDebugEnabled()) { + logger.debug("Spring Security login successful for user=" + user); + } + } + } diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java index f03505800..0bd03144f 100644 --- a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java +++ b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java @@ -23,8 +23,6 @@ */ package org.collectionspace.services.authorization; -import org.collectionspace.authentication.AuthN; - /** * CSpaceResourceImpl abstract resource implementation * @author @@ -39,6 +37,7 @@ public abstract class CSpaceResourceImpl implements CSpaceResource { private String tenantId; private CSpaceResourceImpl() { + // Do nothing. } /** @@ -47,10 +46,12 @@ public abstract class CSpaceResourceImpl implements CSpaceResource { * @param action * @param type */ + /* public CSpaceResourceImpl(String id, CSpaceAction action, TYPE type) { setup(id, action, type); tenantId = AuthN.get().getCurrentTenantId(); } + */ /** * constructor that uses given tenant id to associate the resource with diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionActionUtil.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionActionUtil.java index 92af7c9d0..306e0e10b 100644 --- a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionActionUtil.java +++ b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionActionUtil.java @@ -1,9 +1,5 @@ package org.collectionspace.services.authorization; -import org.collectionspace.services.authorization.perms.PermissionAction; -import org.collectionspace.services.authorization.perms.ActionType; -import org.collectionspace.services.authorization.perms.Permission; - public class PermissionActionUtil { } diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionException.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionException.java index ce282ecb8..77304ea26 100644 --- a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionException.java +++ b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionException.java @@ -31,6 +31,12 @@ package org.collectionspace.services.authorization; public class PermissionException extends Exception { /** + * + */ + private static final long serialVersionUID = 1L; + + + /** * Creates a new instance of PermissionException without detail message. */ public PermissionException() { diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionNotFoundException.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionNotFoundException.java index a6cc3d873..df7527df5 100644 --- a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionNotFoundException.java +++ b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/PermissionNotFoundException.java @@ -30,6 +30,11 @@ package org.collectionspace.services.authorization; public class PermissionNotFoundException extends PermissionException { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Creates a new instance of PermissionNotFoundException without detail message. */ public PermissionNotFoundException() { diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java index 05c12b23f..1381a86ce 100644 --- a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java +++ b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java @@ -41,12 +41,14 @@ public class URIResourceImpl extends CSpaceResourceImpl { * @param uri * @param method an http method */ + /* public URIResourceImpl(String uri, String method) { super(buildId(uri, getAction(method)), getAction(method), TYPE.URI); this.uri = uri; this.method = method; } + */ /** * constructor that is usually called from service runtime @@ -67,11 +69,13 @@ public class URIResourceImpl extends CSpaceResourceImpl { * @param resourceName no leading / and no trailing / needed * @param actionType */ + /* public URIResourceImpl(String resourceName, CSpaceAction action) { //FIXME more validation might be needed super(buildId(resourceName, action), action, TYPE.URI); } + */ /** * constructor that is usually called from administrative interface diff --git a/services/blob/service/pom.xml b/services/blob/service/pom.xml index 61b76134d..414b20afb 100644 --- a/services/blob/service/pom.xml +++ b/services/blob/service/pom.xml @@ -8,7 +8,6 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.blob.service services.blob.service jar @@ -19,6 +18,11 @@ org.collectionspace.services.common ${project.version} + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + org.collectionspace.services org.collectionspace.services.jaxb diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java index afa7c4b53..b1ac28b3a 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java @@ -37,13 +37,13 @@ import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils; -import org.collectionspace.services.common.service.ListResultField; -import org.collectionspace.services.common.service.ObjectPartType; +import org.collectionspace.services.config.service.ListResultField; +import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.jaxb.BlobJAXBSchema; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.CommonList; + import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.IdRef; diff --git a/services/common/pom.xml b/services/common/pom.xml index 0488ea274..ebf68c577 100644 --- a/services/common/pom.xml +++ b/services/common/pom.xml @@ -13,6 +13,11 @@ + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + org.collectionspace.services org.collectionspace.services.common-api diff --git a/services/common/src/main/cspace/config/services/service-config.xml b/services/common/src/main/cspace/config/services/service-config.xml index 06b543238..890fa00c4 100644 --- a/services/common/src/main/cspace/config/services/service-config.xml +++ b/services/common/src/main/cspace/config/services/service-config.xml @@ -10,9 +10,9 @@ --> + xmlns:svc='http://collectionspace.org/services/config' + xmlns:types='http://collectionspace.org/services/config/types' + xsi:schemaLocation='http://collectionspace.org/services/config ../resources/common.xsd'> diff --git a/services/common/src/main/cspace/config/services/tenants/core/tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/core/tenant-bindings.delta.xml index ca6021a13..783708d19 100644 --- a/services/common/src/main/cspace/config/services/tenants/core/tenant-bindings.delta.xml +++ b/services/common/src/main/cspace/config/services/tenants/core/tenant-bindings.delta.xml @@ -1,11 +1,10 @@ + xmlns:tenant='http://collectionspace.org/services/config/tenant'> - diff --git a/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml index 2cd346a9d..e24cf4664 100644 --- a/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml +++ b/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml @@ -1,14 +1,14 @@ + xmlns:tenant='http://collectionspace.org/services/config/tenant'> - + @@ -20,27 +20,27 @@ - + - + authRef taxonomicIdentGroupList/*/taxon - + authRef associatedTaxaGroupList/*/taxon - + authRef taxonomicIdentGroupList/*/identBy - + authRef taxonomicIdentGroupList/*/institution - + authRef annotationGroupList/*/annotationAuthor @@ -54,7 +54,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -76,27 +76,27 @@ - + authRef affiliatedPersonOrgGroupList/*/affiliatedPersonOrg - + authRef orgContactNames|orgContactName - + termRef affiliatedPersonOrgGroupList/*/affiliatedPersonOrgType - + termRef nameTypes|nameType - + termRef nameSource - + termRef entityType diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml index 41ba2ca28..fd1b92a70 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml @@ -11,21 +11,21 @@ $LastChangedRevision$ $LastChangedDate$ --> - + - + datePattern MM/dd/yyyy - + datePattern MMM dd, yyyy - + datePattern dd.MM.yyyy @@ -35,7 +35,7 @@ dd/MM/yyyy --> - + localeLanguage en @@ -57,7 +57,7 @@ @@ -69,23 +69,23 @@ but provides tools like keyword search across many types of services. --> - default-domain - org.collectionspace.services.servicegroup.nuxeo.ServiceGroupDocumentModelHandler + default-domain + org.collectionspace.services.servicegroup.nuxeo.ServiceGroupDocumentModelHandler - /collectionobjects/*/workflow/ + /collectionobjects/*/workflow/ - default-domain - org.collectionspace.services.collectionobject.nuxeo.CollectionObjectDocumentModelHandler - + default-domain + org.collectionspace.services.collectionobject.nuxeo.CollectionObjectDocumentModelHandler + org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler collectionobjects @@ -110,8 +110,8 @@ - org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler - + org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler + org.collectionspace.services.common.init.ModifyFieldDatatypes @@ -146,20 +146,20 @@ - - + + objectNameProperty objectNameList/[0]/objectName - + objectNumberProperty objectNumber - + - + @@ -168,67 +168,67 @@ - + authRef contentActivities|contentActivity - + authRef contentConcepts|contentConcept - + authRef contentEventNameGroupList/*/contentEventName - + authRef contentEventNameGroupList/*/contentEventNameType - + authRef contentOrganizations|contentOrganization - + authRef contentOtherGroupList/*/contentOther - + authRef contentOtherGroupList/*/contentOtherType - + authRef contentPeoples|contentPeople - + authRef contentPersons|contentPerson - + authRef contentPlaces|contentPlace - + authRef measuredPartGroupList/*/dimensionSubGroupList/*/measuredBy - + authRef textualInscriptionGroupList/*/inscriptionContentInscriber - + authRef textualInscriptionGroupList/*/inscriptionContentMethod - + authRef nonTextualInscriptionGroupList/*/inscriptionDescriptionInscriber - + authRef nonTextualInscriptionGroupList/*/inscriptionDescriptionMethod - + authRef materialGroupList/*/material @@ -236,45 +236,45 @@ - + authRef materialGroupList/*/materialSource - + authRef styles|style - + authRef objectComponentGroupList/*/objectComponentName - + authRef objectProductionOrganizationGroupList/*/objectProductionOrganization - + authRef objectProductionPeopleGroupList/*/objectProductionPeople - + authRef objectProductionPersonGroupList/*/objectProductionPerson - + authRef objectProductionPlaceGroupList/*/objectProductionPlace - + authRef techniqueGroupList/*/technique - + authRef techniqueGroupList/*/techniqueType @@ -283,36 +283,36 @@ - + authRef assocOrganizationGroupList/*/assocOrganization - + authRef assocPeopleGroupList/*/assocPeople - + authRef assocPersonGroupList/*/assocPerson - + authRef assocPlaceGroupList/*/assocPlace @@ -320,11 +320,11 @@ - + authRef referenceGroupList/*/reference - + authRef fieldCollectionPlace - + authRef fieldCollectionSources|fieldCollectionSource - + authRef fieldCollectors|fieldCollector - + authRef fieldColEventNames|fieldColEventName @@ -359,159 +359,159 @@ - + termRef otherNumberList/*/numberType - + termRef objectNameList/*/objectNameCurrency - + termRef objectNameList/*/objectNameLevel - + termRef objectNameList/*/objectNameSystem - + termRef objectNameList/*/objectNameType - + termRef objectNameList/*/objectNameLanguage - + termRef responsibleDepartments|responsibleDepartment - + termRef collection - + termRef titleGroupList/*/titleLanguage - + termRef titleGroupList/*/titleTranslationSubGroupList/*/titleTranslationLanguage - + termRef titleGroupList/*/titleType - + termRef recordStatus - + termRef ageUnit - + termRef contentLanguages|contentLanguage - + termRef contentObjectGroupList/*/contentObjectType - + termRef contentPositions|contentPosition - + termRef contentScripts|contentScript - + termRef measuredPartGroupList/*/measuredPart - + termRef measuredPartGroupList/*/dimensionSubGroupList/*/dimension - + termRef measuredPartGroupList/*/dimensionSubGroupList/*/measurementUnit - + termRef measuredPartGroupList/*/dimensionSubGroupList/*/measurementMethod - + termRef forms|form - + termRef textualInscriptionGroupList/*/inscriptionContentLanguage - + termRef textualInscriptionGroupList/*/inscriptionContentPosition - + termRef textualInscriptionGroupList/*/inscriptionContentScript - + termRef textualInscriptionGroupList/*/inscriptionContentType - + termRef nonTextualInscriptionGroupList/*/inscriptionDescriptionPosition - + termRef nonTextualInscriptionGroupList/*/inscriptionDescriptionType - + termRef objectStatusList|objectStatus - + termRef phase - + termRef sex - + termRef technicalAttributeGroupList/*/technicalAttribute - + termRef technicalAttributeGroupList/*/technicalAttributeMeasurement - + termRef technicalAttributeGroupList/*/technicalAttributeMeasurementUnit - + termRef objectComponentGroupList/*/objectComponentInformation - + termRef assocActivityGroupList/*/assocActivity - + termRef assocConceptGroupList/*/assocConcept - + termRef assocCulturalContextGroupList/*/assocCulturalContext @@ -519,20 +519,20 @@ - + termRef assocObjectGroupList/*/assocObject - + termRef assocObjectGroupList/*/assocObjectType @@ -540,20 +540,20 @@ - + termRef usageGroupList/*/usage @@ -564,7 +564,7 @@ - + termRef fieldCollectionMethods|fieldCollectionMethod @@ -585,10 +585,10 @@ - /blobs/*/workflow/ - default-domain - org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler - + /blobs/*/workflow/ + default-domain + org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler + @@ -610,11 +610,11 @@ - org.collectionspace.services.blob.nuxeo.BlobValidatorHandler - + org.collectionspace.services.blob.nuxeo.BlobValidatorHandler + - + @@ -647,16 +647,16 @@ - /intakes/*/workflow/ + /intakes/*/workflow/ - default-domain - org.collectionspace.services.intake.nuxeo.IntakeDocumentModelHandler - + default-domain + org.collectionspace.services.intake.nuxeo.IntakeDocumentModelHandler + org.collectionspace.services.group.nuxeo.IntakeDocumentModelHandler intakes @@ -681,92 +681,92 @@ - org.collectionspace.services.intake.nuxeo.IntakeValidatorHandler - - + org.collectionspace.services.intake.nuxeo.IntakeValidatorHandler + + objectNameProperty currentOwner - + objectNumberProperty entryNumber - + - + - + authRef currentOwner - + authRef depositor - + authRef fieldCollectionPlace - + authRef fieldCollectionSources|fieldCollectionSource - + authRef fieldCollectors|fieldCollector - + authRef fieldCollectionEventNames|fieldCollectionEventName - + authRef valuer - + authRef insurers|insurer - + authRef currentLocationGroupList/*/currentLocation - + authRef normalLocation - + authRef conditionCheckersOrAssessors|conditionCheckerOrAssessor - + termRef entryMethods|entryMethod - + termRef entryReason - + termRef fieldCollectionMethods|fieldCollectionMethod - + termRef currentLocationGroupList/*/currentLocationFitness - + termRef conditionCheckMethods|conditionCheckMethod - + termRef conditionCheckReasons|conditionCheckReason @@ -788,16 +788,16 @@ - /loansin/*/workflow/ + /loansin/*/workflow/ - default-domain - org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler - + default-domain + org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler + org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler loansin @@ -822,9 +822,9 @@ - org.collectionspace.services.loanin.nuxeo.LoaninValidatorHandler + org.collectionspace.services.loanin.nuxeo.LoaninValidatorHandler - + org.collectionspace.services.common.init.InitHandler @@ -851,11 +851,11 @@ - + datePattern MMM dd, yyyy - + datePattern dd.MM.yyyy @@ -865,7 +865,7 @@ dd/MM/yyyy --> - + localeLanguage en @@ -876,55 +876,55 @@ --> - - + + objectNameProperty lenderGroupList/[0]/lender - + objectNumberProperty loanInNumber - + - + - + authRef lenderGroupList/*/lender - + authRef lenderGroupList/*/lendersAuthorizer - + authRef lenderGroupList/*/lendersContact - + authRef borrowersAuthorizer - + authRef borrowersContact - + authRef loanInContact - + termRef loanPurpose - + termRef loanStatusGroupList/*/loanStatus @@ -944,16 +944,16 @@ - /loansout/*/workflow/ + /loansout/*/workflow/ - default-domain - org.collectionspace.services.loanout.nuxeo.LoanoutDocumentModelHandler - + default-domain + org.collectionspace.services.loanout.nuxeo.LoanoutDocumentModelHandler + @@ -971,48 +971,48 @@ - org.collectionspace.services.loanout.nuxeo.LoanoutValidatorHandler - - + org.collectionspace.services.loanout.nuxeo.LoanoutValidatorHandler + + objectNameProperty borrower - + objectNumberProperty loanOutNumber - + - + - + authRef borrower - + authRef borrowersContact - + authRef lendersAuthorizer - + authRef lendersContact - + termRef loanPurpose - + termRef loanStatusGroupList/*/loanStatus @@ -1032,10 +1032,10 @@ - /objectexit/*/workflow/ - default-domain - org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler - + /objectexit/*/workflow/ + default-domain + org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler + org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler @@ -1052,40 +1052,40 @@ - org.collectionspace.services.objectexit.nuxeo.ObjectExitValidatorHandler - - + org.collectionspace.services.objectexit.nuxeo.ObjectExitValidatorHandler + + objectNameProperty currentOwner - + objectNumberProperty exitNumber - + - + - + authRef currentOwner - + authRef depositor - + termRef exitMethods|exitMethod - + termRef exitReason @@ -1105,10 +1105,10 @@ - /batch/*/workflow/ - default-domain - org.collectionspace.services.batch.nuxeo.BatchDocumentModelHandler - + /batch/*/workflow/ + default-domain + org.collectionspace.services.batch.nuxeo.BatchDocumentModelHandler + @@ -1119,11 +1119,11 @@ - org.collectionspace.services.batch.nuxeo.BatchValidatorHandler - + org.collectionspace.services.batch.nuxeo.BatchValidatorHandler + - + @@ -1142,10 +1142,10 @@ - /groups/*/workflow/ - default-domain - org.collectionspace.services.group.nuxeo.GroupDocumentModelHandler - + /groups/*/workflow/ + default-domain + org.collectionspace.services.group.nuxeo.GroupDocumentModelHandler + @@ -1159,32 +1159,32 @@ - org.collectionspace.services.group.nuxeo.GroupValidatorHandler - - + org.collectionspace.services.group.nuxeo.GroupValidatorHandler + + objectNameProperty groups_common:owner - + objectNumberProperty groups_common:title - + - + - + authRef owner - + termRef responsibleDepartment @@ -1204,10 +1204,10 @@ - /imports/*/workflow/ - default-domain - org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler - + /imports/*/workflow/ + default-domain + org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler + org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler imports @@ -1225,10 +1225,10 @@ - + - + @@ -1248,10 +1248,10 @@ - /media/*/workflow/ - default-domain - org.collectionspace.services.media.nuxeo.MediaDocumentModelHandler - + /media/*/workflow/ + default-domain + org.collectionspace.services.media.nuxeo.MediaDocumentModelHandler + @@ -1277,73 +1277,73 @@ - org.collectionspace.services.media.nuxeo.MediaValidatorHandler - - + org.collectionspace.services.media.nuxeo.MediaValidatorHandler + + objectNameProperty title - + objectNumberProperty identificationNumber - + - + - + authRef contributor - + authRef coverage - + authRef creator - + authRef publisher - + authRef rightsHolder - + authRef subjectList|subject - + authRef measuredPartGroupList/*/dimensionSubGroupList/*/measuredBy - + termRef languageList|language - + termRef typeList|type - + termRef measuredPartGroupList/*/dimensionSubGroupList/*/dimension - + termRef measuredPartGroupList/*/dimensionSubGroupList/*/measurementUnit - + termRef measuredPartGroupList/*/dimensionSubGroupList/*/measurementMethod @@ -1363,16 +1363,16 @@ - /movements/*/workflow/ + /movements/*/workflow/ - default-domain - org.collectionspace.services.movement.nuxeo.MovementDocumentModelHandler - + default-domain + org.collectionspace.services.movement.nuxeo.MovementDocumentModelHandler + @@ -1390,18 +1390,18 @@ - org.collectionspace.services.movement.nuxeo.MovementValidatorHandler - - + org.collectionspace.services.movement.nuxeo.MovementValidatorHandler + + objectNameProperty currentLocation - + objectNumberProperty movementReferenceNumber - + org.collectionspace.services.common.init.AddIndices @@ -1410,10 +1410,10 @@ - + - + @@ -1421,45 +1421,45 @@ - + authRef currentLocation - + authRef normalLocation - + authRef movementContact - + authRef inventoryContactList|inventoryContact - + termRef currentLocationFitness - + termRef movementMethods|movementMethod - + termRef reasonForMove - + termRef inventoryActionRequired - + termRef frequencyForInventory @@ -1479,13 +1479,13 @@ - default-domain - org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler - org.collectionspace.services.workflow.nuxeo.WorkflowValidatorHandler - + default-domain + org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler + org.collectionspace.services.workflow.nuxeo.WorkflowValidatorHandler + - + @@ -1499,15 +1499,15 @@ - /reports/*/workflow/ + /reports/*/workflow/ - default-domain - org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler - + default-domain + org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler + @@ -1517,8 +1517,8 @@ - org.collectionspace.services.report.nuxeo.ReportValidatorHandler - + org.collectionspace.services.report.nuxeo.ReportValidatorHandler + org.collectionspace.services.report.nuxeo.ReportPostInitHandler @@ -1527,10 +1527,10 @@ - + - + @@ -1549,13 +1549,13 @@ - /vocabularies/*/workflow/ - /vocabularies/*/items/*/workflow/ + /vocabularies/*/workflow/ + /vocabularies/*/items/*/workflow/ - default-domain - org.collectionspace.services.vocabulary.nuxeo.VocabularyDocumentModelHandler - org.collectionspace.services.vocabulary.nuxeo.VocabularyValidatorHandler - + default-domain + org.collectionspace.services.vocabulary.nuxeo.VocabularyDocumentModelHandler + org.collectionspace.services.vocabulary.nuxeo.VocabularyValidatorHandler + @@ -1577,7 +1577,7 @@ - + org.collectionspace.services.common.init.AddIndices @@ -1590,10 +1590,10 @@ - + - + @@ -1615,19 +1615,19 @@ Repository workspace so we have to configure that. --> - /vocabularyitems/*/workflow/ + /vocabularyitems/*/workflow/ - default-domain - org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler - + default-domain + org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler + @@ -1638,8 +1638,8 @@ - org.collectionspace.services.vocabulary.nuxeo.VocabularyItemValidatorHandler - + org.collectionspace.services.vocabulary.nuxeo.VocabularyItemValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -1656,10 +1656,10 @@ - + - + @@ -1678,17 +1678,17 @@ - /orgauthorities/*/workflow/ - /orgauthorities/*/items/*/workflow/ + /orgauthorities/*/workflow/ + /orgauthorities/*/items/*/workflow/ - default-domain - org.collectionspace.services.organization.nuxeo.OrgAuthorityDocumentModelHandler - + default-domain + org.collectionspace.services.organization.nuxeo.OrgAuthorityDocumentModelHandler + @@ -1710,8 +1710,8 @@ - org.collectionspace.services.organization.nuxeo.OrgAuthorityValidatorHandler - + org.collectionspace.services.organization.nuxeo.OrgAuthorityValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -1724,10 +1724,10 @@ - + - + @@ -1751,24 +1751,24 @@ - default-domain - org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler - + default-domain + org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler + - org.collectionspace.services.organization.nuxeo.OrganizationValidatorHandler - + org.collectionspace.services.organization.nuxeo.OrganizationValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -1785,46 +1785,46 @@ - - + + objectNameProperty displayName - + objectNumberProperty shortIdentifier - + - + - + authRef contactNames|contactName - + authRef foundingPlace - + authRef groups|group - + authRef functions|function - + termRef termStatus @@ -1844,20 +1844,20 @@ - /personauthorities/*/workflow/ - /personauthorities/*/items/*/workflow/ + /personauthorities/*/workflow/ + /personauthorities/*/items/*/workflow/ - default-domain - org.collectionspace.services.person.nuxeo.PersonAuthorityDocumentModelHandler - + default-domain + org.collectionspace.services.person.nuxeo.PersonAuthorityDocumentModelHandler + @@ -1879,8 +1879,8 @@ - org.collectionspace.services.person.nuxeo.PersonAuthorityValidatorHandler - + org.collectionspace.services.person.nuxeo.PersonAuthorityValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -1893,10 +1893,10 @@ - + - + @@ -1920,13 +1920,13 @@ - default-domain - org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler - + default-domain + org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler + @@ -1941,8 +1941,8 @@ - org.collectionspace.services.person.nuxeo.PersonValidatorHandler - + org.collectionspace.services.person.nuxeo.PersonValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -1959,21 +1959,21 @@ - - + + objectNameProperty displayName - + objectNumberProperty shortIdentifier - + - + @@ -1982,44 +1982,44 @@ - + authRef birthPlace - + authRef deathPlace - + authRef groups|group - + authRef nationalities|nationality - + authRef occupations|occupation - + authRef schoolsOrStyles|schoolOrStyle - + termRef salutation - + termRef title - + termRef gender - + termRef termStatus @@ -2036,17 +2036,17 @@ - /locationauthorities/*/workflow/ - /locationauthorities/*/items/*/workflow/ + /locationauthorities/*/workflow/ + /locationauthorities/*/items/*/workflow/ - default-domain - org.collectionspace.services.location.nuxeo.LocationAuthorityDocumentModelHandler - + default-domain + org.collectionspace.services.location.nuxeo.LocationAuthorityDocumentModelHandler + @@ -2068,7 +2068,7 @@ - + org.collectionspace.services.common.init.AddIndices @@ -2081,10 +2081,10 @@ - + - + @@ -2106,9 +2106,9 @@ Repository workspace so we have to configure that. --> - default-domain - org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler - + default-domain + org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler + @@ -2119,8 +2119,8 @@ - org.collectionspace.services.location.nuxeo.LocationValidatorHandler - + org.collectionspace.services.location.nuxeo.LocationValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -2137,30 +2137,30 @@ - - + + objectNameProperty displayName - + objectNumberProperty shortIdentifier - + - + - + - + termRef locationType - + termRef termStatus @@ -2179,16 +2179,16 @@ - /placeauthorities/*/workflow/ - /placeauthorities/*/items/*/workflow/ + /placeauthorities/*/workflow/ + /placeauthorities/*/items/*/workflow/ - default-domain - org.collectionspace.services.place.nuxeo.PlaceAuthorityDocumentModelHandler - + default-domain + org.collectionspace.services.place.nuxeo.PlaceAuthorityDocumentModelHandler + @@ -2210,7 +2210,7 @@ - + org.collectionspace.services.common.init.AddIndices @@ -2223,10 +2223,10 @@ - + - + @@ -2247,17 +2247,17 @@ Repository workspace so we have to configure that. --> - default-domain - org.collectionspace.services.place.nuxeo.PlaceDocumentModelHandler - + default-domain + org.collectionspace.services.place.nuxeo.PlaceDocumentModelHandler + - org.collectionspace.services.place.nuxeo.PlaceValidatorHandler - + org.collectionspace.services.place.nuxeo.PlaceValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -2274,73 +2274,73 @@ - - + + objectNameProperty displayName - + objectNumberProperty shortIdentifier - + - + - - + + authRef placeOwnerGroupList/*/owner - + termRef termStatus - + termRef placeType - + termRef placeNameGroupList/*/nameLanguage - + termRef placeNameGroupList/*/nameType - + termRef placeNameGroupList/*/nameStatus - + termRef placeNameGroupList/*/nameAdminStatus - + termRef vCoordSys - + termRef vSpatialReferenceSystem - + termRef vUnitofMeasure - + termRef placeGeoRefGroupList/*/geodeticDatum - + termRef placeGeoRefGroupList/*/geoRefProtocol - + termRef placeGeoRefGroupList/*/geoRefVerificationStatus @@ -2359,17 +2359,17 @@ - /taxonomyauthority/*/workflow/ - /taxonomyauthority/*/items/*/workflow/ + /taxonomyauthority/*/workflow/ + /taxonomyauthority/*/items/*/workflow/ - default-domain - org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityDocumentModelHandler - + default-domain + org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityDocumentModelHandler + @@ -2391,7 +2391,7 @@ - + org.collectionspace.services.common.init.AddIndices @@ -2404,10 +2404,10 @@ - + - + @@ -2429,9 +2429,9 @@ Repository workspace so we have to configure that. --> - default-domain - org.collectionspace.services.taxonomy.nuxeo.TaxonDocumentModelHandler - + default-domain + org.collectionspace.services.taxonomy.nuxeo.TaxonDocumentModelHandler + @@ -2442,8 +2442,8 @@ - org.collectionspace.services.taxonomy.nuxeo.TaxonValidatorHandler - + org.collectionspace.services.taxonomy.nuxeo.TaxonValidatorHandler + org.collectionspace.services.common.init.AddIndices @@ -2460,51 +2460,51 @@ - - + + objectNameProperty displayName - + objectNumberProperty shortIdentifier - + - + - + - + authRef taxonAuthorGroupList/*/taxonAuthor - + termRef taxonRank - + termRef taxonCurrency - + termRef taxonAuthorGroupList/*/taxonAuthorType - + termRef taxonomicStatus - + termRef taxonNameSource - + termRef termStatus @@ -2524,16 +2524,16 @@ - /acquisitions/*/workflow/ + /acquisitions/*/workflow/ - default-domain - org.collectionspace.services.acquisition.nuxeo.AcquisitionDocumentModelHandler - + default-domain + org.collectionspace.services.acquisition.nuxeo.AcquisitionDocumentModelHandler + @@ -2551,72 +2551,72 @@ - org.collectionspace.services.acquisition.nuxeo.AcquisitionValidatorHandler - - + org.collectionspace.services.acquisition.nuxeo.AcquisitionValidatorHandler + + objectNameProperty acquisitionSources/[0] - + objectNumberProperty acquisitionReferenceNumber - + - + - + authRef acquisitionAuthorizer - + authRef acquisitionFundingList/*/acquisitionFundingSource - + authRef owners|owner - + authRef acquisitionSources|acquisitionSource - + authRef fieldCollectionEventNames|fieldCollectionEventName - + termRef acquisitionFundingList/*/acquisitionFundingCurrency - + termRef acquisitionMethod - + termRef groupPurchasePriceCurrency - + termRef objectOfferPriceCurrency - + termRef objectPurchaseOfferPriceCurrency - + termRef objectPurchasePriceCurrency - + termRef originalObjectPurchasePriceCurrency @@ -2636,14 +2636,14 @@ - /relations/*/workflow/ + /relations/*/workflow/ - default-domain - org.collectionspace.services.relation.nuxeo.RelationDocumentModelHandler + default-domain + org.collectionspace.services.relation.nuxeo.RelationDocumentModelHandler - org.collectionspace.services.relation.nuxeo.RelationValidatorHandler - - + org.collectionspace.services.relation.nuxeo.RelationValidatorHandler + + objectNameProperty subjectCsid - + objectNumberProperty predicateDisplayName - + org.collectionspace.services.common.init.AddIndices @@ -2715,10 +2715,10 @@ - + - + @@ -2738,8 +2738,8 @@ - org.collectionspace.services.account.storage.AccountDocumentHandler - + org.collectionspace.services.account.storage.AccountDocumentHandler + @@ -2761,11 +2761,11 @@ - org.collectionspace.services.account.storage.AccountValidatorHandler - + org.collectionspace.services.account.storage.AccountValidatorHandler + - + @@ -2785,13 +2785,13 @@ - /dimensions/*/workflow/ - default-domain - org.collectionspace.services.dimension.nuxeo.DimensionDocumentModelHandler - + /dimensions/*/workflow/ + default-domain + org.collectionspace.services.dimension.nuxeo.DimensionDocumentModelHandler + - + @@ -2812,16 +2812,16 @@ - default-domain - org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler - + default-domain + org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler + @@ -2831,45 +2831,45 @@ - + - + - + authRef addressGroupList/*/addressMunicipality - + authRef addressGroupList/*/addressStateOrProvince - + authRef addressGroupList/*/addressCountry - + termRef emailGroupList/*/emailType - + termRef telephoneNumberGroupList/*/telephoneNumberType - + termRef faxNumberGroupList/*/faxNumberType - + termRef webAddressGroupList/*/webAddressType - + termRef addressGroupList/*/addressType @@ -2889,13 +2889,13 @@ - /notes/*/workflow/ - default-domain - org.collectionspace.services.note.nuxeo.NoteDocumentModelHandler - + /notes/*/workflow/ + default-domain + org.collectionspace.services.note.nuxeo.NoteDocumentModelHandler + - + @@ -2915,12 +2915,12 @@ - org.collectionspace.services.authorization.storage.RoleDocumentHandler - org.collectionspace.services.authorization.storage.RoleValidatorHandler - + org.collectionspace.services.authorization.storage.RoleDocumentHandler + org.collectionspace.services.authorization.storage.RoleValidatorHandler + - + @@ -2935,12 +2935,12 @@ - org.collectionspace.services.authorization.storage.PermissionDocumentHandler - org.collectionspace.services.authorization.storage.PermissionValidatorHandler - + org.collectionspace.services.authorization.storage.PermissionDocumentHandler + org.collectionspace.services.authorization.storage.PermissionValidatorHandler + - + @@ -2958,20 +2958,20 @@ - org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler + org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler - + - + @@ -2987,20 +2987,20 @@ - org.collectionspace.services.account.storage.AccountRoleDocumentHandler + org.collectionspace.services.account.storage.AccountRoleDocumentHandler - + - + @@ -3018,20 +3018,20 @@ - org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler + org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler - + - + @@ -3049,20 +3049,20 @@ - org.collectionspace.services.account.storage.AccountRoleDocumentHandler + org.collectionspace.services.account.storage.AccountRoleDocumentHandler - + - + diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index 3f2d2896c..78242c97a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@ -29,21 +29,17 @@ import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.common.context.MultipartServiceContextImpl; -import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.DocumentNotFoundException; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.query.QueryManager; -import org.collectionspace.services.common.security.UnauthorizedException; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo; +import org.collectionspace.services.config.ClientType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; 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.nuxeo.ecm.core.api.repository.RepositoryInstance; @@ -52,7 +48,6 @@ import javax.ws.rs.*; import javax.ws.rs.core.*; import java.util.List; -import java.util.Map; /** * $LastChangedRevision: $ diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index 7d1a64324..0bf0add2d 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -18,19 +18,24 @@ import javax.servlet.ServletContext; import javax.sql.DataSource; import org.collectionspace.authentication.AuthN; + +import org.collectionspace.services.config.service.InitHandler; import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon; import org.collectionspace.services.common.config.ServicesConfigReaderImpl; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.init.IInitHandler; import org.collectionspace.services.common.security.SecurityUtils; -import org.collectionspace.services.common.service.*; import org.collectionspace.services.common.storage.JDBCTools; import org.collectionspace.services.common.storage.DatabaseProductType; -import org.collectionspace.services.common.tenant.TenantBindingType; -import org.collectionspace.services.common.types.PropertyItemType; -import org.collectionspace.services.common.types.PropertyType; +import org.collectionspace.services.config.ClientType; +import org.collectionspace.services.config.ServiceConfig; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.TenantBindingType; +import org.collectionspace.services.config.types.PropertyItemType; +import org.collectionspace.services.config.types.PropertyType; import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded; import org.collectionspace.services.nuxeo.client.java.TenantRepository; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -202,7 +207,6 @@ public class ServiceMain { } } } - public void firePostInitHandlers() throws Exception { DataSource dataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME); @@ -215,15 +219,15 @@ public class ServiceMain { List sbtList = tbt.getServiceBindings(); for (ServiceBindingType sbt: sbtList){ //Get the list of InitHandler elements, extract the first one (only one supported right now) and fire it using reflection. - List list = sbt.getInitHandler(); + List list = sbt.getInitHandler(); if (list!=null && list.size()>0){ - org.collectionspace.services.common.service.InitHandler handlerType = list.get(0); + org.collectionspace.services.config.service.InitHandler handlerType = list.get(0); String initHandlerClassname = handlerType.getClassname(); - List + List fields = handlerType.getParams().getField(); - List + List props = handlerType.getParams().getProperty(); //org.collectionspace.services.common.service.InitHandler.Fields ft = handlerType.getFields(); 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 45141ad0b..6dac00e22 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 @@ -7,17 +7,20 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.UUID; import javax.naming.NamingException; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; import org.collectionspace.services.authorization.AuthZ; import org.collectionspace.services.authorization.CSpaceAction; -import org.collectionspace.services.authorization.PermissionActionUtil; import org.collectionspace.services.authorization.PermissionException; import org.collectionspace.services.authorization.PermissionRole; +import org.collectionspace.services.authorization.PermissionRoleRel; import org.collectionspace.services.authorization.PermissionValue; import org.collectionspace.services.authorization.Role; import org.collectionspace.services.authorization.RoleValue; @@ -30,16 +33,16 @@ import org.collectionspace.services.authorization.perms.PermissionAction; import org.collectionspace.services.client.RoleClient; import org.collectionspace.services.client.workflow.WorkflowClient; - -import org.collectionspace.services.common.authorization_mgt.AuthorizationStore; import org.collectionspace.services.common.config.ServiceConfigUtils; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.document.DocumentHandler; +import org.collectionspace.services.common.profile.Profiler; import org.collectionspace.services.common.security.SecurityUtils; -import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.common.storage.DatabaseProductType; import org.collectionspace.services.common.storage.JDBCTools; -import org.collectionspace.services.common.tenant.TenantBindingType; +import org.collectionspace.services.common.storage.jpa.JpaStorageUtils; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.TenantBindingType; import org.collectionspace.services.lifecycle.Lifecycle; import org.collectionspace.services.lifecycle.TransitionDef; @@ -92,11 +95,15 @@ public class AuthorizationCommon { final static Logger logger = LoggerFactory.getLogger(AuthorizationCommon.class); + // + // The "super" role has a predefined ID of "0" and a tenant ID of "0"; + // final public static String ROLE_ADMINISTRATOR = "ADMINISTRATOR"; - final public static String ROLE_TENANT_ADMINISTRATOR = "TENANT_ADMINISTRATOR"; - final public static String ROLE_TENANT_READER = "TENANT_READER"; final public static String ROLE_ADMINISTRATOR_ID = "0"; final public static String ADMINISTRATOR_TENANT_ID = "0"; + + final public static String ROLE_TENANT_ADMINISTRATOR = "TENANT_ADMINISTRATOR"; + final public static String ROLE_TENANT_READER = "TENANT_READER"; public static final String TENANT_ADMIN_ACCT_PREFIX = "admin@"; public static final String TENANT_READER_ACCT_PREFIX = "reader@"; @@ -119,6 +126,16 @@ public class AuthorizationCommon { return role; } + public static Role getRole(EntityManager em, String tenantId, String displayName) { + Role role = null; + + String roleName = AuthorizationCommon.getQualifiedRoleName(tenantId, displayName); + role = AuthorizationStore.getRoleByName(em, roleName, tenantId); + + return role; + } + + public static Role createRole(String tenantId, String name, String description) { return createRole(tenantId, name, description, false /* mutable by default */); } @@ -229,7 +246,10 @@ public class AuthorizationCommon { String resourceName, String description, ActionGroup actionGroup) { - String id = UUID.randomUUID().toString(); //FIXME: Could this be something like a refname instead of a UUID? +// String id = UUID.randomUUID().toString(); //FIXME: Could this be something like a refname instead of a UUID? + String id = tenantId + + "-" + resourceName + + "-" + actionGroup.name; Permission perm = new Permission(); perm.setCsid(id); perm.setDescription(description); @@ -257,12 +277,20 @@ public class AuthorizationCommon { Permission result = null; String tenantId = tenantBinding.getId(); - String resourceName = serviceBinding.getName().toLowerCase().trim() + String resourceName = "/" + + serviceBinding.getName().toLowerCase().trim() + WorkflowClient.SERVICE_AUTHZ_SUFFIX + transitionDef.getName(); - String description = "A generate workflow permission for actiongroup " + actionGroup.name; + String description = "A generated workflow permission for actiongroup " + actionGroup.name; result = createPermission(tenantId, resourceName, description, actionGroup); + if (logger.isDebugEnabled() == true) { + logger.debug("Generated a workflow permission: " + + result.getResourceName() + + ":" + transitionDef.getName() + + ":" + "tenant id=" + result.getTenantId()); + } + return result; } @@ -271,8 +299,13 @@ public class AuthorizationCommon { boolean enforceTenancy) throws Exception { PermissionRole permRole = new PermissionRole(); - - if (enforceTenancy && role.getTenantId().equalsIgnoreCase(permission.getTenantId())) { + // Check to see if the tenant ID of the permission and the tenant ID of the role match + boolean tenantIdsMatch = role.getTenantId().equalsIgnoreCase(permission.getTenantId()); + if (tenantIdsMatch == false && enforceTenancy == false) { + tenantIdsMatch = true; // If we don't need to enforce tenancy then we'll just consider them matched. + } + + if (tenantIdsMatch == true) { permRole.setSubject(SubjectType.ROLE); // // Set of the permission value list of the permrole @@ -303,48 +336,6 @@ public class AuthorizationCommon { return permRole; } - public static void createDefaultPermissions(TenantBindingConfigReaderImpl tenantBindingConfigReader) throws Exception - { - PermissionAction pa = new PermissionAction(); - pa.getHjid(); - - Hashtable tenantBindings = - tenantBindingConfigReader.getTenantBindings(); - for (String tenantId : tenantBindings.keySet()) { - TenantBindingType tenantBinding = tenantBindings.get(tenantId); - for (ServiceBindingType serviceBinding : tenantBinding.getServiceBindings()) { - try { - DocumentHandler docHandler = ServiceConfigUtils.createDocumentHandlerInstance( - tenantBinding, serviceBinding); - Lifecycle lifecycle = docHandler.getLifecycle(); - TransitionDefList transitionDefList = lifecycle.getTransitionDefList(); - for (TransitionDef transitionDef : transitionDefList.getTransitionDef()) { - // - // Create the permission for the admin role - // - Permission adminPerm = createWorkflowPermission(tenantBinding, serviceBinding, transitionDef, AuthorizationCommon.ACTIONGROUP_CRUDL); - Role adminRole = AuthorizationCommon.getRole(tenantBinding.getId(), AuthorizationCommon.ROLE_TENANT_ADMINISTRATOR); - PermissionRole adminPermRole = createPermissionRole(adminPerm, adminRole, true); - addPermissionsForUri(adminPerm, adminPermRole); - // - // Create the permission for the read-only role - Permission readonlyPerm = createWorkflowPermission(tenantBinding, serviceBinding, transitionDef, AuthorizationCommon.ACTIONGROUP_RL); - Role readonlyRole = AuthorizationCommon.getRole(tenantBinding.getId(), AuthorizationCommon.ROLE_TENANT_READER); - PermissionRole readonlyPermRole = createPermissionRole(readonlyPerm, readonlyRole, true); - addPermissionsForUri(readonlyPerm, readonlyPermRole); - // - // Create the permission for the super-admin role. Note we use the same "adminPerm" instance we used for the "adminPermRole" instance - // - Role superRole = AuthorizationCommon.getRole(tenantBinding.getId(), AuthorizationCommon.ROLE_TENANT_READER); - PermissionRole superPermRole = createPermissionRole(adminPerm, superRole, false); - addPermissionsForUri(adminPerm, superPermRole); - } - } catch (IllegalStateException e) { - logger.debug(e.getLocalizedMessage(), e); //We end up here if there is no document handler for the service -this is ok for some of the services. - } - } - } - } /* * FIXME: REM - This method is way too big -over 300 lines! We need to break it up into @@ -764,6 +755,158 @@ public class AuthorizationCommon { return pa; } + private static TransitionDefList getTransitionDefList(TenantBindingType tenantBinding, ServiceBindingType serviceBinding) { + TransitionDefList result = null; + try { + DocumentHandler docHandler = ServiceConfigUtils.createDocumentHandlerInstance( + tenantBinding, serviceBinding); + Lifecycle lifecycle = docHandler.getLifecycle(); + if (lifecycle != null) { + result = lifecycle.getTransitionDefList(); + } + } catch (Exception e) { + // Ignore this exception and return an empty non-null TransitionDefList + } + + if (result == null) { + logger.warn("Could not retrieve a lifecycle transition definition list from: " + + serviceBinding.getName() + + " with tenant ID = " + + tenantBinding.getId()); + // return an empty list + result = new TransitionDefList(); + } else { + logger.debug("Successfully etrieved a lifecycle transition definition list from: " + + serviceBinding.getName() + + " with tenant ID = " + + tenantBinding.getId()); + } + + return result; + } + + public static void createDefaultPermissions(TenantBindingConfigReaderImpl tenantBindingConfigReader) throws Exception + { + AuthZ.get().login(); //login to Spring Security manager + + EntityManagerFactory emf = JpaStorageUtils.getEntityManagerFactory(JpaStorageUtils.CS_PERSISTENCE_UNIT); + EntityManager em = null; + + try { + em = emf.createEntityManager(); + + Role superRole = AuthorizationCommon.getRole(em, ADMINISTRATOR_TENANT_ID, ROLE_ADMINISTRATOR); + Hashtable tenantBindings = + tenantBindingConfigReader.getTenantBindings(); + for (String tenantId : tenantBindings.keySet()) { + 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); + for (ServiceBindingType serviceBinding : tenantBinding.getServiceBindings()) { + try { + TransitionDefList transitionDefList = getTransitionDefList(tenantBinding, serviceBinding); + for (TransitionDef transitionDef : transitionDefList.getTransitionDef()) { + em.getTransaction().begin(); + /* + // + // Create the permission for the admin role + // + Permission adminPerm = createWorkflowPermission(tenantBinding, serviceBinding, transitionDef, ACTIONGROUP_CRUDL); + persist(em, adminPerm, adminRole, true); + */ + // + // Create the permission for the read-only role + Permission readonlyPerm = createWorkflowPermission(tenantBinding, serviceBinding, transitionDef, ACTIONGROUP_RL); + + Profiler profiler = new Profiler(AuthorizationCommon.class, 1); + profiler.start("createDefaultPermissions started:" + readonlyPerm.getCsid()); + persist(em, readonlyPerm, readonlyRole, true); + profiler.stop("createDefaultPermissions finished:" + readonlyPerm.getCsid()); + logger.debug("Finished full perm generation for " + + ":" + tenantBinding.getId() + + ":" + serviceBinding.getName() + + ":" + transitionDef.getName() + + ":" + ACTIONGROUP_RL + + ":" + profiler.getCumulativeTime()); + + /* + // + // Create the permission for the super-admin role. Note we use the same "adminPerm" instance we used for the "adminPermRole" instance + // + persist(em, adminPerm, superRole, false); + + */ + em.getTransaction().commit(); + } + } catch (IllegalStateException e) { + logger.debug(e.getLocalizedMessage(), e); //We end up here if there is no document handler for the service -this is ok for some of the services. + } + } + } + em.close(); + } catch (Exception e) { + if (em != null && em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + if (logger.isDebugEnabled()) { + logger.debug("Caught exception and rolling back permission creation: ", e); + } + throw e; + } finally { + if (em != null) { + JpaStorageUtils.releaseEntityManagerFactory(emf); + } + } + } + + private static PermissionRoleRel findPermRoleRel(EntityManager em, String permissionId, String RoleId) { + PermissionRoleRel result = null; + + try { + String whereClause = "where permissionId = :id and roleId = :roleId"; + HashMap params = new HashMap(); + params.put("id", permissionId); + params.put("roleId", RoleId); + result = (PermissionRoleRel) JpaStorageUtils.getEntity(em, + PermissionRoleRel.class.getCanonicalName(), whereClause, params); + } catch (Exception e) { + //Do nothing. Will return null; + } + + return result; + } + + /* + * Persists the Permission, PermissionRoleRel, and Spring Security table entries all in one transaction + */ + private static void persist(EntityManager em, Permission permission, Role role, boolean enforceTenancy) throws Exception { + AuthorizationStore authzStore = new AuthorizationStore(); + // First persist the Permission record + authzStore.store(em, permission); + + // If the PermRoleRel doesn't already exists then relate the permission and the role in a new PermissionRole (the service payload) + // Create a PermissionRoleRel (the database relation table for the permission and role) + PermissionRoleRel permRoleRel = findPermRoleRel(em, permission.getCsid(), role.getCsid()); + if (permRoleRel == null) { + PermissionRole permRole = createPermissionRole(permission, role, enforceTenancy); + List permRoleRels = new ArrayList(); + PermissionRoleUtil.buildPermissionRoleRel(em, permRole, SubjectType.ROLE, permRoleRels, false /*not for delete*/); + for (PermissionRoleRel prr : permRoleRels) { + authzStore.store(em, prr); + } + Profiler profiler = new Profiler(AuthorizationCommon.class, 2); + profiler.start(); + // Add a corresponding entry in the Spring Security Tables + addPermissionsForUri(permission, permRole); + profiler.stop(); + logger.debug("Finished full perm generation for " + + ":" + permission.getTenantId() + + ":" + permission.getResourceName() + + ":" + ACTIONGROUP_RL + + ":" + profiler.getCumulativeTime()); + } + + } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationRoleRel.java b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationRoleRel.java index 1ef90a4e9..b2828e936 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationRoleRel.java +++ b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationRoleRel.java @@ -5,7 +5,6 @@ import org.collectionspace.services.authorization.PermissionRoleRel; import org.collectionspace.services.authorization.AccountRoleRel; import org.collectionspace.services.authorization.PermissionValue; import org.collectionspace.services.authorization.RoleValue; -import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon; public class AuthorizationRoleRel { diff --git a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationStore.java b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationStore.java index d28de34ea..281b88756 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationStore.java +++ b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationStore.java @@ -54,7 +54,7 @@ public class AuthorizationStore { try { theRole = (Role)JpaStorageUtils.getEnityByKey(Role.class.getName(), RoleStorageConstants.ROLE_NAME, roleName, tenantId); - } catch (Exception e) { + } catch (Throwable e) { if (logger.isTraceEnabled() == true) { logger.trace("Could not retrieve role with name =" + roleName, e); } @@ -63,6 +63,22 @@ public class AuthorizationStore { return theRole; } + static public Role getRoleByName(EntityManager em, String roleName, String tenantId) { + Role theRole = null; + + try { + theRole = (Role)JpaStorageUtils.getEnityByKey(em, Role.class.getName(), + RoleStorageConstants.ROLE_NAME, roleName, tenantId); + } catch (Throwable e) { + if (logger.isTraceEnabled() == true) { + logger.trace("Could not retrieve role with name =" + roleName, e); + } + } + + return theRole; + } + + static public Permission getPermission(Permission permission) { Permission result = null; // @@ -111,8 +127,53 @@ public class AuthorizationStore { throw e; } finally { if (em != null) { + em.clear(); + em.close(); JpaStorageUtils.releaseEntityManagerFactory(emf); } } } + + private boolean exists(EntityManager em, Object entity) { + boolean result = false; + + try { + String csid = (String)JaxbUtils.getValue(entity, "getCsid"); + Object existingEntity = em.find(entity.getClass(), csid); + if (existingEntity != null) { + result = true; + } + } catch (Exception e) { + //NOTE: Not all entities have a CSID attribute + } + + return result; + } + /* + * Use this method if you've already started a transaction with an EntityManager + */ + public String store(EntityManager em, Object entity) throws Exception { + boolean entityExists = exists(em, entity); + if (entityExists == true) { + logger.debug("Entity to persist already exists."); + } + if (JaxbUtils.getValue(entity, "getCreatedAt") == null) { + JaxbUtils.setValue(entity, "setCreatedAtItem", Date.class, new Date()); + } + + if (entityExists == true) { + em.merge(entity); + } else { + em.persist(entity); + } + + // look for a CSID + String id = null; + try{ + id = (String) JaxbUtils.getValue(entity, "getCsid"); //NOTE: Not all entities have a CSID attribute + } catch(NoSuchMethodException nsme) { + //do nothing ok, relationship does not have csid + } + return id; + } } diff --git a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleUtil.java b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/PermissionRoleUtil.java similarity index 77% rename from services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleUtil.java rename to services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/PermissionRoleUtil.java index c2a53b686..f55daf08d 100644 --- a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/storage/PermissionRoleUtil.java +++ b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/PermissionRoleUtil.java @@ -21,11 +21,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.collectionspace.services.authorization.storage; +package org.collectionspace.services.common.authorization_mgt; import java.util.HashMap; import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.context.ServiceContextProperties; @@ -51,7 +54,7 @@ import org.slf4j.LoggerFactory; */ public class PermissionRoleUtil { - final Logger logger = LoggerFactory.getLogger(PermissionRoleUtil.class); + static final Logger logger = LoggerFactory.getLogger(PermissionRoleUtil.class); /** * Gets the relation subject. @@ -59,7 +62,7 @@ public class PermissionRoleUtil { * @param ctx the ctx * @return the relation subject */ - static SubjectType getRelationSubject(ServiceContext ctx) { + static public SubjectType getRelationSubject(ServiceContext ctx) { Object o = ctx.getProperty(ServiceContextProperties.SUBJECT); if (o == null) { throw new IllegalArgumentException(ServiceContextProperties.SUBJECT @@ -76,7 +79,7 @@ public class PermissionRoleUtil { * @param pr the pr * @return the relation subject */ - static SubjectType getRelationSubject(ServiceContext ctx, PermissionRole pr) { + static public SubjectType getRelationSubject(ServiceContext ctx, PermissionRole pr) { SubjectType subject = pr.getSubject(); if (subject == null) { //it is not required to give subject as URI determines the subject @@ -94,17 +97,17 @@ public class PermissionRoleUtil { * @param prrl persistent entities built are inserted into this list * @param toDelete the to delete */ - static public void buildPermissionRoleRel(PermissionRole pr, + static public void buildPermissionRoleRel(EntityManager em, + PermissionRole pr, SubjectType subject, List prrl, - boolean handleDelete) - throws DocumentNotFoundException { + boolean handleDelete) throws Exception { if (subject.equals(SubjectType.ROLE)) { List permissionValues = pr.getPermission(); if (permissionValues != null && permissionValues.size() > 0) { PermissionValue pv = permissionValues.get(0); for (RoleValue rv : pr.getRole()) { - PermissionRoleRel prr = buildPermissonRoleRel(pv, rv, subject, handleDelete); + PermissionRoleRel prr = buildPermissonRoleRel(em, pv, rv, subject, handleDelete); prrl.add(prr); } } @@ -113,12 +116,43 @@ public class PermissionRoleUtil { if (roleValues != null && roleValues.size() > 0) { RoleValue rv = roleValues.get(0); for (PermissionValue pv : pr.getPermission()) { - PermissionRoleRel prr = buildPermissonRoleRel(pv, rv, subject, handleDelete); + PermissionRoleRel prr = buildPermissonRoleRel(em, pv, rv, subject, handleDelete); prrl.add(prr); } } } } + + static public void buildPermissionRoleRel( + PermissionRole pr, + SubjectType subject, + List prrl, + boolean handleDelete) throws Exception { + EntityManagerFactory emf = null; + EntityManager em = null; + try { + emf = JpaStorageUtils.getEntityManagerFactory(JpaStorageUtils.CS_PERSISTENCE_UNIT); + em = emf.createEntityManager(); + em.getTransaction().begin(); + + buildPermissionRoleRel(em, pr, subject, prrl, handleDelete); + + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + if (em != null && em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + if (logger.isDebugEnabled()) { + logger.debug("Caught exception ", e); + } + throw e; + } finally { + if (em != null) { + JpaStorageUtils.releaseEntityManagerFactory(emf); + } + } + } /** * Builds a permisson role relationship for either 'create' or 'delete' @@ -128,7 +162,7 @@ public class PermissionRoleUtil { * @param handleDelete the handle delete * @return the permission role rel */ - static private PermissionRoleRel buildPermissonRoleRel(PermissionValue permissionValue, + static private PermissionRoleRel buildPermissonRoleRel(EntityManager em, PermissionValue permissionValue, RoleValue roleValue, SubjectType subject, boolean handleDelete) @@ -142,8 +176,13 @@ public class PermissionRoleUtil { // correctly. The import utility should create and store the permissions and roles BEFORE creating the relationships // PermissionValue pv = permissionValue; + + // + // This lookup is slow, do we really need it? + // + /* try { - Permission permission = (Permission)JpaStorageUtils.getEntity(pv.getPermissionId(), + Permission permission = (Permission)JpaStorageUtils.getEntity(em, pv.getPermissionId(), //FIXME: REM 4/5/2012 - To improve performance, we should use a passed in Permission instance Permission.class); if (permission != null) { // If the permission already exists, then use it to fill our the relation record @@ -152,14 +191,19 @@ public class PermissionRoleUtil { } catch (DocumentNotFoundException e) { // ignore this exception, pv is set to permissionValue; } + */ + // // Ensure we can find both the Permission and Role to relate. // FIXME: REM - This is a workaround until the Import utility creates Perm/Role relationships // correctly. The import utility should create and store the permissions and roles BEFORE creating the relationships // RoleValue rv = roleValue; + + /* + * This lookup is slow, can we avoid it? try { - Role role = (Role)JpaStorageUtils.getEntity(rv.getRoleId(), + Role role = (Role)JpaStorageUtils.getEntity(em, rv.getRoleId(), Role.class); if (role != null) { // If the role already exists, then use it to fill out the relation record @@ -168,6 +212,7 @@ public class PermissionRoleUtil { } catch (DocumentNotFoundException e) { // ignore this exception, rv is set to roleValue } + */ result = new PermissionRoleRel(); result.setPermissionId(pv.getPermissionId()); diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/ServiceConfigUtils.java b/services/common/src/main/java/org/collectionspace/services/common/config/ServiceConfigUtils.java index ff59b020b..be56353ed 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/config/ServiceConfigUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/config/ServiceConfigUtils.java @@ -26,13 +26,13 @@ package org.collectionspace.services.common.config; import java.util.ArrayList; import java.util.List; -import org.collectionspace.services.common.RepositoryClientConfigType; -import org.collectionspace.services.common.ServiceConfig; import org.collectionspace.services.common.document.DocumentHandler; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.tenant.TenantBindingType; -import org.collectionspace.services.common.types.PropertyItemType; -import org.collectionspace.services.common.types.PropertyType; +import org.collectionspace.services.config.RepositoryClientConfigType; +import org.collectionspace.services.config.ServiceConfig; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.TenantBindingType; +import org.collectionspace.services.config.types.PropertyItemType; +import org.collectionspace.services.config.types.PropertyType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,6 +59,9 @@ public class ServiceConfigUtils { Class c = tccl.loadClass(getDocumentHandlerClass(tenantBinding, serviceBinding)); if (DocumentHandler.class.isAssignableFrom(c)) { docHandler = (DocumentHandler) c.newInstance(); + if (logger.isDebugEnabled()) { + logger.debug("Created an instance of the DocumentHandler for: " + getDocumentHandlerClass(tenantBinding, serviceBinding)); + } } else { throw new IllegalArgumentException("Not of type " + DocumentHandler.class.getCanonicalName()); @@ -76,10 +79,10 @@ public class ServiceConfigUtils { ServiceBindingType serviceBinding) { if (serviceBinding.getDocumentHandler() == null || serviceBinding.getDocumentHandler().isEmpty()) { - String msg = "Missing documentHandler in service binding for " - + serviceBinding.getName() + " for tenant id=" + tenantBinding.getId() + String msg = "Missing documentHandler in service binding for service name \"" + + serviceBinding.getName() + "\" for tenant id=" + tenantBinding.getId() + " name=" + tenantBinding.getName(); - logger.error(msg); + logger.warn(msg); throw new IllegalStateException(msg); } return serviceBinding.getDocumentHandler().trim(); diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java b/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java index dfbb4fe1f..f6a4295d2 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java @@ -32,12 +32,12 @@ import java.util.Hashtable; import java.util.List; import org.apache.commons.io.FileUtils; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.ServiceObjectType; -import org.collectionspace.services.common.tenant.RepositoryDomainType; -import org.collectionspace.services.common.tenant.TenantBindingType; -import org.collectionspace.services.common.tenant.TenantBindingConfig; -import org.collectionspace.services.common.types.PropertyItemType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.service.ServiceObjectType; +import org.collectionspace.services.config.tenant.RepositoryDomainType; +import org.collectionspace.services.config.tenant.TenantBindingConfig; +import org.collectionspace.services.config.tenant.TenantBindingType; +import org.collectionspace.services.config.types.PropertyItemType; import ch.elca.el4j.services.xmlmerge.Configurer; import ch.elca.el4j.services.xmlmerge.config.AttributeMergeConfigurer; diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingUtils.java b/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingUtils.java index 05ee63bde..142c4ba64 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingUtils.java @@ -4,10 +4,11 @@ import java.util.ArrayList; import java.util.List; import org.collectionspace.services.common.context.ServiceBindingUtils; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.tenant.TenantBindingType; -import org.collectionspace.services.common.types.PropertyItemType; -import org.collectionspace.services.common.types.PropertyType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.TenantBindingType; +import org.collectionspace.services.config.types.PropertyItemType; +import org.collectionspace.services.config.types.PropertyType; + public class TenantBindingUtils { diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java index c114ba955..d3fa9f3a7 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java @@ -32,7 +32,6 @@ import javax.ws.rs.core.UriInfo; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.config.PropertyItemUtils; import org.collectionspace.services.common.config.ServiceConfigUtils; @@ -43,12 +42,13 @@ import org.collectionspace.services.common.document.ValidatorHandler; import org.collectionspace.services.common.security.SecurityContext; import org.collectionspace.services.common.security.SecurityContextImpl; import org.collectionspace.services.common.security.UnauthorizedException; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.tenant.RepositoryDomainType; -import org.collectionspace.services.common.tenant.TenantBindingType; -import org.collectionspace.services.common.types.PropertyItemType; -import org.collectionspace.services.common.types.PropertyType; +import org.collectionspace.services.config.ClientType; +import org.collectionspace.services.config.service.ObjectPartType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.RepositoryDomainType; +import org.collectionspace.services.config.tenant.TenantBindingType; +import org.collectionspace.services.config.types.PropertyItemType; +import org.collectionspace.services.config.types.PropertyType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java index 248ad43c8..934a90cac 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java @@ -5,12 +5,11 @@ import java.util.List; import java.util.Map; import org.collectionspace.services.common.config.PropertyItemUtils; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.ServiceObjectType; -import org.collectionspace.services.common.tenant.TenantBindingType; -import org.collectionspace.services.common.types.PropertyItemType; -import org.collectionspace.services.common.types.PropertyType; +import org.collectionspace.services.config.service.ObjectPartType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.service.ServiceObjectType; +import org.collectionspace.services.config.types.PropertyItemType; +import org.collectionspace.services.config.types.PropertyType; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java index 193167e1c..fee621f1b 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java @@ -29,15 +29,13 @@ import java.util.Map; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; -import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.ValidatorHandler; -import org.collectionspace.services.common.query.QueryContext; import org.collectionspace.services.common.security.SecurityContext; -import org.collectionspace.services.common.security.UnauthorizedException; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.common.service.ServiceBindingType; +import org.collectionspace.services.config.ClientType; +import org.collectionspace.services.config.service.ObjectPartType; +import org.collectionspace.services.config.service.ServiceBindingType; /** * diff --git a/services/common/src/main/java/org/collectionspace/services/common/datetime/DateTimeFormatUtils.java b/services/common/src/main/java/org/collectionspace/services/common/datetime/DateTimeFormatUtils.java index 373b9c0d4..eab1a2efa 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/datetime/DateTimeFormatUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/datetime/DateTimeFormatUtils.java @@ -34,7 +34,7 @@ import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.config.TenantBindingUtils; import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.tenant.TenantBindingType; +import org.collectionspace.services.config.tenant.TenantBindingType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java index 3037f290b..26899f784 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java @@ -23,8 +23,6 @@ */ package org.collectionspace.services.common.document; -import java.util.Calendar; - import java.lang.reflect.Array; import java.io.File; @@ -56,9 +54,9 @@ import javax.xml.transform.TransformerException; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.datetime.DateTimeFormatUtils; -import org.collectionspace.services.common.service.ObjectPartContentType; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.common.service.XmlContentType; +import org.collectionspace.services.config.service.ObjectPartContentType; +import org.collectionspace.services.config.service.ObjectPartType; +import org.collectionspace.services.config.service.XmlContentType; import org.dom4j.io.DOMReader; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; diff --git a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java index 656ccc5a0..7e0dfc172 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java @@ -90,7 +90,6 @@ import org.slf4j.LoggerFactory; import org.collectionspace.services.common.blob.BlobInput; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; -import org.collectionspace.services.common.service.ListResultField; import org.collectionspace.services.blob.BlobsCommon; import org.collectionspace.services.blob.DimensionSubGroup; import org.collectionspace.services.blob.DimensionSubGroupList; @@ -102,6 +101,8 @@ import org.collectionspace.services.jaxb.BlobJAXBSchema; import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.common.blob.BlobOutput; +import org.collectionspace.services.config.service.ListResultField; + //import org.collectionspace.ecm.platform.quote.api.QuoteManager; // TODO: Auto-generated Javadoc diff --git a/services/common/src/main/java/org/collectionspace/services/common/init/AddIndices.java b/services/common/src/main/java/org/collectionspace/services/common/init/AddIndices.java index 944fd2d57..6e62f1416 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/init/AddIndices.java +++ b/services/common/src/main/java/org/collectionspace/services/common/init/AddIndices.java @@ -26,11 +26,11 @@ import java.util.List; import javax.sql.DataSource; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.InitHandler.Params.Field; -import org.collectionspace.services.common.service.InitHandler.Params.Property; import org.collectionspace.services.common.storage.DatabaseProductType; import org.collectionspace.services.common.storage.JDBCTools; +import org.collectionspace.services.config.service.InitHandler.Params.Field; +import org.collectionspace.services.config.service.InitHandler.Params.Property; +import org.collectionspace.services.config.service.ServiceBindingType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/common/init/IInitHandler.java b/services/common/src/main/java/org/collectionspace/services/common/init/IInitHandler.java index fa7eccdfb..9eecbcfff 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/init/IInitHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/init/IInitHandler.java @@ -1,13 +1,13 @@ package org.collectionspace.services.common.init; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.InitHandler.Params.Field; -import org.collectionspace.services.common.service.InitHandler.Params.Property; - import java.util.List; import javax.sql.DataSource; +import org.collectionspace.services.config.service.InitHandler.Params.Field; +import org.collectionspace.services.config.service.InitHandler.Params.Property; +import org.collectionspace.services.config.service.ServiceBindingType; + /** * User: laramie * $LastChangedRevision$ diff --git a/services/common/src/main/java/org/collectionspace/services/common/init/InitHandler.java b/services/common/src/main/java/org/collectionspace/services/common/init/InitHandler.java index f99287b96..6318b633c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/init/InitHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/init/InitHandler.java @@ -17,16 +17,13 @@ */ package org.collectionspace.services.common.init; -import org.collectionspace.services.common.storage.DatabaseProductType; -import org.collectionspace.services.common.storage.JDBCTools; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.InitHandler.Params.Field; -import org.collectionspace.services.common.service.InitHandler.Params.Property; +import org.collectionspace.services.config.service.InitHandler.Params.Field; +import org.collectionspace.services.config.service.InitHandler.Params.Property; +import org.collectionspace.services.config.service.ServiceBindingType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.sql.ResultSet; import java.util.List; import javax.sql.DataSource; diff --git a/services/common/src/main/java/org/collectionspace/services/common/init/ModifyFieldDatatypes.java b/services/common/src/main/java/org/collectionspace/services/common/init/ModifyFieldDatatypes.java index c575579a7..8e1cca0f1 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/init/ModifyFieldDatatypes.java +++ b/services/common/src/main/java/org/collectionspace/services/common/init/ModifyFieldDatatypes.java @@ -33,11 +33,11 @@ import java.util.Map; import javax.sql.DataSource; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.InitHandler.Params.Field; -import org.collectionspace.services.common.service.InitHandler.Params.Property; import org.collectionspace.services.common.storage.DatabaseProductType; import org.collectionspace.services.common.storage.JDBCTools; +import org.collectionspace.services.config.service.InitHandler.Params.Field; +import org.collectionspace.services.config.service.InitHandler.Params.Property; +import org.collectionspace.services.config.service.ServiceBindingType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java index 64af8a48c..9d9d508cc 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java +++ b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java @@ -24,9 +24,9 @@ package org.collectionspace.services.common.repository; import java.util.Hashtable; -import org.collectionspace.services.common.RepositoryClientConfigType; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.config.ServicesConfigReaderImpl; +import org.collectionspace.services.config.RepositoryClientConfigType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java index c1b4b9ed0..6187754a8 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java +++ b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java @@ -124,7 +124,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn // if (resName.equalsIgnoreCase(ACCOUNT_PERMISSIONS) != true) { //see comment immediately above AuthZ authZ = AuthZ.get(); - CSpaceResource res = new URIResourceImpl(resName, httpMethod); + CSpaceResource res = new URIResourceImpl(AuthN.get().getCurrentTenantId(), resName, httpMethod); if (authZ.isAccessAllowed(res) == false) { logger.error("Access to " + res.getId() + " is NOT allowed to " + " user=" + AuthN.get().getUserId()); @@ -138,7 +138,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn // if (uriPath.endsWith(WorkflowClient.SERVICE_PATH_COMPONENT) == true) { String workflowSubResName = SecurityUtils.getResourceName(request.getUri()); - res = new URIResourceImpl(workflowSubResName, httpMethod); + res = new URIResourceImpl(AuthN.get().getCurrentTenantId(), workflowSubResName, httpMethod); if (authZ.isAccessAllowed(res) == false) { logger.error("Access to " + resName + ":" + res.getId() + " is NOT allowed to " + " user=" + AuthN.get().getUserId()); diff --git a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java index 76156efad..9d0df0934 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java @@ -32,8 +32,7 @@ import java.util.StringTokenizer; import org.collectionspace.services.authorization.AuthZ; import org.collectionspace.services.authorization.CSpaceResource; import org.collectionspace.services.authorization.URIResourceImpl; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.ServiceObjectType; +import org.collectionspace.services.config.service.ServiceBindingType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; @@ -202,7 +201,7 @@ public class SecurityUtils { AuthZ authZ = AuthZ.get(); for(ServiceBindingType binding:serviceBindings) { String resourceName = binding.getName().toLowerCase(); - CSpaceResource res = new URIResourceImpl(resourceName, "GET"); + CSpaceResource res = new URIResourceImpl(AuthN.get().getCurrentTenantId(), resourceName, "GET"); if (authZ.isAccessAllowed(res) == true) { readableList.add(binding); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageUtils.java b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageUtils.java index 01153762e..9013358da 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageUtils.java @@ -63,18 +63,12 @@ public class JpaStorageUtils { /** The Constant CS_PERSISTENCE_UNIT. */ public final static String CS_PERSISTENCE_UNIT = "org.collectionspace.services"; - private final static String CS_AUTHZ_PERSISTENCE_UNIT = "org.collectionspace.services.authorization"; + public static String CS_AUTHZ_PERSISTENCE_UNIT = "org.collectionspace.services.authorization"; public final static String CS_CURRENT_USER = "0"; // This is the column name for ID field of all the JPA objects public static final String CSID_LABEL = "csid"; - - /** - * getEntity for given id and class - * @param id - * @param entityClazz - * @return null if entity is not found - */ + public static Object getEntity(String id, Class entityClazz) throws DocumentNotFoundException { EntityManagerFactory emf = null; @@ -92,6 +86,7 @@ public class JpaStorageUtils { } return entityFound; } + public static Object getEntity(long id, Class entityClazz) throws DocumentNotFoundException { @@ -119,7 +114,7 @@ public class JpaStorageUtils { * @param entityClazz * @return */ - public static Object getEntity(EntityManager em, String id, Class entityClazz) { + public static Object getEntity(EntityManager em, String id, Class entityClazz) throws DocumentNotFoundException { if (entityClazz == null) { String msg = "Not constructed with JpaStorageClientImpl(entityClazz) ctor"; logger.error(msg); @@ -227,7 +222,7 @@ public class JpaStorageUtils { String userId = account.getUserId(); String currentUserId = AuthN.get().getUserId(); if (currentUserId.equalsIgnoreCase(userId) == false) { - CSpaceResource res = new URIResourceImpl("accounts", "GET"); + CSpaceResource res = new URIResourceImpl(AuthN.get().getCurrentTenantId(), "accounts", "GET"); if (AuthZ.get().isAccessAllowed(res) == false) { String msg = "Access to the permissions for the account with csid = " + csid + " is NOT allowed for " + " user=" + currentUserId; @@ -296,12 +291,10 @@ public class JpaStorageUtils { return result; } - public static Object getEnityByKey(String entityName, String key, String value, + public static Object getEnityByKey(EntityManager em, String entityName, String key, String value, String tenantId) { - EntityManagerFactory emf = null; - EntityManager em = null; - Object o = null; - + Object result = null; + if (entityName == null) { throw new IllegalArgumentException("entityName is required"); } @@ -311,24 +304,36 @@ public class JpaStorageUtils { if (tenantId == null) { throw new IllegalArgumentException("tenantId is required"); } + + StringBuilder queryStrBldr = new StringBuilder("SELECT a FROM "); + queryStrBldr.append(entityName); + queryStrBldr.append(" a"); + queryStrBldr.append(" WHERE " + key + " = :" + key); + boolean csAdmin = SecurityUtils.isCSpaceAdmin(); + if (!csAdmin) { + queryStrBldr.append(" AND tenantId = :tenantId"); + } + String queryStr = queryStrBldr.toString(); //for debugging + Query q = em.createQuery(queryStr); + q.setParameter(key, value); + if (!csAdmin) { + q.setParameter("tenantId", tenantId); + } + result = q.getSingleResult(); + + return result; + } + + public static Object getEnityByKey(String entityName, String key, String value, + String tenantId) { + EntityManagerFactory emf = null; + EntityManager em = null; + Object o = null; + try { - StringBuilder queryStrBldr = new StringBuilder("SELECT a FROM "); - queryStrBldr.append(entityName); - queryStrBldr.append(" a"); - queryStrBldr.append(" WHERE " + key + " = :" + key); - boolean csAdmin = SecurityUtils.isCSpaceAdmin(); - if (!csAdmin) { - queryStrBldr.append(" AND tenantId = :tenantId"); - } emf = getEntityManagerFactory(); em = emf.createEntityManager(); - String queryStr = queryStrBldr.toString(); //for debugging - Query q = em.createQuery(queryStr); - q.setParameter(key, value); - if (!csAdmin) { - q.setParameter("tenantId", tenantId); - } - o = q.getSingleResult(); + o = getEnityByKey(em, entityName, key, value, tenantId); } catch (NoResultException nre) { if (em != null && em.getTransaction().isActive()) { em.getTransaction().rollback(); @@ -342,7 +347,7 @@ public class JpaStorageUtils { em.getTransaction().rollback(); } if (logger.isDebugEnabled()) { - logger.debug("could not find entity(2) with id=" + key, e); + logger.debug("Could not find entity with id=" + key, e); } //returns null } finally { @@ -423,6 +428,37 @@ public class JpaStorageUtils { return o; } + public static Object getEntity(EntityManager em, String entityName, + String whereClause, HashMap paramBindings) { + Object result = null; + + if (entityName == null) { + throw new IllegalArgumentException("entityName is required"); + } + if (whereClause == null) { + throw new IllegalArgumentException("whereClause is required"); + } + + StringBuilder queryStrBldr = new StringBuilder("SELECT a FROM "); + queryStrBldr.append(entityName); + queryStrBldr.append(" a"); + queryStrBldr.append(" " + whereClause); + + String queryStr = queryStrBldr.toString(); //for debugging + Query q = em.createQuery(queryStr); + for (String paramName : paramBindings.keySet()) { + q.setParameter(paramName, paramBindings.get(paramName)); + } + + result = q.getSingleResult(); + + if (result == null) { + logger.debug("Call to getEntity() returned empty set."); + } + + return result; + } + /** * getEntity using given where clause with given param bindings * @param entityName @@ -432,29 +468,13 @@ public class JpaStorageUtils { */ public static Object getEntity(String entityName, String whereClause, HashMap paramBindings) { - if (entityName == null) { - throw new IllegalArgumentException("entityName is required"); - } - if (whereClause == null) { - throw new IllegalArgumentException("whereClause is required"); - } - EntityManagerFactory emf = null; - EntityManager em = null; + EntityManagerFactory emf = null; + EntityManager em = null; Object o = null; try { - StringBuilder queryStrBldr = new StringBuilder("SELECT a FROM "); - queryStrBldr.append(entityName); - queryStrBldr.append(" a"); - queryStrBldr.append(" " + whereClause); - //FIXME it would be nice to insert tenant id in the where clause here emf = getEntityManagerFactory(); em = emf.createEntityManager(); - String queryStr = queryStrBldr.toString(); //for debugging - Query q = em.createQuery(queryStr); - for (String paramName : paramBindings.keySet()) { - q.setParameter(paramName, paramBindings.get(paramName)); - } - o = q.getSingleResult(); + o = getEntity(em, entityName, whereClause, paramBindings); } catch (NoResultException nre) { if (em != null && em.getTransaction().isActive()) { em.getTransaction().rollback(); @@ -523,8 +543,33 @@ public class JpaStorageUtils { */ public static EntityManagerFactory getEntityManagerFactory( String persistenceUnit) { - return Persistence.createEntityManagerFactory(persistenceUnit); + EntityManagerFactory result = null; + + try { + result = Persistence.createEntityManagerFactory(persistenceUnit); + } catch (javax.persistence.PersistenceException e) { + logger.warn("Could not find a persistence unit for: " + persistenceUnit); + } + + // + // Try using a backup persistence unit if the specified one is not available and log a warning + // + if (result == null && !persistenceUnit.equalsIgnoreCase(CS_PERSISTENCE_UNIT)) try { + result = Persistence.createEntityManagerFactory(CS_PERSISTENCE_UNIT); + } catch (javax.persistence.PersistenceException e) { + logger.warn("Could not find a persistence unit for: " + CS_PERSISTENCE_UNIT); + } + + // + // One more try. + // + if (result == null && !persistenceUnit.equalsIgnoreCase(CS_AUTHZ_PERSISTENCE_UNIT)) try { + result = Persistence.createEntityManagerFactory(CS_AUTHZ_PERSISTENCE_UNIT); + } catch (javax.persistence.PersistenceException e) { + logger.warn("Could not find a persistence unit for: " + CS_AUTHZ_PERSISTENCE_UNIT); + } + return result; } /** diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index 92a016006..534d4b36d 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -59,7 +59,7 @@ import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.common.security.SecurityUtils; -import org.collectionspace.services.common.service.ServiceBindingType; +import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.util.NuxeoUtils; diff --git a/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java index 59b334800..14a1e7801 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java @@ -24,29 +24,20 @@ package org.collectionspace.services.common.workflow.service.nuxeo; import java.util.HashMap; -import java.util.List; import java.util.Map; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import org.collectionspace.services.client.PayloadInputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.common.context.MultipartServiceContext; import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.document.BadRequestException; -import org.collectionspace.services.common.document.DocumentNotFoundException; -import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.document.DocumentHandler.Action; -import org.collectionspace.services.common.service.ObjectPartType; import org.collectionspace.services.common.workflow.jaxb.WorkflowJAXBSchema; +import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.collectionspace.services.workflow.WorkflowCommon; -import org.dom4j.Element; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.slf4j.Logger; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java index 8d13e45c7..4e1ada976 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java @@ -32,16 +32,13 @@ import java.util.List; import org.collectionspace.services.common.ReflectionMapper; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.repository.RepositoryClient; -import org.collectionspace.services.common.repository.RepositoryClientFactory; -import org.collectionspace.services.common.service.ListResultField; -import org.collectionspace.services.common.service.DocHandlerParams; -import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.common.context.MultipartServiceContext; -import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.datetime.DateTimeFormatUtils; import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.config.service.DocHandlerParams; +import org.collectionspace.services.config.service.ListResultField; +import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java index ae1ee63e2..fbb14e66f 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java @@ -27,7 +27,8 @@ import java.io.File; import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; -import org.collectionspace.services.common.RepositoryClientConfigType; + +import org.collectionspace.services.config.RepositoryClientConfigType; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.repository.RepositoryInstance; 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 1fdf95492..bda350a79 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 @@ -2,27 +2,17 @@ package org.collectionspace.services.nuxeo.client.java; import java.io.File; import java.io.IOException; -import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; -import javax.servlet.ServletConfig; import javax.servlet.ServletContext; -//import org.collectionspace.services.common.RepositoryClientConfigType; -import org.collectionspace.services.common.RepositoryClientConfigType; +import org.collectionspace.services.config.RepositoryClientConfigType; import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.api.CoreInstance; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.repository.Repository; import org.nuxeo.ecm.core.api.repository.RepositoryInstance; -import org.nuxeo.ecm.core.api.repository.RepositoryManager; -import org.nuxeo.ecm.core.client.DefaultLoginHandler; -import org.nuxeo.ecm.core.client.NuxeoApp; -//import org.nuxeo.ecm.core.client.NuxeoClient; import org.nuxeo.osgi.application.FrameworkBootstrap; -import org.nuxeo.runtime.api.Framework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java index 2949e2131..bada25bd7 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java @@ -5,7 +5,7 @@ import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; -import org.collectionspace.services.common.RepositoryClientConfigType; +import org.collectionspace.services.config.RepositoryClientConfigType; import org.nuxeo.ecm.core.api.CoreInstance; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java index 50892eee9..343d9f6d7 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java @@ -24,7 +24,6 @@ package org.collectionspace.services.nuxeo.client.java; import java.util.ArrayList; -import java.util.Collection; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; @@ -44,26 +43,22 @@ import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.context.JaxRsContext; import org.collectionspace.services.common.context.MultipartServiceContext; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.datetime.DateTimeFormatUtils; import org.collectionspace.services.common.document.BadRequestException; -import org.collectionspace.services.common.document.DocumentException; -import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.document.DocumentFilter; -import org.collectionspace.services.common.document.DocumentHandler.Action; import org.collectionspace.services.common.profile.Profiler; import org.collectionspace.services.common.security.SecurityUtils; -import org.collectionspace.services.common.service.ObjectPartType; import org.collectionspace.services.common.storage.jpa.JpaStorageUtils; import org.collectionspace.services.common.vocabulary.RefNameUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo; +import org.collectionspace.services.config.service.ObjectPartType; import org.dom4j.Element; import org.nuxeo.ecm.core.api.DocumentModel; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteSubItemDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteSubItemDocumentModelHandlerImpl.java index 37856ad86..8ce7ccd12 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteSubItemDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteSubItemDocumentModelHandlerImpl.java @@ -33,7 +33,7 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentUtils; -import org.collectionspace.services.common.service.ObjectPartType; +import org.collectionspace.services.config.service.ObjectPartType; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import javax.ws.rs.core.MediaType; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/TenantRepository.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/TenantRepository.java index e5b7e1844..93fa7e6a8 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/TenantRepository.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/TenantRepository.java @@ -28,14 +28,14 @@ import java.util.Hashtable; import javax.security.auth.login.LoginContext; import org.collectionspace.services.common.ServiceMain; -import org.collectionspace.services.common.ClientType; -import org.collectionspace.services.common.RepositoryClientConfigType; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.repository.RepositoryClientFactory; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.tenant.TenantBindingType; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; -import org.collectionspace.services.common.tenant.RepositoryDomainType; +import org.collectionspace.services.config.ClientType; +import org.collectionspace.services.config.RepositoryClientConfigType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.tenant.RepositoryDomainType; +import org.collectionspace.services.config.tenant.TenantBindingType; import org.nuxeo.runtime.api.Framework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/AbstractConfigReaderImpl.java b/services/config/src/main/java/org/collectionspace/services/common/config/AbstractConfigReaderImpl.java similarity index 100% rename from services/common/src/main/java/org/collectionspace/services/common/config/AbstractConfigReaderImpl.java rename to services/config/src/main/java/org/collectionspace/services/common/config/AbstractConfigReaderImpl.java diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/ConfigReader.java b/services/config/src/main/java/org/collectionspace/services/common/config/ConfigReader.java similarity index 100% rename from services/common/src/main/java/org/collectionspace/services/common/config/ConfigReader.java rename to services/config/src/main/java/org/collectionspace/services/common/config/ConfigReader.java diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/PropertyItemUtils.java b/services/config/src/main/java/org/collectionspace/services/common/config/PropertyItemUtils.java similarity index 95% rename from services/common/src/main/java/org/collectionspace/services/common/config/PropertyItemUtils.java rename to services/config/src/main/java/org/collectionspace/services/common/config/PropertyItemUtils.java index dd15f33c8..154045b74 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/config/PropertyItemUtils.java +++ b/services/config/src/main/java/org/collectionspace/services/common/config/PropertyItemUtils.java @@ -3,8 +3,8 @@ package org.collectionspace.services.common.config; import java.util.ArrayList; import java.util.List; -import org.collectionspace.services.common.types.PropertyItemType; -import org.collectionspace.services.common.types.PropertyType; +import org.collectionspace.services.config.types.PropertyItemType; +import org.collectionspace.services.config.types.PropertyType; public class PropertyItemUtils { diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java b/services/config/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java similarity index 96% rename from services/common/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java rename to services/config/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java index a576f4a5c..f5ab1c02f 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java +++ b/services/config/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java @@ -24,7 +24,9 @@ package org.collectionspace.services.common.config; import java.io.File; -import org.collectionspace.services.common.*; + +import org.collectionspace.services.config.ClientType; +import org.collectionspace.services.config.ServiceConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/common/src/main/resources/service-config.xsd b/services/config/src/main/resources/service-config.xsd similarity index 93% rename from services/common/src/main/resources/service-config.xsd rename to services/config/src/main/resources/service-config.xsd index 514d3fd17..84381ba6c 100644 --- a/services/common/src/main/resources/service-config.xsd +++ b/services/config/src/main/resources/service-config.xsd @@ -12,13 +12,13 @@ - + diff --git a/services/common/src/main/resources/service.xsd b/services/config/src/main/resources/service.xsd similarity index 98% rename from services/common/src/main/resources/service.xsd rename to services/config/src/main/resources/service.xsd index e7fbbb1d3..1c30a8f37 100644 --- a/services/common/src/main/resources/service.xsd +++ b/services/config/src/main/resources/service.xsd @@ -21,14 +21,14 @@ --> - + diff --git a/services/common/src/main/resources/tenant.xsd b/services/config/src/main/resources/tenant.xsd similarity index 91% rename from services/common/src/main/resources/tenant.xsd rename to services/config/src/main/resources/tenant.xsd index 04cee10c3..84d86f1a6 100644 --- a/services/common/src/main/resources/tenant.xsd +++ b/services/config/src/main/resources/tenant.xsd @@ -15,15 +15,15 @@ --> - - + + diff --git a/services/common/src/main/resources/types.xsd b/services/config/src/main/resources/types.xsd similarity index 91% rename from services/common/src/main/resources/types.xsd rename to services/config/src/main/resources/types.xsd index be364649f..ddf3a6d8e 100644 --- a/services/common/src/main/resources/types.xsd +++ b/services/config/src/main/resources/types.xsd @@ -15,8 +15,8 @@ --> + config common-api authentication + authorization-common authorization blob client diff --git a/services/relation/service/pom.xml b/services/relation/service/pom.xml index 07496cd9c..5e618f7b1 100644 --- a/services/relation/service/pom.xml +++ b/services/relation/service/pom.xml @@ -7,12 +7,16 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.relation.service services.relation.service jar + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + org.collectionspace.services org.collectionspace.services.common diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java index ebd2323fc..0405bbb8e 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java @@ -33,17 +33,19 @@ import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; -import org.collectionspace.services.common.context.ServiceBindingUtils; + import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.InvalidDocumentException; import org.collectionspace.services.common.relation.RelationJAXBSchema; import org.collectionspace.services.common.relation.nuxeo.RelationConstants; +import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; +import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.repository.RepositoryClientFactory; -import org.collectionspace.services.common.service.ServiceBindingType; + import org.collectionspace.services.nuxeo.util.NuxeoUtils; + import org.collectionspace.services.relation.RelationsCommon; import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.relation.RelationsCommonList.RelationListItem; @@ -52,14 +54,16 @@ import org.collectionspace.services.relation.RelationsCommonList.RelationListIte import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.client.LocationAuthorityClient; -import org.collectionspace.services.client.TaxonomyAuthorityClient; import org.collectionspace.services.client.PlaceAuthorityClient; +import org.collectionspace.services.client.TaxonomyAuthorityClient; import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.relation.RelationsDocListItem; + import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; diff --git a/services/report/service/pom.xml b/services/report/service/pom.xml index 54a899aec..841650270 100644 --- a/services/report/service/pom.xml +++ b/services/report/service/pom.xml @@ -8,12 +8,16 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.report.service services.report.service jar + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + org.collectionspace.services org.collectionspace.services.authority.jaxb diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java index 3192d519d..79ed1e968 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java @@ -23,46 +23,24 @@ */ package org.collectionspace.services.report; -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JasperExportManager; -import net.sf.jasperreports.engine.JasperFillManager; -import net.sf.jasperreports.engine.JasperPrint; - import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.jaxb.InvocableJAXBSchema; import org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler; -import org.collectionspace.services.ReportJAXBSchema; 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.ResourceBase; -import org.collectionspace.services.common.ResourceMap; -import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.ServiceMessages; -import org.collectionspace.services.common.config.ConfigReader; import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.document.BadRequestException; import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentHandler; -import org.collectionspace.services.common.document.DocumentNotFoundException; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.invocable.Invocable; import org.collectionspace.services.common.invocable.InvocationContext; -import org.collectionspace.services.common.invocable.InvocationResults; -import org.collectionspace.services.common.invocable.Invocable.InvocationError; import org.collectionspace.services.common.query.QueryManager; -import org.collectionspace.services.common.security.UnauthorizedException; import org.collectionspace.services.common.storage.JDBCTools; -import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.nuxeo.ecm.core.api.DocumentModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.security.auth.login.LoginException; -import javax.sql.DataSource; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -70,16 +48,8 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; @Path(ReportClient.SERVICE_PATH) @Consumes("application/xml") diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java index da78c16dc..6e6dbf030 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java @@ -41,13 +41,10 @@ import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import org.collectionspace.services.ReportJAXBSchema; -import org.collectionspace.services.report.ReportResource; import org.collectionspace.services.report.ReportsCommon; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMain; -import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.config.ConfigReader; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.BadRequestException; diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportPostInitHandler.java b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportPostInitHandler.java index ea2efeb80..34121f4c5 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportPostInitHandler.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportPostInitHandler.java @@ -26,14 +26,15 @@ import java.util.List; import javax.sql.DataSource; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.common.init.IInitHandler; import org.collectionspace.services.common.init.InitHandler; -import org.collectionspace.services.common.service.InitHandler.Params.Field; -import org.collectionspace.services.common.service.InitHandler.Params.Property; import org.collectionspace.services.common.storage.DatabaseProductType; import org.collectionspace.services.common.storage.JDBCTools; +import org.collectionspace.services.config.service.InitHandler.Params.Field; +import org.collectionspace.services.config.service.InitHandler.Params.Property; +import org.collectionspace.services.config.service.ServiceBindingType; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/servicegroup/service/pom.xml b/services/servicegroup/service/pom.xml index 1a87ab720..9b8ab53ee 100644 --- a/services/servicegroup/service/pom.xml +++ b/services/servicegroup/service/pom.xml @@ -8,12 +8,16 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.servicegroup.service services.servicegroup.service jar + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + org.collectionspace.services org.collectionspace.services.common diff --git a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java index dcd5ea369..1e26f73a3 100644 --- a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java +++ b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java @@ -52,8 +52,8 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.repository.RepositoryClientFactory; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.ServiceObjectType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.service.ServiceObjectType; import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.servicegroup.nuxeo.ServiceGroupDocumentModelHandler; diff --git a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java index 207321b81..ed56291be 100644 --- a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java +++ b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java @@ -54,8 +54,8 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.security.SecurityUtils; -import org.collectionspace.services.common.service.ServiceBindingType; -import org.collectionspace.services.common.service.ServiceObjectType; +import org.collectionspace.services.config.service.ServiceBindingType; +import org.collectionspace.services.config.service.ServiceObjectType; import org.collectionspace.services.servicegroup.ServicegroupsCommon; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList;