--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<document name="vocabularies">
+ <ns3:vocabularies_common xmlns:ns3="http://collectionspace.org/services/vocabulary" xmlns:ns2="http://collectionspace.org/services/jaxb">
+ <displayName>Updated createDeleteItemFromPagesOfItems Vocabulary</displayName>
+ <shortIdentifier>createDeleteItemFromPagesOfItems</shortIdentifier>
+ <description>This is an updated test vocabulary created in the createDeleteItemFromPagesOfItems XMLReplay test group</description>
+ <source>Some updated mythical book posted with item terms in createDeleteItemFromPagesOfItems test group</source>
+ </ns3:vocabularies_common>
+ <ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+ <list-item>
+ <order>1</order>
+ <displayName>createItem101</displayName>
+ <shortIdentifier>createItem101</shortIdentifier>
+ </list-item>
+ <list-item>
+ <order>2</order>
+ <displayName>createItem201</displayName>
+ <shortIdentifier>createItem201</shortIdentifier>
+ </list-item>
+ </ns2:abstract-common-list>
+</document>
--- /dev/null
+<document name="vocabularies">
+ <ns2:vocabularies_common xmlns:ns2="http://collectionspace.org/services/vocabulary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <shortIdentifier>createDeleteItemFromPagesOfItems</shortIdentifier>
+ <csid>${csid}</csid>
+ <displayName>Updated createDeleteItemFromPagesOfItems Vocabulary</displayName>
+ <description>
+ This is an updated test vocabulary created in the createDeleteItemFromPagesOfItems XMLReplay test group
+ </description>
+ <source>
+ Some updated mythical book posted with item terms in createDeleteItemFromPagesOfItems test group
+ </source>
+ <refName>
+ urn:cspace:testsci.collectionspace.org:vocabularies:name(createDeleteItemFromPagesOfItems)'createDeleteItemFromPagesOfItems Vocabulary'
+ </refName>
+ <vocabType>enum</vocabType>
+ </ns2:vocabularies_common>
+ <ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+ <pageNum>0</pageNum>
+ <itemsInPage>2</itemsInPage>
+ <totalItems>2</totalItems>
+ <fieldsReturned>
+ csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier
+ </fieldsReturned>
+ <list-item>
+ <refName>
+ urn:cspace:testsci.collectionspace.org:vocabularies:name(createDeleteItemFromPagesOfItems):item:name(createItem101)'createItem101'
+ </refName>
+ <workflowState>project</workflowState>
+ <rev>1</rev>
+ <sas>false</sas>
+ <proposed>true</proposed>
+ <order>1</order>
+ <displayName>createItem101</displayName>
+ <shortIdentifier>createItem101</shortIdentifier>
+ </list-item>
+ <list-item>
+ <refName>
+ urn:cspace:testsci.collectionspace.org:vocabularies:name(createDeleteItemFromPagesOfItems):item:name(createItem201)'createItem201'
+ </refName>
+ <workflowState>project</workflowState>
+ <rev>1</rev>
+ <sas>false</sas>
+ <proposed>true</proposed>
+ <order>2</order>
+ <displayName>createItem201</displayName>
+ <shortIdentifier>createItem201</shortIdentifier>
+ </list-item>
+ </ns2:abstract-common-list>
+</document>
\ No newline at end of file
<auth ID="admin@core.collectionspace.org">YWRtaW5AY29yZS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>
<auth ID="admin@testsci.collectionspace.org">YWRtaW5AdGVzdHNjaS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>
</auths>
+
+ <!--
+ Test deleting a vocabulary item from a list with multiple pages of items.
+ -->
+ <testGroup ID="DeleteItemFromPagesOfItems" autoDeletePOSTS="true" authForCleanup="admin@testsci.collectionspace.org">
+ <test ID="createDeleteItemFromPagesOfItems" auth="admin@testsci.collectionspace.org">
+ <method>POST</method>
+ <uri>/cspace-services/vocabularies/</uri>
+ <filename>vocabulary/vocab-Template.xml</filename>
+ </test>
+ <test ID="createItem101">
+ <method>POST</method>
+ <uri>/cspace-services/vocabularies/${createDeleteItemFromPagesOfItems.CSID}/items/</uri>
+ <filename>vocabulary/vocab-Item-template.xml</filename>
+ <vars>
+ <var ID="order">1</var>
+ </vars>
+ </test>
+ <test ID="createItem201">
+ <method>POST</method>
+ <uri>/cspace-services/vocabularies/${createDeleteItemFromPagesOfItems.CSID}/items/</uri>
+ <filename>vocabulary/vocab-Item-template.xml</filename>
+ <vars>
+ <var ID="order">2</var>
+ </vars>
+ </test>
+ <test ID="createItem301">
+ <method>POST</method>
+ <uri>/cspace-services/vocabularies/${createDeleteItemFromPagesOfItems.CSID}/items/</uri>
+ <filename>vocabulary/vocab-Item-template.xml</filename>
+ <vars>
+ <var ID="order">3</var>
+ </vars>
+ </test>
+ <test ID="deleteItemFromSecondPage" auth="admin@testsci.collectionspace.org">
+ <method>PUT</method>
+ <uri>/cspace-services/vocabularies/${createDeleteItemFromPagesOfItems.CSID}?omittedItemAction=delete&pgSz=2</uri>
+ <filename>vocabulary/DeleteItemFromPagesOfItems/deleteItemFromSecondPage-vocab.xml</filename>
+ </test>
+ <test ID="xgetUpdatedVocabItems">
+ <method>GET</method>
+ <uri>/cspace-services/vocabularies/${createDeleteItemFromPagesOfItems.CSID}?showItems=true</uri>
+ <response>
+ <vars>
+ <var ID="csid">${createDeleteItemFromPagesOfItems.CSID}</var>
+ </vars>
+ <expected level="ADDOK" />
+ <filename>vocabulary/DeleteItemFromPagesOfItems/responses/deleteItemFromPagesOfItems.res.xml</filename>
+ </response>
+ </test>
+ </testGroup>
<!--
Test adding to a vocabulary's terms with an entirely new set of terms.
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
+import java.util.ArrayList;
import java.util.Base64;
import java.util.HashSet;
import java.util.Set;
// Next, delete the items that were omitted from the incoming payload
//
if (shouldDeleteOmittedItems(uriInfo) == true) {
- String omittedItemAction = getOmittedItemAction(uriInfo);
- AbstractCommonList abstractCommonList = this.getAuthorityItemList(existingCtx, parentIdentifier, uriInfo);
- if (abstractCommonList != null && !Tools.isEmpty(abstractCommonList.getListItem())) {
- if (omittedItemAction.equalsIgnoreCase(VocabularyClient.DELETE_OMITTED_ITEMS)) {
- deleteAuthorityItems(existingCtx, abstractCommonList, shortIdsInPayload, parentIdentifier);
- } else {
- sotfDeleteAuthorityItems(existingCtx, abstractCommonList, shortIdsInPayload, parentIdentifier);
+ UriInfo uriInfoCopy = new UriInfoWrapper(uriInfo);
+ String omittedItemAction = getOmittedItemAction(uriInfoCopy);
+ long itemsProcessed = 0;
+ long currentPage = 0;
+ while (true) {
+ AbstractCommonList abstractCommonList = this.getAuthorityItemList(existingCtx, parentIdentifier, uriInfoCopy);
+ if (abstractCommonList != null && !Tools.isEmpty(abstractCommonList.getListItem())) {
+ if (omittedItemAction.equalsIgnoreCase(VocabularyClient.DELETE_OMITTED_ITEMS)) {
+ deleteAuthorityItems(existingCtx, abstractCommonList, shortIdsInPayload, parentIdentifier);
+ } else {
+ sotfDeleteAuthorityItems(existingCtx, abstractCommonList, shortIdsInPayload, parentIdentifier);
+ }
}
+ itemsProcessed = itemsProcessed + abstractCommonList.getItemsInPage();
+ if (itemsProcessed >= abstractCommonList.getTotalItems()) {
+ break;
+ }
+ ArrayList<String> pageNum = new ArrayList<String>();
+ pageNum.add(Long.toString(++currentPage));
+ uriInfoCopy.getQueryParameters().put(IClientQueryParams.START_PAGE_PARAM, pageNum);
}
}
}