]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4168: Fixing import service to support mutliple tenants and tenant specific...
authorRichard Millet <richard.millet@berkeley.edu>
Wed, 29 Jun 2011 18:27:38 +0000 (18:27 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Wed, 29 Jun 2011 18:27:38 +0000 (18:27 +0000)
12 files changed:
services/common/src/main/java/org/collectionspace/services/common/ConfigurationException.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java
services/imports/build.xml
services/imports/service/pom.xml
services/imports/service/src/main/java/org/collectionspace/services/imports/ImportsResource.java
services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java
services/imports/service/src/main/resources/templates/service-document.xml
services/imports/service/src/test/java/org/collectionspace/services/test/ImportsServiceTest.java
services/imports/service/src/test/resources/requests/collectionobject-request.xml

diff --git a/services/common/src/main/java/org/collectionspace/services/common/ConfigurationException.java b/services/common/src/main/java/org/collectionspace/services/common/ConfigurationException.java
new file mode 100644 (file)
index 0000000..53477a4
--- /dev/null
@@ -0,0 +1,65 @@
+package org.collectionspace.services.common;\r
+\r
+public class ConfigurationException extends ServiceException {\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = -6399176494104282779L;\r
+       \r
+       final public static int HTTP_CODE = 500;\r
+\r
+    /**\r
+     * Creates a new instance of <code>BadRequestException</code> without detail message.\r
+     */\r
+    public ConfigurationException() {\r
+        super(HTTP_CODE);\r
+    }\r
+\r
+    /**\r
+     * Constructs an instance of <code>BadRequestException</code> with the specified detail message.\r
+     * @param msg the detail message.\r
+     */\r
+    public ConfigurationException(String msg) {\r
+        super(msg);\r
+        setErrorCode(HTTP_CODE);\r
+    }\r
+\r
+    /**\r
+     * Constructs a new exception with the specified detail message and\r
+     * cause.  <p>Note that the detail message associated with\r
+     * <code>cause</code> is <i>not</i> automatically incorporated in\r
+     * this exception's detail message.\r
+     *\r
+     * @param  message the detail message (which is saved for later retrieval\r
+     *         by the {@link #getMessage()} method).\r
+     * @param  cause the cause (which is saved for later retrieval by the\r
+     *         {@link #getCause()} method).  (A <tt>null</tt> value is\r
+     *         permitted, and indicates that the cause is nonexistent or\r
+     *         unknown.)\r
+     * @since  1.4\r
+     */\r
+    public ConfigurationException(String message, Throwable cause) {\r
+        super(message, cause);\r
+        setErrorCode(HTTP_CODE);\r
+    }\r
+    \r
+    /**\r
+     * Constructs a new exception with the specified cause and a detail\r
+     * message of <tt>(cause==null ? null : cause.toString())</tt> (which\r
+     * typically contains the class and detail message of <tt>cause</tt>).\r
+     * This constructor is useful for exceptions that are little more than\r
+     * wrappers for other throwables (for example, {@link\r
+     * java.security.PrivilegedActionException}).\r
+     *\r
+     * @param  cause the cause (which is saved for later retrieval by the\r
+     *         {@link #getCause()} method).  (A <tt>null</tt> value is\r
+     *         permitted, and indicates that the cause is nonexistent or\r
+     *         unknown.)\r
+     * @since  1.4\r
+     */\r
+    public ConfigurationException(Throwable cause) {\r
+        super(cause);\r
+        setErrorCode(HTTP_CODE);\r
+    }\r
+    \r
+}\r
index 3a611d7dd040311789b189c6b7b0fc74ef195854..c1465a2c7283bab071c1dc8b3338d670b06638b1 100644 (file)
@@ -341,7 +341,7 @@ public abstract class AbstractServiceContextImpl<IT, OT>
     public String getTenantQualifiedDoctype(String docType) {
         // If they have not overridden the setting, use the type of the service
         // object.
-        String result = docType + ServiceContext.TENANT_SUFFIX + this.getTenantId();
+        String result = ServiceBindingUtils.getTenantQualifiedDocType(this.getTenantId(), docType);
         
         return result;
     }
index f3587a53fdd6a0b7cec7d40a17c052820a74f04c..051321370d56e88af9a6b2d96b24bb3e42e07ed8 100644 (file)
@@ -24,6 +24,11 @@ public class ServiceBindingUtils {
        public static final String SERVICE_TYPE_OBJECT = "object";\r
        public static final String SERVICE_TYPE_PROCEDURE = "procedure";\r
        \r
+    public static String getTenantQualifiedDocType(String tenantId, String docType) {\r
+       String result = docType + ServiceContext.TENANT_SUFFIX + tenantId;\r
+       return result;\r
+    }\r
+       \r
        // TODO consider building up a hashTable of the properties for each\r
        // service binding. There will be generic properties, as well as\r
        // properties on each part. Could build up a key from tenant id, \r
index 3eadf6ed7a737632ece05f464fe92887abf8392c..118b4ff120a0c1eebb4fd926253fac1a6c6d984e 100644 (file)
@@ -836,7 +836,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             repoSession = getRepositorySession();
             DocumentRef parentDocRef = new PathRef(
                     "/" + domainName
-                    + "/" + "workspaces");
+                    + "/" + NuxeoUtils.WORKSPACES);
             DocumentModel parentDoc = repoSession.getDocument(parentDocRef);
             DocumentModel doc = repoSession.createDocumentModel(parentDoc.getPathAsString(),
                     workspaceName, "Workspace");
@@ -874,7 +874,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             repoSession = getRepositorySession();
             DocumentRef docRef = new PathRef(
                     "/" + tenantDomain
-                    + "/" + "workspaces"
+                    + "/" + NuxeoUtils.WORKSPACES
                     + "/" + workspaceName);
             DocumentModel workspace = repoSession.getDocument(docRef);
             workspaceId = workspace.getId();
index 0a02150757679302c40a8a4a436038b870c6b765..4832fbf512ede8f9e3b22ba0cc9913eae0df5843 100644 (file)
@@ -34,6 +34,7 @@ import java.util.regex.PatternSyntaxException;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
 import org.collectionspace.services.common.document.DocumentException;
@@ -85,6 +86,7 @@ public class NuxeoUtils {
     // Base document type in Nuxeo is "Document"
     //
     public static final String BASE_DOCUMENT_TYPE = "Document";
+    public static final String WORKSPACES = "workspaces";
     
     // Regular expressions pattern for identifying valid ORDER BY clauses.
     // FIXME: Currently supports only USASCII word characters in field names.
@@ -437,7 +439,7 @@ public class NuxeoUtils {
      */
     public static DocumentRef createPathRef(ServiceContext ctx, String id) {
         return new PathRef("/" + ctx.getRepositoryDomainStorageName() +
-                "/" + "workspaces" +
+                "/" + WORKSPACES +
                 "/" + ctx.getRepositoryWorkspaceName() +
                 "/" + id);
     }
@@ -516,6 +518,19 @@ public class NuxeoUtils {
                return result;
     }
     
+    public static String getTenantQualifiedDocType(String tenantId, String docType) throws Exception {
+       String result = docType;
+       
+               String tenantQualifiedDocType = ServiceBindingUtils.getTenantQualifiedDocType(tenantId, docType);
+
+               if (docTypeExists(tenantQualifiedDocType) == true) {
+                       result = tenantQualifiedDocType;
+               }
+               
+       return result;
+    }
+
+    
     public static String getTenantQualifiedDocType(ServiceContext ctx, String docType) throws Exception {
        String result = docType;
        
index 315cd675fd02b873e9c48ee28d40c2fd702e8acf..c3782e191f4325bc75bb51c75991c996180f0ff6 100755 (executable)
     <target name="deploy" depends="install"
     description="deploy imports service">
         <ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>
-        <copy todir="${jboss.server.cspace}/cspace/config/services/resources/templates">
+       <!-- REM - This logic should be pushed down into the "service" module -->
+       <copy todir="${jboss.server.cspace}/cspace/config/services/resources/templates">
             <fileset dir="${basedir}/service/src/main/resources/templates"/>
         </copy>
     </target>
index 89a400a5018e4663fb7f122ccc7f209e4a54d5ac..cab70f3ee2326ed48c5142e15b01c6104077a887 100755 (executable)
             <artifactId>org.collectionspace.services.common</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.authentication.service</artifactId>
+            <version>${project.version}</version>
+                       <scope>provided</scope>
+        </dependency>
         <dependency>
             <groupId>org.collectionspace.services</groupId>
             <artifactId>org.collectionspace.services.imports.jaxb</artifactId>
index 64af759903b0c316d62efeb713a78353b4db30a7..4282bec378f5e4e247b10be23d9c8638acd93917 100755 (executable)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.imports;
 
+import org.collectionspace.services.common.ConfigurationException;
 import org.collectionspace.services.common.FileUtils;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ServiceMain;
@@ -31,7 +32,12 @@ import org.collectionspace.services.common.api.FileTools;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.api.ZipTools;
 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
+import org.collectionspace.services.common.tenant.RepositoryDomainType;
+import org.collectionspace.services.common.tenant.TenantBindingType;
+import org.collectionspace.authentication.AuthN;
+
 import org.collectionspace.services.imports.nuxeo.ImportCommand;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.jboss.resteasy.plugins.providers.multipart.InputPart;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
 import org.xml.sax.InputSource;
@@ -66,6 +72,29 @@ public class ImportsResource extends ResourceBase {
     public static final String SERVICE_PATH = "imports";
     public static final String SERVICE_NAME = "imports";
     
+    /*
+     * ASSUMPTION: All Nuxeo services of a given tenancy store their stuff in the same repository domain under
+     * the "workspaces" directory.
+     * 
+     * Using the tenant ID of the currently authenticated user, this method returns the repository domain name of the
+     * current tenancy.
+     */
+    private static String getWorkspaces() throws ConfigurationException {
+       String result = null;
+       
+       TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+       TenantBindingType tenantBinding = tReader.getTenantBinding(AuthN.get().getCurrentTenantId());
+       List<RepositoryDomainType> repositoryDomainList = tenantBinding.getRepositoryDomain();
+       if (repositoryDomainList.size() == 1) {
+               String domainName = repositoryDomainList.get(0).getStorageName().trim();
+               result = "/" + domainName + "/" + NuxeoUtils.WORKSPACES;                
+       } else {
+               throw new ConfigurationException("Tenant bindings contains 0 or more than 1 repository domains.");
+       }
+       
+       return result;
+    }
+    
     @Override
     public String getServiceName(){
         return SERVICE_NAME;
@@ -145,15 +174,17 @@ public class ImportsResource extends ResourceBase {
     }
 
     public static String createFromInputSource(InputSource inputSource) throws Exception {
+       String tenantId = AuthN.get().getCurrentTenantId();
         // We must expand the request and wrap it with all kinds of Nuxeo baggage, which expandXmlPayloadToDir knows how to do.
         String outputDir = FileTools.createTmpDir("imports-").getCanonicalPath();
         File outpd = new File(outputDir);
         outpd.mkdirs();
-        expandXmlPayloadToDir(inputSource, getTemplateDir(), outpd.getCanonicalPath());
+        expandXmlPayloadToDir(tenantId, inputSource, getTemplateDir(), outpd.getCanonicalPath());
 
         // Next, call the nuxeo import service, pointing it to our local directory that has the expanded request.
         ImportCommand importCommand = new ImportCommand();
-        String destWorkspaces = "/default-domain/workspaces";
+//        String destWorkspaces = "/default-domain/workspaces";
+        String destWorkspaces = getWorkspaces();
         String report = "NORESULTS";
         try {
             report = importCommand.run(outputDir, destWorkspaces);
@@ -165,15 +196,17 @@ public class ImportsResource extends ResourceBase {
     }
 
     public static String createFromFilename(String filename) throws Exception {
+       String tenantId = AuthN.get().getCurrentTenantId();
          // We must expand the request and wrap it with all kinds of Nuxeo baggage, which expandXmlPayloadToDir knows how to do.
          String outputDir = FileTools.createTmpDir("imports-").getCanonicalPath();
          File outpd = new File(outputDir);
          outpd.mkdirs();
-         expandXmlPayloadToDir(filename, getTemplateDir(), outpd.getCanonicalPath());
+         expandXmlPayloadToDir(tenantId, filename, getTemplateDir(), outpd.getCanonicalPath());
 
          // Next, call the nuxeo import service, pointing it to our local directory that has the expanded request.
          ImportCommand importCommand = new ImportCommand();
-         String destWorkspaces = "/default-domain/workspaces";
+//         String destWorkspaces = "/default-domain/workspaces";
+         String destWorkspaces = getWorkspaces();
          String report = importCommand.run(outputDir, destWorkspaces);
          String result = "<?xml ?><import><msg>SUCCESS</msg><report></report>"+report+"</import>";
          return result;
@@ -206,13 +239,13 @@ public class ImportsResource extends ResourceBase {
         return requestFilename;
     }
 
-    public static void expandXmlPayloadToDir(String inputFilename, String templateDir, String outputDir) throws Exception {
+    public static void expandXmlPayloadToDir(String tenantId, String inputFilename, String templateDir, String outputDir) throws Exception {
      System.out.println("############## TEMPLATE_DIR: "+templateDir);
         System.out.println("############## OUTPUT_DIR:"+outputDir);
         File file = new File(inputFilename);
         FileInputStream is = new FileInputStream(file);
         InputSource inputSource = new InputSource(is);
-        TemplateExpander.expandInputSource(templateDir, outputDir, inputSource, "/imports/import");
+        TemplateExpander.expandInputSource(tenantId, templateDir, outputDir, inputSource, "/imports/import");
     }
 
     /** This method may be called statically from outside this class; there is a test call in
@@ -224,10 +257,10 @@ public class ImportsResource extends ResourceBase {
      * @param templateDir  The local directory where templates are to be found at runtime.
      * @param outputDir    The local directory where expanded files and directories are found, ready to be passed to the Nuxeo importer.
      */
-    public static void expandXmlPayloadToDir(InputSource inputSource, String templateDir, String outputDir) throws Exception {
+    public static void expandXmlPayloadToDir(String tenantId, InputSource inputSource, String templateDir, String outputDir) throws Exception {
         System.out.println("############## TEMPLATE_DIR: "+templateDir);
         System.out.println("############## OUTPUT_DIR:"+outputDir);
-        TemplateExpander.expandInputSource(templateDir, outputDir, inputSource, "/imports/import");
+        TemplateExpander.expandInputSource(tenantId, templateDir, outputDir, inputSource, "/imports/import");
         //TemplateExpander.expandInputSource(templateDir, outputDir, inputFilename, "/imports/import");
     }
 
index d34aa480cc903a6efb9207b1a7cc520e575bb130..5b4cecb710dfc3c4c292e4e9af785cc4ad636a53 100755 (executable)
@@ -32,6 +32,9 @@ import org.collectionspace.services.common.XmlSaxFragmenter;
 import org.collectionspace.services.common.XmlTools;\r
 import org.collectionspace.services.common.api.FileTools;\r
 import org.collectionspace.services.common.api.Tools;\r
+import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;\r
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
+\r
 import org.dom4j.Document;\r
 import org.dom4j.Element;\r
 import org.hibernate.sql.Template;\r
@@ -62,7 +65,7 @@ public class TemplateExpander {
         return Tools.searchAndReplace(source, var(theVar), replace);\r
     }\r
 \r
-    public static String doOneService(String outDir, String partTmpl, String wrapperTmpl,\r
+    public static String doOneService(String tenantId, String outDir, String partTmpl, String wrapperTmpl,\r
                                       String SERVICE_TYPE, String SERVICE_NAME, String CSID) throws Exception {\r
         String docID;\r
         if (Tools.notBlank(CSID)){\r
@@ -74,9 +77,13 @@ public class TemplateExpander {
 \r
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("Schema"), part);\r
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("docID"), docID);\r
+        wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("tenantID"), tenantId);\r
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("ServiceType"), SERVICE_TYPE);\r
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("ServiceName"), SERVICE_NAME);\r
         //TODO: set timestamp via creating a ${created} variable.\r
+        String nowTime = GregorianCalendarDateTimeUtils.timestampUTC();\r
+        wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("createdDate"), nowTime);\r
+        wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("updatedDate"), nowTime);\r
 \r
         String serviceDir = outDir+'/'+docID;\r
         FileTools.saveFile(serviceDir, "document.xml", wrapperTmpl, true/*true=create parent dirs*/);\r
@@ -96,24 +103,26 @@ public class TemplateExpander {
      * @param CSID An optional parameter which forces the document CSID, otherwise the CSID is set to a random UUID.\r
      * @throws Exception\r
      */\r
-    public static void createDocInWorkspace(String partTmpl,\r
-                                            String SERVICE_NAME,\r
-                                            String SERVICE_TYPE,\r
-                                            String TEMPLATE_DIR,\r
-                                            String OUTPUT_DIR,\r
-                                            String CSID) throws Exception {\r
+    public static void createDocInWorkspace(\r
+               String tenantId,\r
+            String partTmpl,\r
+            String SERVICE_NAME,\r
+            String SERVICE_TYPE,\r
+            String TEMPLATE_DIR,\r
+            String OUTPUT_DIR,\r
+            String CSID) throws Exception {\r
         String wrapperTmpl = FileTools.readFile(TEMPLATE_DIR,"service-document.xml");\r
         String outputDir = OUTPUT_DIR+'/'+SERVICE_NAME;\r
-        doOneService(outputDir, partTmpl, wrapperTmpl, SERVICE_TYPE, SERVICE_NAME, CSID);\r
+        doOneService(tenantId, outputDir, partTmpl, wrapperTmpl, SERVICE_TYPE, SERVICE_NAME, CSID);\r
     }\r
 \r
-    public static void expand(String TEMPLATE_DIR, String outputDir, String requestFilename, String chopPath){\r
-        FragmentHandlerImpl callback = new FragmentHandlerImpl(TEMPLATE_DIR, outputDir);\r
+    public static void expand(String tenantId, String TEMPLATE_DIR, String outputDir, String requestFilename, String chopPath){\r
+        FragmentHandlerImpl callback = new FragmentHandlerImpl(tenantId, TEMPLATE_DIR, outputDir);\r
         XmlSaxFragmenter.parse(requestFilename, chopPath, callback, false);\r
     }\r
 \r
-    public static void expandInputSource(String TEMPLATE_DIR, String outputDir, InputSource requestSource, String chopPath){\r
-        FragmentHandlerImpl callback = new FragmentHandlerImpl(TEMPLATE_DIR, outputDir);\r
+    public static void expandInputSource(String tenantId, String TEMPLATE_DIR, String outputDir, InputSource requestSource, String chopPath){\r
+        FragmentHandlerImpl callback = new FragmentHandlerImpl(tenantId, TEMPLATE_DIR, outputDir);\r
         XmlSaxFragmenter.parse(requestSource, chopPath, callback, false);\r
     }\r
 \r
@@ -124,14 +133,21 @@ public class TemplateExpander {
      *      &lt;import ID="1" service="Personauthorities" type="Personauthority">\r
      */\r
     public static class FragmentHandlerImpl implements IFragmentHandler {\r
+        public String SERVICE_NAME = "";   //You can provide a default.\r
+        public String SERVICE_TYPE = "";   //You can provide a default.\r
+        public String TEMPLATE_DIR = "";   //You MUST provide a default via constructor.\r
+        public String OUPUT_DIR = "";      //You MUST provide a default via constructor.\r
+        public String TENANT_ID = "";\r
+\r
         //============IFragmentHandler===========================================================\r
         public void onFragmentReady(Document context, Element fragmentParent, String currentPath, int fragmentIndex, String fragment){\r
             try {\r
                 dump(context, currentPath, fragmentIndex, fragment);\r
                 String serviceName = checkAttribute(fragmentParent, "service", SERVICE_NAME);\r
                 String serviceType = checkAttribute(fragmentParent, "type", SERVICE_TYPE);\r
+                serviceType = NuxeoUtils.getTenantQualifiedDocType(TENANT_ID, serviceType); //REM - Ensure a tenant qualified Nuxeo doctype\r
                 String CSID  = fragmentParent.attributeValue("CSID");\r
-                TemplateExpander.createDocInWorkspace(fragment, serviceName, serviceType, TEMPLATE_DIR, OUPUT_DIR, CSID);\r
+                TemplateExpander.createDocInWorkspace(TENANT_ID, fragment, serviceName, serviceType, TEMPLATE_DIR, OUPUT_DIR, CSID);\r
             } catch (Exception e){\r
                 System.err.println("ERROR calling expandXmlPayloadToDir"+e);\r
                 e.printStackTrace();\r
@@ -141,14 +157,11 @@ public class TemplateExpander {
             System.out.println("====TemplateExpander DONE============\r\n"+ XmlTools.prettyPrint(document)+"================");\r
         }\r
         //============helper methods==============================================================\r
-        public FragmentHandlerImpl(String templateDir, String outputDir){\r
+        public FragmentHandlerImpl(String tenantId, String templateDir, String outputDir){\r
             TEMPLATE_DIR = templateDir;\r
             OUPUT_DIR = outputDir;\r
+            TENANT_ID = tenantId;\r
         }\r
-        public String SERVICE_NAME = "";   //You can provide a default.\r
-        public String SERVICE_TYPE = "";   //You can provide a default.\r
-        public String TEMPLATE_DIR = "";   //You MUST provide a default via constructor.\r
-        public String OUPUT_DIR = "";      //You MUST provide a default via constructor.\r
         private String checkAttribute(Element fragmentParent, String attName, String defaultVal){\r
             String val = fragmentParent.attributeValue(attName);\r
             if (Tools.notEmpty(val)){\r
index e3cef97a1305ab057a42460d15949d14efbe7ef3..858fe6a573e9e6d53e99493e689d2ca1a459b5e1 100755 (executable)
@@ -36,9 +36,9 @@
     <size/>\r
   </schema>\r
   <schema xmlns:collectionspace_core="http://collectionspace.org/collectionspace_core/" name="collectionspace_core">\r
-    <collectionspace_core:updatedAt>2011-03-05T00:06:17Z</collectionspace_core:updatedAt>\r
-    <collectionspace_core:createdAt>2011-03-05T00:06:17Z</collectionspace_core:createdAt>\r
-    <collectionspace_core:tenantId>1</collectionspace_core:tenantId>\r
+    <collectionspace_core:updatedAt>${updatedDate}</collectionspace_core:updatedAt>\r
+    <collectionspace_core:createdAt>${createdDate}</collectionspace_core:createdAt>\r
+    <collectionspace_core:tenantId>${tenantID}</collectionspace_core:tenantId>\r
   </schema>\r
   ${Schema}\r
 </document>\r
index 89239a0e93a9c6ebed7ceff5b2279d0bcff9da56..ec9832010c1e72b8cae93b28583ea86da58499ae 100755 (executable)
@@ -45,6 +45,7 @@ public class ImportsServiceTest {
     //These paths won't work when deployed in jboss, but they will work in the build in the source tree, which is what this test is for.
     public static final String TEMPLATES_REL_DIR_TO_MODULE = "./src/main/resources/templates";
     public static final String REQUESTS_REL_DIR_TO_MODULE = "./src/test/resources/requests";
+    public static final String BOGUS_TENANT_ID = "-1";
 
     /** this test just attempts to expand a single file upload to nuxeo's import/export file/directory format,
      *   but does not do the import, so that this test may be run without a nuxeo instance running.
@@ -58,7 +59,7 @@ public class ImportsServiceTest {
 
         String xmlPayload = FileTools.readFile(REQUESTS_DIR,"authority-request.xml");
         InputSource inputSource = ImportsResource.payloadToInputSource(xmlPayload);
-        ImportsResource.expandXmlPayloadToDir(inputSource, TEMPLATE_DIR, outputDir);
+        ImportsResource.expandXmlPayloadToDir(BOGUS_TENANT_ID, inputSource, TEMPLATE_DIR, outputDir);
 
         //TODO: inspect dir, then *cleanup*!!
     }
index 9e4f549b7503ac82e13db85b247a3ae79ee9f18a..49c21c9621871aa7b62c3df042d099740cf1f63d 100755 (executable)
@@ -1,13 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <imports>\r
     <import seq="1" service="CollectionObjects" type="CollectionObject">\r
-        <schema xmlns:collectionobjects_naturalhistory="http://collectionspace.org/collectionobject/" name="collectionobjects_naturalhistory">\r
-            <collectionobjects_naturalhistory:nh-int/>\r
-            <collectionobjects_naturalhistory:nh-note/>\r
-            <collectionobjects_naturalhistory:nh-string/>\r
-            <collectionobjects_naturalhistory:nh-long/>\r
-            <collectionobjects_naturalhistory:nh-date/>\r
-         </schema>\r
          <schema xmlns:collectionobjects_common="http://collectionspace.org/collectionobject/" name="collectionobjects_common">\r
             <collectionobjects_common:assocCulturalContextGroupList/>\r
             <collectionobjects_common:assocCulturalContextGroupList/>\r