Merge "Issue #1910 More registry object validators, shutdown BandwidthManagers in a finally" into development

Former-commit-id: af84e9cd46 [formerly 7d004ed429300259d521f48acbe8435a0207f93e]
Former-commit-id: 385738535e
This commit is contained in:
Dustin Johnson 2013-05-03 08:33:22 -05:00 committed by Gerrit Code Review
commit 7c0d93ec74
39 changed files with 2716 additions and 440 deletions

View file

@ -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.
* </pre>
*
* @author dhladky
@ -1310,16 +1311,20 @@ public abstract class BandwidthManager extends
BandwidthMap copyOfCurrentMap = BandwidthMap
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
BandwidthManager proposedBwManager = startProposedBandwidthManager(copyOfCurrentMap);
Set<String> 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<String> 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<BandwidthAllocation> 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<Subscription> subscriptions = new HashSet<Subscription>();
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<BandwidthAllocation> 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<String> 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);
}
}

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.ebxml</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -42,7 +42,6 @@
<bean name="AuditableEventTypeDao"
class="com.raytheon.uf.edex.registry.ebxml.dao.AuditableEventTypeDao">
<property name="subscriptionManager" ref="registrySubscriptionManagerInvoker" />
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>

View file

@ -0,0 +1,250 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="validatorPluginRegistry" factory-bean="validatorServiceImpl"
factory-method="getPluginValidatorRegistry" />
<bean id="registryObjectTypeValidator"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.RegistryObjectTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean id="organizationTypeValidatorPlugin"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.OrganizationTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean id="associationTypeValidatorPlugin"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.AssociationTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean id="classificationTypeValidatorPlugin"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.ClassificationTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean id="externalIdentifierTypeValidatorPlugin"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.ExternalIdentifierTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean id="externalLinkTypeValidatorPlugin"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.ExternalLinkTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Organization" />
<constructor-arg ref="organizationTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Association" />
<constructor-arg ref="associationTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification" />
<constructor-arg ref="classificationTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier" />
<constructor-arg ref="externalIdentifierTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalLink" />
<constructor-arg ref="externalLinkTypeValidatorPlugin" />
</bean>
<!--
These are the remaining validator plugins to be implemented, when the validator ticket is worked.
Each validator corresponds directly with a registry object in the SubmitObjectsRequest_ObjectTypeScheme.xml
file.
-->
<!--
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:AuditableEvent" />
<constructor-arg ref="auditableEventTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:QueryDefinition" />
<constructor-arg ref="queryDefinitionTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Notification" />
<constructor-arg ref="notificationTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Party" />
<constructor-arg ref="partyTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Person" />
<constructor-arg ref="personTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Subscription" />
<constructor-arg ref="subscriptionTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:TaxonomyElement" />
<constructor-arg ref="taxonomyElementTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ClassificationNode" />
<constructor-arg ref="classificationNodeTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ClassificationScheme" />
<constructor-arg ref="classificationSchemeTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Federation" />
<constructor-arg ref="federationTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Registry" />
<constructor-arg ref="registryTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage" />
<constructor-arg ref="registryPackageTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage:Register" />
<constructor-arg ref="registerTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Role" />
<constructor-arg ref="roleTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Service" />
<constructor-arg ref="serviceTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ServiceEndpoint" />
<constructor-arg ref="serviceEndpointTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ServiceBinding" />
<constructor-arg ref="serviceBindingTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ServiceInterface" />
<constructor-arg ref="serviceInterfaceTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject" />
<constructor-arg ref="extrinsicObjectTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:Comment" />
<constructor-arg ref="commentTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML" />
<constructor-arg ref="xmlTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XSLT" />
<constructor-arg ref="xsltTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XMLSchema" />
<constructor-arg ref="xmlSchemaTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:Schematron" />
<constructor-arg ref="schematronTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XHTML" />
<constructor-arg ref="xhtmlTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XHTML:XForm" />
<constructor-arg ref="xformTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XACML" />
<constructor-arg ref="xacmlTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XACML:Policy" />
<constructor-arg ref="policyTypeValidatorPlugin" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML:XACML:PolicySet" />
<constructor-arg ref="policySetTypeValidatorPlugin" />
</bean>
-->
</beans>

View file

