From: remillet Date: Fri, 26 Jan 2018 19:05:42 +0000 (-0800) Subject: DRYD-202: PUT requests to /vocabularies/${csid} that include an items-list part now... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=1843921cdd317c707a85c70b2003ebbaeb0d62d7;p=tmp%2Fjakarta-migration.git DRYD-202: PUT requests to /vocabularies/${csid} that include an items-list part now return an items-list part in the response. --- diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 4bd707726..c73266f2d 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -569,6 +569,7 @@ public abstract class AuthorityResource @PUT @Path("{csid}") public byte[] updateAuthority( + @Context Request request, @Context ResourceMap resourceMap, @Context UriInfo uriInfo, @PathParam("csid") String specifier, diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java index 6389a5164..0272c9216 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java @@ -23,7 +23,6 @@ */ package org.collectionspace.services.common.vocabulary.nuxeo; -import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.api.Tools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +44,7 @@ public class AuthorityIdentifierUtils { // FIXME: Verify uniqueness before returning the generated short identifier. // FIXME: Consider using a hash of the display name, rather than a timestamp, // when it is necessary to add a suffix for uniqueness. - protected static String generateShortIdentifierFromDisplayName(String displayName, String shortDisplayName) { + public static String generateShortIdentifierFromDisplayName(String displayName, String shortDisplayName) { String generatedShortIdentifier = ""; if (Tools.notEmpty(displayName)) { generatedShortIdentifier = displayName + '-' + Tools.now().toString(); @@ -62,6 +61,4 @@ public class AuthorityIdentifierUtils { } return generatedShortIdentifier; } - - } diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java index 1ae94b8c1..7a924496b 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java @@ -46,6 +46,7 @@ import org.collectionspace.services.common.vocabulary.AuthorityServiceUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm; +import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityIdentifierUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.jaxb.AbstractCommonList.ListItem; import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; @@ -142,6 +143,7 @@ public class VocabularyResource extends @Path("{csid}") @Override public byte[] updateAuthority( + @Context Request request, @Context ResourceMap resourceMap, @Context UriInfo ui, @PathParam("csid") String specifier, @@ -165,8 +167,11 @@ public class VocabularyResource extends csid = getRepositoryClient(ctx).findDocCSID(null, ctx, whereClause); } getRepositoryClient(ctx).update(ctx, csid, handler); - handleItemsPayload(Method.PUT, ctx, csid, resourceMap, uriInfo, theUpdate); - result = ctx.getOutput(); + if (handleItemsPayload(Method.PUT, ctx, csid, resourceMap, uriInfo, theUpdate) == true) { + result = this.getAuthority(ctx, request, uriInfo, specifier, true); + } else { + result = ctx.getOutput(); + } } catch (Throwable t) { repoSession.setTransactionRollbackOnly(); throw t; @@ -375,7 +380,7 @@ public class VocabularyResource extends ResourceMap resourceMap, UriInfo uriInfo, PoxPayloadIn input) throws Exception { - boolean result = true; + boolean result = false; PayloadInputPart abstractCommonListPart = input.getPart(PoxPayload.ABSTRACT_COMMON_LIST_ROOT_ELEMENT_LABEL); if (abstractCommonListPart != null) { @@ -388,6 +393,7 @@ public class VocabularyResource extends updateWithItemsPayload(itemsList, existingCtx, parentIdentifier, resourceMap, uriInfo, input); break; } + result = true; // mark that we've handled an items-list payload } return result; @@ -493,14 +499,12 @@ public class VocabularyResource extends break; } } - + // + // We need to create a short ID if one wasn't supplied + // if (Tools.isEmpty(vocabularyItem.getShortIdentifier())) { - // - // We need to create a short ID since one wasn't supplied - // - String value = String.format("%s%d", getDisplayName(item), System.currentTimeMillis()); - value = DatatypeConverter.printHexBinary(value.getBytes()).toUpperCase(); - vocabularyItem.setShortIdentifier(value); + vocabularyItem.setShortIdentifier(AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName( + vocabularyItem.getDisplayName() , null)); ; } result = new PoxPayloadIn(VocabularyClient.SERVICE_ITEM_PAYLOAD_NAME, vocabularyItem,