From a73a0ac4c4c6de052d91f6f2ee77455e7c094287 Mon Sep 17 00:00:00 2001 From: Dustin Johnson Date: Fri, 26 Apr 2013 08:02:49 -0500 Subject: [PATCH] Issue #1910 More registry object validators, shutdown BandwidthManagers in a finally Amend: Add comment to validator xml Change-Id: I8c0007b94bf01a15eb2030ede7bc02dff68bca38 Former-commit-id: 3429859d84274d7986a4526819bea70a773dc85c --- .../bandwidth/BandwidthManager.java | 113 ++++---- edexOsgi/com.raytheon.uf.edex.ebxml/.project | 28 -- .../res/spring/ebxml-registry-dao.xml | 1 - .../res/spring/ebxml-validator-plugins.xml | 250 +++++++++++++++++ .../res/spring/ebxml-webservices.xml | 33 +-- .../ebxml/dao/AuditableEventTypeDao.java | 28 +- .../ebxml/services/AuditableEventService.java | 118 ++++++++ .../lifecycle/LifecycleManagerImpl.java | 13 +- .../IRegistryObjectReferenceValidator.java | 22 ++ ...erverRegistryObjectReferenceValidator.java | 20 ++ .../services/validator/ValidatorImpl.java | 4 + .../plugins/AssociationTypeValidator.java | 91 +++++++ .../plugins/ClassificationTypeValidator.java | 118 ++++++++ .../ExternalIdentifierTypeValidator.java | 88 ++++++ .../plugins/ExternalLinkTypeValidator.java | 85 ++++++ .../plugins/OrganizationTypeValidator.java | 22 +- .../plugins/RegistryObjectTypeValidator.java | 25 +- .../validator/plugins/ValidatorPlugin.java | 98 ++++++- .../web/webServiceBeans.xml | 1 + .../LifecycleManagerSubmitObjectsTest.java | 6 +- .../dao/RegistryNotificationManagerTest.java | 240 ----------------- .../services/validator/ValidatorImplTest.java | 3 + .../resources/ebxml/unit-test-ebxml-beans.xml | 12 +- .../raytheon/uf/common/util/SpringFiles.java | 7 +- ...ctlyInvokeRegistrySubscriptionManager.java | 22 +- ...stractRegistryObjectTypeValidatorTest.java | 235 ++++++++++++++++ .../plugins/AssociationTypeValidatorTest.java | 251 ++++++++++++++++++ .../ClassificationTypeValidatorTest.java | 207 +++++++++++++++ .../ExternalIdentifierTypeValidatorTest.java | 209 +++++++++++++++ .../ExternalLinkTypeValidatorTest.java | 146 ++++++++++ .../OrganizationTypeValidatorTest.java | 98 +++++++ .../regrep/xsd/rim/v4/ActionTypeFixture.java | 62 +++++ .../xsd/rim/v4/AssociationTypeFixture.java | 79 ++++++ .../xsd/rim/v4/AuditableEventTypeFixture.java | 78 ++++++ .../xsd/rim/v4/ClassificationTypeFixture.java | 78 ++++++ .../rim/v4/ExternalIdentifierTypeFixture.java | 78 ++++++ .../xsd/rim/v4/ExternalLinkTypeFixture.java | 82 ++++++ .../xsd/rim/v4/OrganizationTypeFixture.java | 34 ++- .../xsd/rim/v4/RegistryObjectTypeFixture.java | 71 +++++ 39 files changed, 2716 insertions(+), 440 deletions(-) delete mode 100644 edexOsgi/com.raytheon.uf.edex.ebxml/.project create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-validator-plugins.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/AuditableEventService.java create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidator.java create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidator.java create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidator.java create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidator.java delete mode 100644 tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/RegistryNotificationManagerTest.java create mode 100644 tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AbstractRegistryObjectTypeValidatorTest.java create mode 100644 tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidatorTest.java create mode 100644 tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidatorTest.java create mode 100644 tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidatorTest.java create mode 100644 tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidatorTest.java create mode 100644 tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidatorTest.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ActionTypeFixture.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AssociationTypeFixture.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AuditableEventTypeFixture.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ClassificationTypeFixture.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalIdentifierTypeFixture.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalLinkTypeFixture.java create mode 100644 tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/RegistryObjectTypeFixture.java diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java index ec12beb6c0..a11c7fb206 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java @@ -108,6 +108,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Feb 27, 2013 1644 djohnson Force sub-classes to provide an implementation for how to schedule SBN routed subscriptions. * Mar 11, 2013 1645 djohnson Watch configuration file for changes. * Mar 28, 2013 1841 djohnson Subscription is now UserSubscription. + * May 02, 2013 1910 djohnson Shutdown proposed bandwidth managers in a finally. * * * @author dhladky @@ -1310,16 +1311,20 @@ public abstract class BandwidthManager extends BandwidthMap copyOfCurrentMap = BandwidthMap .load(EdexBandwidthContextFactory.getBandwidthMapConfig()); - BandwidthManager proposedBwManager = startProposedBandwidthManager(copyOfCurrentMap); + Set unscheduled = Collections.emptySet(); + BandwidthManager proposedBwManager = null; + try { + proposedBwManager = startProposedBandwidthManager(copyOfCurrentMap); - IBandwidthRequest request = new IBandwidthRequest(); - request.setRequestType(RequestType.SCHEDULE_SUBSCRIPTION); - request.setSubscriptions(subscriptions); + IBandwidthRequest request = new IBandwidthRequest(); + request.setRequestType(RequestType.SCHEDULE_SUBSCRIPTION); + request.setSubscriptions(subscriptions); - final Set unscheduled = proposedBwManager - .scheduleSubscriptions(subscriptions); - - proposedBwManager.shutdown(); + unscheduled = proposedBwManager + .scheduleSubscriptions(subscriptions); + } finally { + nullSafeShutdown(proposedBwManager); + } final ProposeScheduleResponse proposeScheduleResponse = new ProposeScheduleResponse(); proposeScheduleResponse.setUnscheduledSubscriptions(unscheduled); @@ -1327,6 +1332,18 @@ public abstract class BandwidthManager extends return proposeScheduleResponse; } + /** + * Shutdown if not null. + * + * @param bandwidthManager + * the bandwidth manager + */ + private void nullSafeShutdown(BandwidthManager bandwidthManager) { + if (bandwidthManager != null) { + bandwidthManager.shutdown(); + } + } + /** * Propose changing a route's bandwidth to the specified amount. * @@ -1342,45 +1359,49 @@ public abstract class BandwidthManager extends BandwidthRoute route = copyOfCurrentMap.getRoute(requestNetwork); route.setDefaultBandwidth(bandwidth); - BandwidthManager proposedBwManager = startProposedBandwidthManager(copyOfCurrentMap); - - if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { - statusHandler.debug("Current retrieval plan:" + Util.EOL - + showRetrievalPlan(requestNetwork) + Util.EOL - + "Proposed retrieval plan:" + Util.EOL - + proposedBwManager.showRetrievalPlan(requestNetwork)); - } - - List unscheduledAllocations = proposedBwManager.bandwidthDao - .getBandwidthAllocationsInState(RetrievalStatus.UNSCHEDULED); - - if (!unscheduledAllocations.isEmpty() - && statusHandler.isPriorityEnabled(Priority.DEBUG)) { - LogUtil.logIterable( - statusHandler, - Priority.DEBUG, - "The following unscheduled allocations would occur with the proposed bandwidth:", - unscheduledAllocations); - } - Set subscriptions = new HashSet(); - for (BandwidthAllocation allocation : unscheduledAllocations) { - if (allocation instanceof SubscriptionRetrieval) { - subscriptions.add(((SubscriptionRetrieval) allocation) - .getSubscription()); + BandwidthManager proposedBwManager = null; + try { + proposedBwManager = startProposedBandwidthManager(copyOfCurrentMap); + + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.debug("Current retrieval plan:" + Util.EOL + + showRetrievalPlan(requestNetwork) + Util.EOL + + "Proposed retrieval plan:" + Util.EOL + + proposedBwManager.showRetrievalPlan(requestNetwork)); } + + List unscheduledAllocations = proposedBwManager.bandwidthDao + .getBandwidthAllocationsInState(RetrievalStatus.UNSCHEDULED); + + if (!unscheduledAllocations.isEmpty() + && statusHandler.isPriorityEnabled(Priority.DEBUG)) { + LogUtil.logIterable( + statusHandler, + Priority.DEBUG, + "The following unscheduled allocations would occur with the proposed bandwidth:", + unscheduledAllocations); + } + + for (BandwidthAllocation allocation : unscheduledAllocations) { + if (allocation instanceof SubscriptionRetrieval) { + subscriptions.add(((SubscriptionRetrieval) allocation) + .getSubscription()); + } + } + + if (!subscriptions.isEmpty() + && statusHandler.isPriorityEnabled(Priority.INFO)) { + LogUtil.logIterable( + statusHandler, + Priority.INFO, + "The following subscriptions would not be scheduled with the proposed bandwidth:", + subscriptions); + } + } finally { + nullSafeShutdown(proposedBwManager); } - if (!subscriptions.isEmpty() - && statusHandler.isPriorityEnabled(Priority.INFO)) { - LogUtil.logIterable( - statusHandler, - Priority.INFO, - "The following subscriptions would not be scheduled with the proposed bandwidth:", - subscriptions); - } - - proposedBwManager.shutdown(); return subscriptions; } @@ -1694,11 +1715,11 @@ public abstract class BandwidthManager extends BandwidthMap copyOfCurrentMap = BandwidthMap .load(EdexBandwidthContextFactory.getBandwidthMapConfig()); - BandwidthManager proposedBandwidthManager = startProposedBandwidthManager(copyOfCurrentMap); + BandwidthManager proposedBandwidthManager = null; try { + proposedBandwidthManager = startProposedBandwidthManager(copyOfCurrentMap); Set unscheduled = proposedBandwidthManager .scheduleSubscriptions(Arrays.asList(subscription)); - proposedBandwidthManager.shutdown(); return unscheduled.isEmpty(); } catch (SerializationException e) { statusHandler @@ -1706,6 +1727,8 @@ public abstract class BandwidthManager extends "Serialization error while determining required latency. Returning true in order to be fault tolerant.", e); return true; + } finally { + nullSafeShutdown(proposedBandwidthManager); } } diff --git a/edexOsgi/com.raytheon.uf.edex.ebxml/.project b/edexOsgi/com.raytheon.uf.edex.ebxml/.project deleted file mode 100644 index 0dd0f1d820..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ebxml/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.ebxml - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-registry-dao.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-registry-dao.xml index e8d1ddf656..6f4cab8b85 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-registry-dao.xml +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-registry-dao.xml @@ -42,7 +42,6 @@ - diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-validator-plugins.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-validator-plugins.xml new file mode 100644 index 0000000000..5f3a7490af --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-validator-plugins.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-webservices.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-webservices.xml index 4562eaee80..ec3db3c7bc 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-webservices.xml +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/spring/ebxml-webservices.xml @@ -1,10 +1,7 @@ - + - + @@ -28,7 +25,7 @@ - + @@ -100,25 +97,9 @@ - - - - - + + + - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java index a45e91db3d..6971ffc9bd 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java @@ -43,7 +43,6 @@ import com.raytheon.uf.common.registry.constants.StatusTypes; import com.raytheon.uf.common.registry.ebxml.RegistryUtil; import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; -import com.raytheon.uf.edex.registry.ebxml.services.IRegistrySubscriptionManager; import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; /** @@ -58,6 +57,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; * 3/18/2013 1802 bphillip Initial creation * 4/9/2013 1802 bphillip Removed exception catching * Apr 17, 2013 1914 djohnson Use strategy for subscription processing. + * May 02, 2013 1910 djohnson Broke out registry subscription notification to a service class. * * * @@ -85,8 +85,6 @@ public class AuditableEventTypeDao extends /** Order by clause */ private static final String ORDER_CLAUSE = " order by event.timestamp asc"; - private IRegistrySubscriptionManager subscriptionManager; - /** * Constructor. * @@ -98,14 +96,6 @@ public class AuditableEventTypeDao extends @Override public void create(AuditableEventType event) { template.save(event); - // Notify the subscription monitor that a new event has occurred - try { - subscriptionManager.processSubscriptions(); - } catch (Throwable t) { - statusHandler - .error("Unexpected error ecountered while processing subscriptions!", - t); - } } /** @@ -302,20 +292,4 @@ public class AuditableEventTypeDao extends return AuditableEventType.class; } - /** - * @return the subscription manager - */ - public IRegistrySubscriptionManager getSubscriptionManager() { - return subscriptionManager; - } - - /** - * @param subscriptionManager - * the subscriptionManager to set - */ - public void setSubscriptionManager( - IRegistrySubscriptionManager subscriptionManager) { - this.subscriptionManager = subscriptionManager; - } - } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/AuditableEventService.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/AuditableEventService.java new file mode 100644 index 0000000000..da2e197a2d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/AuditableEventService.java @@ -0,0 +1,118 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services; + +import java.util.List; +import java.util.Map; + +import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.RemoveObjectsRequest; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AuditableEventType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryRequestType; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.registry.ebxml.dao.AuditableEventTypeDao; +import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; + +/** + * Service to interact with {@link AuditableEventType} objects. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 02, 2013 1910       djohnson     Extracted subscription notification from the dao.
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class AuditableEventService { + + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(AuditableEventService.class); + + private final AuditableEventTypeDao auditDao; + + private final IRegistrySubscriptionManager subscriptionManager; + + public AuditableEventService(AuditableEventTypeDao auditDao, + IRegistrySubscriptionManager subscriptionManager) { + this.auditDao = auditDao; + this.subscriptionManager = subscriptionManager; + } + + /** + * Creates an auditable event from a registry request and registry objects + * + * @param request + * The request that generated the events + * @param actionMap + * The actions that occurred + * @param currentTime + * The time the event occurred @ the event + * @throws EbxmlRegistryException + * If errors occur while creating + */ + public void createAuditableEventsFromObjects(RegistryRequestType request, + Map> actionMap, long currentTime) + throws EbxmlRegistryException { + auditDao.createAuditableEventsFromObjects(request, actionMap, + currentTime); + notifySubscriptionManager(); + } + + /** + * Creates an auditable event from a registry request and object references + * + * @param request + * The request that generated the events + * @param actionMap + * The actions that occurred + * @param currentTime + * The time the event occurred @ the event + * @throws EbxmlRegistryException + * If errors occur while creating + */ + public void createAuditableEventsFromRefs(RemoveObjectsRequest request, + Map> actionMap, long currentTimeMillis) + throws EbxmlRegistryException { + auditDao.createAuditableEventsFromRefs(request, actionMap, + currentTimeMillis); + notifySubscriptionManager(); + } + + private void notifySubscriptionManager() { + // Notify the subscription monitor that a new event has occurred + try { + subscriptionManager.processSubscriptions(); + } catch (Throwable t) { + statusHandler + .error("Unexpected error ecountered while processing subscriptions!", + t); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/lifecycle/LifecycleManagerImpl.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/lifecycle/LifecycleManagerImpl.java index fdb1da05d9..f374dcec0a 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/lifecycle/LifecycleManagerImpl.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/lifecycle/LifecycleManagerImpl.java @@ -73,10 +73,10 @@ import com.raytheon.uf.common.registry.event.RegistryStatisticsEvent; import com.raytheon.uf.common.registry.event.RemoveRegistryEvent; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.edex.registry.ebxml.dao.AuditableEventTypeDao; import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao; import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectTypeDao; import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; +import com.raytheon.uf.edex.registry.ebxml.services.AuditableEventService; import com.raytheon.uf.edex.registry.ebxml.services.cataloger.CatalogerImpl; import com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl; import com.raytheon.uf.edex.registry.ebxml.services.validator.ValidatorImpl; @@ -132,7 +132,7 @@ public class LifecycleManagerImpl implements LifecycleManager { /** The registry object data access object */ private RegistryObjectDao registryObjectDao; - private AuditableEventTypeDao auditableEventDao; + private AuditableEventService auditableEventService; /** * The Remove Objects protocol allows a client to remove or delete one or @@ -242,7 +242,7 @@ public class LifecycleManagerImpl implements LifecycleManager { try { Map> actionMap = new HashMap>(); actionMap.put(ActionTypes.delete, objRefs); - auditableEventDao.createAuditableEventsFromRefs(request, actionMap, + auditableEventService.createAuditableEventsFromRefs(request, actionMap, System.currentTimeMillis()); registryObjectDao.deleteByRefs(objRefs); @@ -610,7 +610,7 @@ public class LifecycleManagerImpl implements LifecycleManager { if (!objsUpdated.isEmpty()) { actionMap.put(ActionTypes.update, objsUpdated); } - auditableEventDao.createAuditableEventsFromObjects(request, + auditableEventService.createAuditableEventsFromObjects(request, actionMap, System.currentTimeMillis()); } catch (EbxmlRegistryException e) { response.getException() @@ -716,8 +716,9 @@ public class LifecycleManagerImpl implements LifecycleManager { this.validator = validator; } - public void setAuditableEventDao(AuditableEventTypeDao auditableEventDao) { - this.auditableEventDao = auditableEventDao; + public void setAuditableEventService( + AuditableEventService auditableEventService) { + this.auditableEventService = auditableEventService; } public void setCataloger(CatalogerImpl cataloger) { diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/IRegistryObjectReferenceValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/IRegistryObjectReferenceValidator.java index 353eaefb55..83e1849fb7 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/IRegistryObjectReferenceValidator.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/IRegistryObjectReferenceValidator.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.edex.registry.ebxml.services.validator; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; + /** * Interface to validate a registry object reference. * @@ -29,6 +31,7 @@ package com.raytheon.uf.edex.registry.ebxml.services.validator; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 23, 2013 1910 djohnson Initial creation + * May 02, 2013 1910 djohnson Add ability to validate registry object type. * * * @@ -37,6 +40,13 @@ package com.raytheon.uf.edex.registry.ebxml.services.validator; */ public interface IRegistryObjectReferenceValidator { + /** + * Return values for validating the type of a reference. + */ + enum ValidateObjectTypeResponse { + VALID, DOESNT_EXIST, WRONG_TYPE; + } + /** * Check a reference for validity. * @@ -46,4 +56,16 @@ public interface IRegistryObjectReferenceValidator { */ boolean isValidReference(final String reference); + /** + * Check a reference to be of the correct type of registry object. + * + * @param reference + * the reference + * @param expectedType + * the expected type + * @return true if the registry object is of the expected type + */ + ValidateObjectTypeResponse isValidObjectType(String reference, + Class expectedType); + } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/LocalServerRegistryObjectReferenceValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/LocalServerRegistryObjectReferenceValidator.java index 29dcfd4dd1..d8cfe78446 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/LocalServerRegistryObjectReferenceValidator.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/LocalServerRegistryObjectReferenceValidator.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.edex.registry.ebxml.services.validator; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; + import org.springframework.transaction.annotation.Transactional; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -37,6 +39,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 23, 2013 1910 djohnson Initial creation + * May 02, 2013 1910 djohnson Add ability to validate registry object type. * * * @@ -78,4 +81,21 @@ public class LocalServerRegistryObjectReferenceValidator implements public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) { this.registryObjectDao = registryObjectDao; } + + /** + * {@inheritDoc} + */ + @Override + public ValidateObjectTypeResponse isValidObjectType(String reference, + Class expectedType) { + final RegistryObjectType registryObject = registryObjectDao + .getById(reference); + if (registryObject == null) { + return ValidateObjectTypeResponse.DOESNT_EXIST; + } else if (!expectedType.isAssignableFrom(registryObject.getClass())) { + return ValidateObjectTypeResponse.WRONG_TYPE; + } + + return ValidateObjectTypeResponse.VALID; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImpl.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImpl.java index 115f83c296..ae24bd3a79 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImpl.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImpl.java @@ -229,6 +229,10 @@ public class ValidatorImpl implements Validator { ValidateObjectsRequest validateRegistryObjects = new ValidateObjectsRequest(); validateRegistryObjects.setOriginalObjects(registryObjectListType); + // TODO: Make sure to include any registry objects passed in, + // e.g. an AssociationType can create an association between two + // objects that were passed in with it + // Find any specific validator for this type Validator validator = validatorPlugins .getRegisteredObject(objectType); diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidator.java new file mode 100644 index 0000000000..cab667881a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidator.java @@ -0,0 +1,91 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import java.util.List; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationNodeType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * {@link Validator} plugin implementation for {@link AssociationType} + * instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class AssociationTypeValidator extends ValidatorPlugin { + + /** + * Constructor. + * + * @param registryObjectReferenceValidator + */ + protected AssociationTypeValidator( + IRegistryObjectReferenceValidator registryObjectReferenceValidator) { + super(registryObjectReferenceValidator); + } + + /** + * {@inheritDoc} + */ + @Override + protected Class getRegistryObjectTypeClass() { + return AssociationType.class; + } + + /** + * {@inheritDoc} + */ + @Override + protected void validate(AssociationType registryObject, + List exceptions) { + final String sourceObject = registryObject.getSourceObject(); + final String targetObject = registryObject.getTargetObject(); + final String type = registryObject.getType(); + + final String registryObjectId = registryObject.getId(); + validateNotNull(sourceObject, "sourceObject", registryObjectId, + exceptions); + validateNotNull(targetObject, "targetObject", registryObjectId, + exceptions); + validateNotNull(type, "type", registryObjectId, exceptions); + + validateReference(sourceObject, exceptions); + validateReference(targetObject, exceptions); + validateReferenceOfType(type, ClassificationNodeType.class, exceptions); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidator.java new file mode 100644 index 0000000000..ae84d7da8d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidator.java @@ -0,0 +1,118 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import java.util.List; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationNodeType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationSchemeType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; +import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidationExceptionType; + +import com.raytheon.uf.common.registry.constants.ErrorSeverity; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; +import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; + +/** + * {@link Validator} plugin implementation for {@link ClassificationType} + * instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ClassificationTypeValidator extends + ValidatorPlugin { + + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(ClassificationType.class); + + /** + * Constructor. + * + * @param registryObjectReferenceValidator + */ + protected ClassificationTypeValidator( + IRegistryObjectReferenceValidator registryObjectReferenceValidator) { + super(registryObjectReferenceValidator); + } + + /** + * {@inheritDoc} + */ + @Override + protected Class getRegistryObjectTypeClass() { + return ClassificationType.class; + } + + /** + * {@inheritDoc} + */ + @Override + protected void validate(ClassificationType registryObject, + List exceptions) { + final String classificationScheme = registryObject + .getClassificationScheme(); + final String classificationNode = registryObject + .getClassificationNode(); + final String classifiedObject = registryObject.getClassifiedObject(); + final String nodeRepresentation = registryObject + .getNodeRepresentation(); + + if ((classificationScheme != null && classificationNode != null) + || (classificationScheme == null && classificationNode == null)) { + final String message = "One and only one of classificationNode or classificationScheme must be specified"; + exceptions.add(EbxmlExceptionUtil.createRegistryException( + ValidationExceptionType.class, "", message, message, + ErrorSeverity.ERROR, statusHandler)); + } + + final String registryObjectId = registryObject.getId(); + validateReferenceOfType(classificationScheme, + ClassificationSchemeType.class, exceptions); + validateReferenceOfType(classificationNode, + ClassificationNodeType.class, exceptions); + + validateNotNull(classifiedObject, "classifiedObject", registryObjectId, + exceptions); + validateReference(classifiedObject, exceptions); + + // External classification type, node representation is required + if (classificationScheme != null) { + validateNotNull(nodeRepresentation, "nodeRepresentation", + registryObjectId, exceptions); + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidator.java new file mode 100644 index 0000000000..ee99598450 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidator.java @@ -0,0 +1,88 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import java.util.List; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalIdentifierType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * {@link Validator} plugin implementation for {@link ExternalIdentifierType} + * instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ExternalIdentifierTypeValidator extends + ValidatorPlugin { + + /** + * Constructor. + * + * @param registryObjectReferenceValidator + */ + protected ExternalIdentifierTypeValidator( + IRegistryObjectReferenceValidator registryObjectReferenceValidator) { + super(registryObjectReferenceValidator); + } + + /** + * {@inheritDoc} + */ + @Override + protected Class getRegistryObjectTypeClass() { + return ExternalIdentifierType.class; + } + + /** + * {@inheritDoc} + */ + @Override + protected void validate(ExternalIdentifierType registryObject, + List exceptions) { + final String registryObjectId = registryObject.getId(); + final String identificationScheme = registryObject + .getIdentificationScheme(); + + validateNotNull(registryObject.getValue(), "value", registryObjectId, + exceptions); + validateNotNull(identificationScheme, "identificationScheme", + registryObjectId, exceptions); + + validateReference(identificationScheme, exceptions); + validateReference(registryObject.getRegistryObject(), exceptions); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidator.java new file mode 100644 index 0000000000..6dfb7d35c8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidator.java @@ -0,0 +1,85 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import java.util.List; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalLinkType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SimpleLinkType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * {@link Validator} plugin implementation for {@link ExternalLinkType} + * instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ExternalLinkTypeValidator extends + ValidatorPlugin { + + /** + * Constructor. + * + * @param registryObjectReferenceValidator + */ + protected ExternalLinkTypeValidator( + IRegistryObjectReferenceValidator registryObjectReferenceValidator) { + super(registryObjectReferenceValidator); + } + + /** + * {@inheritDoc} + */ + @Override + protected Class getRegistryObjectTypeClass() { + return ExternalLinkType.class; + } + + /** + * {@inheritDoc} + */ + @Override + protected void validate(ExternalLinkType registryObject, + List exceptions) { + final String registryObjectId = registryObject.getId(); + final SimpleLinkType externalRef = registryObject.getExternalRef(); + + validateNotNull(externalRef, "externalRef", registryObjectId, + exceptions); + + validateReference(registryObject.getRegistryObject(), exceptions); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidator.java index ab8f548916..22997df73b 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidator.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidator.java @@ -25,11 +25,7 @@ import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; -import com.google.common.collect.Lists; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; -import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; /** * {@link Validator} plugin implementation for {@link OrganizationType} @@ -42,6 +38,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 23, 2013 1910 djohnson Initial creation + * May 02, 2013 1910 djohnson Extracted reusable methods to parent class. * * * @@ -52,9 +49,6 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; public class OrganizationTypeValidator extends ValidatorPlugin { - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(OrganizationTypeValidator.class); - /** * Constructor. * @@ -78,19 +72,11 @@ public class OrganizationTypeValidator extends * {@inheritDoc} */ @Override - protected List validate( - OrganizationType registryObject) { - List exceptions = Lists.newArrayList(); + protected void validate(OrganizationType registryObject, + List exceptions) { - final boolean validReference = registryObjectReferenceValidator - .isValidReference(registryObject.getPrimaryContact()); - if (!validReference) { - exceptions.add(EbxmlExceptionUtil - .createUnresolvedReferenceException(null, - registryObject.getPrimaryContact(), statusHandler)); - } + validateReference(registryObject.getPrimaryContact(), exceptions); - return exceptions; } } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/RegistryObjectTypeValidator.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/RegistryObjectTypeValidator.java index cebc2bdcda..cb92edbb08 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/RegistryObjectTypeValidator.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/RegistryObjectTypeValidator.java @@ -29,7 +29,6 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalLinkType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; -import com.google.common.collect.Lists; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; @@ -45,6 +44,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 23, 2013 1910 djohnson Initial creation + * May 02, 2013 1910 djohnson Extract reusable code to parent class. * * * @@ -79,12 +79,9 @@ public class RegistryObjectTypeValidator extends * {@inheritDoc} */ @Override - protected List validate( - RegistryObjectType registryObject) { - List exceptions = Lists.newArrayList(); - exceptions.addAll(resolveReferences(registryObject, - registryObject.getId())); - return exceptions; + protected void validate(RegistryObjectType registryObject, + List exceptions) { + resolveReferences(registryObject, registryObject.getId(), exceptions); } /** @@ -101,30 +98,28 @@ public class RegistryObjectTypeValidator extends * If errors occur while querying the registry, or there is an * unresolvable property */ - private List resolveReferences( - RegistryObjectType object, String originalId) { - List exceptions = Lists.newArrayList(); + private void resolveReferences(RegistryObjectType object, + String originalId, List exceptions) { final String objectId = object.getId(); statusHandler.info("Checking references for object with id [" + objectId + "]..."); Set classifications = object.getClassification(); if (classifications != null) { for (ClassificationType classification : classifications) { - exceptions - .addAll(resolveReferences(classification, originalId)); + resolveReferences(classification, originalId, exceptions); } } Set externIdents = object .getExternalIdentifier(); if (externIdents != null) { for (ExternalIdentifierType externIdent : externIdents) { - exceptions.addAll(resolveReferences(externIdent, originalId)); + resolveReferences(externIdent, originalId, exceptions); } } Set externLinks = object.getExternalLink(); if (externLinks != null) { for (ExternalLinkType externLink : externLinks) { - exceptions.addAll(resolveReferences(externLink, originalId)); + resolveReferences(externLink, originalId, exceptions); } } @@ -143,6 +138,6 @@ public class RegistryObjectTypeValidator extends } } - return exceptions; } + } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ValidatorPlugin.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ValidatorPlugin.java index a7364b2322..c500c08d5f 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ValidatorPlugin.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ValidatorPlugin.java @@ -30,12 +30,13 @@ import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus; import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsRequest; import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsResponse; +import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidationExceptionType; import com.raytheon.uf.common.registry.constants.ErrorSeverity; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.util.CollectionUtil; import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator.ValidateObjectTypeResponse; import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; /** @@ -48,6 +49,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 23, 2013 1910 djohnson Initial creation + * May 02, 2013 1910 djohnson Extract reusable code to parent class. * * * @@ -97,10 +99,7 @@ public abstract class ValidatorPlugin implements for (RegistryObjectType registryObject : originalObjects .getRegistryObject()) { final T expectedType = castToExpectedType(registryObject); - final List exceptions = validate(expectedType); - if (!CollectionUtil.isNullOrEmpty(exceptions)) { - allExceptions.addAll(exceptions); - } + validate(expectedType, allExceptions); } RegistryResponseStatus status = (allExceptions.isEmpty()) ? RegistryResponseStatus.SUCCESS @@ -110,6 +109,90 @@ public abstract class ValidatorPlugin implements return response; } + /** + * Check a reference for validity. A null reference will return true, + * sub-classes should validate any required fields on their own. + * + * @param reference + * the reference to check + * @param exceptions + * the exceptions collection + */ + protected void validateReference(String reference, + List exceptions) { + final boolean validReference = (reference == null) ? true + : registryObjectReferenceValidator.isValidReference(reference); + if (!validReference) { + exceptions.add(EbxmlExceptionUtil + .createUnresolvedReferenceException(null, reference, + statusHandler)); + } + } + + /** + * Check a reference for validity and its type. A null reference will return + * true, sub-classes should validate any required fields on their own. + * + * @param reference + * the reference to check + * @param expectedType + * the expected registry object type + * @param exceptions + * the exceptions collection + */ + protected void validateReferenceOfType(String reference, + Class expectedType, + List exceptions) { + if (reference == null) { + return; + } + final ValidateObjectTypeResponse validationResponse = registryObjectReferenceValidator + .isValidObjectType(reference, expectedType); + + switch (validationResponse) { + case DOESNT_EXIST: + exceptions.add(EbxmlExceptionUtil + .createUnresolvedReferenceException(null, reference, + statusHandler)); + break; + case WRONG_TYPE: + exceptions.add(EbxmlExceptionUtil.createRegistryException( + ValidationExceptionType.class, + "", + "Referenced object has the wrong type", + "Referenced object with id [" + reference + + "] is not of type [" + + expectedType.getCanonicalName(), + ErrorSeverity.ERROR, statusHandler)); + break; + case VALID: + break; + } + } + + /** + * Validate the value is not null. If it's null, an + * {@link InvalidRequestExceptionType} will be added to the exceptions. + * + * @param value + * the value + * @param registryObjectId + * the registry object id + * @param exceptions + * the exceptions + */ + protected void validateNotNull(Object value, String fieldName, + String registryObjectId, List exceptions) { + if (value == null) { + String exceptionMessage = "[" + fieldName + + "] must not be null on registry object [" + + registryObjectId + "]"; + exceptions.add(EbxmlExceptionUtil.createRegistryException( + ValidationExceptionType.class, "", exceptionMessage, + exceptionMessage, ErrorSeverity.ERROR, statusHandler)); + } + } + /** * Verify the {@link RegistryObjectType} is a type supported by this * Validator plugin. @@ -147,6 +230,9 @@ public abstract class ValidatorPlugin implements * * @param registryObject * the object to validate + * @param exceptions + * the collection to add exceptions to */ - protected abstract List validate(T registryObject); + protected abstract void validate(T registryObject, + List exceptions); } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/webServiceBeans.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/webServiceBeans.xml index 343dddbd33..04accb53af 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/webServiceBeans.xml +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/webServiceBeans.xml @@ -13,6 +13,7 @@ + diff --git a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java index 7bfbe454bc..0f1ebe8932 100644 --- a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java +++ b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java @@ -69,6 +69,7 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil; * Apr 15, 2013 1693 djohnson Initial creation * Apr 18, 2013 1693 djohnson More tests verifying spec compliance.. * Apr 23, 2013 1910 djohnson More checkReference tests. + * May 02, 2013 1910 djohnson Add validator plugins spring file. * * * @@ -80,6 +81,8 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil; SpringFiles.EBXML_XML, SpringFiles.EBXML_IMPL_XML, SpringFiles.EBXML_QUERYTYPES_XML, SpringFiles.EBXML_REGISTRY_DAO_XML, SpringFiles.EBXML_WEBSERVICES_XML, SpringFiles.EBXML_XACML_XML, + SpringFiles.EBXML_VALIDATOR_PLUGINS_XML, + SpringFiles.EBXML_SUBSCRIPTION_XML, SpringFiles.UNIT_TEST_EBXML_BEANS_XML, SpringFiles.UNIT_TEST_LOCALIZATION_BEANS_XML }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) @@ -114,8 +117,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest { * @throws MsgRegistryException */ @Test - public void createOnlyWithExistantObjectFails() - throws MsgRegistryException { + public void createOnlyWithExistantObjectFails() throws MsgRegistryException { SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest( MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, Mode.CREATE_ONLY); diff --git a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/RegistryNotificationManagerTest.java b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/RegistryNotificationManagerTest.java deleted file mode 100644 index e68cc82cf5..0000000000 --- a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/RegistryNotificationManagerTest.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.registry.ebxml.dao; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; - -import java.util.Arrays; - -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.ws.wsaddressing.W3CEndpointReference; -import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder; - -import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; -import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.NotificationListener; -import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode; -import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest; -import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DeliveryInfoType; -import oasis.names.tc.ebxml.regrep.xsd.rim.v4.NotificationType; -import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType; -import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType; -import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType; -import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes; -import com.raytheon.uf.common.registry.constants.DeliveryMethodTypes; -import com.raytheon.uf.common.registry.constants.Namespaces; -import com.raytheon.uf.common.registry.constants.NotificationOptionTypes; -import com.raytheon.uf.common.registry.ebxml.RegistryUtil; -import com.raytheon.uf.common.util.SpringFiles; -import com.raytheon.uf.edex.database.dao.DatabaseUtil; -import com.raytheon.uf.edex.registry.ebxml.services.notification.MockNotificationListenerFactory; -import com.raytheon.uf.edex.registry.ebxml.services.notification.RegistryNotificationManager; -import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl; - -/** - * Test {@link RegistryNotificationManager}. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Apr 16, 2013 1672       djohnson     Initial creation
- * 
- * 
- * - * @author djohnson - * @version 1.0 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, - SpringFiles.EBXML_XML, SpringFiles.EBXML_WEBSERVICES_XML, - SpringFiles.EBXML_QUERYTYPES_XML, SpringFiles.EBXML_REGISTRY_DAO_XML, - SpringFiles.EBXML_REPLICATION_XML, SpringFiles.EBXML_XACML_XML, - SpringFiles.EBXML_REPLICATION_DATADELIVERY_WFO_XML, - SpringFiles.UNIT_TEST_EBXML_BEANS_XML, - SpringFiles.UNIT_TEST_EBXML_REPLICATION_BEANS_XML, - SpringFiles.UNIT_TEST_EBXML_PLUGIN_NOTIFICATION_LISTENER_XML, - SpringFiles.UNIT_TEST_LOCALIZATION_BEANS_XML }) -@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) -public class RegistryNotificationManagerTest extends AbstractRegistryTest { - - private static final String PLUGIN_SUBSCRIBED_LISTENER_ADDRESS = "pluginSubscribedListener"; - - private static final String WEB_SERVICE_ADDRESS = "http://myWebServiceAddress"; - - @Autowired - private MockNotificationListenerFactory notificationListenerFactory; - - @Autowired - private PluginSubscribedListener pluginSubscribedListener; - - @Test - public void webServiceDestinationIsNotifiedOnSubscribedObjectInsert() - throws MsgRegistryException { - - final SubscriptionType subscription = createSubscriptionForNotifications( - WEB_SERVICE_ADDRESS, DeliveryMethodTypes.SOAP); - final SubmitObjectsRequest submitObjects = createSubmitObjectsRequestForSubscription(subscription); - - lifecycleManager.submitObjects(submitObjects); - - final SubmitObjectsRequest objectsRequest = createSubmitObjectsRequest( - MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, - Mode.CREATE_OR_REPLACE); - lifecycleManager.submitObjects(objectsRequest); - - final NotificationListener notificationListenerForWebService = notificationListenerFactory - .getMockForDestination(WEB_SERVICE_ADDRESS); - verify(notificationListenerForWebService).onNotification( - any(NotificationType.class)); - } - - @Test - public void webServiceDestinationIsNotNotifiedOnNonSubscribedObjectInsert() - throws MsgRegistryException { - - final SubscriptionType subscription = createSubscriptionForNotifications( - WEB_SERVICE_ADDRESS, DeliveryMethodTypes.SOAP); - final SubmitObjectsRequest submitObjects = createSubmitObjectsRequestForSubscription(subscription); - - lifecycleManager.submitObjects(submitObjects); - - final SubmitObjectsRequest objectsRequest = createSubmitObjectsRequest( - "thisIsADifferentRegistryObjectId", "SomeRandomObjectType", - Mode.CREATE_OR_REPLACE); - lifecycleManager.submitObjects(objectsRequest); - - final NotificationListener notificationListenerForWebService = notificationListenerFactory - .getMockForDestination(WEB_SERVICE_ADDRESS); - verifyZeroInteractions(notificationListenerForWebService); - } - - @Test - public void pluginDestinationIsNotifiedOnSubscribedObjectInsert() - throws MsgRegistryException { - final SubscriptionType subscription = createSubscriptionForNotifications( - PLUGIN_SUBSCRIBED_LISTENER_ADDRESS, DeliveryMethodTypes.PLUGIN); - final SubmitObjectsRequest submitObjects = createSubmitObjectsRequestForSubscription(subscription); - - lifecycleManager.submitObjects(submitObjects); - - final SubmitObjectsRequest objectsRequest = createSubmitObjectsRequest( - MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, - Mode.CREATE_OR_REPLACE); - lifecycleManager.submitObjects(objectsRequest); - - assertThat(pluginSubscribedListener.hasBeenNotified(), is(true)); - } - - @Test - public void pluginDestinationIsNotNotifiedOnNonSubscribedObjectInsert() - throws MsgRegistryException { - - final SubscriptionType subscription = createSubscriptionForNotifications( - PLUGIN_SUBSCRIBED_LISTENER_ADDRESS, DeliveryMethodTypes.PLUGIN); - final SubmitObjectsRequest submitObjects = createSubmitObjectsRequestForSubscription(subscription); - - lifecycleManager.submitObjects(submitObjects); - - final SubmitObjectsRequest objectsRequest = createSubmitObjectsRequest( - "thisIsADifferentRegistryObjectId", "SomeRandomObjectType", - Mode.CREATE_OR_REPLACE); - lifecycleManager.submitObjects(objectsRequest); - - assertThat(pluginSubscribedListener.hasBeenNotified(), is(false)); - } - - private SubmitObjectsRequest createSubmitObjectsRequestForSubscription( - SubscriptionType subscription) { - final SubmitObjectsRequest submitObjects = createSubmitObjectsRequest( - "theSubmitObjectsRequestId", SubscriptionType.class.getName(), - Mode.CREATE_ONLY); - submitObjects.getRegistryObjectList().getRegistryObject().clear(); - submitObjects.getRegistryObjectList().getRegistryObject() - .add(subscription); - return submitObjects; - } - - private SubscriptionType createSubscriptionForNotifications( - final String webServiceAddress, final String deliveryMethod) { - QueryType selectorQuery = new QueryType(); - selectorQuery.setQueryDefinition(CanonicalQueryTypes.BASIC_QUERY); - SlotType slot = new SlotType(); - StringValueType valType = new StringValueType(); - valType.setValue(REGISTRY_OBJECT_TYPE); - slot.setName("objectType"); - slot.setSlotValue(valType); - selectorQuery.getSlot().add(slot); - - W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); - builder.address(webServiceAddress); - W3CEndpointReference ref = builder.build(); - DOMResult dom = new DOMResult(); - ref.writeTo(dom); - Document doc = (Document) dom.getNode(); - NodeList nodes = doc.getElementsByTagNameNS( - Namespaces.ADDRESSING_NAMESPACE, "Address"); - for (int i = 0; i < nodes.getLength(); i++) { - Node addressNode = nodes.item(i); - Attr endpointTypeAttr = doc.createAttributeNS( - Namespaces.EBXML_RIM_NAMESPACE_URI, "endpointType"); - endpointTypeAttr.setValue(deliveryMethod); - addressNode.getAttributes().setNamedItemNS(endpointTypeAttr); - } - ref = new W3CEndpointReference(new DOMSource(dom.getNode())); - - // Set subscription specific fields - DeliveryInfoType deliveryInfo = new DeliveryInfoType(); - deliveryInfo.setNotificationOption(NotificationOptionTypes.OBJECT_REFS); - deliveryInfo.setNotifyTo(ref); - - SubscriptionType subscription = new SubscriptionType(); - subscription.setStartTime(new XMLGregorianCalendarImpl()); - subscription.setId("someSubscriptionId"); - subscription.setLid("someSubscriptionId"); - subscription.setName(RegistryUtil - .getInternationalString("subscriptionName")); - subscription.setObjectType(SubscriptionType.class.getName()); - subscription.setSelector(selectorQuery); - subscription.setDeliveryInfo(Arrays.asList(deliveryInfo)); - return subscription; - } - -} diff --git a/tests/integration/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImplTest.java b/tests/integration/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImplTest.java index 5556e8496b..fd237c40ee 100644 --- a/tests/integration/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImplTest.java +++ b/tests/integration/com/raytheon/uf/edex/registry/ebxml/services/validator/ValidatorImplTest.java @@ -65,6 +65,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; * ------------ ---------- ----------- -------------------------- * Apr 23, 2013 1910 djohnson Initial creation * Apr 29, 2013 1910 djohnson Move to integration tests section. + * May 02, 2013 1910 djohnson Add validator plugins spring file. * * * @@ -74,7 +75,9 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, SpringFiles.EBXML_XML, SpringFiles.EBXML_XACML_XML, + SpringFiles.EBXML_SUBSCRIPTION_XML, SpringFiles.EBXML_WEBSERVICES_XML, + SpringFiles.EBXML_VALIDATOR_PLUGINS_XML, SpringFiles.EBXML_QUERYTYPES_XML, SpringFiles.EBXML_REGISTRY_DAO_XML, SpringFiles.UNIT_TEST_EBXML_BEANS_XML, SpringFiles.UNIT_TEST_LOCALIZATION_BEANS_XML }) diff --git a/tests/resources/ebxml/unit-test-ebxml-beans.xml b/tests/resources/ebxml/unit-test-ebxml-beans.xml index 5f23ef6448..f159a38e37 100644 --- a/tests/resources/ebxml/unit-test-ebxml-beans.xml +++ b/tests/resources/ebxml/unit-test-ebxml-beans.xml @@ -7,6 +7,16 @@ class="com.raytheon.uf.edex.registry.ebxml.dao.EbxmlHsqlValidationStrategy" /> + class="com.raytheon.uf.edex.registry.ebxml.dao.DirectlyInvokeRegistrySubscriptionManager"> + + + + + + + + + +
\ No newline at end of file diff --git a/tests/unit/com/raytheon/uf/common/util/SpringFiles.java b/tests/unit/com/raytheon/uf/common/util/SpringFiles.java index 17cda7aabc..63c217a402 100644 --- a/tests/unit/com/raytheon/uf/common/util/SpringFiles.java +++ b/tests/unit/com/raytheon/uf/common/util/SpringFiles.java @@ -32,6 +32,7 @@ import org.junit.Ignore; * ------------ ---------- ----------- -------------------------- * Feb 12, 2013 1543 djohnson Initial creation * Apr 23, 2013 1910 djohnson Add constants for ebxml spring files. + * May 02, 2013 1910 djohnson Add validator plugins spring file. * * * @@ -71,14 +72,16 @@ public class SpringFiles { public static final String EBXML_REGISTRY_DAO_XML = "/spring/ebxml-registry-dao.xml"; - public static final String EBXML_REPLICATION_XML = "/spring/ebxml-replication.xml"; - public static final String EBXML_REPLICATION_DATADELIVERY_WFO_XML = "/spring/registry-replication-datadelivery-wfo.xml"; + public static final String EBXML_SUBSCRIPTION_XML = "/spring/ebxml-subscription.xml"; + public static final String EBXML_XACML_XML = "/spring/ebxml-xacml.xml"; public static final String EBXML_WEBSERVICES_XML = "/spring/ebxml-webservices.xml"; + public static final String EBXML_VALIDATOR_PLUGINS_XML = "/spring/ebxml-validator-plugins.xml"; + public static final String UNIT_TEST_LOCALIZATION_BEANS_XML = "/unit-test-localization-beans.xml"; public static final String UNIT_TEST_EBXML_BEANS_XML = "/ebxml/unit-test-ebxml-beans.xml"; diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/DirectlyInvokeRegistrySubscriptionManager.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/DirectlyInvokeRegistrySubscriptionManager.java index 91658509c2..be50154e6e 100644 --- a/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/DirectlyInvokeRegistrySubscriptionManager.java +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/DirectlyInvokeRegistrySubscriptionManager.java @@ -19,10 +19,8 @@ **/ package com.raytheon.uf.edex.registry.ebxml.dao; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.registry.ebxml.services.IRegistrySubscriptionManager; +import com.raytheon.uf.edex.registry.ebxml.services.notification.RegistrySubscriptionManager; /** * Invokes the registry subscription manager directly. @@ -34,6 +32,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.IRegistrySubscriptionManager * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 16, 2013 1914 djohnson Initial creation + * May 02, 2013 1910 djohnson Dependency moved to baseline. * * * @@ -42,10 +41,11 @@ import com.raytheon.uf.edex.registry.ebxml.services.IRegistrySubscriptionManager */ public class DirectlyInvokeRegistrySubscriptionManager implements IRegistrySubscriptionManager { - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(DirectlyInvokeRegistrySubscriptionManager.class); + private final RegistrySubscriptionManager registrySubscriptionManager; - public DirectlyInvokeRegistrySubscriptionManager() { + public DirectlyInvokeRegistrySubscriptionManager( + RegistrySubscriptionManager registrySubscriptionManager) { + this.registrySubscriptionManager = registrySubscriptionManager; } /** @@ -53,15 +53,7 @@ public class DirectlyInvokeRegistrySubscriptionManager implements IRegistrySubsc */ @Override public void processSubscriptions() { - // RegistrySubscriptionManager doesn't exist in this repo, so it must be - // looked up dynamically until 5-Data_Delivery is merged in - try { - EDEXUtil.getESBComponent(IRegistrySubscriptionManager.class, - "RegistrySubscriptionManager").processSubscriptions(); - } catch (Exception e) { - statusHandler - .info("Registry subscription management is not enabled."); - } + registrySubscriptionManager.processSubscriptions(); } } diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AbstractRegistryObjectTypeValidatorTest.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AbstractRegistryObjectTypeValidatorTest.java new file mode 100644 index 0000000000..d011b8a763 --- /dev/null +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AbstractRegistryObjectTypeValidatorTest.java @@ -0,0 +1,235 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Arrays; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.InvalidRequestExceptionType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus; +import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnresolvedReferenceExceptionType; +import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsRequest; +import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsResponse; +import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidationExceptionType; + +import org.junit.Before; +import org.junit.Ignore; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator.ValidateObjectTypeResponse; + +/** + * Base test for {@link ValidatorPlugin}s. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +@Ignore +public abstract class AbstractRegistryObjectTypeValidatorTest> { + + // Local static reference as taken from ebXML 4.0 ebRIM specification + // section 2.9.3.3 + protected static final String INVALID_LOCAL_STATIC_REFERENCE = "urn:acme:person:Danyal"; + + protected static final String VALID_LOCAL_STATIC_REFERENCE = "urn:acme:person:SomeDude"; + + protected final IRegistryObjectReferenceValidator mockReferenceValidator = mock(IRegistryObjectReferenceValidator.class); + + protected final VALIDATOR validator = getValidator(mockReferenceValidator); + + @SuppressWarnings("unchecked") + @Before + public void setUp() { + // By default, all references will resolve as valid + when(mockReferenceValidator.isValidReference(anyString())).thenReturn( + true); + when(mockReferenceValidator.isValidObjectType(anyString(), + any(Class.class))).thenReturn( + ValidateObjectTypeResponse.VALID); + // The local static reference will resolve as bad whenever it's used + when( + mockReferenceValidator + .isValidReference(INVALID_LOCAL_STATIC_REFERENCE)) + .thenReturn(false); + when(mockReferenceValidator.isValidObjectType( + eq(INVALID_LOCAL_STATIC_REFERENCE), any(Class.class))) + .thenReturn(ValidateObjectTypeResponse.DOESNT_EXIST); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that an {@link UnresolvedReferenceExceptionType} was returned in the + * response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + protected void expectUnresolvedReferenceExceptionReturned( + REGISTRY_OBJECT registryObject) throws MsgRegistryException { + expectExceptionReturned(registryObject, + UnresolvedReferenceExceptionType.class); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that an {@link UnresolvedReferenceExceptionType} was returned in the + * response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + protected void expectInvalidRequestExceptionReturned( + REGISTRY_OBJECT registryObject) throws MsgRegistryException { + expectExceptionReturned(registryObject, + InvalidRequestExceptionType.class); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that a {@link ValidationExceptionType} was returned in the response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + protected void expectValidationExceptionReturned( + REGISTRY_OBJECT registryObject) throws MsgRegistryException { + expectExceptionReturned(registryObject, ValidationExceptionType.class); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that an {@link UnresolvedReferenceExceptionType} was returned in the + * response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + private void expectExceptionReturned( + REGISTRY_OBJECT registryObject, Class exceptionType) + throws MsgRegistryException { + + final ValidateObjectsResponse response = validator + .validateObjects(createValidationRequest(registryObject)); + assertThat(response.getException(), contains(instanceOf(exceptionType))); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that a {@link RegistryResponseStatus#PARTIAL_SUCCESS} was returned in the + * response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + protected void expectPartialSuccessResponseStatus( + REGISTRY_OBJECT registryObject) throws MsgRegistryException { + + final ValidateObjectsResponse response = validator + .validateObjects(createValidationRequest(registryObject)); + assertThat(response.getStatus(), + is(RegistryResponseStatus.PARTIAL_SUCCESS)); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that no {@link RegistryExceptionType}s were returned in the response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + protected void expectNoExceptionsReturned(REGISTRY_OBJECT registryObject) + throws MsgRegistryException { + + final ValidateObjectsResponse response = validator + .validateObjects(createValidationRequest(registryObject)); + assertThat(response.getException(), is(empty())); + } + + /** + * Convenience method to perform validation on a registry object, and assert + * that a {@link RegistryResponseStatus#SUCCESS} was returned in the + * response. + * + * @param registryObject + * the registry object to validate + * @throws MsgRegistryException + */ + protected void expectSuccessResponseStatus(REGISTRY_OBJECT registryObject) + throws MsgRegistryException { + + final ValidateObjectsResponse response = validator + .validateObjects(createValidationRequest(registryObject)); + assertThat(response.getStatus(), is(RegistryResponseStatus.SUCCESS)); + } + + /** + * Create the validation request. + * + * @param registryObject + * the registry object to validate + * @return the request + */ + protected ValidateObjectsRequest createValidationRequest( + REGISTRY_OBJECT registryObject) { + ValidateObjectsRequest request = new ValidateObjectsRequest(); + request.setOriginalObjects(new RegistryObjectListType(Arrays + . asList(registryObject))); + return request; + } + + /** + * Get the validator to test. + * + * @param referenceValidator + * @return the validator instance + */ + protected abstract VALIDATOR getValidator( + IRegistryObjectReferenceValidator referenceValidator); +} diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidatorTest.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidatorTest.java new file mode 100644 index 0000000000..567b69b600 --- /dev/null +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/AssociationTypeValidatorTest.java @@ -0,0 +1,251 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import static org.mockito.Mockito.when; +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationTypeFixture; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationNodeType; + +import org.junit.Test; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator.ValidateObjectTypeResponse; + +/** + * Test {@link AssociationTypeValidator}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class AssociationTypeValidatorTest + extends + AbstractRegistryObjectTypeValidatorTest { + + private final AssociationType registryObject = AssociationTypeFixture.INSTANCE + .get(); + + /** + * Attribute sourceObject - Each Association MUST have a sourceObject + * attribute that references the RegistryObjectType instance that is the + * source of that Association. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadSourceObjectReference() + throws MsgRegistryException { + + registryObject.setSourceObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute sourceObject - Each Association MUST have a sourceObject + * attribute that references the RegistryObjectType instance that is the + * source of that Association. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullSourceObjectReference() + throws MsgRegistryException { + + registryObject.setSourceObject(null); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute sourceObject - Each Association MUST have a sourceObject + * attribute that references the RegistryObjectType instance that is the + * source of that Association. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadSourceObjectReference() + throws MsgRegistryException { + + registryObject.setSourceObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute targetObject - Each Association MUST have a targetObject + * attribute that references the RegistryObjectType instance that is the + * target of that Association. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadTargetObjectReference() + throws MsgRegistryException { + + registryObject.setTargetObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute targetObject - Each Association MUST have a targetObject + * attribute that references the RegistryObjectType instance that is the + * target of that Association. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullTargetObjectReference() + throws MsgRegistryException { + + registryObject.setTargetObject(null); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute targetObject - Each Association MUST have a targetObject + * attribute that references the RegistryObjectType instance that is the + * target of that Association. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadTargetObjectReference() + throws MsgRegistryException { + + registryObject.setTargetObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute type - Each Association MUST have a type attribute that + * identifies the type of that association. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadTypeReference() throws MsgRegistryException { + + registryObject.setType(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute type - Each Association MUST have a type attribute that + * identifies the type of that association. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullTypeReference() throws MsgRegistryException { + + registryObject.setType(null); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute type - Each Association MUST have a type attribute that + * identifies the type of that association. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadTypeReference() throws MsgRegistryException { + + registryObject.setType(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * The value of the type attribute MUST be a reference to a + * ClassificationNode within the canonical AssociationType + * ClassificationScheme. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnGoodTypeReferenceToWrongObjectType() + throws MsgRegistryException { + + when( + mockReferenceValidator.isValidObjectType( + registryObject.getType(), ClassificationNodeType.class)) + .thenReturn(ValidateObjectTypeResponse.WRONG_TYPE); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute type - Each Association MUST have a type attribute that + * identifies the type of that association. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnGoodTypeReferenceToWrongObjectType() + throws MsgRegistryException { + + when( + mockReferenceValidator.isValidObjectType( + registryObject.getType(), ClassificationNodeType.class)) + .thenReturn(ValidateObjectTypeResponse.WRONG_TYPE); + + expectPartialSuccessResponseStatus(registryObject); + } + + @Test + public void noExceptionsOnAllGoodReferences() throws MsgRegistryException { + expectNoExceptionsReturned(registryObject); + } + + @Test + public void successOnAllGoodReferences() throws MsgRegistryException { + expectSuccessResponseStatus(registryObject); + } + + /** + * {@inheritDoc} + */ + @Override + protected AssociationTypeValidator getValidator( + IRegistryObjectReferenceValidator referenceValidator) { + return new AssociationTypeValidator(referenceValidator); + } + +} diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidatorTest.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidatorTest.java new file mode 100644 index 0000000000..e114415dc4 --- /dev/null +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ClassificationTypeValidatorTest.java @@ -0,0 +1,207 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationTypeFixture; + +import org.junit.Test; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * Test {@link ClassificationTypeValidator}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class ClassificationTypeValidatorTest + extends + AbstractRegistryObjectTypeValidatorTest { + + private final ClassificationType registryObject = ClassificationTypeFixture.INSTANCE + .get(); + + /** + * Attribute classificationNode - If the ClassificationType instance + * represents an internal classification, then the classificationNode + * attribute is required. The classificationNode value MUST reference a + * ClassificationNodeType instance. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadClassificationNodeReference() + throws MsgRegistryException { + + registryObject.setClassificationNode(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute classificationNode - If the ClassificationType instance + * represents an internal classification, then the classificationNode + * attribute is required. The classificationNode value MUST reference a + * ClassificationNodeType instance. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadClassificationNodeReference() + throws MsgRegistryException { + + registryObject.setClassificationNode(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute nodeRepresentation - If the ClassificationType instance + * represents an external classification, then the nodeRepresentation + * attribute is required. It is a representation of a taxonomy value from a + * classification scheme. + * + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullNodeRepresentationWhenClassificationSchemeIsNotNull() + throws MsgRegistryException { + + registryObject.setNodeRepresentation(null); + registryObject.setClassificationScheme(VALID_LOCAL_STATIC_REFERENCE); + registryObject.setClassificationNode(null); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute nodeRepresentation - If the ClassificationType instance + * represents an external classification, then the nodeRepresentation + * attribute is required. It is a representation of a taxonomy value from a + * classification scheme. + * + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnNullNodeRepresentationWhenClassificationSchemeIsNotNull() + throws MsgRegistryException { + + registryObject.setNodeRepresentation(null); + registryObject.setClassificationScheme(VALID_LOCAL_STATIC_REFERENCE); + registryObject.setClassificationNode(null); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute classifiedObject - For both internal and external + * classifications, the classifiedObject attribute is required and it + * references the RegistryObjectType instance that is classified by this + * Classification. + * + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadClassifiedObjectReference() + throws MsgRegistryException { + + registryObject.setClassifiedObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute classifiedObject - For both internal and external + * classifications, the classifiedObject attribute is required and it + * references the RegistryObjectType instance that is classified by this + * Classification. + * + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadClassifiedObjectReference() + throws MsgRegistryException { + + registryObject.setClassifiedObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + @Test + public void exceptionWhenInternalAndExternalFieldsSpecified() + throws MsgRegistryException { + + registryObject.setClassificationScheme(VALID_LOCAL_STATIC_REFERENCE); + registryObject.setClassificationNode(VALID_LOCAL_STATIC_REFERENCE); + registryObject.setNodeRepresentation(VALID_LOCAL_STATIC_REFERENCE); + + expectValidationExceptionReturned(registryObject); + } + + @Test + public void partialSuccessWhenInternalAndExternalFieldsSpecified() + throws MsgRegistryException { + + registryObject.setClassificationScheme(VALID_LOCAL_STATIC_REFERENCE); + registryObject.setClassificationNode(VALID_LOCAL_STATIC_REFERENCE); + registryObject.setNodeRepresentation(VALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + @Test + public void noExceptionOnGoodReferences() + throws MsgRegistryException { + + expectNoExceptionsReturned(registryObject); + } + + @Test + public void successOnGoodReferences() + throws MsgRegistryException { + + expectSuccessResponseStatus(registryObject); + } + + /** + * {@inheritDoc} + */ + @Override + protected ClassificationTypeValidator getValidator( + IRegistryObjectReferenceValidator referenceValidator) { + return new ClassificationTypeValidator(referenceValidator); + } +} diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidatorTest.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidatorTest.java new file mode 100644 index 0000000000..4126a7a0ac --- /dev/null +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalIdentifierTypeValidatorTest.java @@ -0,0 +1,209 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalIdentifierType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalIdentifierTypeFixture; + +import org.junit.Test; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * Test {@link ExternalIdentifierTypeValidator}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class ExternalIdentifierTypeValidatorTest + extends + AbstractRegistryObjectTypeValidatorTest { + + private final ExternalIdentifierType registryObject = ExternalIdentifierTypeFixture.INSTANCE + .get(); + + /** + * Attribute identificationScheme - Each ExternalIdentifier instance MUST + * have an identificationScheme attribute that references a + * ClassificationScheme. This ClassificationScheme defines the namespace + * within which an identifier is defined using the value attribute for the + * RegistryObjectType instance referenced by the RegistryObject attribute. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadIdentificationSchemeReference() + throws MsgRegistryException { + + registryObject.setIdentificationScheme(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute identificationScheme - Each ExternalIdentifier instance MUST + * have an identificationScheme attribute that references a + * ClassificationScheme. This ClassificationScheme defines the namespace + * within which an identifier is defined using the value attribute for the + * RegistryObjectType instance referenced by the RegistryObject attribute. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadIdentificationSchemeReference() + throws MsgRegistryException { + + registryObject.setIdentificationScheme(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute registryObject - Each ExternalIdentifier instance MAY have a + * registryObject attribute specified. This attribute references the parent + * RegistryObjectType instance for which this is an ExternalIdentifier. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadRegistryObjectReference() + throws MsgRegistryException { + + registryObject.setRegistryObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute registryObject - Each ExternalIdentifier instance MAY have a + * registryObject attribute specified. This attribute references the parent + * RegistryObjectType instance for which this is an ExternalIdentifier. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadRegistryObjectReference() + throws MsgRegistryException { + + registryObject.setRegistryObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute identificationScheme - Each ExternalIdentifier instance MUST + * have an identificationScheme attribute that references a + * ClassificationScheme. This ClassificationScheme defines the namespace + * within which an identifier is defined using the value attribute for the + * RegistryObjectType instance referenced by the RegistryObject attribute. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullIdentificationSchemeReference() + throws MsgRegistryException { + + registryObject.setIdentificationScheme(null); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute identificationScheme - Each ExternalIdentifier instance MUST + * have an identificationScheme attribute that references a + * ClassificationScheme. This ClassificationScheme defines the namespace + * within which an identifier is defined using the value attribute for the + * RegistryObjectType instance referenced by the RegistryObject attribute. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnNullIdentificationSchemeReference() + throws MsgRegistryException { + + registryObject.setIdentificationScheme(null); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute value - Each ExternalIdentifier instance MUST have a value + * attribute that provides the identifier value for this ExternalIdentifier + * (e.g., the tax payer id in example above). + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullValue() throws MsgRegistryException { + + registryObject.setValue(null); + + expectValidationExceptionReturned(registryObject); + } + + /** + * Attribute value - Each ExternalIdentifier instance MUST have a value + * attribute that provides the identifier value for this ExternalIdentifier + * (e.g., the tax payer id in example above). + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnNullValue() throws MsgRegistryException { + + registryObject.setValue(null); + + expectPartialSuccessResponseStatus(registryObject); + } + + @Test + public void noExceptionOnGoodReferences() + throws MsgRegistryException { + + expectNoExceptionsReturned(registryObject); + } + + @Test + public void successOnGoodReferences() + throws MsgRegistryException { + + expectSuccessResponseStatus(registryObject); + } + + /** + * {@inheritDoc} + */ + @Override + protected ExternalIdentifierTypeValidator getValidator( + IRegistryObjectReferenceValidator referenceValidator) { + return new ExternalIdentifierTypeValidator(referenceValidator); + } +} diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidatorTest.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidatorTest.java new file mode 100644 index 0000000000..bb05ec6e4a --- /dev/null +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/ExternalLinkTypeValidatorTest.java @@ -0,0 +1,146 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalLinkType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalLinkTypeFixture; + +import org.junit.Test; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * Test {@link ExternalLinkTypeValidator}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class ExternalLinkTypeValidatorTest + extends + AbstractRegistryObjectTypeValidatorTest { + + private final ExternalLinkType registryObject = ExternalLinkTypeFixture.INSTANCE + .get(); + + /** + * Element ExternalRef - Each ExternalLink instance MUST have an ExternalRef + * sub-element defined. This element provides a URI to the external resource + * pointed to by this ExternalLink instance. + * + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnNullExternalRef() throws MsgRegistryException { + + registryObject.setExternalRef(null); + + expectValidationExceptionReturned(registryObject); + } + + // TODO: Do we need to test for certain invariants on a link? + + /** + * Element ExternalRef - Each ExternalLink instance MUST have an ExternalRef + * sub-element defined. This element provides a URI to the external resource + * pointed to by this ExternalLink instance. + * + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnNullExternalRef() + throws MsgRegistryException { + + registryObject.setExternalRef(null); + + expectPartialSuccessResponseStatus(registryObject); + } + + /** + * Attribute registryObject - references the parent RegistryObjectType + * instance within which the ExtrnalLink - Type instance is composed. The + * value MUST be provided by client when an ExtrenalLink is submitted + * separate from its parent object. The value MUST be set by the server if + * the ExternalLink is submitted as part of the submission of its parent + * object. + * + * @throws MsgRegistryException + */ + @Test + public void exceptionOnBadRegistryObjectReference() + throws MsgRegistryException { + + registryObject.setRegistryObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + /** + * Attribute registryObject - references the parent RegistryObjectType + * instance within which the ExtrnalLink - Type instance is composed. The + * value MUST be provided by client when an ExtrenalLink is submitted + * separate from its parent object. The value MUST be set by the server if + * the ExternalLink is submitted as part of the submission of its parent + * object. + * + * @throws MsgRegistryException + */ + @Test + public void partialSuccessOnBadRegistryObjectReference() + throws MsgRegistryException { + + registryObject.setRegistryObject(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + @Test + public void noExceptionOnGoodReferences() throws MsgRegistryException { + + expectNoExceptionsReturned(registryObject); + } + + @Test + public void successOnGoodReferences() throws MsgRegistryException { + + expectSuccessResponseStatus(registryObject); + } + + /** + * {@inheritDoc} + */ + @Override + protected ExternalLinkTypeValidator getValidator( + IRegistryObjectReferenceValidator referenceValidator) { + return new ExternalLinkTypeValidator(referenceValidator); + } +} diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidatorTest.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidatorTest.java new file mode 100644 index 0000000000..4164a2ce94 --- /dev/null +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/services/validator/plugins/OrganizationTypeValidatorTest.java @@ -0,0 +1,98 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.registry.ebxml.services.validator.plugins; + +import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationTypeFixture; + +import org.junit.Test; + +import com.raytheon.uf.edex.registry.ebxml.services.validator.IRegistryObjectReferenceValidator; + +/** + * Test {@link OrganizationTypeValidator}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class OrganizationTypeValidatorTest + extends + AbstractRegistryObjectTypeValidatorTest { + + private final OrganizationType registryObject = OrganizationTypeFixture.INSTANCE + .get(); + + @Test + public void exceptionOnBadPrimaryContactReference() + throws MsgRegistryException { + + registryObject.setPrimaryContact(INVALID_LOCAL_STATIC_REFERENCE); + + expectUnresolvedReferenceExceptionReturned(registryObject); + } + + @Test + public void partialSuccessOnBadPrimaryContactReference() + throws MsgRegistryException { + + registryObject.setPrimaryContact(INVALID_LOCAL_STATIC_REFERENCE); + + expectPartialSuccessResponseStatus(registryObject); + } + + @Test + public void noExceptionOnGoodPrimaryContactReference() + throws MsgRegistryException { + + registryObject.setPrimaryContact(VALID_LOCAL_STATIC_REFERENCE); + + expectNoExceptionsReturned(registryObject); + } + + + @Test + public void successOnGoodPrimaryContactReference() + throws MsgRegistryException { + + registryObject.setPrimaryContact(VALID_LOCAL_STATIC_REFERENCE); + + expectSuccessResponseStatus(registryObject); + } + + /** + * {@inheritDoc} + */ + @Override + protected OrganizationTypeValidator getValidator( + IRegistryObjectReferenceValidator referenceValidator) { + return new OrganizationTypeValidator(referenceValidator); + } +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ActionTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ActionTypeFixture.java new file mode 100644 index 0000000000..60e436f2ac --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ActionTypeFixture.java @@ -0,0 +1,62 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Random; + +import com.raytheon.uf.common.registry.constants.EventTypes; +import com.raytheon.uf.common.util.AbstractFixture; + +/** + * Fixture to retrieve {@link ActionType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 24, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ActionTypeFixture extends AbstractFixture { + + public static final ActionTypeFixture INSTANCE = new ActionTypeFixture(); + + protected ActionTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected ActionType getInstance(long seedValue, Random random) { + final ActionType instance = new ActionType(); + instance.setEventType(EventTypes.CREATED); + instance.setKey(random.nextInt()); + + return instance; + } +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AssociationTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AssociationTypeFixture.java new file mode 100644 index 0000000000..0dd0feb2c7 --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AssociationTypeFixture.java @@ -0,0 +1,79 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Random; + +/** + * Fixture to retrieve {@link OrganizationType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 24, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class AssociationTypeFixture extends + RegistryObjectTypeFixture { + + public static final AssociationTypeFixture INSTANCE = new AssociationTypeFixture(); + + protected AssociationTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected AssociationType getInstance(long seedValue, Random random) { + final AssociationType registryObject = super.getInstance(seedValue, + random); + registryObject.setSourceObject("sourceObject" + seedValue); + registryObject.setTargetObject("targetObject" + seedValue); + registryObject.setType("associationType" + seedValue); + + return registryObject; + } + + /** + * {@inheritDoc} + */ + @Override + protected String getObjectType() { + return "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Association"; + } + + /** + * {@inheritDoc} + */ + @Override + protected AssociationType getRegistryObject() { + return new AssociationType(); + } + +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AuditableEventTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AuditableEventTypeFixture.java new file mode 100644 index 0000000000..6cf5b75094 --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/AuditableEventTypeFixture.java @@ -0,0 +1,78 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Arrays; +import java.util.Random; + +/** + * Fixture to retrieve {@link AuditableEventType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 24, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class AuditableEventTypeFixture extends + RegistryObjectTypeFixture { + + public static final AuditableEventTypeFixture INSTANCE = new AuditableEventTypeFixture(); + + protected AuditableEventTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected AuditableEventType getInstance(long seedValue, Random random) { + final AuditableEventType instance = super.getInstance( + seedValue, random); + instance.setAction(Arrays.asList(ActionTypeFixture.INSTANCE + .get(seedValue))); + return instance; + } + + /** + * {@inheritDoc} + */ + @Override + protected String getObjectType() { + return "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:AuditableEvent"; + } + + /** + * {@inheritDoc} + */ + @Override + protected AuditableEventType getRegistryObject() { + return new AuditableEventType(); + } + +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ClassificationTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ClassificationTypeFixture.java new file mode 100644 index 0000000000..cdbaacfc28 --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ClassificationTypeFixture.java @@ -0,0 +1,78 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Random; + +/** + * Fixture to retrieve {@link ClassificationType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 24, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ClassificationTypeFixture extends + RegistryObjectTypeFixture { + + public static final ClassificationTypeFixture INSTANCE = new ClassificationTypeFixture(); + + protected ClassificationTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected ClassificationType getInstance(long seedValue, Random random) { + final ClassificationType instance = super.getInstance( + seedValue, random); + instance.setClassificationNode("classificationNode" + seedValue); + instance.setClassifiedObject("classifiedObject" + seedValue); + + return instance; + } + + /** + * {@inheritDoc} + */ + @Override + protected String getObjectType() { + return "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification"; + } + + /** + * {@inheritDoc} + */ + @Override + protected ClassificationType getRegistryObject() { + return new ClassificationType(); + } + +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalIdentifierTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalIdentifierTypeFixture.java new file mode 100644 index 0000000000..4dfe33bf09 --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalIdentifierTypeFixture.java @@ -0,0 +1,78 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Random; + +/** + * Fixture to retrieve {@link ExternalIdentifierType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 24, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ExternalIdentifierTypeFixture extends + RegistryObjectTypeFixture { + + public static final ExternalIdentifierTypeFixture INSTANCE = new ExternalIdentifierTypeFixture(); + + protected ExternalIdentifierTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected ExternalIdentifierType getInstance(long seedValue, Random random) { + final ExternalIdentifierType instance = super.getInstance( + seedValue, random); + instance.setIdentificationScheme("identificationScheme" + seedValue); + instance.setValue("value" + seedValue); + + return instance; + } + + /** + * {@inheritDoc} + */ + @Override + protected String getObjectType() { + return "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier"; + } + + /** + * {@inheritDoc} + */ + @Override + protected ExternalIdentifierType getRegistryObject() { + return new ExternalIdentifierType(); + } + +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalLinkTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalLinkTypeFixture.java new file mode 100644 index 0000000000..308af12322 --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExternalLinkTypeFixture.java @@ -0,0 +1,82 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Random; + +/** + * Fixture to retrieve {@link ExternalLinkType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 24, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ExternalLinkTypeFixture extends + RegistryObjectTypeFixture { + + public static final ExternalLinkTypeFixture INSTANCE = new ExternalLinkTypeFixture(); + + protected ExternalLinkTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected ExternalLinkType getInstance(long seedValue, Random random) { + final ExternalLinkType instance = super.getInstance( + seedValue, random); + + SimpleLinkType value = new SimpleLinkType(); + value.setHref("http://www.link" + seedValue + ".com"); + + instance.setExternalRef(value); + instance.setRegistryObject("someRegistryObject" + seedValue); + + return instance; + } + + /** + * {@inheritDoc} + */ + @Override + protected String getObjectType() { + return "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalLink"; + } + + /** + * {@inheritDoc} + */ + @Override + protected ExternalLinkType getRegistryObject() { + return new ExternalLinkType(); + } + +} diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/OrganizationTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/OrganizationTypeFixture.java index 30a9d8bc7e..020748efac 100644 --- a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/OrganizationTypeFixture.java +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/OrganizationTypeFixture.java @@ -21,8 +21,6 @@ package oasis.names.tc.ebxml.regrep.xsd.rim.v4; import java.util.Random; -import com.raytheon.uf.common.util.AbstractFixture; - /** * Fixture to retrieve {@link OrganizationType} instances. * @@ -33,6 +31,7 @@ import com.raytheon.uf.common.util.AbstractFixture; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 24, 2013 1910 djohnson Initial creation + * May 02, 2013 1910 djohnson Create RegistryObjectTypeFixture. * * * @@ -40,20 +39,39 @@ import com.raytheon.uf.common.util.AbstractFixture; * @version 1.0 */ -public class OrganizationTypeFixture extends AbstractFixture { +public class OrganizationTypeFixture extends + RegistryObjectTypeFixture { public static final OrganizationTypeFixture INSTANCE = new OrganizationTypeFixture(); + protected OrganizationTypeFixture() { + } + /** * {@inheritDoc} */ @Override protected OrganizationType getInstance(long seedValue, Random random) { - OrganizationType entity = new OrganizationType(); - entity.setObjectType("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Organization"); - entity.setId(entity.getClass().getSimpleName() + seedValue); - entity.setLid(entity.getId()); - return entity; + final OrganizationType organizationType = super.getInstance(seedValue, + random); + organizationType.setPrimaryContact("primaryContact" + seedValue); + return organizationType; + } + + /** + * {@inheritDoc} + */ + @Override + protected String getObjectType() { + return "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Organization"; + } + + /** + * {@inheritDoc} + */ + @Override + protected OrganizationType getRegistryObject() { + return new OrganizationType(); } } diff --git a/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/RegistryObjectTypeFixture.java b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/RegistryObjectTypeFixture.java new file mode 100644 index 0000000000..c04b327844 --- /dev/null +++ b/tests/unit/oasis/names/tc/ebxml/regrep/xsd/rim/v4/RegistryObjectTypeFixture.java @@ -0,0 +1,71 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package oasis.names.tc.ebxml.regrep.xsd.rim.v4; + +import java.util.Random; + +import com.raytheon.uf.common.util.AbstractFixture; + +/** + * Base {@link AbstractFixture} for {@link RegistryObjectType} instances. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 25, 2013 1910       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public abstract class RegistryObjectTypeFixture + extends AbstractFixture { + + protected RegistryObjectTypeFixture() { + } + + /** + * {@inheritDoc} + */ + @Override + protected T getInstance(long seedValue, Random random) { + T registryObject = getRegistryObject(); + registryObject.setObjectType(getObjectType()); + registryObject.setId(registryObject.getClass().getSimpleName() + + seedValue); + registryObject.setLid(registryObject.getId()); + return registryObject; + } + + /** + * @return the object type for the registry object + */ + protected abstract String getObjectType(); + + /** + * @return the registry object instance + */ + protected abstract T getRegistryObject(); +}