@ -1,10 +1,7 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- QUERY -->
<!-- QUERY -->
<!-- Define concrete implementation of the service -->
<bean id="queryServiceImpl"
class="com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl">
@ -28,7 +25,7 @@
<property name="queryManager" ref="queryServiceImpl" />
<property name="validator" ref="validatorServiceImpl" />
<property name="registryObjectDao" ref="registryObjectDao" />
<property name="auditableEventDao" ref="AuditableEventTypeDao" />
<property name="auditableEventService" ref="AuditableEventService" />
<property name="cataloger" ref="catalogerServiceImpl" />
</bean>
@ -100,25 +97,9 @@
<property name="roleDao" ref="roleDao" />
</bean>
<!-- Validator Plugins -->
<bean id="validatorPluginRegistry" factory-bean="validatorServiceImpl"
factory-method="getPluginValidatorRegistry" />
<bean id="registryObjectTypeValidator"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.RegistryObjectTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
<bean id="AuditableEventService" class="com.raytheon.uf.edex.registry.ebxml.services.AuditableEventService">
<constructor-arg ref="AuditableEventTypeDao" />
<constructor-arg ref="registrySubscriptionManagerInvoker" />
</bean>
<bean id="organizationTypeValidatorPlugin"
class="com.raytheon.uf.edex.registry.ebxml.services.validator.plugins.OrganizationTypeValidator">
<constructor-arg ref="registryObjectReferenceValidator" />
</bean>
<bean factory-bean="validatorPluginRegistry" factory-method="register">
<constructor-arg
value="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Organization" />
<constructor-arg ref="organizationTypeValidatorPlugin" />
</bean>
<!-- End Validator Plugins -->
</beans>

View file

@ -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.
*
* </pre>
*
@ -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;
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 02, 2013 1910 djohnson Extracted subscription notification from the dao.
*
* </pre>
*
* @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<String, List<RegistryObjectType>> 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<String, List<ObjectRefType>> 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);
}
}
}

View file

@ -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<String, List<ObjectRefType>> actionMap = new HashMap<String, List<ObjectRefType>>();
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) {

View file

@ -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.
*
* </pre>
*
@ -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<? extends RegistryObjectType> expectedType);
}

View file

@ -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.
*
* </pre>
*
@ -78,4 +81,21 @@ public class LocalServerRegistryObjectReferenceValidator implements
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
this.registryObjectDao = registryObjectDao;
}
/**
* {@inheritDoc}
*/
@Override
public ValidateObjectTypeResponse isValidObjectType(String reference,
Class<? extends RegistryObjectType> 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;
}
}

View file

