]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5678-D: Adjusting Service's XML merge of bindings to deal with new Application...
authorRichard Millet <remillet@berkeley.edu>
Sat, 13 Jul 2013 00:02:25 +0000 (17:02 -0700)
committerRichard Millet <remillet@berkeley.edu>
Sat, 13 Jul 2013 00:02:25 +0000 (17:02 -0700)
13 files changed:
services/authorization-mgt/import/pom.xml
services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java
services/common-api/src/main/java/org/collectionspace/services/common/api/JEEServerDeployment.java
services/common/pom.xml
services/common/src/main/cspace/config/services/service-config.xml
services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java
services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java
services/config/pom.xml
services/config/src/main/java/org/collectionspace/services/common/config/AbstractConfigReaderImpl.java
services/config/src/main/java/org/collectionspace/services/common/config/ConfigReader.java
services/config/src/main/java/org/collectionspace/services/common/config/ServicesConfigReaderImpl.java
services/config/src/main/resources/service-config.xsd
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java

index 7efc29c429aa874ab0b2c0ac2c51f894b8056ef5..e9345e0ef2322afea2e48c0cbf75c08b556ab144 100644 (file)
             <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>\r
+        <dependency>\r
+                   <groupId>org.collectionspace.services</groupId>\r
+               <artifactId>org.collectionspace.services.config</artifactId>\r
+                       <version>${project.version}</version>\r
+        </dependency>        \r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.common</artifactId>\r
index b45d1defd28c02d842fa6e08fbd4946494533861..bfd913991144f774f6e801920633f1df94392503 100644 (file)
@@ -49,6 +49,7 @@ import org.collectionspace.services.authorization.RoleValue;
 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.ServicesConfigReaderImpl;
 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
 import org.collectionspace.services.common.security.SecurityUtils;
 import org.collectionspace.services.config.service.ServiceBindingType;
