From: Aron Roberts Date: Tue, 8 May 2012 22:11:05 +0000 (-0700) Subject: CSPACE-5122,CSPACE-5156,CSPACE-3718: Updated Scientific Taxonomy authority service... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=c8ffaf416b38dab9b90b15abde2b2c3722988bc1;p=tmp%2Fjakarta-migration.git CSPACE-5122,CSPACE-5156,CSPACE-3718: Updated Scientific Taxonomy authority service to use repeatable term group. taxonomy module builds; client tests (including create) are failing. Can successfully create a taxonomy authority and taxon item, and list taxon items in that authority, in the lifesci tenant via curl. --- diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml index 39e6ff342..2d275c1c3 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml @@ -2437,8 +2437,8 @@ inauthority - taxon_common - displayname + taxontermgroup + termdisplayname taxon_common @@ -2492,7 +2492,15 @@ termRef - termStatus + taxonTermGroupList/*/termType + + + termRef + taxonTermGroupList/*/termLanguage + + + termRef + taxonTermGroupList/*/termStatus @@ -2628,7 +2636,7 @@ termRef recordType - + termRef conceptTermGroupList/*/termType diff --git a/services/taxonomy/3rdparty/nuxeo-platform-cs-taxonomy/src/main/resources/schemas/taxon_common.xsd b/services/taxonomy/3rdparty/nuxeo-platform-cs-taxonomy/src/main/resources/schemas/taxon_common.xsd index 6fb5f1bb8..2f8e427f4 100644 --- a/services/taxonomy/3rdparty/nuxeo-platform-cs-taxonomy/src/main/resources/schemas/taxon_common.xsd +++ b/services/taxonomy/3rdparty/nuxeo-platform-cs-taxonomy/src/main/resources/schemas/taxon_common.xsd @@ -12,11 +12,11 @@ --> @@ -25,15 +25,13 @@ - - - - - - - - + + + + + + @@ -66,5 +64,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java index b2f1f239f..0c3542d8c 100644 --- a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java +++ b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java @@ -37,7 +37,7 @@ public class TaxonomyAuthorityClient extends AuthorityClientImpl taxonInfo, + String taxonomyAuthRefName, Map taxonInfo, List terms, TaxonAuthorGroupList taxonAuthorGroupList, TaxonCitationList taxonCitationList, String headerLabel) { TaxonCommon taxon = new TaxonCommon(); String shortId = taxonInfo.get(TaxonJAXBSchema.SHORT_IDENTIFIER); - String displayName = taxonInfo.get(TaxonJAXBSchema.DISPLAY_NAME); taxon.setShortIdentifier(shortId); - // String taxonomyRefName = createTaxonomyRefName(taxonomyAuthRefName, shortId, displayName); - // taxon.setRefName(taxonomyRefName); - String value = null; - value = taxonInfo.get(TaxonJAXBSchema.DISPLAY_NAME_COMPUTED); - boolean displayNameComputed = (value == null) || value.equalsIgnoreCase("true"); - taxon.setDisplayNameComputed(displayNameComputed); - if ((value = (String) taxonInfo.get(TaxonJAXBSchema.TERM_STATUS)) != null) { - taxon.setTermStatus(value); - } + // Set values in the Term Information Group + String displayName = taxonInfo.get(TaxonJAXBSchema.DISPLAY_NAME); + TaxonTermGroupList termList = new TaxonTermGroupList(); + if (terms == null || terms.isEmpty()) { + if (Tools.notBlank(displayName)) { + terms = getTermGroupInstance(displayName); + } else { + terms = getTermGroupInstance(getGeneratedIdentifier()); + } + } + terms.get(0).setTermStatus(taxonInfo.get(TaxonJAXBSchema.TERM_STATUS)); + termList.getTaxonTermGroup().addAll(terms); + taxon.setTaxonTermGroupList(termList); + + String value = null; // Fields specific to this authority record type. if ((value = (String) taxonInfo.get(TaxonJAXBSchema.NAME)) != null) { taxon.setTaxonFullName(value); @@ -128,7 +133,7 @@ public class TaxonomyAuthorityClientUtils { */ public static String createItemInAuthority(String vcsid, String TaxonomyauthorityRefName, Map taxonMap, - TaxonAuthorGroupList taxonAuthorGroupList, + List terms, TaxonAuthorGroupList taxonAuthorGroupList, TaxonCitationList taxonCitationList, TaxonomyAuthorityClient client) { // Expected status code: 201 Created int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); @@ -154,7 +159,7 @@ public class TaxonomyAuthorityClientUtils { } PoxPayloadOut multipart = createTaxonInstance(TaxonomyauthorityRefName, - taxonMap, taxonAuthorGroupList, taxonCitationList, client.getItemCommonPartName()); + taxonMap, terms, taxonAuthorGroupList, taxonCitationList, client.getItemCommonPartName()); String newID = null; ClientResponse res = client.createItem(vcsid, multipart); try { @@ -317,4 +322,20 @@ public class TaxonomyAuthorityClientUtils { newStr.append(name); return newStr.toString(); } + + public static List getTermGroupInstance(String identifier) { + if (Tools.isBlank(identifier)) { + identifier = getGeneratedIdentifier(); + } + List terms = new ArrayList(); + TaxonTermGroup term = new TaxonTermGroup(); + term.setTermDisplayName(identifier); + term.setTermName(identifier); + terms.add(term); + return terms; + } + + private static String getGeneratedIdentifier() { + return "id" + new Date().getTime(); + } } diff --git a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java index 8650b4c54..45fb4eac1 100644 --- a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java +++ b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java @@ -44,6 +44,7 @@ import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon; import org.collectionspace.services.taxonomy.TaxonCommon; import javax.ws.rs.core.Response; +import org.collectionspace.services.taxonomy.*; import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; @@ -65,24 +66,23 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest NULL_TAXON_TERMS_LIST = null; + private final TaxonAuthorGroupList NULL_TAXON_AUTHOR_GROUP_LIST = null; + private final TaxonCitationList NULL_TAXON_CITATION_LIST = null; private String knownResourceShortIdentifer = null; private String knownTaxonomyTypeRefName = null; @@ -157,7 +157,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest res = client.readItem(knownResourceId, knownItemResourceId); - TaxonCommon taxon = null; - try { - assertStatusCode(res, testName); - // Check whether taxon has expected displayName. - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - taxon = (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(taxon); - } finally { - if (res != null) { - res.releaseConnection(); - } - } - // - // Now setup for an update - // - String displayName = taxon.getDisplayName(); - // Make sure displayName matches computed form - String expectedDisplayName = - TaxonomyAuthorityClientUtils.prepareDefaultDisplayName(TEST_TAXON_FULL_NAME); - Assert.assertNotNull(displayName, "Display name was null. Expected it to be: " + expectedDisplayName); - // Update the shortName and verify the computed name is updated. - taxon.setCsid(null); - taxon.setDisplayNameComputed(true); - taxon.setTaxonFullName("updated-" + TEST_TAXON_FULL_NAME); - expectedDisplayName = - TaxonomyAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_TAXON_FULL_NAME); - - // Create the update payload. - PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), taxon); - - setupUpdate(); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - TaxonCommon updatedTaxon = null; - try { - assertStatusCode(res, testName); - // Retrieve the updated resource and verify that its contents exist. - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - updatedTaxon = - (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(updatedTaxon); - } finally { - if (res != null) { - res.releaseConnection(); - } - } - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedTaxon.getTaxonFullName(), taxon.getTaxonFullName(), - "Updated ForeName in Taxonomy did not match submitted data."); - // Verify that the updated resource computes the right displayName. - Assert.assertEquals(updatedTaxon.getDisplayName(), expectedDisplayName, - "Updated ForeName in Taxonomy not reflected in computed DisplayName."); - // - // Now Update the displayName, not computed and verify the computed name is overriden. - // - taxon.setDisplayNameComputed(false); - expectedDisplayName = "TestName"; - taxon.setDisplayName(expectedDisplayName); - - // Submit the updated resource to the service and store the response. - output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - commonPart = output.addPart(client.getItemCommonPartName(), taxon); - setupUpdate(); // setup expected status code for result - res = client.updateItem(knownResourceId, knownItemResourceId, output); - try { - assertStatusCode(res, testName); - // Retrieve the updated resource and verify that its contents exist. - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - updatedTaxon = - (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(updatedTaxon); - } finally { - if (res != null) { - res.releaseConnection(); - } - } - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedTaxon.isDisplayNameComputed(), false, - "Updated displayNameComputed in Taxonomy did not match submitted data."); - // Verify that the updated resource computes the right displayName. - Assert.assertEquals(updatedTaxon.getDisplayName(), - expectedDisplayName, - "Updated DisplayName (not computed) in Taxonomy not stored."); - } - /** * Verify illegal item display name. * * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider = "testName", - dependsOnMethods = {"verifyItemDisplayName"}) + @Test(dataProvider = "testName") public void verifyIllegalItemDisplayName(String testName) throws Exception { // // First read in our known resource. @@ -308,10 +204,15 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest terms = termList.getTaxonTermGroup(); + Assert.assertNotNull(terms); + Assert.assertTrue(terms.size() > 0); + terms.get(0).setTermDisplayName(null); + terms.get(0).setTermName(null); PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), taxon); @@ -393,10 +294,10 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest terms = termList.getTaxonTermGroup(); + Assert.assertNotNull(terms); + Assert.assertTrue(terms.size() > 0); + terms.get(0).setTermDisplayName("updated-" + terms.get(0).getTermDisplayName()); + terms.get(0).setTermName("updated-" + terms.get(0).getTermName()); + result.setTaxonTermGroupList(termList); + return result; } @Override protected void compareUpdatedItemInstances(TaxonCommon original, TaxonCommon updated) throws Exception { - Assert.assertEquals(updated.getTaxonFullName(), original.getTaxonFullName(), - "Taxon full name in updated Taxon did not match submitted data."); + + TaxonTermGroupList originalTermList = original.getTaxonTermGroupList(); + Assert.assertNotNull(originalTermList); + List originalTerms = originalTermList.getTaxonTermGroup(); + Assert.assertNotNull(originalTerms); + Assert.assertTrue(originalTerms.size() > 0); + + TaxonTermGroupList updatedTermList = updated.getTaxonTermGroupList(); + Assert.assertNotNull(updatedTermList); + List updatedTerms = updatedTermList.getTaxonTermGroup(); + Assert.assertNotNull(updatedTerms); + Assert.assertTrue(updatedTerms.size() > 0); + + Assert.assertEquals(updatedTerms.get(0).getTermDisplayName(), + originalTerms.get(0).getTermDisplayName(), + "Value in updated record did not match submitted data."); } @Override @@ -605,15 +524,10 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest +> @@ -24,13 +24,12 @@ - - - - - - - + + + + + + @@ -67,6 +66,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java index 7aaa10d37..72cdb3465 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java @@ -1,73 +1,66 @@ /** - * This document is a part of the source code and related artifacts - * for CollectionSpace, an open source collections management system - * for museums and related institutions: - - * http://www.collectionspace.org - * http://wiki.collectionspace.org - - * Copyright 2009 University of California at Berkeley - - * Licensed under the Educational Community License (ECL), Version 2.0. - * You may not use this file except in compliance with this License. - - * You may obtain a copy of the ECL 2.0 License at - - * https://source.collectionspace.org/collection-space/LICENSE.txt - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * This document is a part of the source code and related artifacts for + * CollectionSpace, an open source collections management system for museums and + * related institutions: + * + * http://www.collectionspace.org http://wiki.collectionspace.org + * + * Copyright 2009 University of California at Berkeley + * + * Licensed under the Educational Community License (ECL), Version 2.0. You may + * not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * + * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. */ package org.collectionspace.services.taxonomy; +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; import org.collectionspace.services.client.TaxonomyAuthorityClient; import org.collectionspace.services.common.vocabulary.AuthorityResource; import org.collectionspace.services.taxonomy.nuxeo.TaxonDocumentModelHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.Consumes; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - +/** + * TaxonomyAuthorityResource + * + * Handles, dispatches, and returns responses to RESTful requests related to + * Taxonomy authority-related resources. + */ @Path(TaxonomyAuthorityClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class TaxonomyAuthorityResource - extends AuthorityResource { - - private final static String taxonomyAuthorityServiceName = "taxonomyauthority"; - private final static String TAXONOMYAUTHORITY_COMMON = "taxonomyauthority_common"; - private final static String taxonomyItemServiceName = "taxon"; - private final static String TAXONOMYITEM_COMMON = "taxon_common"; +public class TaxonomyAuthorityResource extends AuthorityResource { final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityResource.class); public TaxonomyAuthorityResource() { super(TaxonomyauthorityCommon.class, TaxonomyAuthorityResource.class, - TAXONOMYAUTHORITY_COMMON, TAXONOMYITEM_COMMON); + TaxonomyAuthorityClient.SERVICE_COMMON_PART_NAME, TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override public String getServiceName() { - return taxonomyAuthorityServiceName; + return TaxonomyAuthorityClient.SERVICE_NAME; } @Override public String getItemServiceName() { - return taxonomyItemServiceName; + return TaxonomyAuthorityClient.SERVICE_ITEM_NAME; } @Override - public Class getCommonPartClass() { - return TaxonomyauthorityCommon.class; - } - - @Override - public String getItemTermInfoGroupXPathBase() { + public String getItemTermInfoGroupXPathBase() { return TaxonomyAuthorityClient.TERM_INFO_GROUP_XPATH_BASE; - } -} + } +} \ No newline at end of file diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonValidatorHandler.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonValidatorHandler.java index abc758b33..51b85ff94 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonValidatorHandler.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonValidatorHandler.java @@ -23,77 +23,125 @@ */ package org.collectionspace.services.taxonomy.nuxeo; +import java.util.List; import java.util.regex.Pattern; -import org.collectionspace.services.taxonomy.TaxonCommon; -import org.collectionspace.services.common.context.MultipartServiceContext; -import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.document.DocumentHandler.Action; +import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.document.InvalidDocumentException; -import org.collectionspace.services.common.document.ValidatorHandler; +import org.collectionspace.services.common.document.ValidatorHandlerImpl; +import org.collectionspace.services.taxonomy.TaxonCommon; +import org.collectionspace.services.taxonomy.TaxonTermGroup; +import org.collectionspace.services.taxonomy.TaxonTermGroupList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * TaxonValidatorHandler * - * Validates data supplied when attempting to create and/or update Taxon records. - * - * $LastChangedRevision$ - * $LastChangedDate$ + * Performs validation when making requests related to Taxon records. + * As an example, you can modify this class to customize validation of + * payloads supplied in requests to create and/or update records. */ -public class TaxonValidatorHandler implements ValidatorHandler { +public class TaxonValidatorHandler extends ValidatorHandlerImpl { final Logger logger = LoggerFactory.getLogger(TaxonValidatorHandler.class); - private static final Pattern shortIdBadPattern = Pattern.compile("[\\W]"); //.matcher(input).matches() + // 'Bad pattern' for shortIdentifiers matches any non-word characters + private static final Pattern SHORT_ID_BAD_PATTERN = Pattern.compile("[\\W]"); //.matcher(input).matches() + private static final String VALIDATION_ERROR = "The record payload was invalid. See log file for more details."; + private static final String SHORT_ID_BAD_CHARS_ERROR = + "shortIdentifier must only contain standard word characters"; + private static final String HAS_NO_TERMS_ERROR = + "Authority items must contain at least one term."; + private static final String HAS_AN_EMPTY_TERM_ERROR = + "Each term group in an authority item must contain " + + "a non-empty term name or " + + "a non-empty term display name."; @Override - public void validate(Action action, ServiceContext ctx) - throws InvalidDocumentException { - if (logger.isDebugEnabled()) { - logger.debug("validate() action=" + action.name()); - } - - // Bail out if the validation action is for delete. - if (action.equals(Action.DELETE)) { - return; - } - - try { - MultipartServiceContext mctx = (MultipartServiceContext) ctx; - TaxonCommon taxon = (TaxonCommon) mctx.getInputPart(mctx.getCommonPartLabel(), - TaxonCommon.class); - String msg = ""; - boolean invalid = false; - - // Validation occurring on both creates and updates - String displayName = taxon.getDisplayName(); - if (!taxon.isDisplayNameComputed() && ((displayName == null) || displayName.trim().isEmpty())) { - invalid = true; - msg += "displayName must be non-null and non-blank if displayNameComputed is false"; + protected Class getCommonPartClass() { + return TaxonCommon.class; + } + + @Override + protected void handleCreate() throws InvalidDocumentException { + TaxonCommon organization = (TaxonCommon) getCommonPart(); + // No guarantee that there is a common part in every post/update. + if (organization != null) { + try { + String shortId = organization.getShortIdentifier(); + if (shortId != null) { + CS_ASSERT(shortIdentifierContainsOnlyValidChars(shortId), SHORT_ID_BAD_CHARS_ERROR); + } + CS_ASSERT(containsAtLeastOneTerm(organization), HAS_NO_TERMS_ERROR); + CS_ASSERT(allTermsContainNameOrDisplayName(organization), HAS_AN_EMPTY_TERM_ERROR); + } catch (AssertionError e) { + if (logger.isErrorEnabled()) { + logger.error(e.getMessage(), e); + } + throw new InvalidDocumentException(VALIDATION_ERROR, e); } + } + } - // Validation specific to creates or updates - if (action.equals(Action.CREATE)) { - String shortId = taxon.getShortIdentifier(); - // Per CSPACE-2215, shortIdentifier values that are null (missing) - // oe the empty string are now legally accepted in create payloads. - // In either of those cases, a short identifier will be synthesized from - // a display name or supplied in another manner. - if ((shortId != null) && (shortIdBadPattern.matcher(shortId).find())) { - invalid = true; - msg += "shortIdentifier must only contain standard word characters"; + @Override + protected void handleGet() throws InvalidDocumentException { + } + + @Override + protected void handleGetAll() throws InvalidDocumentException { + } + + @Override + protected void handleUpdate() throws InvalidDocumentException { + TaxonCommon organization = (TaxonCommon) getCommonPart(); + // No guarantee that there is a common part in every post/update. + if (organization != null) { + try { + // shortIdentifier is among a set of fields that are + // prevented from being changed on an update, and thus + // we don't need to check its value here. + CS_ASSERT(containsAtLeastOneTerm(organization), HAS_NO_TERMS_ERROR); + CS_ASSERT(allTermsContainNameOrDisplayName(organization), HAS_AN_EMPTY_TERM_ERROR); + } catch (AssertionError e) { + if (logger.isErrorEnabled()) { + logger.error(e.getMessage(), e); } - } else if (action.equals(Action.UPDATE)) { + throw new InvalidDocumentException(VALIDATION_ERROR, e); } + } + } + + @Override + protected void handleDelete() throws InvalidDocumentException { + } + + private boolean shortIdentifierContainsOnlyValidChars(String shortId) { + // Check whether any characters match the 'bad' pattern + if (SHORT_ID_BAD_PATTERN.matcher(shortId).find()) { + return false; + } + return true; + } + + private boolean containsAtLeastOneTerm(TaxonCommon organization) { + TaxonTermGroupList termGroupList = organization.getTaxonTermGroupList(); + if (termGroupList == null) { + return false; + } + List termGroups = termGroupList.getTaxonTermGroup(); + if ((termGroups == null) || (termGroups.isEmpty())){ + return false; + } + return true; + } - if (invalid) { - logger.error(msg); - throw new InvalidDocumentException(msg); + private boolean allTermsContainNameOrDisplayName(TaxonCommon organization) { + TaxonTermGroupList termGroupList = organization.getTaxonTermGroupList(); + List termGroups = termGroupList.getTaxonTermGroup(); + for (TaxonTermGroup termGroup : termGroups) { + if (Tools.isBlank(termGroup.getTermName()) || Tools.isBlank(termGroup.getTermDisplayName())) { + return false; } - } catch (InvalidDocumentException ide) { - throw ide; - } catch (Exception e) { - throw new InvalidDocumentException(e); } + return true; } }