@ -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);

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class AssociationTypeValidator extends ValidatorPlugin<AssociationType> {
/**
* Constructor.
*
* @param registryObjectReferenceValidator
*/
protected AssociationTypeValidator(
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
super(registryObjectReferenceValidator);
}
/**
* {@inheritDoc}
*/
@Override
protected Class<AssociationType> getRegistryObjectTypeClass() {
return AssociationType.class;
}
/**
* {@inheritDoc}
*/
@Override
protected void validate(AssociationType registryObject,
List<RegistryExceptionType> 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);
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ClassificationTypeValidator extends
ValidatorPlugin<ClassificationType> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(ClassificationType.class);
/**
* Constructor.
*
* @param registryObjectReferenceValidator
*/
protected ClassificationTypeValidator(
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
super(registryObjectReferenceValidator);
}
/**
* {@inheritDoc}
*/
@Override
protected Class<ClassificationType> getRegistryObjectTypeClass() {
return ClassificationType.class;
}
/**
* {@inheritDoc}
*/
@Override
protected void validate(ClassificationType registryObject,
List<RegistryExceptionType> 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);
}
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ExternalIdentifierTypeValidator extends
ValidatorPlugin<ExternalIdentifierType> {
/**
* Constructor.
*
* @param registryObjectReferenceValidator
*/
protected ExternalIdentifierTypeValidator(
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
super(registryObjectReferenceValidator);
}
/**
* {@inheritDoc}
*/
@Override
protected Class<ExternalIdentifierType> getRegistryObjectTypeClass() {
return ExternalIdentifierType.class;
}
/**
* {@inheritDoc}
*/
@Override
protected void validate(ExternalIdentifierType registryObject,
List<RegistryExceptionType> 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);
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ExternalLinkTypeValidator extends
ValidatorPlugin<ExternalLinkType> {
/**
* Constructor.
*
* @param registryObjectReferenceValidator
*/
protected ExternalLinkTypeValidator(
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
super(registryObjectReferenceValidator);
}
/**
* {@inheritDoc}
*/
@Override
protected Class<ExternalLinkType> getRegistryObjectTypeClass() {
return ExternalLinkType.class;
}
/**
* {@inheritDoc}
*/
@Override
protected void validate(ExternalLinkType registryObject,
List<RegistryExceptionType> exceptions) {
final String registryObjectId = registryObject.getId();
final SimpleLinkType externalRef = registryObject.getExternalRef();
validateNotNull(externalRef, "externalRef", registryObjectId,
exceptions);
validateReference(registryObject.getRegistryObject(), exceptions);
}
}

View file

@ -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.
*
* </pre>
*
@ -52,9 +49,6 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil;
public class OrganizationTypeValidator extends
ValidatorPlugin<OrganizationType> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(OrganizationTypeValidator.class);
/**
* Constructor.
*
@ -78,19 +72,11 @@ public class OrganizationTypeValidator extends
* {@inheritDoc}
*/
@Override
protected List<RegistryExceptionType> validate(
OrganizationType registryObject) {
List<RegistryExceptionType> exceptions = Lists.newArrayList();
protected void validate(OrganizationType registryObject,
List<RegistryExceptionType> exceptions) {
final boolean validReference = registryObjectReferenceValidator
.isValidReference(registryObject.getPrimaryContact());
if (!validReference) {
exceptions.add(EbxmlExceptionUtil
.createUnresolvedReferenceException(null,
registryObject.getPrimaryContact(), statusHandler));
}
validateReference(registryObject.getPrimaryContact(), exceptions);
return exceptions;
}
}

View file

@ -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.
*
* </pre>
*
@ -79,12 +79,9 @@ public class RegistryObjectTypeValidator extends
* {@inheritDoc}
*/
@Override
protected List<RegistryExceptionType> validate(
RegistryObjectType registryObject) {
List<RegistryExceptionType> exceptions = Lists.newArrayList();
exceptions.addAll(resolveReferences(registryObject,
registryObject.getId()));
return exceptions;
protected void validate(RegistryObjectType registryObject,
List<RegistryExceptionType> 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<RegistryExceptionType> resolveReferences(
RegistryObjectType object, String originalId) {
List<RegistryExceptionType> exceptions = Lists.newArrayList();
private void resolveReferences(RegistryObjectType object,
String originalId, List<RegistryExceptionType> exceptions) {
final String objectId = object.getId();
statusHandler.info("Checking references for object with id ["
+ objectId + "]...");
Set<ClassificationType> classifications = object.getClassification();
if (classifications != null) {
for (ClassificationType classification : classifications) {
exceptions
.addAll(resolveReferences(classification, originalId));
resolveReferences(classification, originalId, exceptions);
}
}
Set<ExternalIdentifierType> externIdents = object
.getExternalIdentifier();
if (externIdents != null) {
for (ExternalIdentifierType externIdent : externIdents) {
exceptions.addAll(resolveReferences(externIdent, originalId));
resolveReferences(externIdent, originalId, exceptions);
}
}
Set<ExternalLinkType> 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;
}
}

View file

@ -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.
*
* </pre>
*
@ -97,10 +99,7 @@ public abstract class ValidatorPlugin<T extends RegistryObjectType> implements
for (RegistryObjectType registryObject : originalObjects
.getRegistryObject()) {
final T expectedType = castToExpectedType(registryObject);
final List<RegistryExceptionType> 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<T extends RegistryObjectType> 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<RegistryExceptionType> 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<? extends RegistryObjectType> expectedType,
List<RegistryExceptionType> 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<RegistryExceptionType> 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<T extends RegistryObjectType> implements
*
* @param registryObject
* the object to validate
* @param exceptions
* the collection to add exceptions to
*/
protected abstract List<RegistryExceptionType> validate(T registryObject);
protected abstract void validate(T registryObject,
List<RegistryExceptionType> exceptions);
}

View file

@ -13,6 +13,7 @@
<import resource="file:///${edex.home}/conf/spring/edex-db.xml" />
<import resource="classpath:res/spring/ebxml.xml" />
<import resource="classpath:res/spring/ebxml-webservices.xml" />
<import resource="classpath:res/spring/ebxml-validator-plugins.xml" />
<import resource="classpath:res/spring/ebxml-querytypes.xml" />
<import resource="classpath:res/spring/ebxml-registry-dao.xml" />
<import resource="classpath:res/spring/ebxml-subscription.xml" />

View file

@ -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.
*
* </pre>
*
@ -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);

View file

@ -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}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2013 1672 djohnson Initial creation
*
* </pre>
*
* @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;
}
}

