<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
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;
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();
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;
}
<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
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 -->
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
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
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;
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);
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;
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);
}
@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);
<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>
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) {
}
} 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;
+ }
}
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
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
}
@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);
}
<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" />
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;
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;