@@ -88,9 +89,13 @@ public class AuthorizationGen {
        private List<Role> allRoleList;
 
     public void initialize(String tenantRootDirPath) throws Exception {
+       ServicesConfigReaderImpl servicesConfigReader = new ServicesConfigReaderImpl(tenantRootDirPath);
+        servicesConfigReader.read();        
+        Boolean useAppGeneratedBindings = servicesConfigReader.getConfiguration().isUseAppGeneratedTenantBindings();
+
         TenantBindingConfigReaderImpl tenantBindingConfigReader =
                 new TenantBindingConfigReaderImpl(tenantRootDirPath);
-        tenantBindingConfigReader.read();
+        tenantBindingConfigReader.read(useAppGeneratedBindings);
         tenantBindings = tenantBindingConfigReader.getTenantBindings();
         cspaceTenantMgmntRole = buildTenantMgmntRole();
 
index 8ebd399bbb2541a2151d424358146e1730e12fca..fc6108180a80a61c766280ab73638627e3bd2e3e 100644 (file)
@@ -1,7 +1,17 @@
 package org.collectionspace.services.common.api;
 
+import java.io.File;
+
 public interface JEEServerDeployment {
+    final public static String CSPACE_DIR_NAME = "cspace";
+    final public static String CONFIG_DIR_PATH = "config" + File.separator + "services";
+
+    final public static String TENANT_BINDINGS_FILENAME_PREFIX = "tenant-bindings";
+    final public static String TENANT_BINDINGS_PROTOTYPE_FILENAME = TENANT_BINDINGS_FILENAME_PREFIX + "-proto.xml";
+    final public static String TENANT_BINDINGS_ROOTDIRNAME = "tenants";
+       
        public final static String NUXEO_CLIENT_DIR = "nuxeo-client";
        public final static String NUXEO_SERVER_DIR = "nuxeo-server";
-       public final static String NUXEO_SERVER_PLUGINS_DIR = NUXEO_SERVER_DIR + "/" + "plugins";
+       public final static String NUXEO_PLUGINS_DIR = "plugins";
+       public final static String NUXEO_SERVER_PLUGINS_DIR = NUXEO_SERVER_DIR + File.separator + NUXEO_PLUGINS_DIR;
 }
index 8ce480629be0c87fd4360d7c658f85e6b439e963..7551c8f4b3e4aa2e58b91fc2c6d9d50e73de2404 100644 (file)
             <artifactId>spring-security-acl</artifactId>\r
             <version>${spring.security.version}</version>\r
             <scope>provided</scope>\r
-        </dependency>        \r
+        </dependency>\r
+        <dependency>\r
+                   <groupId>org.collectionspace.services</groupId>\r
+               <artifactId>org.collectionspace.services.common-api</artifactId>\r
+                       <version>${project.version}</version>\r
+        </dependency>\r
     </dependencies>\r
 \r
     <repositories>\r
index d4d669e4b39d657fdc32ae7d4f68f5089c5d39c8..dd9bb6ed8d47a7ed163a900ac28934d8ff5a67ac 100644 (file)
@@ -14,6 +14,7 @@
                      xmlns:types='http://collectionspace.org/services/config/types'
                      xsi:schemaLocation='http://collectionspace.org/services/config ../resources/common.xsd'>
 
+       <use-app-generated-tenant-bindings>true</use-app-generated-tenant-bindings>
     <!-- name of the repository client is referred in each service binding -->
     <repository-client name="nuxeo-java" default="true">
         <!-- ip of network interface to which Nuxeo server is listening on -->
index 111123a7212a7d27772ddddb44f03ec6531f75bc..2bf566b30a5a489f7e5acdeb36f6536b99062122 100644 (file)
@@ -68,6 +68,7 @@ public class ServiceMain {
     private UriTemplateRegistry uriTemplateRegistry = new UriTemplateRegistry();\r
     \r
     private static final String SERVER_HOME_PROPERTY = "catalina.home";\r
+       private static final boolean USE_APP_GENERATED_CONFIG = true;\r
     \r
     private ServiceMain() {\r
        //empty\r
@@ -207,10 +208,11 @@ public class ServiceMain {
     private void readConfig() throws Exception {\r
         //read service config\r
         servicesConfigReader = new ServicesConfigReaderImpl(getServerRootDir());\r
-        servicesConfigReader.read();\r
-\r
+        servicesConfigReader.read(USE_APP_GENERATED_CONFIG);\r
+        \r
+        Boolean useAppGeneratedBindings = servicesConfigReader.getConfiguration().isUseAppGeneratedTenantBindings();\r
         tenantBindingConfigReader = new TenantBindingConfigReaderImpl(getServerRootDir()); \r
-        tenantBindingConfigReader.read();\r
+        tenantBindingConfigReader.read(useAppGeneratedBindings);\r
     }\r
 \r
     private void propagateConfiguredProperties() {\r
index 103cecc2f483df708273f1b7086f5a12b04669dd..6f1e41f200bd6ded6f099eaeae8c72ba7c5853c2 100644 (file)
@@ -33,6 +33,8 @@ import java.util.Hashtable;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
+import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.config.service.ServiceObjectType;
@@ -57,10 +59,7 @@ import org.slf4j.LoggerFactory;
 public class TenantBindingConfigReaderImpl
         extends AbstractConfigReaderImpl<List<TenantBindingType>> {
     final private static String TENANT_BINDINGS_ERROR = "Tenant bindings error: ";
-    final private static String TENANT_BINDINGS_ROOTDIRNAME = "tenants";
-    final private static String TENANT_BINDINGS_FILENAME_PREFIX = "tenant-bindings";
-    final private static String TENANT_BINDINGS_PROTOTYPE_FILENAME = TENANT_BINDINGS_FILENAME_PREFIX + "-proto.xml";
-    final private static String TENANT_BINDINGS_DELTA_FILENAME = TENANT_BINDINGS_FILENAME_PREFIX + ".delta.xml";
+    final private static String TENANT_BINDINGS_DELTA_FILENAME = JEEServerDeployment.TENANT_BINDINGS_FILENAME_PREFIX + ".delta.xml";
     final private static String MERGED_SUFFIX = ".merged.xml";
     
     final Logger logger = LoggerFactory.getLogger(TenantBindingConfigReaderImpl.class);
@@ -93,7 +92,7 @@ public class TenantBindingConfigReaderImpl
                File result = null;
                String errMessage = null;
                try {
-                       String tenantsRootPath = getConfigRootDir() + File.separator + TENANT_BINDINGS_ROOTDIRNAME;
+                       String tenantsRootPath = getConfigRootDir() + File.separator + JEEServerDeployment.TENANT_BINDINGS_ROOTDIRNAME;
                        File tenantsRootDir = new File(tenantsRootPath);
                        if (tenantsRootDir.exists() == true) {
                                result = tenantsRootDir;
@@ -145,7 +144,7 @@ public class TenantBindingConfigReaderImpl
                if (result != null) {
                        File outputDir = deltaFile.getParentFile();
                        String mergedFileName = outputDir.getAbsolutePath() + File.separator +
-                               TenantBindingConfigReaderImpl.TENANT_BINDINGS_FILENAME_PREFIX + MERGED_SUFFIX;                  
+                                       JEEServerDeployment.TENANT_BINDINGS_FILENAME_PREFIX + MERGED_SUFFIX;                    
                        File mergedOutFile = new File(mergedFileName);
                        try {
                                FileUtils.copyInputStreamToFile(result, mergedOutFile);
@@ -160,20 +159,20 @@ public class TenantBindingConfigReaderImpl
        }
 
     @Override
-    public void read() throws Exception {
+    public void read(boolean useAppGeneratedBindings) throws Exception {
        String tenantsRootPath = getTenantsRootDir().getAbsolutePath();
-        read(tenantsRootPath);
+        read(tenantsRootPath, useAppGeneratedBindings);
     }
 
     @Override
-    public void read(String tenantRootDirPath) throws Exception {
+    public void read(String tenantRootDirPath, boolean useAppGeneratedBindings) throws Exception {
         File tenantsRootDir = new File(tenantRootDirPath);
         if (tenantsRootDir.exists() == false) {
                throw new Exception("Cound not find tenant bindings root directory: " +
                                tenantRootDirPath);
         }
         File protoBindingsFile = new File(tenantRootDirPath + File.separator +
-                       TENANT_BINDINGS_PROTOTYPE_FILENAME);
+                       JEEServerDeployment.TENANT_BINDINGS_PROTOTYPE_FILENAME);
         
         List<File> tenantDirs = getDirectories(tenantsRootDir);
         tenantBindingTypeList = readTenantConfigs(protoBindingsFile, tenantDirs);
index bd7943e510a237b24b0d863be9d5437d98e3ec10..c8eadb8a4a821a1203f1ab6d939b36c433a7e228 100644 (file)
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics-runtime</artifactId>
                </dependency>
-        
+               <dependency>
+                   <groupId>org.collectionspace.services</groupId>
+                       <artifactId>org.collectionspace.services.common-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
     </dependencies>
 
     <repositories>
index eb3439c2b0cb908d0231116f20cb60eb957c39d9..8afe5879515ac1dde1725be2a17f4bc45c9d04bb 100644 (file)
@@ -34,48 +34,53 @@ import java.util.List;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
+
+import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * AbstractConfigReader
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * 
+ * $LastChangedRevision: $ $LastChangedDate: $
  */
-public abstract class AbstractConfigReaderImpl<T>
-        implements ConfigReader<T> {
+public abstract class AbstractConfigReaderImpl<T> implements ConfigReader<T> {
 
-    private final Logger logger = LoggerFactory.getLogger(AbstractConfigReaderImpl.class);
-    private String serverRootDir;
+       private final Logger logger = LoggerFactory
+                       .getLogger(AbstractConfigReaderImpl.class);
+       private String serverRootDir;
 
-    AbstractConfigReaderImpl(String serverRootDir) {
-        this.serverRootDir = serverRootDir;
-    }
+       AbstractConfigReaderImpl(String serverRootDir) {
+               this.serverRootDir = serverRootDir;
+       }
 
-    @Override
-    abstract public String getFileName();
+       @Override
+       abstract public String getFileName();
 
-    @Override
-    abstract public void read() throws Exception;
+       @Override
+       abstract public void read(boolean useAppGeneratedBindings) throws Exception;
 
-    @Override
-    abstract public void read(String configFile) throws Exception;
+       @Override
+       abstract public void read(String configFile, boolean useAppGeneratedBindings) throws Exception;
 
-    @Override
-    abstract public T getConfiguration();
+       @Override
+       abstract public T getConfiguration();
 
        /**
-        * Gets a list of File items in the specified directory.  If 'isDirectory' is true, then this
-        * method will return a list of items that are directories/folders; otherwise, it returns a list
-        * of file/document items.
-        *
-        * @param rootDir the root dir
-        * @param isDirectory the is directory
+        * Gets a list of File items in the specified directory. If 'isDirectory' is
+        * true, then this method will return a list of items that are
+        * directories/folders; otherwise, it returns a list of file/document items.
+        * 
+        * @param rootDir
+        *            the root dir
+        * @param isDirectory
+        *            the is directory
         * @return the file children
-        * @throws IOException Signals that an I/O exception has occurred.
+        * @throws IOException
+        *             Signals that an I/O exception has occurred.
         */
-       List<File> getFileChildren(File rootDir, boolean getDirectories) throws IOException {
+       List<File> getFileChildren(File rootDir, boolean getDirectories)
+                       throws IOException {
                ArrayList<File> result = new ArrayList<File>();
                File[] children = rootDir.listFiles();
                if (children != null) {
@@ -88,73 +93,79 @@ public abstract class AbstractConfigReaderImpl<T>
                        }
                } else {
                        String errMessage = "An IO exception and/or error occurred while reading the directory: "
-                               + rootDir.getAbsolutePath();
+                                       + rootDir.getAbsolutePath();
                        logger.debug(errMessage);
                        throw new IOException(errMessage);
                }
                return result;
        }
-       
+
        /**
-        * Gets a list of files/documents in the specified folder -does not return directories/folders.
-        *
-        * @param rootDir the root dir
+        * Gets a list of files/documents in the specified folder -does not return
+        * directories/folders.
+        * 
+        * @param rootDir
+        *            the root dir
         * @return the files
-        * @throws IOException Signals that an I/O exception has occurred.
+        * @throws IOException
+        *             Signals that an I/O exception has occurred.
         */
        List<File> getFiles(File rootDir) throws IOException {
                return getFileChildren(rootDir, false);
        }
-       
+
        List<File> getDirectories(File rootDir) throws IOException {
                return getFileChildren(rootDir, true);
        }
-    
-    protected Object parse(File configFile, Class<?> clazz) throws FileNotFoundException, JAXBException {
-       Object result = null;
-       
-       InputStream inputStream = new FileInputStream(configFile);
-       result = parse(inputStream, clazz);
-        if (logger.isDebugEnabled()) {
-            logger.debug("read() read file " + configFile.getAbsolutePath());
-        }
-       
-       return result;
-    }
-    
-    /**
-     * parse parses given configuration file from the disk based on given class
-     * definition
-     * @param configFile
-     * @param clazz
-     * @return A JAXB object
-     * @throws JAXBException 
-     * @throws Exception
-     */
-    protected Object parse(InputStream configFileStream, Class<?> clazz) throws JAXBException {
-       Object result = null;
-
-               JAXBContext jc = JAXBContext.newInstance(clazz);
-               Unmarshaller um = jc.createUnmarshaller();
-               result = um.unmarshal(configFileStream);
-
-        return result;
-    }
-
-    protected String getAbsoluteFileName(String configFileName) {
-        return serverRootDir
-                + File.separator + CSPACE_DIR_NAME
-                + File.separator + CONFIG_DIR_PATH
-                + File.separator + configFileName;
-    }
-
-    protected String getServerRootDir() {
-        return serverRootDir;
-    }
-    
-    protected String getConfigRootDir() {
-        return serverRootDir
-        + File.separator + CSPACE_DIR_NAME
-        + File.separator + CONFIG_DIR_PATH;
-    }
+
+       protected Object parse(File configFile, Class<?> clazz)
+                       throws FileNotFoundException, JAXBException {
+               Object result = null;
+
+               InputStream inputStream = new FileInputStream(configFile);
+               result = parse(inputStream, clazz);
+               if (logger.isDebugEnabled()) {
+                       logger.debug("read() read file " + configFile.getAbsolutePath());
+               }
+
+               return result;
+       }
+
+       /**
+        * parse parses given configuration file from the disk based on given class
+        * definition
+        * 
+        * @param configFile
+        * @param clazz
+        * @return A JAXB object
+        * @throws JAXBException
+        * @throws Exception
+        */
+       protected Object parse(InputStream configFileStream, Class<?> clazz)
+                       throws JAXBException {
+               Object result = null;
+
+               JAXBContext jc = JAXBContext.newInstance(clazz);
+               Unmarshaller um = jc.createUnmarshaller();
+               result = um.unmarshal(configFileStream);
+
+               return result;
+       }
+
+       protected String getAbsoluteFileName(String configFileName) {
+               return serverRootDir + File.separator
+                               + JEEServerDeployment.CSPACE_DIR_NAME + File.separator
+                               + JEEServerDeployment.CONFIG_DIR_PATH + File.separator
+                               + configFileName;
+       }
+
+       protected String getServerRootDir() {
+               return serverRootDir;
+       }
+
+       protected String getConfigRootDir() {
+               return serverRootDir + File.separator
+                               + JEEServerDeployment.CSPACE_DIR_NAME + File.separator
+                               + JEEServerDeployment.CONFIG_DIR_PATH;
+       }
 }
index 0ba485543e6edab5456c5f76ab7460ff725f8a50..6bc2e4de4a4da09f1130fc1eb0c1240611fa28bd 100644 (file)
 package org.collectionspace.services.common.config;
 
 import java.io.File;
+import org.collectionspace.services.common.api.JEEServerDeployment;
 
 /**
  * ConfigReader is an interface for a configuration reader
  */
 public interface ConfigReader<T> {
 
-    final public static String CSPACE_DIR_NAME = "cspace";
-    final public static String CONFIG_DIR_PATH = "config" + File.separator + "services";
     final public static String RESOURCES_DIR_NAME = "resources";
-    final public static String RESOURCES_DIR_PATH = CSPACE_DIR_NAME + File.separator + CONFIG_DIR_PATH + File.separator + RESOURCES_DIR_NAME;
+    final public static String RESOURCES_DIR_PATH = JEEServerDeployment.CSPACE_DIR_NAME + File.separator +
+               JEEServerDeployment.CONFIG_DIR_PATH + File.separator + RESOURCES_DIR_NAME;
 
     /**
      * getFileName - get configuration file name
@@ -42,17 +42,17 @@ public interface ConfigReader<T> {
     public String getFileName();
 
     /**
-     * read parse and read the default configruation file from default location
+     * read parse and read the default configuration file from default location
      * @throws Exception
      */
-    public void read() throws Exception;
+    public void read(boolean useAppGeneratedBindings) throws Exception;
 
     /**
      * read parse and read the given configruation file.
      * @param configFile fully qualified file name
      * @throws Exception
      */
-    public void read(String configFile) throws Exception;
+    public void read(String configFile, boolean useAppGeneratedBindings) throws Exception;
 
     /**
      * getConfig get configuration binding
index f5ab1c02ffb87a16495bd1ee44c3aa00d248680e..d92a96adc77e9a08c52b193500db10a1ab157693 100644 (file)
@@ -55,13 +55,13 @@ public class ServicesConfigReaderImpl
     }
 
     @Override
-    public void read() throws Exception {
+    public void read(boolean useAppGeneratedBindings) throws Exception {
         String configFileName = getAbsoluteFileName(CONFIG_FILE_NAME);
-        read(configFileName);
+        read(configFileName, useAppGeneratedBindings);
     }
 
     @Override
-    public void read(String configFileName) throws Exception {
+    public void read(String configFileName, boolean useAppGeneratedBindings) throws Exception {
         if (logger.isDebugEnabled()) {
             logger.debug("read() config file=" + configFileName);
         }
index 84381ba6c531f088f41ae8044c4d5b8275efd93d..cda398ffb60b63d488f9d2dc30d5a7db529d9051 100644 (file)
@@ -23,6 +23,7 @@
     <xs:element name="service-config">
         <xs:complexType>
             <xs:sequence>
+               <xs:element name="use-app-generated-tenant-bindings" type="xs:boolean" minOccurs="0"  maxOccurs="1"/>
                 <!-- assumption: there is only one type of repository client used  -->
                 <xs:element name="repository-client" type="RepositoryClientConfigType" minOccurs="1"  maxOccurs="1"/>
                 <xs:element name="repository-workspace" type="RepositoryWorkspaceType" minOccurs="0"  maxOccurs="1" />
index 41d71ea3cdd9536a5e6bd93e88287d7cdc38e8f1..30b7e97624a7878913d9c7f44ea22241fafb48ff 100644 (file)
@@ -45,6 +45,7 @@ import org.collectionspace.services.report.ReportsCommon;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.collectionspace.services.common.config.ConfigReader;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
@@ -185,7 +186,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
                Response response = null;
        try {
                        String fullPath = ServiceMain.getInstance().getServerRootDir() +
-                                                               File.separator + ConfigReader.CSPACE_DIR_NAME + 
+                                                               File.separator + JEEServerDeployment.CSPACE_DIR_NAME + 
                                                                File.separator + REPORTS_FOLDER +
                                                                // File.separator + tenantName +
                                                                File.separator + reportFileName;