View file

@ -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.
*
* </pre>
*
@ -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 })

View file

@ -7,6 +7,16 @@
class="com.raytheon.uf.edex.registry.ebxml.dao.EbxmlHsqlValidationStrategy" />
<bean id="registrySubscriptionManagerInvoker"
class="com.raytheon.uf.edex.registry.ebxml.dao.DirectlyInvokeRegistrySubscriptionManager" />
class="com.raytheon.uf.edex.registry.ebxml.dao.DirectlyInvokeRegistrySubscriptionManager">
<constructor-arg ref="RegistrySubscriptionManager" />
</bean>
<bean id="ebxmlSubscriptionsEnabled" class="java.lang.Boolean">
<constructor-arg value="true" />
</bean>
<bean id="ebxmlEmailEnabled" class="java.lang.Boolean">
<constructor-arg value="true" />
</bean>
</beans>

View file

@ -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.
*
* </pre>
*
@ -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";

View file

@ -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.
*
* </pre>
*
@ -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();
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public abstract class AbstractRegistryObjectTypeValidatorTest<REGISTRY_OBJECT extends RegistryObjectType, VALIDATOR extends ValidatorPlugin<REGISTRY_OBJECT>> {
// 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 <T extends RegistryExceptionType> void expectExceptionReturned(
REGISTRY_OBJECT registryObject, Class<T> 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
.<RegistryObjectType> asList(registryObject)));
return request;
}
/**
* Get the validator to test.
*
* @param referenceValidator
* @return the validator instance
*/
protected abstract VALIDATOR getValidator(
IRegistryObjectReferenceValidator referenceValidator);
}

View file

@ -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}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class AssociationTypeValidatorTest
extends
AbstractRegistryObjectTypeValidatorTest<AssociationType, AssociationTypeValidator> {
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);
}
}

View file

@ -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}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ClassificationTypeValidatorTest
extends
AbstractRegistryObjectTypeValidatorTest<ClassificationType, ClassificationTypeValidator> {
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);
}
}

View file

@ -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}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ExternalIdentifierTypeValidatorTest
extends
AbstractRegistryObjectTypeValidatorTest<ExternalIdentifierType, ExternalIdentifierTypeValidator> {
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);
}
}

View file

@ -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}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ExternalLinkTypeValidatorTest
extends
AbstractRegistryObjectTypeValidatorTest<ExternalLinkType, ExternalLinkTypeValidator> {
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);
}
}

View file

@ -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}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class OrganizationTypeValidatorTest
extends
AbstractRegistryObjectTypeValidatorTest<OrganizationType, OrganizationTypeValidator> {
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);
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ActionTypeFixture extends AbstractFixture<ActionType> {
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;
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class AssociationTypeFixture extends
RegistryObjectTypeFixture<AssociationType> {
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();
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class AuditableEventTypeFixture extends
RegistryObjectTypeFixture<AuditableEventType> {
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();
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ClassificationTypeFixture extends
RegistryObjectTypeFixture<ClassificationType> {
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();
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ExternalIdentifierTypeFixture extends
RegistryObjectTypeFixture<ExternalIdentifierType> {
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();
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class ExternalLinkTypeFixture extends
RegistryObjectTypeFixture<ExternalLinkType> {
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();
}
}

View file

@ -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.
*
* </pre>
*
@ -40,20 +39,39 @@ import com.raytheon.uf.common.util.AbstractFixture;
* @version 1.0
*/
public class OrganizationTypeFixture extends AbstractFixture<OrganizationType> {
public class OrganizationTypeFixture extends
RegistryObjectTypeFixture<OrganizationType> {
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();
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2013 1910 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public abstract class RegistryObjectTypeFixture<T extends RegistryObjectType>
extends AbstractFixture<T> {
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();
}