Issue #1910 Add initial validator framework supporting checkReferences
Change-Id: I11aeacf7859d5c755111cc5169ccaedae595146c Former-commit-id:d41698aa81
[formerlyaa85728ffa
] [formerlyd41698aa81
[formerlyaa85728ffa
] [formerly93f97aa45e
[formerly c6ec100fda197235fd82fc50432491b78344bab2]]] Former-commit-id:93f97aa45e
Former-commit-id:af4e80ed03
[formerlya8c44998b5
] Former-commit-id:6fe93684b0
This commit is contained in:
parent
f4b0f5b3a1
commit
283c67e926
29 changed files with 1548 additions and 135 deletions
|
@ -29,6 +29,7 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType;
|
|||
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.RegistryExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnresolvedReferenceExceptionType;
|
||||
|
||||
|
@ -48,7 +49,6 @@ import com.raytheon.uf.common.registry.RegistryResponse;
|
|||
import com.raytheon.uf.common.registry.annotations.RegistryObject;
|
||||
import com.raytheon.uf.common.registry.constants.AssociationTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryErrorMessage;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -77,6 +77,7 @@ import com.raytheon.uf.common.util.ReflectionException;
|
|||
* 3/18/2013 1802 bphillip Implemented transaction boundaries
|
||||
* 3/27/2013 1802 bphillip Changed visibility of processRequest and fixed catch block to catch the correct Exception type
|
||||
* 4/9/2013 1802 bphillip Modified to use constants in constants package instead of RegistryUtil
|
||||
* Apr 24, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
@ -45,9 +45,9 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
|
||||
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.RegistryResponseType;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
|
@ -62,6 +62,8 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/9/2013 1802 bphillip Initial implementation
|
||||
* Apr 24, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -382,7 +384,7 @@ public class RegistrySOAPServices {
|
|||
throw new RegistryServiceException(
|
||||
"Error executing submitObjects!", e);
|
||||
}
|
||||
String status = response.getStatus();
|
||||
RegistryResponseStatus status = response.getStatus();
|
||||
if (status.equals(RegistryResponseStatus.SUCCESS)) {
|
||||
statusHandler.info("Submit Objects request ["
|
||||
+ response.getRequestId() + "] successful");
|
||||
|
|
|
@ -95,6 +95,24 @@ public class RegistryObjectListType implements Serializable {
|
|||
@DynamicSerializeElement
|
||||
protected List<RegistryObjectType> registryObject;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public RegistryObjectListType() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param registryObjects
|
||||
* the collection of registry objects
|
||||
*/
|
||||
public RegistryObjectListType(List<RegistryObjectType> registryObjects) {
|
||||
// Defensive list copy, not using the original list
|
||||
this.registryObject = new ArrayList<RegistryObjectType>(registryObjects);
|
||||
}
|
||||
|
||||
public Integer getKey() {
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,25 @@ public class RegistryObjectType extends IdentifiableType {
|
|||
@DynamicSerializeElement
|
||||
protected String status;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public RegistryObjectType() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id
|
||||
* the id to use
|
||||
* @param lid
|
||||
* the lid to use
|
||||
*/
|
||||
public RegistryObjectType(String id, String lid) {
|
||||
this.id = id;
|
||||
this.lid = lid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
package com.raytheon.uf.common.registry.constants;
|
||||
package oasis.names.tc.ebxml.regrep.xsd.rs.v4;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
|
||||
/**
|
||||
* This class holds the canonical ClassificationNodes are defined for the
|
||||
|
@ -15,35 +18,49 @@ package com.raytheon.uf.common.registry.constants;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/9/2012 184 bphillip Initial Coding
|
||||
* 4/9/2013 1802 bphillip Moved into EBXML common plugin
|
||||
* Apr 24, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class RegistryResponseStatus {
|
||||
@XmlEnum
|
||||
public enum RegistryResponseStatus {
|
||||
|
||||
/**
|
||||
* This status specifies that the request encountered a failure. This value
|
||||
* MUST never be returned since a server MUST indicate failure conditions by
|
||||
* returning an appropriate fault message.
|
||||
*/
|
||||
public static final String FAILURE = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure";
|
||||
@XmlEnumValue(RegistryResponseStatus.FAILURE_STRING)
|
||||
FAILURE,
|
||||
|
||||
/**
|
||||
* This status specifies that the request was partially successful. Certain
|
||||
* requests such as federated queries allow this status to be returned
|
||||
*/
|
||||
public static final String PARTIAL_SUCCESS = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:PartialSuccess";
|
||||
@XmlEnumValue(RegistryResponseStatus.PARTIAL_SUCCESS_STRING)
|
||||
PARTIAL_SUCCESS,
|
||||
|
||||
/**
|
||||
* This status specifies that the request was successful
|
||||
*/
|
||||
public static final String SUCCESS = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success";
|
||||
@XmlEnumValue(RegistryResponseStatus.SUCCESS_STRING)
|
||||
SUCCESS,
|
||||
|
||||
/**
|
||||
* This status specifies that the response is not yet available. This may be
|
||||
* the case if this RegistryResponseType represents an immediate response to
|
||||
* an asynchronous request where the actual response is not yet available.
|
||||
*/
|
||||
public static final String UNAVAILABLE = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Unavailable";
|
||||
@XmlEnumValue(RegistryResponseStatus.UNAVAILABLE_STRING)
|
||||
UNAVAILABLE;
|
||||
|
||||
private static final String FAILURE_STRING = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure";
|
||||
|
||||
private static final String PARTIAL_SUCCESS_STRING = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:PartialSuccess";
|
||||
|
||||
private static final String SUCCESS_STRING = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success";
|
||||
|
||||
private static final String UNAVAILABLE_STRING = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Unavailable";
|
||||
}
|
|
@ -94,7 +94,7 @@ public class RegistryResponseType extends ExtensibleObjectType {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
protected String status;
|
||||
protected RegistryResponseStatus status;
|
||||
|
||||
@XmlAttribute
|
||||
@XmlSchemaType(name = "anyURI")
|
||||
|
@ -180,10 +180,10 @@ public class RegistryResponseType extends ExtensibleObjectType {
|
|||
/**
|
||||
* Gets the value of the status property.
|
||||
*
|
||||
* @return possible object is {@link String }
|
||||
* @return possible object is {@link RegistryResponseStatus }
|
||||
*
|
||||
*/
|
||||
public String getStatus() {
|
||||
public RegistryResponseStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -191,10 +191,10 @@ public class RegistryResponseType extends ExtensibleObjectType {
|
|||
* Sets the value of the status property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is {@link String }
|
||||
* allowed object is {@link RegistryResponseStatus }
|
||||
*
|
||||
*/
|
||||
public void setStatus(String value) {
|
||||
public void setStatus(RegistryResponseStatus value) {
|
||||
this.status = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExtrinsicObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryRequestType;
|
||||
|
@ -184,4 +185,16 @@ public class ValidateObjectsRequest extends RegistryRequestType {
|
|||
this.invocationControlFile = invocationControlFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object references contained by the request.
|
||||
*
|
||||
* @return the object references
|
||||
*/
|
||||
public List<ObjectRefType> getObjectRefs() {
|
||||
if (objectRefList == null) {
|
||||
objectRefList = new ObjectRefListType();
|
||||
}
|
||||
return objectRefList.getObjectRef();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<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">
|
||||
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="edexRegistryManager"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.util.EDEXRegistryManager">
|
||||
|
|
|
@ -32,12 +32,14 @@
|
|||
<property name="cataloger" ref="catalogerServiceImpl" />
|
||||
</bean>
|
||||
|
||||
<!-- VALIDATOR -->
|
||||
<!-- Define concrete implementation of the service -->
|
||||
<bean id="validatorServiceImpl"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.services.validator.ValidatorImpl">
|
||||
<property name="queryManager" ref="queryServiceImpl" />
|
||||
</bean>
|
||||
<!-- VALIDATOR -->
|
||||
<!-- Define concrete implementation of the service -->
|
||||
<bean id="validatorServiceImpl"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.services.validator.ValidatorImpl">
|
||||
<property name="queryManager" ref="queryServiceImpl" />
|
||||
<property name="registryObjectDao" ref="registryObjectDao" />
|
||||
<property name="registryObjectTypeValidator" ref="registryObjectTypeValidator" />
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- CATALOGER -->
|
||||
|
@ -97,6 +99,26 @@
|
|||
<property name="personDao" ref="personDao" />
|
||||
<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>
|
||||
|
||||
<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>
|
|
@ -23,4 +23,8 @@
|
|||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="registryObjectReferenceValidator" class="com.raytheon.uf.edex.registry.ebxml.services.validator.LocalServerRegistryObjectReferenceValidator">
|
||||
<property name="registryObjectDao" ref="registryObjectDao" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -34,6 +34,7 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefListType;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus;
|
||||
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.opensaml.xacml.XACMLObject;
|
||||
|
@ -57,7 +58,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import com.raytheon.uf.common.registry.IRegistryRequest;
|
||||
import com.raytheon.uf.common.registry.IRegistryRequest.Action;
|
||||
import com.raytheon.uf.common.registry.constants.QueryReturnTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.ws.WebServiceContext;
|
||||
|
@ -41,10 +40,7 @@ import oasis.names.tc.ebxml.regrep.xsd.query.v4.ResponseOptionType;
|
|||
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.rim.v4.ClassificationSchemeType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExtensibleObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalIdentifierType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalLinkType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
|
@ -53,9 +49,12 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.VersionInfoType;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.InvalidRequestExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.ObjectExistsExceptionType;
|
||||
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.RegistryResponseType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnresolvedReferenceExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnsupportedCapabilityExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsResponse;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -66,7 +65,6 @@ import com.raytheon.uf.common.registry.constants.DeletionScope;
|
|||
import com.raytheon.uf.common.registry.constants.ErrorSeverity;
|
||||
import com.raytheon.uf.common.registry.constants.QueryReturnTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.registry.constants.StatusTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
|
||||
|
@ -103,6 +101,8 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* 3/18/2013 1802 bphillip Modified to use transaction boundaries and spring injection
|
||||
* 4/9/2013 1802 bphillip Changed how auditable events are handled
|
||||
* Apr 18, 2013 1693 djohnson Changes to conform to Ebxml 4.0 SubmitObjects protocol.
|
||||
* Apr 24, 2013 1910 djohnson Use validation framework to check references.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -113,7 +113,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
public class LifecycleManagerImpl implements LifecycleManager {
|
||||
|
||||
/** The logger */
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(LifecycleManagerImpl.class);
|
||||
|
||||
@Resource
|
||||
|
@ -123,7 +123,6 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
private QueryManagerImpl queryManager;
|
||||
|
||||
/** The validator */
|
||||
@SuppressWarnings("unused")
|
||||
private ValidatorImpl validator;
|
||||
|
||||
/** The cataloger */
|
||||
|
@ -323,16 +322,39 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
if (checkReferences) {
|
||||
statusHandler
|
||||
.info("Client has selected to check object references before submitting objects.");
|
||||
// check the references. A MsgRegistryException error will be thrown
|
||||
// if references fail to resolve
|
||||
for (RegistryObjectType obj : objs) {
|
||||
resolveReferences(obj, obj.getId());
|
||||
ValidateObjectsRequest validateObjectsRequest = new ValidateObjectsRequest();
|
||||
validateObjectsRequest.setOriginalObjects(request.getRegistryObjectList());
|
||||
|
||||
// Uses the validation service directly, not going through the
|
||||
// web-service client interface
|
||||
final ValidateObjectsResponse validationResponse = validator
|
||||
.serverValidateObjects(validateObjectsRequest,
|
||||
EbxmlObjectUtil.spiObjectFactory
|
||||
.createValidateObjectsResponse());
|
||||
|
||||
final List<RegistryExceptionType> validationExceptions = validationResponse.getException();
|
||||
final List<RegistryExceptionType> responseExceptions = response.getException();
|
||||
|
||||
if (!validationExceptions.isEmpty()) {
|
||||
// Only care about unresolved references
|
||||
for (RegistryExceptionType exception : validationExceptions) {
|
||||
if (exception instanceof UnresolvedReferenceExceptionType) {
|
||||
responseExceptions.add(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!responseExceptions.isEmpty()) {
|
||||
throw EbxmlExceptionUtil
|
||||
.createMsgRegistryException(
|
||||
"Unresolved references occurred with the submitted registry objects",
|
||||
responseExceptions.get(0), statusHandler);
|
||||
|
||||
}
|
||||
}
|
||||
if (submitMode.equals(Mode.CREATE_OR_REPLACE)
|
||||
|| submitMode.equals(Mode.CREATE_OR_VERSION)
|
||||
|| submitMode.equals(Mode.CREATE_ONLY)) {
|
||||
// TODO: Add object validation
|
||||
processSubmit(request, response);
|
||||
} else {
|
||||
throw EbxmlExceptionUtil
|
||||
|
@ -370,64 +392,6 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the specified object to ensure that all references via references
|
||||
* attributes and slots to other RegistryObjects are resolvable
|
||||
*
|
||||
* @param object
|
||||
* The object to check
|
||||
* @param originalId
|
||||
* A record of the original object's id as this id will not need
|
||||
* to pass the check since it is the id of the object being
|
||||
* submitted
|
||||
* @throws MsgRegistryException
|
||||
* If errors occur while querying the registry, or there is an
|
||||
* unresolvable property
|
||||
*/
|
||||
private void resolveReferences(RegistryObjectType object, String originalId)
|
||||
throws MsgRegistryException {
|
||||
statusHandler.info("Checking references for object with id ["
|
||||
+ object.getId() + "]...");
|
||||
Set<ClassificationType> classifications = object.getClassification();
|
||||
if (classifications != null) {
|
||||
for (ClassificationType classification : classifications) {
|
||||
resolveReferences(classification, originalId);
|
||||
}
|
||||
}
|
||||
Set<ExternalIdentifierType> externIdents = object
|
||||
.getExternalIdentifier();
|
||||
if (externIdents != null) {
|
||||
for (ExternalIdentifierType externIdent : externIdents) {
|
||||
resolveReferences(externIdent, originalId);
|
||||
}
|
||||
}
|
||||
Set<ExternalLinkType> externLinks = object.getExternalLink();
|
||||
if (externLinks != null) {
|
||||
for (ExternalLinkType externLink : externLinks) {
|
||||
resolveReferences(externLink, originalId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!object.getId().equals(originalId)) {
|
||||
RegistryObjectType classResult = registryObjectDao.getById(object
|
||||
.getId());
|
||||
|
||||
if (classResult == null) {
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(
|
||||
"Unresolved reference found",
|
||||
UnresolvedReferenceExceptionType.class, "",
|
||||
"Unresolved reference found",
|
||||
"The registry does not contain a reference to type ["
|
||||
+ object.getClass().getCanonicalName()
|
||||
+ "] with id [" + object.getId() + "]",
|
||||
ErrorSeverity.ERROR, statusHandler);
|
||||
}
|
||||
}
|
||||
statusHandler
|
||||
.info("References successfully resolve for object with id ["
|
||||
+ object.getId() + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Submits objects to the registry
|
||||
|
@ -637,7 +601,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
break;
|
||||
}
|
||||
|
||||
// TODO: Implement proper cataloging of objects accorind to EbXML
|
||||
// TODO: Implement proper cataloging of objects according to EbXML
|
||||
// spec
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.ResponseOptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnsupportedCapabilityExceptionType;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.ErrorSeverity;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -76,6 +76,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2012 184 bphillip Initial creation
|
||||
* 3/18/2013 1802 bphillip Modified to use transaction boundaries and spring injection
|
||||
* Apr 24, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -90,28 +91,28 @@ public class QueryManagerImpl implements QueryManager {
|
|||
|
||||
private boolean eagerFetch = false;
|
||||
|
||||
protected static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
protected static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(QueryManagerImpl.class);
|
||||
|
||||
private QueryTypeManager queryTypeMgr;
|
||||
|
||||
/**
|
||||
* · ObjectRef - This option specifies that the QueryResponse MUST contain a
|
||||
* ObjectRef - This option specifies that the QueryResponse MUST contain a
|
||||
* <rim:ObjectRefList> element. The purpose of this option is to return
|
||||
* references to objects rather than the actual objects.
|
||||
*
|
||||
* · RegistryObject - This option specifies that the QueryResponse MUST
|
||||
* RegistryObject - This option specifies that the QueryResponse MUST
|
||||
* contain a <rim:RegistryObjectList> element containing
|
||||
* <rim:RegistryObject> elements with xsi:type=“rim:RegistryObjectType”.
|
||||
* <rim:RegistryObject> elements with xsi:type=rim:RegistryObjectType.
|
||||
*
|
||||
* · LeafClass - This option specifies that the QueryResponse MUST contain a
|
||||
* LeafClass - This option specifies that the QueryResponse MUST contain a
|
||||
* collection of <rim:RegistryObjectList> element containing
|
||||
* <rim:RegistryObject> elements that have an xsi:type attribute that
|
||||
* corresponds to leaf classes as defined in [regrep-xsd-v4.0]. No
|
||||
* RepositoryItems SHOULD be included for any rim:ExtrinsicObjectType
|
||||
* instance in the <rim:RegistryObjectList> element.
|
||||
*
|
||||
* · LeafClassWithRepositoryItem - This option is the same as the LeafClass
|
||||
* LeafClassWithRepositoryItem - This option is the same as the LeafClass
|
||||
* option with the additional requirement that the response include the
|
||||
* RepositoryItems, if any, for every rim:ExtrinsicObjectType instance in
|
||||
* the <rim:RegistryObjectList> element.
|
||||
|
|
|
@ -26,6 +26,7 @@ import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
|||
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.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes;
|
||||
|
@ -42,33 +43,33 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.types.CanonicalEbxmlQu
|
|||
* match the specified criteria.
|
||||
* <p>
|
||||
* <b>Parameter Summary:</b> <br>
|
||||
* · <b><i>associationType</i></b> -- Matches associated RegistryObjects of
|
||||
* <b><i>associationType</i></b> -- Matches associated RegistryObjects of
|
||||
* Association's whose type attribute references a ClassificationNode where
|
||||
* rim:ClassificationNode/@path matches specified value
|
||||
* <p>
|
||||
* · <b><i>matchOnAnyParameter</i></b> -- If true then use logical OR between
|
||||
* <b><i>matchOnAnyParameter</i></b> -- If true then use logical OR between
|
||||
* predicates for each parameter
|
||||
* <p>
|
||||
* · <b><i>sourceObjectId</i></b> --Matches target RegistryObjects of
|
||||
* Associations where the source RegistryObject's id matches
|
||||
* <b><i>sourceObjectId</i></b> --Matches target RegistryObjects of Associations
|
||||
* where the source RegistryObject's id matches
|
||||
* rim:/RegistryObject[@xsi:type="rim:AssociationType"]/@sourceObject.<br>
|
||||
* Allows use of “%” wildcard character to match multiple characters.<br>
|
||||
* Allows use of “?” wildcard character to match a single character.<br>
|
||||
* Allows use of % wildcard character to match multiple characters.<br>
|
||||
* Allows use of ? wildcard character to match a single character.<br>
|
||||
* <p>
|
||||
* · <b><i>sourceObjectType</i></b> -- Matches target RegistryObjects of
|
||||
* <b><i>sourceObjectType</i></b> -- Matches target RegistryObjects of
|
||||
* Associations whose sourceObject attribute references a RegistryObject whose
|
||||
* objectType attribute matches the id of the ClassificationNode where
|
||||
* rim:ClassificationNode/@path matches specified value
|
||||
* <p>
|
||||
* · <b><i>targetObjectId</i></b> --
|
||||
* <b><i>targetObjectId</i></b> --
|
||||
*
|
||||
* Matches source RegistryObjects of Associations where the target
|
||||
* RegistryObject's id matches
|
||||
* rim:/RegistryObject[@xsi:type="rim:AssociationType"]/@targetObject.<br>
|
||||
* Allows use of “%” wildcard character to match multiple characters.<br>
|
||||
* Allows use of “?” wildcard character to match a single character.<br>
|
||||
* Allows use of % wildcard character to match multiple characters.<br>
|
||||
* Allows use of ? wildcard character to match a single character.<br>
|
||||
* <p>
|
||||
* · <b><i>targetObjectType</i></b> --
|
||||
* <b><i>targetObjectType</i></b> --
|
||||
*
|
||||
* Matches source RegistryObjects of Associations whose targetObject attribute
|
||||
* references a RegistryObject whose objectType attribute matches the id of the
|
||||
|
@ -81,8 +82,9 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.types.CanonicalEbxmlQu
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/13/2012 #184 bphillip Initial creation
|
||||
* 3/18/2013 1802 bphillip Modified to use transaction boundaries and spring dao injection
|
||||
* 3/18/2013 1802 bphillip Modified to use transaction boundaries and spring dao injection
|
||||
* 4/9/2013 1802 bphillip Changed abstract method signature, modified return processing, and changed static variables
|
||||
* Apr 23, 2013 1910 djohnson Don't allow NPE on registry object list, remove non ANSI Javadoc.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -156,8 +158,15 @@ public class FindAssociatedObjects extends CanonicalEbxmlQuery {
|
|||
ids.add(((AssociationType) association).getTargetObject());
|
||||
}
|
||||
}
|
||||
queryResponse.getRegistryObjectList().getRegistryObject()
|
||||
.addAll(registryObjectDao.getById(ids));
|
||||
|
||||
RegistryObjectListType registryObjectList = queryResponse
|
||||
.getRegistryObjectList();
|
||||
if (registryObjectList == null) {
|
||||
registryObjectList = new RegistryObjectListType();
|
||||
queryResponse.setRegistryObjectList(registryObjectList);
|
||||
}
|
||||
registryObjectList.getRegistryObject().addAll(
|
||||
registryObjectDao.getById(ids));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Interface to validate a registry object reference.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2013 1910 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface IRegistryObjectReferenceValidator {
|
||||
|
||||
/**
|
||||
* Check a reference for validity.
|
||||
*
|
||||
* @param reference
|
||||
* the reference to check
|
||||
* @return true if a valid reference
|
||||
*/
|
||||
boolean isValidReference(final String reference);
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||
|
||||
/**
|
||||
* {@link IRegistryObjectReferenceValidator} implementation when checking
|
||||
* references on the same server.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2013 1910 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@Transactional
|
||||
public class LocalServerRegistryObjectReferenceValidator implements
|
||||
IRegistryObjectReferenceValidator {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(LocalServerRegistryObjectReferenceValidator.class);
|
||||
|
||||
/** The registry object data access object */
|
||||
private RegistryObjectDao registryObjectDao;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public LocalServerRegistryObjectReferenceValidator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidReference(final String referenceId) {
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler
|
||||
.debug("Validating reference id [" + referenceId + "]");
|
||||
}
|
||||
return registryObjectDao.getById(referenceId) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param registryObjectDao
|
||||
* the registryObjectDao to set
|
||||
*/
|
||||
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
|
||||
this.registryObjectDao = registryObjectDao;
|
||||
}
|
||||
}
|
|
@ -19,17 +19,44 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.services.validator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.ws.WebServiceContext;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.QueryManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.ResponseOptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
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.RegistryResponseStatus;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsResponse;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.raytheon.uf.common.registry.constants.ErrorSeverity;
|
||||
import com.raytheon.uf.common.registry.constants.QueryReturnTypes;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.util.registry.GenericRegistry;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
||||
|
||||
/**
|
||||
|
@ -43,24 +70,43 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/13/12 184 bphillip Initial creation
|
||||
* Apr 24, 2013 1910 djohnson Start to fill in the validation logic.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1.0
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class ValidatorImpl implements Validator {
|
||||
|
||||
/** The logger */
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ValidatorImpl.class);
|
||||
|
||||
/** The query manager implementation */
|
||||
private QueryManagerImpl queryManager;
|
||||
/** The query manager **/
|
||||
private QueryManager queryManager;
|
||||
|
||||
/** The registry object data access object */
|
||||
private RegistryObjectDao registryObjectDao;
|
||||
|
||||
private Validator registryObjectTypeValidator;
|
||||
|
||||
@Resource
|
||||
private WebServiceContext wsContext;
|
||||
|
||||
/** Holds the registry of plugin validators **/
|
||||
private final GenericRegistry<String, Validator> validatorPlugins = new GenericRegistry<String, Validator>() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ValidatorImpl() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -75,10 +121,175 @@ public class ValidatorImpl implements Validator {
|
|||
statusHandler
|
||||
.info("Validator service received validateObjects request from ["
|
||||
+ EbxmlObjectUtil.getClientHost(wsContext) + "]");
|
||||
return EbxmlObjectUtil.spiObjectFactory.createValidateObjectsResponse();
|
||||
|
||||
final ValidateObjectsResponse response = EbxmlObjectUtil.spiObjectFactory
|
||||
.createValidateObjectsResponse();
|
||||
|
||||
// Resolve the object references passed in, and validate the objects
|
||||
List<RegistryObjectType> registryObjects = Lists.newArrayList();
|
||||
if (request.getObjectRefList() != null) {
|
||||
final List<ObjectRefType> objectRefs = request.getObjectRefs();
|
||||
registryObjects = Lists
|
||||
.newArrayListWithExpectedSize(objectRefs.size());
|
||||
|
||||
for (ObjectRefType objectRef : objectRefs) {
|
||||
final String referenceId = objectRef.getId();
|
||||
final RegistryObjectType registryObject = registryObjectDao
|
||||
.getById(referenceId);
|
||||
if (registryObject == null) {
|
||||
response.getException().add(
|
||||
EbxmlExceptionUtil
|
||||
.createUnresolvedReferenceException(null,
|
||||
referenceId, statusHandler));
|
||||
continue;
|
||||
}
|
||||
|
||||
registryObjects.add(registryObject);
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve any objects requested by a client query
|
||||
final QueryType query = request.getQuery();
|
||||
if (query != null) {
|
||||
|
||||
final ResponseOptionType responseOption = new ResponseOptionType();
|
||||
responseOption.setReturnType(QueryReturnTypes.REGISTRY_OBJECT);
|
||||
|
||||
QueryRequest queryRequest = new QueryRequest();
|
||||
queryRequest.setResponseOption(responseOption);
|
||||
queryRequest.setQuery(query);
|
||||
|
||||
final QueryResponse queryResponse = queryManager
|
||||
.executeQuery(queryRequest);
|
||||
final RegistryObjectListType registryObjectList = queryResponse
|
||||
.getRegistryObjectList();
|
||||
if (registryObjectList != null) {
|
||||
registryObjects.addAll(registryObjectList.getRegistryObject());
|
||||
}
|
||||
}
|
||||
|
||||
request.setObjectRefList(new ObjectRefListType());
|
||||
request.setOriginalObjects(new RegistryObjectListType(
|
||||
registryObjects));
|
||||
|
||||
return serverValidateObjects(request, response);
|
||||
}
|
||||
|
||||
public void setQueryManager(QueryManagerImpl queryManager) {
|
||||
/**
|
||||
* Performs a server-side only validation using the registry objects on the
|
||||
* request. Will be used by the server itself to verify registry object
|
||||
* integrity, or on a client request when the server resolves the registry
|
||||
* object references and queries to find the objects for validation.
|
||||
*
|
||||
* @param request
|
||||
* the request
|
||||
* @param response
|
||||
* the response to use
|
||||
* @return the response
|
||||
* @throws MsgRegistryException
|
||||
* on errors encountered during validation
|
||||
*/
|
||||
public ValidateObjectsResponse serverValidateObjects(
|
||||
ValidateObjectsRequest request, ValidateObjectsResponse response)
|
||||
throws MsgRegistryException {
|
||||
|
||||
final RegistryObjectListType originalObjects = request
|
||||
.getOriginalObjects();
|
||||
|
||||
if (originalObjects == null) {
|
||||
final String message = "The OriginalObjects element MUST specify the target objects to be verified!";
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(message,
|
||||
InvalidRequestExceptionType.class, "", message, message,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
}
|
||||
|
||||
// Place all of the objects into a map keyed by their object type
|
||||
Multimap<String, RegistryObjectType> objectTypeToObjects = ArrayListMultimap
|
||||
.create();
|
||||
final List<RegistryObjectType> objects = originalObjects
|
||||
.getRegistryObject();
|
||||
for (RegistryObjectType object : objects) {
|
||||
objectTypeToObjects.put(object.getObjectType(), object);
|
||||
}
|
||||
|
||||
// Validate each set of objects with the appropriate validator plugin
|
||||
final Map<String, Collection<RegistryObjectType>> entries = objectTypeToObjects
|
||||
.asMap();
|
||||
for (Entry<String, Collection<RegistryObjectType>> entry : entries
|
||||
.entrySet()) {
|
||||
final String objectType = entry.getKey();
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("Validating registry objects with type ["
|
||||
+ objectType + "]");
|
||||
}
|
||||
|
||||
// Create a validation request
|
||||
final RegistryObjectListType registryObjectListType = new RegistryObjectListType();
|
||||
registryObjectListType.getRegistryObject().addAll(entry.getValue());
|
||||
ValidateObjectsRequest validateRegistryObjects = new ValidateObjectsRequest();
|
||||
validateRegistryObjects.setOriginalObjects(registryObjectListType);
|
||||
|
||||
// Find any specific validator for this type
|
||||
Validator validator = validatorPlugins
|
||||
.getRegisteredObject(objectType);
|
||||
if (validator == null
|
||||
&& statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler
|
||||
.debug("There is no plugin validator for registry objects with type ["
|
||||
+ objectType
|
||||
+ "]. Only the generic registry object validator will be used...");
|
||||
} else {
|
||||
final ValidateObjectsResponse validateRegistryObjectsResponse = validator
|
||||
.validateObjects(request);
|
||||
response.getException().addAll(
|
||||
validateRegistryObjectsResponse.getException());
|
||||
}
|
||||
|
||||
// Perform general registry object validation
|
||||
final ValidateObjectsResponse generalValidationResponse = registryObjectTypeValidator
|
||||
.validateObjects(validateRegistryObjects);
|
||||
response.getException().addAll(
|
||||
generalValidationResponse.getException());
|
||||
}
|
||||
|
||||
RegistryResponseStatus status = (response.getException().isEmpty()) ? RegistryResponseStatus.SUCCESS
|
||||
: RegistryResponseStatus.PARTIAL_SUCCESS;
|
||||
response.setStatus(status);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the plugin validator registry.
|
||||
*
|
||||
* @return the validatorplugins
|
||||
*/
|
||||
public GenericRegistry<String, Validator> getPluginValidatorRegistry() {
|
||||
return validatorPlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param registryObjectDao
|
||||
* the registryObjectDao to set
|
||||
*/
|
||||
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
|
||||
this.registryObjectDao = registryObjectDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param registryObjectTypeValidator
|
||||
* the registryObjectTypeValidator to set
|
||||
*/
|
||||
public void setRegistryObjectTypeValidator(
|
||||
Validator registryObjectTypeValidator) {
|
||||
this.registryObjectTypeValidator = registryObjectTypeValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param queryManager
|
||||
* the queryManager to set
|
||||
*/
|
||||
public void setQueryManager(QueryManager queryManager) {
|
||||
this.queryManager = queryManager;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* 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.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}
|
||||
* instances.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2013 1910 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class OrganizationTypeValidator extends
|
||||
ValidatorPlugin<OrganizationType> {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(OrganizationTypeValidator.class);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param registryObjectReferenceValidator
|
||||
* the registry object reference validator
|
||||
*/
|
||||
public OrganizationTypeValidator(
|
||||
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
|
||||
super(registryObjectReferenceValidator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<OrganizationType> getRegistryObjectTypeClass() {
|
||||
return OrganizationType.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected List<RegistryExceptionType> validate(
|
||||
OrganizationType registryObject) {
|
||||
List<RegistryExceptionType> exceptions = Lists.newArrayList();
|
||||
|
||||
final boolean validReference = registryObjectReferenceValidator
|
||||
.isValidReference(registryObject.getPrimaryContact());
|
||||
if (!validReference) {
|
||||
exceptions.add(EbxmlExceptionUtil
|
||||
.createUnresolvedReferenceException(null,
|
||||
registryObject.getPrimaryContact(), statusHandler));
|
||||
}
|
||||
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
* 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 java.util.Set;
|
||||
|
||||
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.ExternalIdentifierType;
|
||||
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;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil;
|
||||
|
||||
/**
|
||||
* Performs basic {@link RegistryObjectType} validation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2013 1910 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RegistryObjectTypeValidator extends
|
||||
ValidatorPlugin<RegistryObjectType> {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RegistryObjectTypeValidator.class);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param registryObjectReferenceValidator
|
||||
*/
|
||||
public RegistryObjectTypeValidator(
|
||||
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
|
||||
super(registryObjectReferenceValidator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<RegistryObjectType> getRegistryObjectTypeClass() {
|
||||
return RegistryObjectType.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected List<RegistryExceptionType> validate(
|
||||
RegistryObjectType registryObject) {
|
||||
List<RegistryExceptionType> exceptions = Lists.newArrayList();
|
||||
exceptions.addAll(resolveReferences(registryObject,
|
||||
registryObject.getId()));
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the specified object to ensure that all references via references
|
||||
* attributes and slots to other RegistryObjects are resolvable
|
||||
*
|
||||
* @param object
|
||||
* The object to check
|
||||
* @param originalId
|
||||
* A record of the original object's id as this id will not need
|
||||
* to pass the check since it is the id of the object being
|
||||
* submitted
|
||||
* @throws MsgRegistryException
|
||||
* 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();
|
||||
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));
|
||||
}
|
||||
}
|
||||
Set<ExternalIdentifierType> externIdents = object
|
||||
.getExternalIdentifier();
|
||||
if (externIdents != null) {
|
||||
for (ExternalIdentifierType externIdent : externIdents) {
|
||||
exceptions.addAll(resolveReferences(externIdent, originalId));
|
||||
}
|
||||
}
|
||||
Set<ExternalLinkType> externLinks = object.getExternalLink();
|
||||
if (externLinks != null) {
|
||||
for (ExternalLinkType externLink : externLinks) {
|
||||
exceptions.addAll(resolveReferences(externLink, originalId));
|
||||
}
|
||||
}
|
||||
|
||||
if (!objectId.equals(originalId)) {
|
||||
boolean objectReferenceValid = registryObjectReferenceValidator
|
||||
.isValidReference(objectId);
|
||||
|
||||
if (!objectReferenceValid) {
|
||||
exceptions.add(EbxmlExceptionUtil
|
||||
.createUnresolvedReferenceException(object.getClass(),
|
||||
objectId, statusHandler));
|
||||
} else {
|
||||
statusHandler
|
||||
.info("References successfully resolve for object with id ["
|
||||
+ objectId + "]");
|
||||
|
||||
}
|
||||
}
|
||||
return exceptions;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/**
|
||||
* 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.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator;
|
||||
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.spi.v4.ValidateObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.spi.v4.ValidateObjectsResponse;
|
||||
|
||||
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.util.EbxmlExceptionUtil;
|
||||
|
||||
/**
|
||||
* Base class for {@link Validator} plugin implementations.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2013 1910 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class ValidatorPlugin<T extends RegistryObjectType> implements
|
||||
Validator {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ValidatorPlugin.class);
|
||||
|
||||
protected IRegistryObjectReferenceValidator registryObjectReferenceValidator;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param validatorService
|
||||
* the overall validator service
|
||||
*/
|
||||
protected ValidatorPlugin(
|
||||
IRegistryObjectReferenceValidator registryObjectReferenceValidator) {
|
||||
this.registryObjectReferenceValidator = registryObjectReferenceValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ValidateObjectsResponse validateObjects(
|
||||
ValidateObjectsRequest validateObjectsRequest)
|
||||
throws MsgRegistryException {
|
||||
final RegistryObjectListType originalObjects = validateObjectsRequest
|
||||
.getOriginalObjects();
|
||||
if (originalObjects == null) {
|
||||
final String message = "The Validator plugin invocation MUST specify the target objects for that set using the OriginalObjects element";
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(message,
|
||||
InvalidRequestExceptionType.class, "", message, message,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
}
|
||||
|
||||
ValidateObjectsResponse response = new ValidateObjectsResponse();
|
||||
final List<RegistryExceptionType> allExceptions = response
|
||||
.getException();
|
||||
|
||||
for (RegistryObjectType registryObject : originalObjects
|
||||
.getRegistryObject()) {
|
||||
final T expectedType = castToExpectedType(registryObject);
|
||||
final List<RegistryExceptionType> exceptions = validate(expectedType);
|
||||
if (!CollectionUtil.isNullOrEmpty(exceptions)) {
|
||||
allExceptions.addAll(exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
RegistryResponseStatus status = (allExceptions.isEmpty()) ? RegistryResponseStatus.SUCCESS
|
||||
: RegistryResponseStatus.PARTIAL_SUCCESS;
|
||||
response.setStatus(status);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the {@link RegistryObjectType} is a type supported by this
|
||||
* Validator plugin.
|
||||
*
|
||||
* @param registryObject
|
||||
* the registry object to check
|
||||
* @throws MsgRegistryException
|
||||
* on an incorrect registry object type
|
||||
*/
|
||||
private T castToExpectedType(RegistryObjectType registryObject)
|
||||
throws MsgRegistryException {
|
||||
final Class<T> registryObjectTypeClass = getRegistryObjectTypeClass();
|
||||
if (!registryObjectTypeClass
|
||||
.isAssignableFrom(registryObject.getClass())) {
|
||||
final String message = "This Validator plugin should only be passed registry objects of type ["
|
||||
+ registryObjectTypeClass + "]!";
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(message,
|
||||
InvalidRequestExceptionType.class, "", message, message,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
}
|
||||
return registryObjectTypeClass.cast(registryObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the required registry object type class. May be a super-class of
|
||||
* multiple types.
|
||||
*
|
||||
* @return the registry object type class
|
||||
*/
|
||||
protected abstract Class<T> getRegistryObjectTypeClass();
|
||||
|
||||
/**
|
||||
* Validate the object, returning any exceptions that should be added to the
|
||||
* response.
|
||||
*
|
||||
* @param registryObject
|
||||
* the object to validate
|
||||
*/
|
||||
protected abstract List<RegistryExceptionType> validate(T registryObject);
|
||||
}
|
|
@ -25,10 +25,13 @@ import java.io.PrintStream;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnresolvedReferenceExceptionType;
|
||||
|
||||
import org.apache.commons.beanutils.MethodUtils;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.ErrorSeverity;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
|
||||
|
@ -42,6 +45,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 19, 2012 184 bphillip Initial creation
|
||||
* Apr 23, 2013 1910 djohnson Add createUnresolvedReferenceException().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -273,4 +277,28 @@ public class EbxmlExceptionUtil {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link UnresolvedReferenceExceptionType} exception.
|
||||
*
|
||||
* @param referencedObjectType
|
||||
* the referenced object type, can be null
|
||||
* @param id
|
||||
* the id of the referenced object, cannot be null
|
||||
* @param statusHandler
|
||||
* the statusHandler reference
|
||||
* @return the exception type
|
||||
*/
|
||||
public static UnresolvedReferenceExceptionType createUnresolvedReferenceException(
|
||||
Class<? extends RegistryObjectType> referencedObjectType,
|
||||
String id, IUFStatusHandler statusHandler) {
|
||||
final String ofType = (referencedObjectType == null) ? "" : "to type ["
|
||||
+ referencedObjectType.getCanonicalName()
|
||||
+ "] ";
|
||||
final String message = "Registry object reference " + ofType
|
||||
+ "with id [" + id + "] was unresolved";
|
||||
return createRegistryException(UnresolvedReferenceExceptionType.class,
|
||||
"", "Unresolved reference found", message, ErrorSeverity.ERROR,
|
||||
statusHandler);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.PostalAddressType;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.TelephoneNumberType;
|
||||
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.RegistryResponseType;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.AssociationTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.registry.constants.StatusTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.AssociationDao;
|
||||
|
@ -67,6 +67,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 7/30/2012 724 bphillip Initial creation
|
||||
* 3/13/2013 1082 bphillip Modified to use spring injection
|
||||
* Apr 23, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
@ -87,5 +87,6 @@
|
|||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.datadelivery.harvester"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/javax.jms"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.apache.commons.cxf"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -28,6 +29,7 @@ import java.math.BigInteger;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
|
@ -42,6 +44,8 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
|||
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.rs.v4.RegistryExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
@ -65,6 +69,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2013 1914 djohnson Initial creation
|
||||
* Apr 18, 2013 1693 djohnson Consolidate reusable methods.
|
||||
* Apr 23, 2013 1910 djohnson Allow sub-classes to pass callables and monitor for fault exceptions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -89,6 +94,30 @@ public class AbstractRegistryTest {
|
|||
"queryServiceImpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the registry object to the registry and verifies it was
|
||||
* successfully processed.
|
||||
*
|
||||
* @param registryObjectId
|
||||
* the registry object id to use
|
||||
* @param registryObject
|
||||
* the registry object
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
protected void submitRegistryObjectToRegistry(
|
||||
final RegistryObjectType registryObject)
|
||||
throws MsgRegistryException {
|
||||
final SubmitObjectsRequest submitRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, MY_REGISTRY_OBJECT_ID,
|
||||
Mode.CREATE_OR_REPLACE);
|
||||
submitRequest.getRegistryObjects().clear();
|
||||
submitRequest.getRegistryObjects().add(registryObject);
|
||||
|
||||
final RegistryResponseType submitResponse = lifecycleManager
|
||||
.submitObjects(submitRequest);
|
||||
assertSuccessfulResponse(submitResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the submit objects request.
|
||||
*
|
||||
|
@ -163,14 +192,68 @@ public class AbstractRegistryTest {
|
|||
* the expected exception class
|
||||
*/
|
||||
protected <T extends RegistryExceptionType> void expectFaultException(
|
||||
SubmitObjectsRequest submitObjectsRequest,
|
||||
Class<T> expectedException) {
|
||||
Callable<?> callable, Class<T> expectedException) {
|
||||
try {
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
fail("Expected a MsgRegistryException to have been thrown!");
|
||||
callable.call();
|
||||
fail("Expected a MsgRegistryException to have been thrown, wrapping a ["
|
||||
+ expectedException.getName() + "]");
|
||||
} catch (MsgRegistryException exception) {
|
||||
final RegistryExceptionType faultInfo = exception.getFaultInfo();
|
||||
assertThat(faultInfo, is(instanceOf(expectedException)));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Incorrect exception type was thrown!",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a successful response status.
|
||||
*
|
||||
* @param response
|
||||
* the response
|
||||
*/
|
||||
protected void assertSuccessfulResponse(RegistryResponseType response) {
|
||||
assertResponseStatus("The response did not have a successful status!",
|
||||
response, RegistryResponseStatus.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a successful response status.
|
||||
*
|
||||
* @param response
|
||||
* the response
|
||||
*/
|
||||
protected void assertPartialSuccessResponse(RegistryResponseType response) {
|
||||
assertResponseStatus(
|
||||
"The response did not have a partial success status!",
|
||||
response, RegistryResponseStatus.PARTIAL_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a successful response status.
|
||||
*
|
||||
* @param response
|
||||
* the response
|
||||
*/
|
||||
protected void assertFailureResponse(RegistryResponseType response) {
|
||||
assertResponseStatus(
|
||||
"The response did not have a partial success status!",
|
||||
response, RegistryResponseStatus.FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response has the given status.
|
||||
*
|
||||
* @param failMessage
|
||||
* the assertion failure message
|
||||
* @param response
|
||||
* the response
|
||||
* @param expected
|
||||
* the expected status
|
||||
*/
|
||||
private void assertResponseStatus(String failMessage,
|
||||
RegistryResponseType response, RegistryResponseStatus expected) {
|
||||
assertThat(failMessage, response.getStatus(), is(equalTo(expected)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.assertThat;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
|
@ -35,9 +36,13 @@ import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationTypeFixture;
|
||||
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.ObjectExistsExceptionType;
|
||||
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.RegistryResponseType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnresolvedReferenceExceptionType;
|
||||
|
||||
|
@ -49,7 +54,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
|
||||
/**
|
||||
|
@ -63,6 +68,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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -71,10 +77,11 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
|||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
"/spring/ebxml.xml", "/spring/ebxml-xacml.xml",
|
||||
"/spring/ebxml-webservices.xml", "/spring/ebxml-impl.xml",
|
||||
"/spring/ebxml-querytypes.xml", "/spring/ebxml-registry-dao.xml",
|
||||
"/ebxml/unit-test-ebxml-beans.xml", "/unit-test-localization-beans.xml" })
|
||||
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.UNIT_TEST_EBXML_BEANS_XML,
|
||||
SpringFiles.UNIT_TEST_LOCALIZATION_BEANS_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
||||
|
||||
|
@ -317,6 +324,37 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute checkReferences - true - Specifies that a server MUST check
|
||||
* submitted objects and make sure that all references via reference
|
||||
* attributes and slots to other RegistryObjects are resolvable. If a
|
||||
* reference does not resolve then the server MUST return
|
||||
* UnresolvedReferenceException
|
||||
*/
|
||||
@Test
|
||||
public void checkReferencesTrueWithNonExistantLocalStaticFails()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_VERSION);
|
||||
submitObjectsRequest.setCheckReferences(true);
|
||||
|
||||
final OrganizationType organizationType = OrganizationTypeFixture.INSTANCE
|
||||
.get();
|
||||
// Local static reference as taken from ebXML 4.0 ebRIM specification
|
||||
// section 2.9.3.3
|
||||
organizationType.setPrimaryContact("urn:acme:person:Danyal");
|
||||
|
||||
final List<RegistryObjectType> registryObjects = submitObjectsRequest
|
||||
.getRegistryObjects();
|
||||
registryObjects.clear();
|
||||
registryObjects.add(organizationType);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
UnresolvedReferenceExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* id - MUST be specified by client or else server MUST return
|
||||
* InvalidRequestException
|
||||
|
@ -457,4 +495,27 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
expectFaultException(submitObjectsRequest,
|
||||
ObjectExistsExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect the specified exception to be wrapped in a
|
||||
* {@link MsgRegistryException}.
|
||||
*
|
||||
* @param <T>
|
||||
* the expected exception type
|
||||
* @param submitObjectsRequest
|
||||
* the request
|
||||
* @param expectedException
|
||||
* the expected exception class
|
||||
*/
|
||||
private <T extends RegistryExceptionType> void expectFaultException(
|
||||
final SubmitObjectsRequest submitObjectsRequest,
|
||||
Class<T> expectedException) {
|
||||
expectFaultException(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
return null;
|
||||
}
|
||||
}, expectedException);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.UpdateObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
||||
|
||||
import com.raytheon.uf.common.registry.OperationStatus;
|
||||
import com.raytheon.uf.common.registry.RegistryQuery;
|
||||
import com.raytheon.uf.common.registry.RegistryQueryResponse;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
|
||||
/**
|
||||
* Extends {@link FactoryRegistryHandler} to allow it to be testable.
|
||||
|
@ -44,6 +44,7 @@ import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 20, 2012 0743 djohnson Initial creation
|
||||
* Apr 23, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.junit.Ignore;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 12, 2013 1543 djohnson Initial creation
|
||||
* Apr 23, 2013 1910 djohnson Add constants for ebxml spring files.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,4 +62,28 @@ public class SpringFiles {
|
|||
public static final String BANDWIDTH_DATADELIVERY_NCF_XML = "/spring/bandwidth-datadelivery-ncf.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_WFO_XML = "/spring/bandwidth-datadelivery-wfo.xml";
|
||||
|
||||
public static final String EBXML_XML = "/spring/ebxml.xml";
|
||||
|
||||
public static final String EBXML_IMPL_XML = "/spring/ebxml-impl.xml";
|
||||
|
||||
public static final String EBXML_QUERYTYPES_XML = "/spring/ebxml-querytypes.xml";
|
||||
|
||||
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_XACML_XML = "/spring/ebxml-xacml.xml";
|
||||
|
||||
public static final String EBXML_WEBSERVICES_XML = "/spring/ebxml-webservices.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";
|
||||
|
||||
public static final String UNIT_TEST_EBXML_REPLICATION_BEANS_XML = "/ebxml/unit-test-ebxml-replication-beans.xml";
|
||||
|
||||
public static final String UNIT_TEST_EBXML_PLUGIN_NOTIFICATION_LISTENER_XML = "/ebxml/ebxml-plugin-notification-listener.xml";
|
||||
}
|
|
@ -0,0 +1,349 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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 oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
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.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 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 com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.AbstractRegistryTest;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
||||
|
||||
/**
|
||||
* Test {@link ValidatorImpl}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2013 1910 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_XACML_XML,
|
||||
SpringFiles.EBXML_WEBSERVICES_XML,
|
||||
SpringFiles.EBXML_QUERYTYPES_XML, SpringFiles.EBXML_REGISTRY_DAO_XML,
|
||||
SpringFiles.UNIT_TEST_EBXML_BEANS_XML,
|
||||
SpringFiles.UNIT_TEST_LOCALIZATION_BEANS_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class ValidatorImplTest extends AbstractRegistryTest {
|
||||
|
||||
private static final String LOCAL_STATIC_REFERENCE = "urn:acme:person:Danyal";
|
||||
|
||||
@Autowired
|
||||
private ValidatorImpl validator;
|
||||
|
||||
/**
|
||||
* Section 5.2.1 Validator Plugin Interface - The server selects the
|
||||
* RegistryObjects that are the target of the validateObjects operations
|
||||
* using the <spi:Query> and <rim:ObjectRefList> elements. Any objects
|
||||
* specified by the OriginalObjects element MUST be ignored by the server.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void clientSpecifyingOriginalObjectsAreIgnored()
|
||||
throws MsgRegistryException {
|
||||
|
||||
ValidateObjectsRequest request = new ValidateObjectsRequest();
|
||||
request.setObjectRefList(null);
|
||||
// This object would fail validation if it were validated
|
||||
request.setOriginalObjects(new RegistryObjectListType(
|
||||
Arrays.<RegistryObjectType> asList(organizationWithLocalStaticReference())));
|
||||
|
||||
final ValidateObjectsResponse response = validator
|
||||
.validateObjects(request);
|
||||
assertSuccessfulResponse(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Element OriginalObjects - Specifies a collection of RegistryObject
|
||||
* instances. A server MUST validate all objects that are contained in this
|
||||
* element. This element is typically used when a server initiates the
|
||||
* validateObjects protocol during the processing of a submitObjects or
|
||||
* updateObjects protocol request or when it is delegating a client
|
||||
* initiated validateObjects protocol request to a Validator plugin.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void invalidLocalStaticReferenceReturnsPartialSuccessStatus()
|
||||
throws MsgRegistryException {
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
final ValidateObjectsResponse response = validateObject(organizationType);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.PARTIAL_SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element OriginalObjects - Specifies a collection of RegistryObject
|
||||
* instances. A server MUST validate all objects that are contained in this
|
||||
* element. This element is typically used when a server initiates the
|
||||
* validateObjects protocol during the processing of a submitObjects or
|
||||
* updateObjects protocol request or when it is delegating a client
|
||||
* initiated validateObjects protocol request to a Validator plugin.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void validLocalStaticReferenceReturnsSuccessStatus()
|
||||
throws MsgRegistryException {
|
||||
addReferencedObjectToRegistry();
|
||||
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
final ValidateObjectsResponse response = validateObject(organizationType);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element OriginalObjects - Specifies a collection of RegistryObject
|
||||
* instances. A server MUST validate all objects that are contained in this
|
||||
* element. This element is typically used when a server initiates the
|
||||
* validateObjects protocol during the processing of a submitObjects or
|
||||
* updateObjects protocol request or when it is delegating a client
|
||||
* initiated validateObjects protocol request to a Validator plugin.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void invalidLocalStaticReferenceReturnsUnresolvedReferenceException()
|
||||
throws MsgRegistryException {
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
final ValidateObjectsResponse response = validateObject(organizationType);
|
||||
final List<RegistryExceptionType> exceptions = response.getException();
|
||||
|
||||
assertThat(exceptions, is(not(empty())));
|
||||
assertThat(exceptions.iterator().next(),
|
||||
is(instanceOf(UnresolvedReferenceExceptionType.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element OriginalObjects - Specifies a collection of RegistryObject
|
||||
* instances. A server MUST validate all objects that are contained in this
|
||||
* element. This element is typically used when a server initiates the
|
||||
* validateObjects protocol during the processing of a submitObjects or
|
||||
* updateObjects protocol request or when it is delegating a client
|
||||
* initiated validateObjects protocol request to a Validator plugin.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void validLocalStaticReferenceDoesNotReturnExceptions()
|
||||
throws MsgRegistryException {
|
||||
addReferencedObjectToRegistry();
|
||||
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
final ValidateObjectsResponse response = validateObject(organizationType);
|
||||
|
||||
assertThat(response.getException(), is(empty()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element Query - Specifies a query to be invoked. A server MUST validate
|
||||
* all objects that match the specified query. This element is typically
|
||||
* used when a client initiates the validateObjects protocol.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void invalidLocalStaticReferenceViaObjectQueryReturnsUnresolvedReferenceException()
|
||||
throws MsgRegistryException {
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
submitRegistryObjectToRegistry(organizationType);
|
||||
|
||||
final ValidateObjectsResponse validateResponse = validateViaQuery(organizationType);
|
||||
final List<RegistryExceptionType> exceptions = validateResponse
|
||||
.getException();
|
||||
|
||||
assertThat(exceptions, is(not(empty())));
|
||||
assertThat(exceptions.iterator().next(),
|
||||
is(instanceOf(UnresolvedReferenceExceptionType.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element Query - Specifies a query to be invoked. A server MUST validate
|
||||
* all objects that match the specified query. This element is typically
|
||||
* used when a client initiates the validateObjects protocol.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void validLocalStaticReferenceViaObjectQueryDoesNotReturnExceptions()
|
||||
throws MsgRegistryException {
|
||||
addReferencedObjectToRegistry();
|
||||
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
submitRegistryObjectToRegistry(organizationType);
|
||||
|
||||
final ValidateObjectsResponse validateResponse = validateViaQuery(organizationType);
|
||||
|
||||
assertThat(validateResponse.getException(), is(empty()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element Query - Specifies a query to be invoked. A server MUST validate
|
||||
* all objects that match the specified query. This element is typically
|
||||
* used when a client initiates the validateObjects protocol.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void invalidLocalStaticReferenceViaObjectQueryReturnsPartialSuccessStatus()
|
||||
throws MsgRegistryException {
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
submitRegistryObjectToRegistry(organizationType);
|
||||
|
||||
final ValidateObjectsResponse validateResponse = validateViaQuery(organizationType);
|
||||
|
||||
assertThat(validateResponse.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.PARTIAL_SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Element Query - Specifies a query to be invoked. A server MUST validate
|
||||
* all objects that match the specified query. This element is typically
|
||||
* used when a client initiates the validateObjects protocol.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void validLocalStaticReferenceViaObjectQueryReturnsSuccessStatus()
|
||||
throws MsgRegistryException {
|
||||
addReferencedObjectToRegistry();
|
||||
|
||||
final OrganizationType organizationType = organizationWithLocalStaticReference();
|
||||
|
||||
submitRegistryObjectToRegistry(organizationType);
|
||||
|
||||
final ValidateObjectsResponse validateResponse = validateViaQuery(organizationType);
|
||||
|
||||
assertThat(validateResponse.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
// TODO: Add tests for remote and dynamic references
|
||||
|
||||
/**
|
||||
* Adds the referenced object to the registry.
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
private void addReferencedObjectToRegistry() throws MsgRegistryException {
|
||||
final RegistryObjectType registryObjectType = new RegistryObjectType(
|
||||
LOCAL_STATIC_REFERENCE, LOCAL_STATIC_REFERENCE);
|
||||
submitRegistryObjectToRegistry(registryObjectType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@link OrganizationType} instance with a local static
|
||||
* reference.
|
||||
*
|
||||
* @return the {@link OrganizationType}
|
||||
*/
|
||||
private OrganizationType organizationWithLocalStaticReference() {
|
||||
final OrganizationType organizationType = OrganizationTypeFixture.INSTANCE
|
||||
.get();
|
||||
// Local static reference as taken from ebXML 4.0 ebRIM specification
|
||||
// section 2.9.3.3
|
||||
organizationType.setPrimaryContact(LOCAL_STATIC_REFERENCE);
|
||||
return organizationType;
|
||||
}
|
||||
|
||||
private ValidateObjectsResponse validateViaQuery(
|
||||
final OrganizationType organizationType)
|
||||
throws MsgRegistryException {
|
||||
final QueryType queryType = createQueryForRegistryObjectByLid(
|
||||
organizationType.getLid()).getQuery();
|
||||
|
||||
final ValidateObjectsRequest validateRequest = new ValidateObjectsRequest();
|
||||
validateRequest.setQuery(queryType);
|
||||
|
||||
final ValidateObjectsResponse validateResponse = validator
|
||||
.validateObjects(validateRequest);
|
||||
return validateResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the object to the validation service.
|
||||
*
|
||||
* @param registryObject
|
||||
* the registry object
|
||||
*
|
||||
* @return the validation response
|
||||
* @throws MsgRegistryException
|
||||
* on error
|
||||
*/
|
||||
private ValidateObjectsResponse validateObject(
|
||||
RegistryObjectType registryObject) throws MsgRegistryException {
|
||||
ValidateObjectsRequest request = new ValidateObjectsRequest();
|
||||
request.setOriginalObjects(new RegistryObjectListType(Arrays
|
||||
.asList(registryObject)));
|
||||
|
||||
return validator.serverValidateObjects(request,
|
||||
EbxmlObjectUtil.spiObjectFactory
|
||||
.createValidateObjectsResponse());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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 OrganizationTypeFixture extends AbstractFixture<OrganizationType> {
|
||||
|
||||
public static final OrganizationTypeFixture INSTANCE = new 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue