]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6277: On import, allow dollar sign characters to be included in authority...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 21 Nov 2013 02:08:34 +0000 (18:08 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 21 Nov 2013 22:16:06 +0000 (14:16 -0800)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/import-locationitem-dollarsign.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/imports.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem-dollarsign.res.xml [new file with mode: 0644]
services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java

diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/import-locationitem-dollarsign.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/import-locationitem-dollarsign.xml
new file mode 100644 (file)
index 0000000..1f926ec
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<imports>
+    <import service="Locations" type="Locationitem" CSID="${recordCSID}">
+        <schema xmlns:locations_common="http://collectionspace.org/services/location" 
+                name="locations_common">
+            <locTermGroupList>
+                <locTermGroup>
+                    <termDisplayName>${termDisplayNameValue}</termDisplayName>
+                </locTermGroup>
+            </locTermGroupList>
+            <shortIdentifier>${shortIdentifierValue}</shortIdentifier>
+            <refName>urn:cspace:core.collectionspace.org:locationauthorities:name(${shortIdentifierValue})'${termDisplayNameValue}'</refName>
+            <inAuthority>${inAuthorityValue}</inAuthority>
+        </schema>
+    </import>
+</imports>
\ No newline at end of file
index d242b11f6e2945403be3cd903a411a2d9b4835b1..5ecea82232ffac0aeffce63078a9bb7536546a04 100644 (file)
             <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithGeneratedRefName.recordCSID}</uri>
         </test>
         
+        <!--
+            Import an authority item record containing a dollar sign character in the display name part of its refName.
+        -->
+        <test ID="importLocationItemWithDollarSignInRefName">
+            <expectedCodes>200</expectedCodes>
+            <method>POST</method>
+            <uri>/cspace-services/imports</uri>
+            <filename>imports/import-locationitem-dollarsign.xml</filename>
+            <vars>
+                <var ID="recordCSID">ec1b0f42-70ef-4ab3-b81e-d73cadbc25f5</var>
+                <var ID="shortIdentifierValue">afistfulofdollars</var>
+                <var ID="inAuthorityValue">${importLocationAuthorityWithVarExpansion.recordCSID}</var>
+                <var ID="termDisplayNameValue">A Fistful of $$$ Dollars</var>
+            </vars>
+            <response>
+                <expected level="TEXT" />
+                <filename>imports/res/import-locationitem-dollarsign.res.xml</filename>
+            </response>
+        </test>
+        <!-- Verify values in the collectionspace_core schema as well as in locations_common -->
+        <test ID="verifyLocationItemWithDollarSignInRefName">
+            <expectedCodes>200</expectedCodes>
+            <method>GET</method>
+            <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}/items/${importLocationItemWithDollarSignInRefName.recordCSID}</uri>
+            <response>
+                <filename>imports/res/import-locationitem-dollarsign.res.xml</filename>
+                <expected level="ADDOK" />
+                <parts>
+                    <part>
+                        <label>collectionspace_core</label>
+                    </part>
+                    <part>
+                        <label>locations_common</label>
+                    </part>
+                </parts>
+                <vars>
+                    <var ID="shortIdentifierValue">${importLocationItemWithDollarSignInRefName.shortIdentifierValue}</var>
+                    <var ID="inAuthorityValue">${importLocationItemWithDollarSignInRefName.inAuthorityValue}</var>
+                    <var ID="termDisplayNameValue">${importLocationItemWithDollarSignInRefName.termDisplayNameValue}</var>
+                    <var ID="uriValue">/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}/items/${importLocationItemWithDollarSignInRefName.recordCSID}</var>
+                </vars>
+            </response>
+        </test>
+        <test ID="deleteLocationItemWithDollarSignInRefName">
+            <expectedCodes>200</expectedCodes>
+            <method>DELETE</method>
+            <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}/items/${importLocationItemWithDollarSignInRefName.recordCSID}</uri>
+        </test>
+        
                 
         <!--
             Import a record containing dollar sign and backslash character(s).
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem-dollarsign.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem-dollarsign.res.xml
new file mode 100644 (file)
index 0000000..5c5e754
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document name="locations">
+    <ns2:locations_common
+        xmlns:ns2="http://collectionspace.org/services/location">
+        <locTermGroupList>
+            <locTermGroup>
+                <termDisplayName>${termDisplayNameValue}</termDisplayName>
+            </locTermGroup>
+        </locTermGroupList>
+        <shortIdentifier>${shortIdentifierValue}</shortIdentifier>
+        <inAuthority>${inAuthorityValue}</inAuthority>
+    </ns2:locations_common>
+    <ns2:collectionspace_core xmlns:ns2="http://collectionspace.org/collectionspace_core/"
+                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <!-- Note: This test may fail if the identifier for the core tenant changes. -->
+        <tenantId>1</tenantId>
+        <uri>${uriValue}</uri>
+        <refName>urn:cspace:core.collectionspace.org:locationauthorities:name(${shortIdentifierValue})'${termDisplayNameValue}'</refName>
+    </ns2:collectionspace_core>
+</document>
+
index c3e3405904451c004b002c6bf9908d6201a41982..223cab2077b14bbe894df8fff083f557e5f4fc9c 100644 (file)
@@ -177,8 +177,7 @@ public class TemplateExpander {
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("uri"),
                 getDocUri(tenantId, SERVICE_TYPE, docID, partTmpl));
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("refName"),
-                getRefName(tenantId, SERVICE_TYPE, docID, partTmpl).replace("&", "&amp;"));
-
+                getRefName(tenantId, SERVICE_TYPE, docID, partTmpl).replace("&", "&amp;").replace("$", "&#x0024;"));
 
         String serviceDir = outDir + '/' + docID;
         FileTools.saveFile(serviceDir, "document.xml", wrapperTmpl, FileTools.FORCE_CREATE_PARENT_DIRS);