Issue #1693 Modified Submit objects to conform to 4.0 spec. Added remote object references and some cleanup
Change-Id: I0f4eafb3fa68f2d1eeade4f047c95d714502cf56 Former-commit-id: 2aa7bdc1a8a942eaa0589527e8987b6fc518479f
This commit is contained in:
parent
a6cccde03f
commit
5bd0d92363
48 changed files with 906 additions and 394 deletions
|
@ -2,6 +2,6 @@
|
|||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry exported="true" kind="lib" path="guava-11.0.2.jar" />
|
||||
<classpathentry exported="true" kind="lib" path="guava-11.0.2.jar" sourcepath="guava-11.0.2-sources.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
BIN
cots/com.google.guava/guava-11.0.2-sources.jar
Normal file
BIN
cots/com.google.guava/guava-11.0.2-sources.jar
Normal file
Binary file not shown.
|
@ -19,9 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.registry.services;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
|
@ -31,6 +34,7 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
|||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.io.Resources;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryAvailability;
|
||||
import com.raytheon.uf.common.registry.services.rest.IRegistryAvailableRestService;
|
||||
import com.raytheon.uf.common.registry.services.rest.IRegistryDataAccessService;
|
||||
|
@ -52,6 +56,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 5/21/2013 2022 bphillip Initial implementation
|
||||
* 7/29/2013 2191 bphillip Implemented registry data access service
|
||||
* 8/1/2013 1693 bphillip Modified getregistry objects method to correctly handle response
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -135,11 +140,19 @@ public class RegistryRESTServices {
|
|||
* @throws JAXBException
|
||||
* If errors occur while serializing the object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends RegistryObjectType> T getRegistryObject(
|
||||
Class<T> expectedType, String baseURL, String objectId)
|
||||
throws JAXBException, RegistryServiceException {
|
||||
return SerializationUtil.unmarshalFromXml(expectedType,
|
||||
getRegistryObjectService(baseURL).getRegistryObject(objectId));
|
||||
String objStr = getRegistryObjectService(baseURL).getRegistryObject(
|
||||
objectId);
|
||||
try {
|
||||
return SerializationUtil.unmarshalFromXml(expectedType, objStr);
|
||||
} catch (ClassCastException e) {
|
||||
JAXBElement<RegistryObjectType> obj = (JAXBElement<RegistryObjectType>) SerializationUtil
|
||||
.getJaxbManager().unmarshalFromXml(objStr);
|
||||
return (T) obj.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,4 +240,31 @@ public class RegistryRESTServices {
|
|||
"Error getting Registry Availability Rest Service", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesses a rest service at the provided URL. This method is primarily
|
||||
* used for resolving remote object references which use a REST service
|
||||
*
|
||||
* @param url
|
||||
* The URL of the rest service
|
||||
* @return
|
||||
*/
|
||||
public static Object accessXMLRestService(String url) {
|
||||
String response = null;
|
||||
try {
|
||||
response = Resources
|
||||
.toString(new URL(url), Charset.forName("UTF8"));
|
||||
} catch (Exception e) {
|
||||
throw new RegistryServiceException(
|
||||
"Error accessing REST service at URL: [" + url + "]", e);
|
||||
}
|
||||
try {
|
||||
return SerializationUtil.getJaxbManager()
|
||||
.unmarshalFromXml(response);
|
||||
} catch (JAXBException e) {
|
||||
throw new RegistryServiceException(
|
||||
"Error unmarshalling xml response from REST Service at URL: ["
|
||||
+ url + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ Require-Bundle: javax.persistence;bundle-version="1.0.0",
|
|||
org.apache.commons.cxf;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.status;bundle-version="1.12.1174"
|
||||
Export-Package: com.raytheon.uf.common.registry.schemas.ebxml.util,
|
||||
com.raytheon.uf.common.registry.schemas.ebxml.util.annotations,
|
||||
oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4,
|
||||
oasis.names.tc.ebxml.regrep.xsd.lcm.v4,
|
||||
oasis.names.tc.ebxml.regrep.xsd.query.v4,
|
||||
|
|
|
@ -61,3 +61,4 @@ oasis.names.tc.ebxml.regrep.xsd.rim.v4.VocabularyTermType
|
|||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.VocabularyTermValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.WorkflowActionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.XMLQueryExpressionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.DynamicObjectRefType
|
|
@ -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.common.registry.schemas.ebxml.util.annotations;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* Annotation used on registry objects to specify fields that are registry
|
||||
* object references
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 8/1/2013 1693 bphillip Initial implementation
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
public @interface RegistryObjectReference {
|
||||
}
|
|
@ -40,6 +40,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -100,6 +101,7 @@ public class ActionType extends ExtensibleObjectType implements Serializable {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String eventType;
|
||||
|
||||
public Integer getKey() {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.hibernate.annotations.Cache;
|
|||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -68,21 +69,24 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "AssociationType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "Association")
|
||||
public class AssociationType extends RegistryObjectType {
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@Index(name = "assoociation_type_idx")
|
||||
@RegistryObjectReference
|
||||
protected String type;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String sourceObject;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String targetObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.hibernate.annotations.Cache;
|
|||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -66,12 +67,13 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlRootElement
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "ClassificationNode")
|
||||
public class ClassificationNodeType extends TaxonomyElementType {
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String parent;
|
||||
|
||||
@XmlAttribute
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -74,6 +75,7 @@ public class ClassificationSchemeType extends TaxonomyElementType {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String nodeType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -67,20 +68,23 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "ClassificationType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "Classification")
|
||||
public class ClassificationType extends RegistryObjectType {
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String classificationScheme;
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String classifiedObject;
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String classificationNode;
|
||||
|
||||
@XmlAttribute
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.hibernate.annotations.Cache;
|
|||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -95,6 +96,7 @@ public class DeliveryInfoType extends ExtensibleObjectType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String notificationOption;
|
||||
|
||||
public Integer getKey() {
|
||||
|
|
|
@ -20,12 +20,20 @@
|
|||
|
||||
package oasis.names.tc.ebxml.regrep.xsd.rim.v4;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.CascadeType;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -60,12 +68,21 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "DynamicObjectRefType", propOrder = { "query" })
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "DynamicObjectRef")
|
||||
public class DynamicObjectRefType extends ObjectRefType {
|
||||
|
||||
@XmlElement(name = "Query", required = true)
|
||||
@DynamicSerializeElement
|
||||
@OneToOne
|
||||
@Cascade(value = { CascadeType.SAVE_UPDATE })
|
||||
protected QueryType query;
|
||||
|
||||
public DynamicObjectRefType() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the query property.
|
||||
*
|
||||
|
|
|
@ -37,6 +37,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -86,6 +87,7 @@ public class EmailAddressType extends ExtensibleObjectType implements
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String type;
|
||||
|
||||
public Integer getKey() {
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -66,16 +67,18 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "ExternalIdentifierType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "ExternalIdentifier")
|
||||
public class ExternalIdentifierType extends RegistryObjectType {
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String registryObject;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String identificationScheme;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
|
|
|
@ -34,6 +34,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -69,7 +70,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "ExternalLinkType", propOrder = { "externalRef" })
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "ExternalLink")
|
||||
public class ExternalLinkType extends RegistryObjectType {
|
||||
|
||||
|
@ -80,6 +81,7 @@ public class ExternalLinkType extends RegistryObjectType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String registryObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,6 +38,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -83,6 +84,7 @@ public class NotificationType extends RegistryObjectType {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String subscription;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,8 @@ package oasis.names.tc.ebxml.regrep.xsd.rim.v4;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
@ -68,6 +70,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
@Table(schema = "ebxml", name = "ObjectRef")
|
||||
public class ObjectRefType extends ExtensibleObjectType implements
|
||||
IPersistableDataObject<String> {
|
||||
|
|
|
@ -38,6 +38,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -83,6 +84,7 @@ public class OrganizationType extends PartyType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String primaryContact;
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -107,6 +108,7 @@ public class PostalAddressType extends ExtensibleObjectType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String type;
|
||||
|
||||
public Integer getKey() {
|
||||
|
|
|
@ -38,6 +38,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -86,6 +87,7 @@ public class QueryExpressionType extends ExtensibleObjectType {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String queryLanguage;
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -81,6 +82,7 @@ public class QueryType extends ExtensibleObjectType {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String queryDefinition;
|
||||
|
||||
public QueryType() {
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -118,7 +119,7 @@ public class RegistryObjectType extends IdentifiableType {
|
|||
@XmlElement(name = "VersionInfo")
|
||||
@DynamicSerializeElement
|
||||
@Embedded
|
||||
protected VersionInfoType versionInfo;
|
||||
protected VersionInfoType versionInfo = new VersionInfoType();
|
||||
|
||||
@XmlElement(name = "Classification")
|
||||
@DynamicSerializeElement
|
||||
|
@ -149,6 +150,7 @@ public class RegistryObjectType extends IdentifiableType {
|
|||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@Index(name = "RegistryObjectType_objectType_idx")
|
||||
@RegistryObjectReference
|
||||
protected String objectType;
|
||||
|
||||
@XmlAttribute
|
||||
|
@ -157,6 +159,7 @@ public class RegistryObjectType extends IdentifiableType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String status;
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,6 +36,7 @@ import javax.xml.datatype.Duration;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -78,7 +79,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "RegistryType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "Registry")
|
||||
public class RegistryType extends RegistryObjectType {
|
||||
|
||||
|
@ -89,6 +90,7 @@ public class RegistryType extends RegistryObjectType {
|
|||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String operator;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -65,12 +66,13 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "RoleType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "Role")
|
||||
public class RoleType extends RegistryObjectType {
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String type;
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -63,12 +64,13 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "ServiceBindingType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "ServiceBinding")
|
||||
public class ServiceBindingType extends RegistryObjectType {
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String serviceInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -66,7 +67,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlType(name = "ServiceEndpointType")
|
||||
@DynamicSerialize
|
||||
@Entity
|
||||
@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@Table(schema = "ebxml", name = "ServiceEndpoint")
|
||||
public class ServiceEndpointType extends RegistryObjectType {
|
||||
|
||||
|
@ -77,6 +78,7 @@ public class ServiceEndpointType extends RegistryObjectType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String serviceBinding;
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,6 +38,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -85,6 +86,7 @@ public class ServiceType extends RegistryObjectType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String serviceInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -97,6 +98,7 @@ public class TelephoneNumberType extends ExtensibleObjectType {
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@RegistryObjectReference
|
||||
protected String type;
|
||||
|
||||
public Integer getKey() {
|
||||
|
|
|
@ -73,6 +73,14 @@ public class VersionInfoType implements Serializable,
|
|||
@DynamicSerializeElement
|
||||
protected String userVersionName;
|
||||
|
||||
public VersionInfoType() {
|
||||
|
||||
}
|
||||
|
||||
public VersionInfoType(String versionName) {
|
||||
this.versionName = versionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the versionName property.
|
||||
*
|
||||
|
|
|
@ -105,6 +105,10 @@ public class RegistryResponseType extends ExtensibleObjectType {
|
|||
@DynamicSerializeElement
|
||||
protected String requestId;
|
||||
|
||||
public boolean isOk() {
|
||||
return status.equals(RegistryResponseStatus.SUCCESS);
|
||||
}
|
||||
|
||||
public List<RegistryObjectType> getRegistryObjects() {
|
||||
if (registryObjectList == null) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -43,9 +43,6 @@ import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
|
|||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.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.DeliveryInfoType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
||||
|
@ -68,7 +65,6 @@ import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes;
|
|||
import com.raytheon.uf.common.registry.constants.DeliveryMethodTypes;
|
||||
import com.raytheon.uf.common.registry.constants.Namespaces;
|
||||
import com.raytheon.uf.common.registry.constants.NotificationOptionTypes;
|
||||
import com.raytheon.uf.common.registry.constants.QueryReturnTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
|
||||
import com.raytheon.uf.common.registry.constants.StatusTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
|
@ -83,7 +79,6 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
import com.raytheon.uf.edex.datadelivery.registry.availability.FederatedRegistryMonitor;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
||||
|
||||
/**
|
||||
|
@ -99,6 +94,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* 4/24/2013 1675 bphillip Initial implementation
|
||||
* 6/4/2013 1707 bphillip Changed to use new NotificationServer objects
|
||||
* 7/29/2013 2191 bphillip Implemented registry sync for registries that have been down for an extended period of time
|
||||
* 8/1/2013 1693 bphillip Switch to use rest service instead of query manager for federation synchronization
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -285,8 +281,11 @@ public class RegistryReplicationManager {
|
|||
if (remoteIds.contains(localId)) {
|
||||
RegistryObjectType objectToSubmit;
|
||||
try {
|
||||
objectToSubmit = getRemoteObject(remoteRegistryUrl,
|
||||
localId);
|
||||
objectToSubmit = RegistryRESTServices
|
||||
.getRegistryObject(RegistryObjectType.class,
|
||||
remoteRegistryUrl,
|
||||
localId.replaceAll(":", "%3A")
|
||||
.replaceAll("\\/", "%2F"));
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Error getting remote object: "
|
||||
+ localId, e);
|
||||
|
@ -313,8 +312,11 @@ public class RegistryReplicationManager {
|
|||
if (!localIds.contains(remoteId)) {
|
||||
RegistryObjectType objectToSubmit;
|
||||
try {
|
||||
objectToSubmit = getRemoteObject(remoteRegistryUrl,
|
||||
remoteId);
|
||||
objectToSubmit = RegistryRESTServices
|
||||
.getRegistryObject(RegistryObjectType.class,
|
||||
remoteRegistryUrl,
|
||||
remoteId.replaceAll(":", "%3A")
|
||||
.replaceAll("\\/", "%2F"));
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Error getting remote object: "
|
||||
+ remoteId, e);
|
||||
|
@ -346,34 +348,6 @@ public class RegistryReplicationManager {
|
|||
+ remoteRegistryUrl + "] completed successfully!");
|
||||
}
|
||||
|
||||
private RegistryObjectType getRemoteObject(String remoteRegistryUrl,
|
||||
String objectId) throws Exception {
|
||||
final QueryType queryType = new QueryType();
|
||||
queryType.setQueryDefinition(CanonicalQueryTypes.GET_OBJECT_BY_ID);
|
||||
Set<SlotType> slots = new HashSet<SlotType>();
|
||||
final SlotType slot = new SlotType();
|
||||
slot.setName(QueryConstants.ID);
|
||||
final StringValueType slotValue = new StringValueType();
|
||||
slotValue.setStringValue(objectId);
|
||||
slot.setSlotValue(slotValue);
|
||||
slots.add(slot);
|
||||
queryType.setSlot(slots);
|
||||
|
||||
QueryRequest queryRequest = new QueryRequest();
|
||||
queryRequest.setResponseOption(new ResponseOptionType(
|
||||
QueryReturnTypes.REGISTRY_OBJECT, true));
|
||||
queryRequest.setFederated(false);
|
||||
queryRequest.setQuery(queryType);
|
||||
QueryResponse response = RegistrySOAPServices.getQueryServiceForHost(
|
||||
remoteRegistryUrl).executeQuery(queryRequest);
|
||||
if (!CollectionUtil.isNullOrEmpty(response.getRegistryObjects())) {
|
||||
return response.getRegistryObjects().get(0);
|
||||
} else {
|
||||
throw new EbxmlRegistryException("Object " + objectId
|
||||
+ " not found on remote server!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method only used during the Spring container to inject the object
|
||||
* types to subscribe to for registry replication
|
||||
|
|
|
@ -32,7 +32,8 @@ Require-Bundle: com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1.
|
|||
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
|
||||
uk.ltd.getahead;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datadelivery.request;bundle-version="1.0.0",
|
||||
javax.mail;bundle-version="1.0.0"
|
||||
javax.mail;bundle-version="1.0.0",
|
||||
org.apache.commons.validator;bundle-version="1.2.0"
|
||||
Export-Package: com.raytheon.uf.edex.registry.ebxml.acp,
|
||||
com.raytheon.uf.edex.registry.ebxml.dao,
|
||||
com.raytheon.uf.edex.registry.ebxml.exception,
|
||||
|
|
|
@ -39,5 +39,11 @@
|
|||
<constructor-arg ref="AuditableEventTypeDao" />
|
||||
<constructor-arg ref="metadataTxTemplate"/>
|
||||
</bean>
|
||||
|
||||
<bean id="objectReferenceResolver" class="com.raytheon.uf.edex.registry.ebxml.services.lifecycle.ObjectReferenceResolver">
|
||||
<property name="registryObjectDao" ref="registryObjectDao"/>
|
||||
<property name="dynamicRefDao" ref="dynamicObjectRefDao"/>
|
||||
<property name="queryManager" ref="queryServiceImpl"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
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-3.1.xsd">
|
||||
|
||||
<bean id="dynamicObjectRefDao" class="com.raytheon.uf.edex.registry.ebxml.dao.DynamicObjectRefDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="slotTypeDao" class="com.raytheon.uf.edex.registry.ebxml.dao.SlotTypeDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
@ -9,6 +13,7 @@
|
|||
<bean id="registryObjectDao"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="slotDao" ref="slotTypeDao"/>
|
||||
</bean>
|
||||
|
||||
<bean id="registryDao" class="com.raytheon.uf.edex.registry.ebxml.dao.RegistryDao">
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<property name="registryObjectDao" ref="registryObjectDao" />
|
||||
<property name="auditableEventService" ref="AuditableEventService" />
|
||||
<property name="cataloger" ref="catalogerServiceImpl" />
|
||||
<property name="referenceResolver" ref="objectReferenceResolver"/>
|
||||
</bean>
|
||||
|
||||
<!-- VALIDATOR -->
|
||||
|
|
|
@ -24,26 +24,16 @@ import java.math.BigInteger;
|
|||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ActionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AuditableEventType;
|
||||
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.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.VersionInfoType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryRequestType;
|
||||
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.ActionTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
|
||||
import com.raytheon.uf.common.registry.constants.StatusTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
||||
|
@ -62,6 +52,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* Apr 17, 2013 1914 djohnson Use strategy for subscription processing.
|
||||
* May 02, 2013 1910 djohnson Broke out registry subscription notification to a service class.
|
||||
* 7/29/2013 2191 bphillip Changed method to get expired events
|
||||
* 8/1/2013 1693 bphillip Moved creation of auditable events to the auditable event service class
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -202,98 +193,6 @@ public class AuditableEventTypeDao extends
|
|||
return auditableEvent.getSlotValue(subscriptionId + deliveryAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an auditable event from a registry request and object references
|
||||
*
|
||||
* @param request
|
||||
* The request that generated the events
|
||||
* @param actionMap
|
||||
* The actions that occurred
|
||||
* @param currentTime
|
||||
* The time the event occurred @ * If errors occur while creating
|
||||
* the event
|
||||
* @throws EbxmlRegistryException
|
||||
*/
|
||||
public void createAuditableEventsFromRefs(RegistryRequestType request,
|
||||
Map<String, List<ObjectRefType>> actionMap, long currentTime)
|
||||
throws EbxmlRegistryException {
|
||||
for (String actionType : actionMap.keySet()) {
|
||||
for (ObjectRefType obj : actionMap.get(actionType)) {
|
||||
AuditableEventType event = createEvent(request, currentTime);
|
||||
ActionType action = new ActionType();
|
||||
action.setEventType(actionType);
|
||||
ObjectRefListType refList = new ObjectRefListType();
|
||||
refList.getObjectRef().add(obj);
|
||||
action.setAffectedObjectRefs(refList);
|
||||
event.getAction().add(action);
|
||||
create(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an auditable event from a registry request and registry objects
|
||||
*
|
||||
* @param request
|
||||
* The request that generated the events
|
||||
* @param actionMap
|
||||
* The actions that occurred
|
||||
* @param currentTime
|
||||
* The time the event occurred @ * If errors occur while creating
|
||||
* the event
|
||||
* @throws EbxmlRegistryException
|
||||
*/
|
||||
public void createAuditableEventsFromObjects(RegistryRequestType request,
|
||||
Map<String, List<RegistryObjectType>> actionMap, long currentTime)
|
||||
throws EbxmlRegistryException {
|
||||
for (String actionType : actionMap.keySet()) {
|
||||
for (RegistryObjectType obj : actionMap.get(actionType)) {
|
||||
AuditableEventType event = createEvent(request, currentTime);
|
||||
ActionType action = new ActionType();
|
||||
action.setEventType(actionType);
|
||||
RegistryObjectListType regObjList = new RegistryObjectListType();
|
||||
regObjList.getRegistryObject().add(obj);
|
||||
action.setAffectedObjects(regObjList);
|
||||
event.getAction().add(action);
|
||||
create(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and Auditable event from a request
|
||||
*
|
||||
* @param request
|
||||
* The request that generated the event
|
||||
* @param currentTime
|
||||
* The time of the event
|
||||
* @return The AuditableEventType object
|
||||
* @throws EbxmlRegistryException
|
||||
* @ * If errors occur while creating the event
|
||||
*/
|
||||
private AuditableEventType createEvent(RegistryRequestType request,
|
||||
long currentTime) throws EbxmlRegistryException {
|
||||
AuditableEventType event = EbxmlObjectUtil.rimObjectFactory
|
||||
.createAuditableEventType();
|
||||
event.setId(EbxmlObjectUtil.getUUID());
|
||||
event.setLid(EbxmlObjectUtil.getUUID());
|
||||
event.setOwner(RegistryUtil.DEFAULT_OWNER);
|
||||
event.setObjectType(RegistryObjectTypes.AUDITABLE_EVENT);
|
||||
event.setRequestId(request.getId());
|
||||
event.setTimestamp(EbxmlObjectUtil
|
||||
.getTimeAsXMLGregorianCalendar(currentTime));
|
||||
event.setUser("Client");
|
||||
event.setStatus(StatusTypes.APPROVED);
|
||||
event.setVersionInfo(new VersionInfoType());
|
||||
String notificationFrom = request
|
||||
.getSlotValue(EbxmlObjectUtil.HOME_SLOT_NAME);
|
||||
if (notificationFrom != null) {
|
||||
event.addSlot(EbxmlObjectUtil.HOME_SLOT_NAME, notificationFrom);
|
||||
}
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<AuditableEventType> getEntityClass() {
|
||||
return AuditableEventType.class;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DynamicObjectRefType;
|
||||
|
||||
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
||||
|
||||
public class DynamicObjectRefDao extends
|
||||
SessionManagedDao<String, DynamicObjectRefType> {
|
||||
|
||||
@Override
|
||||
protected Class<DynamicObjectRefType> getEntityClass() {
|
||||
return DynamicObjectRefType.class;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ package com.raytheon.uf.edex.registry.ebxml.dao;
|
|||
import java.util.List;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
|
||||
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
|
||||
|
@ -38,6 +39,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* 4/9/2013 1802 bphillip Removed exception catching
|
||||
* 6/4/2013 2022 bphillip Added delete objects of type method
|
||||
* 7/29/2013 2191 bphillip Added new methods to support registry synchronization
|
||||
* 8/1/2013 1693 bphillip Added methods to facilitate implementation of the lifecyclemanager according to the 4.0 spec
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,12 +49,98 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
public class RegistryObjectDao extends
|
||||
RegistryObjectTypeDao<RegistryObjectType> {
|
||||
|
||||
/** Data access object for accessing slots */
|
||||
private SlotTypeDao slotDao;
|
||||
|
||||
/** Delete object type parameterized statement */
|
||||
private static final String GET_IDS_BY_OBJECT_TYPE = "SELECT regObj.id FROM RegistryObjectType regObj WHERE regObj.objectType=:objectType";
|
||||
|
||||
/** Query to determine if an object id exists in the registry */
|
||||
private static final String ID_EXISTS_QUERY = "select count(obj.id) from RegistryObjectType obj where id=:id";
|
||||
|
||||
/** Query to determine if an object lid exists in the registry */
|
||||
private static final String LID_EXISTS_QUERY = "select count(obj.lid) from RegistryObjectType obj where lid=:lid";
|
||||
|
||||
/** Query to get all sub versions beneath the given version */
|
||||
private static String GET_SUB_VERSION_QUERY = "select obj.versionInfo.versionName from RegistryObjectType obj where obj.lid=:lid and obj.versionInfo.versionName like :version";
|
||||
|
||||
/**
|
||||
* Creates a new RegistryObjectDao
|
||||
*/
|
||||
public RegistryObjectDao() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the state of the new object onto the persistent object
|
||||
*
|
||||
* @param newObject
|
||||
* The object to get the state from
|
||||
* @param existingObject
|
||||
* The existing persistent object to copy the state on to
|
||||
*/
|
||||
public void merge(RegistryObjectType newObject,
|
||||
RegistryObjectType existingObject) {
|
||||
// Delete the existing slot to prevent orphans
|
||||
for (SlotType slot : existingObject.getSlot()) {
|
||||
slotDao.delete(slot);
|
||||
}
|
||||
newObject.setId(existingObject.getId());
|
||||
template.merge(newObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next version of the given object.
|
||||
*
|
||||
* @param objectToVersion
|
||||
* The object to get the next version number for
|
||||
* @return The next version number
|
||||
*/
|
||||
public String getNextVersion(RegistryObjectType objectToVersion) {
|
||||
String lid = objectToVersion.getLid();
|
||||
String version = objectToVersion.getVersionInfo().getVersionName();
|
||||
|
||||
// Gets all the subversion numbers of this object
|
||||
List<String> queryResult = this.executeHQLQuery(GET_SUB_VERSION_QUERY,
|
||||
"lid", lid, "version", version + ".%");
|
||||
int maxSubVersion = 0;
|
||||
|
||||
// Get the maximum of the retrieved versions
|
||||
for (String ver : queryResult) {
|
||||
if (ver.matches(version + "\\.\\d{1,10}")) {
|
||||
String[] tokens = ver.split("\\.");
|
||||
int parsedVersion = Integer.parseInt(tokens[tokens.length - 1]);
|
||||
if (parsedVersion > maxSubVersion) {
|
||||
maxSubVersion = parsedVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Increment the max version and append to current version
|
||||
return version + "." + String.valueOf(maxSubVersion + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given object id exists in the registry
|
||||
*
|
||||
* @param id
|
||||
* The id to check
|
||||
* @return True if the id exists, else false
|
||||
*/
|
||||
public boolean idExists(String id) {
|
||||
return ((Long) this.executeHQLQuery(ID_EXISTS_QUERY, "id", id).get(0)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given object lid exists in the registry
|
||||
*
|
||||
* @param lid
|
||||
* The lid to check
|
||||
* @return Treu if the lid exists, else false
|
||||
*/
|
||||
public boolean lidExists(String lid) {
|
||||
return ((Long) this.executeHQLQuery(LID_EXISTS_QUERY, "lid", lid)
|
||||
.get(0)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object ids of objects of the given object type
|
||||
*
|
||||
|
@ -93,4 +181,8 @@ public class RegistryObjectDao extends
|
|||
return RegistryObjectType.class;
|
||||
}
|
||||
|
||||
public void setSlotDao(SlotTypeDao slotDao) {
|
||||
this.slotDao = slotDao;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 19, 2012 184 bphillip Initial creation
|
||||
* 4/9/2013 1802 bphillip Removed exception catching. Added merge method.
|
||||
* 8/1/2013 1693 bphillip Moved the merge method down to RegistryObjectDao
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -63,20 +64,6 @@ public abstract class RegistryObjectTypeDao<ENTITY extends RegistryObjectType>
|
|||
public RegistryObjectTypeDao() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the state of the new object onto the persistent object
|
||||
*
|
||||
* @param newObject
|
||||
* The object to get the state from
|
||||
* @param existingObject
|
||||
* The existing persistent object to copy the state on to
|
||||
*/
|
||||
public void merge(RegistryObjectType newObject,
|
||||
RegistryObjectType existingObject) {
|
||||
newObject.setId(existingObject.getId());
|
||||
template.merge(newObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries for all lids of registry objects matching the pattern of the
|
||||
* given id. A query using 'like' will be executed.
|
||||
|
|
|
@ -20,18 +20,27 @@
|
|||
package com.raytheon.uf.edex.registry.ebxml.services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.RemoveObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ActionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AuditableEventType;
|
||||
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.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.VersionInfoType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryRequestType;
|
||||
|
||||
import com.raytheon.uf.common.registry.constants.ActionTypes;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
|
||||
import com.raytheon.uf.common.registry.constants.StatusTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.AuditableEventTypeDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
||||
|
||||
/**
|
||||
* Service to interact with {@link AuditableEventType} objects.
|
||||
|
@ -43,6 +52,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 02, 2013 1910 djohnson Extracted subscription notification from the dao.
|
||||
* 8/1/2013 1692 bphillip Refactored auditable event creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,13 +62,24 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
|
||||
public class AuditableEventService {
|
||||
|
||||
/** The logger */
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AuditableEventService.class);
|
||||
|
||||
/** Data access object for accessing auditable events */
|
||||
private final AuditableEventTypeDao auditDao;
|
||||
|
||||
/** The subscription manager */
|
||||
private final IRegistrySubscriptionManager subscriptionManager;
|
||||
|
||||
/**
|
||||
* Creates a new AuditableEventService
|
||||
*
|
||||
* @param auditDao
|
||||
* Auditable event dao
|
||||
* @param subscriptionManager
|
||||
* The subscription manager
|
||||
*/
|
||||
public AuditableEventService(AuditableEventTypeDao auditDao,
|
||||
IRegistrySubscriptionManager subscriptionManager) {
|
||||
this.auditDao = auditDao;
|
||||
|
@ -66,45 +87,159 @@ public class AuditableEventService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an auditable event from a registry request and registry objects
|
||||
* Creates auditable events from the given objects
|
||||
*
|
||||
* @param request
|
||||
* The request that generated the events
|
||||
* @param actionMap
|
||||
* The actions that occurred
|
||||
* @param currentTime
|
||||
* The time the event occurred @ the event
|
||||
* The request object which was process that generated the events
|
||||
* @param objectsCreated
|
||||
* The objects created during the processing of the request
|
||||
* @param objectsUpdated
|
||||
* The objects updated during the processing of the request
|
||||
* @param objectsVersioned
|
||||
* The objects versioned during the processing of the request
|
||||
* @param objectsRemoved
|
||||
* The objects removed during the processing of the request
|
||||
* @throws EbxmlRegistryException
|
||||
* If errors occur while creating
|
||||
* If errors occur creating the event
|
||||
*/
|
||||
public void createAuditableEventsFromObjects(RegistryRequestType request,
|
||||
Map<String, List<RegistryObjectType>> actionMap, long currentTime)
|
||||
public void createAuditableEventFromObjects(RegistryRequestType request,
|
||||
List<RegistryObjectType> objectsCreated,
|
||||
List<RegistryObjectType> objectsUpdated,
|
||||
List<RegistryObjectType> objectsVersioned,
|
||||
List<RegistryObjectType> objectsRemoved)
|
||||
throws EbxmlRegistryException {
|
||||
auditDao.createAuditableEventsFromObjects(request, actionMap,
|
||||
currentTime);
|
||||
AuditableEventType event = createEvent(request,
|
||||
TimeUtil.currentTimeMillis());
|
||||
addRegistryObjectActionToEvent(event, ActionTypes.create,
|
||||
objectsCreated);
|
||||
addRegistryObjectActionToEvent(event, ActionTypes.update,
|
||||
objectsUpdated);
|
||||
addRegistryObjectActionToEvent(event, ActionTypes.version,
|
||||
objectsVersioned);
|
||||
addRegistryObjectActionToEvent(event, ActionTypes.delete,
|
||||
objectsRemoved);
|
||||
auditDao.create(event);
|
||||
notifySubscriptionManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an auditable event from a registry request and object references
|
||||
* Adds an action to the event object
|
||||
*
|
||||
* @param event
|
||||
* The event to add the action to
|
||||
* @param eventType
|
||||
* The type of event
|
||||
* @param objs
|
||||
* The objects affected by the event
|
||||
*/
|
||||
private void addRegistryObjectActionToEvent(AuditableEventType event,
|
||||
String eventType, List<RegistryObjectType> objs) {
|
||||
if (!CollectionUtil.isNullOrEmpty(objs)) {
|
||||
ActionType action = new ActionType();
|
||||
action.setEventType(eventType);
|
||||
RegistryObjectListType objList = new RegistryObjectListType();
|
||||
objList.getRegistryObject().addAll(objs);
|
||||
action.setAffectedObjects(objList);
|
||||
event.getAction().add(action);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an auditable event from the given object references
|
||||
*
|
||||
* @param request
|
||||
* The request that generated the events
|
||||
* @param actionMap
|
||||
* The actions that occurred
|
||||
* @param currentTime
|
||||
* The time the event occurred @ the event
|
||||
* The request that is generating the event
|
||||
* @param objectsCreated
|
||||
* References to the objects created during the processing of the
|
||||
* request
|
||||
* @param objectsUpdated
|
||||
* References to the objects updated during the processing of the
|
||||
* request
|
||||
* @param objectsVersioned
|
||||
* References to the object versioned during the processing of
|
||||
* the request
|
||||
* @param objectsRemoved
|
||||
* References to the objects removed during the processing of the
|
||||
* request
|
||||
* @throws EbxmlRegistryException
|
||||
* If errors occur while creating
|
||||
* If error occur while creating the event
|
||||
*/
|
||||
public void createAuditableEventsFromRefs(RemoveObjectsRequest request,
|
||||
Map<String, List<ObjectRefType>> actionMap, long currentTimeMillis)
|
||||
throws EbxmlRegistryException {
|
||||
auditDao.createAuditableEventsFromRefs(request, actionMap,
|
||||
currentTimeMillis);
|
||||
public void createAuditableEventFromRefs(RegistryRequestType request,
|
||||
List<ObjectRefType> objectsCreated,
|
||||
List<ObjectRefType> objectsUpdated,
|
||||
List<ObjectRefType> objectsVersioned,
|
||||
List<ObjectRefType> objectsRemoved) throws EbxmlRegistryException {
|
||||
AuditableEventType event = createEvent(request,
|
||||
TimeUtil.currentTimeMillis());
|
||||
addObjectRefActionToEvent(event, ActionTypes.create, objectsCreated);
|
||||
addObjectRefActionToEvent(event, ActionTypes.update, objectsUpdated);
|
||||
addObjectRefActionToEvent(event, ActionTypes.version, objectsVersioned);
|
||||
addObjectRefActionToEvent(event, ActionTypes.delete, objectsRemoved);
|
||||
auditDao.create(event);
|
||||
notifySubscriptionManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an action to the event
|
||||
*
|
||||
* @param event
|
||||
* The event to add the action to
|
||||
* @param eventType
|
||||
* The type of event
|
||||
* @param objs
|
||||
* The object references to add to the event
|
||||
*/
|
||||
private void addObjectRefActionToEvent(AuditableEventType event,
|
||||
String eventType, List<ObjectRefType> objs) {
|
||||
if (!CollectionUtil.isNullOrEmpty(objs)) {
|
||||
ActionType action = new ActionType();
|
||||
action.setEventType(eventType);
|
||||
ObjectRefListType objList = new ObjectRefListType();
|
||||
objList.getObjectRef().addAll(objs);
|
||||
action.setAffectedObjectRefs(objList);
|
||||
event.getAction().add(action);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and Auditable event from a request
|
||||
*
|
||||
* @param request
|
||||
* The request that generated the event
|
||||
* @param currentTime
|
||||
* The time of the event
|
||||
* @return The AuditableEventType object
|
||||
* @throws EbxmlRegistryException
|
||||
* @ * If errors occur while creating the event
|
||||
*/
|
||||
private AuditableEventType createEvent(RegistryRequestType request,
|
||||
long currentTime) throws EbxmlRegistryException {
|
||||
AuditableEventType event = EbxmlObjectUtil.rimObjectFactory
|
||||
.createAuditableEventType();
|
||||
String objectId = RegistryUtil.generateRegistryObjectId();
|
||||
event.setId(objectId);
|
||||
event.setLid(objectId);
|
||||
event.setOwner(RegistryUtil.DEFAULT_OWNER);
|
||||
event.setObjectType(RegistryObjectTypes.AUDITABLE_EVENT);
|
||||
event.setRequestId(request.getId());
|
||||
event.setTimestamp(EbxmlObjectUtil
|
||||
.getTimeAsXMLGregorianCalendar(currentTime));
|
||||
event.setUser("Client");
|
||||
event.setStatus(StatusTypes.APPROVED);
|
||||
event.setVersionInfo(new VersionInfoType());
|
||||
String notificationFrom = request
|
||||
.getSlotValue(EbxmlObjectUtil.HOME_SLOT_NAME);
|
||||
if (notificationFrom != null) {
|
||||
event.addSlot(EbxmlObjectUtil.HOME_SLOT_NAME, notificationFrom);
|
||||
}
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the subscription manager that events have occurred and they must
|
||||
* be propagated to the federation
|
||||
*/
|
||||
private void notifySubscriptionManager() {
|
||||
// Notify the subscription monitor that a new event has occurred
|
||||
try {
|
||||
|
|
|
@ -50,10 +50,7 @@ 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.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -103,6 +100,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* 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.
|
||||
* Jun 24, 2013 2106 djohnson Requires a transaction to already be open.
|
||||
* 8/1/2013 1693 bphillip Added check references and refactored submit objects to conform to EBXML 4.0 spec
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -120,6 +118,8 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
@Resource
|
||||
private WebServiceContext wsContext;
|
||||
|
||||
private ObjectReferenceResolver referenceResolver;
|
||||
|
||||
/** The query manager */
|
||||
private QueryManagerImpl queryManager;
|
||||
|
||||
|
@ -243,8 +243,8 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
try {
|
||||
Map<String, List<ObjectRefType>> actionMap = new HashMap<String, List<ObjectRefType>>();
|
||||
actionMap.put(ActionTypes.delete, objRefs);
|
||||
auditableEventService.createAuditableEventsFromRefs(request,
|
||||
actionMap, System.currentTimeMillis());
|
||||
auditableEventService.createAuditableEventFromRefs(request, null,
|
||||
null, null, objRefs);
|
||||
registryObjectDao.deleteByRefs(objRefs);
|
||||
|
||||
} catch (EbxmlRegistryException e) {
|
||||
|
@ -327,38 +327,8 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
if (checkReferences) {
|
||||
statusHandler
|
||||
.info("Client has selected to check object references before submitting objects.");
|
||||
ValidateObjectsRequest validateObjectsRequest = new ValidateObjectsRequest();
|
||||
validateObjectsRequest.setOriginalObjects(request
|
||||
.getRegistryObjectList());
|
||||
referenceResolver.checkReferences(objs);
|
||||
|
||||
// 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)
|
||||
|
@ -414,103 +384,89 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
private void processSubmit(SubmitObjectsRequest request,
|
||||
RegistryResponseType response) throws MsgRegistryException {
|
||||
|
||||
Map<String, RegistryObjectType> storedObjects = new HashMap<String, RegistryObjectType>();
|
||||
List<RegistryObjectType> objsCreated = new ArrayList<RegistryObjectType>();
|
||||
List<RegistryObjectType> objsVersioned = new ArrayList<RegistryObjectType>();
|
||||
List<RegistryObjectType> objsUpdated = new ArrayList<RegistryObjectType>();
|
||||
for (RegistryObjectType obj : request.getRegistryObjectList()
|
||||
.getRegistryObject()) {
|
||||
String objectId = obj.getId();
|
||||
statusHandler.info("Processing object [" + objectId + "]");
|
||||
if (objectId == null) {
|
||||
if (request.getMode().equals(Mode.CREATE_ONLY)) {
|
||||
statusHandler
|
||||
.info("Generating id for object specified with CREATE_ONLY Mode");
|
||||
objectId = EbxmlObjectUtil.getUUID();
|
||||
obj.setId(objectId);
|
||||
} else {
|
||||
final String message = "The id field MUST be specified by the client";
|
||||
final String pleaseSpecifyId = "Please specify an id for all registry objects submitted";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(message,
|
||||
InvalidRequestExceptionType.class, "",
|
||||
message, pleaseSpecifyId,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(
|
||||
registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
}
|
||||
}
|
||||
|
||||
final String objectLid = obj.getLid();
|
||||
statusHandler.debug("Processing object [" + objectId + "]");
|
||||
if (objectLid == null) {
|
||||
final String message = "The lid field MUST be specified by the client";
|
||||
final String pleaseSpecifyLid = "Please specify an lid for all registry objects submitted";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(message,
|
||||
InvalidRequestExceptionType.class, "", message,
|
||||
pleaseSpecifyLid, ErrorSeverity.ERROR, null,
|
||||
statusHandler);
|
||||
response.getException().add(registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
throw EbxmlExceptionUtil
|
||||
.createInvalidRequestException("LID MUST be specified by client");
|
||||
}
|
||||
|
||||
List<RegistryObjectType> dbObjects = registryObjectDao
|
||||
.getByLid(objectLid);
|
||||
storedObjects.clear();
|
||||
for (RegistryObjectType regObj : dbObjects) {
|
||||
storedObjects.put(regObj.getId(), regObj);
|
||||
}
|
||||
|
||||
if (obj instanceof TaxonomyElementType) {
|
||||
generatePaths((TaxonomyElementType) obj, "");
|
||||
}
|
||||
if (obj.getVersionInfo() == null) {
|
||||
VersionInfoType version = new VersionInfoType();
|
||||
obj.setVersionInfo(version);
|
||||
}
|
||||
|
||||
RegistryObjectType existingObject = null;
|
||||
switch (request.getMode()) {
|
||||
case CREATE_OR_REPLACE:
|
||||
if (storedObjects.containsKey(objectId)) {
|
||||
VersionInfoType versionInfo = storedObjects.get(objectId)
|
||||
.getVersionInfo();
|
||||
obj.setVersionInfo(versionInfo);
|
||||
obj.setStatus(storedObjects.get(objectId).getStatus());
|
||||
|
||||
if (objectId == null) {
|
||||
throw EbxmlExceptionUtil
|
||||
.createInvalidRequestException("ID MUST be specified by client");
|
||||
}
|
||||
existingObject = registryObjectDao.getById(objectId);
|
||||
if (existingObject == null) {
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] created in the registry.");
|
||||
} else {
|
||||
/*
|
||||
* A server MUST NOT perform update operations via
|
||||
* SubmitObjects and UpdateObjects operations on a local
|
||||
* replica of a remote object. (Except in the case of
|
||||
* updating objects from notifications)
|
||||
*/
|
||||
checkReplica(request, obj, storedObjects.get(objectId));
|
||||
checkReplica(request, obj, existingObject);
|
||||
objsUpdated.add(obj);
|
||||
registryObjectDao.merge(obj, existingObject);
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] replaced in the registry.");
|
||||
// registryObjectDao.delete(storedObjects.get(obj.getId()));
|
||||
objsUpdated.add(obj);
|
||||
registryObjectDao.merge(obj, storedObjects.get(objectId));
|
||||
|
||||
} else {
|
||||
obj.setStatus(StatusTypes.APPROVED);
|
||||
obj.setVersionInfo(new VersionInfoType());
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] added to the registry.");
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
}
|
||||
break;
|
||||
case CREATE_OR_VERSION:
|
||||
if (storedObjects.containsKey(objectId)) {
|
||||
VersionInfoType versionInfo = dbObjects.get(0)
|
||||
.getVersionInfo();
|
||||
obj.setVersionInfo(EbxmlObjectUtil
|
||||
.incrementVersion(versionInfo));
|
||||
obj.setStatus(storedObjects.get(objectId).getStatus());
|
||||
if (objectId == null) {
|
||||
throw EbxmlExceptionUtil
|
||||
.createInvalidRequestException("ID MUST be specified by client");
|
||||
}
|
||||
boolean idExists = registryObjectDao.idExists(objectId);
|
||||
boolean lidExists = registryObjectDao.lidExists(objectLid);
|
||||
|
||||
/*
|
||||
* If id does not exist and lid does not exist, server MUST
|
||||
* create new object using the id (create)
|
||||
*/
|
||||
if (!idExists && !lidExists) {
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] versioned in the registry.");
|
||||
obj.setId(EbxmlObjectUtil.getUUID());
|
||||
+ "] created in the registry.");
|
||||
}
|
||||
/*
|
||||
* If id does not exist and lid exists server MUST throw
|
||||
* InvalidRequestException
|
||||
*/
|
||||
else if (!idExists && lidExists) {
|
||||
throw EbxmlExceptionUtil
|
||||
.createInvalidRequestException("Specified object ID does not exist yet lid exists, unable to version");
|
||||
}
|
||||
/*
|
||||
* If id exists, server MUST create a new version of existing
|
||||
* object matching the id
|
||||
*/
|
||||
else if (idExists) {
|
||||
existingObject = registryObjectDao.getById(objectId);
|
||||
String nextVersion = registryObjectDao
|
||||
.getNextVersion(existingObject);
|
||||
obj.setVersionInfo(new VersionInfoType(nextVersion));
|
||||
obj.setStatus(existingObject.getStatus());
|
||||
obj.setId(existingObject.getId()
|
||||
+ "_"
|
||||
+ nextVersion.substring(nextVersion
|
||||
.lastIndexOf(".") + 1));
|
||||
AssociationType versionAssociation = EbxmlObjectUtil.rimObjectFactory
|
||||
.createAssociationType();
|
||||
String idUUID = EbxmlObjectUtil.getUUID();
|
||||
|
@ -520,83 +476,47 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
.getInternationalString("Version Association"));
|
||||
versionAssociation.setDescription(RegistryUtil
|
||||
.getInternationalString(objectId + " Supersedes "
|
||||
+ dbObjects.get(0).getId()));
|
||||
versionAssociation.setOwner(dbObjects.get(0).getOwner());
|
||||
+ existingObject.getId()));
|
||||
versionAssociation.setOwner(existingObject.getOwner());
|
||||
versionAssociation
|
||||
.setObjectType(RegistryObjectTypes.ASSOCIATION);
|
||||
versionAssociation.setSourceObject(objectId);
|
||||
versionAssociation
|
||||
.setTargetObject(dbObjects.get(0).getId());
|
||||
versionAssociation.setTargetObject(existingObject.getId());
|
||||
versionAssociation.setStatus(StatusTypes.APPROVED);
|
||||
versionAssociation.setType(AssociationTypes.SUPERSEDES);
|
||||
versionAssociation.setVersionInfo(new VersionInfoType());
|
||||
registryObjectDao.create(versionAssociation);
|
||||
objsVersioned.add(obj);
|
||||
statusHandler
|
||||
.info("Supersedes association for new version of ["
|
||||
+ objectId + "] persisted to the registry");
|
||||
registryObjectDao.create(obj);
|
||||
} else {
|
||||
if (!dbObjects.isEmpty()) {
|
||||
EbxmlExceptionUtil
|
||||
.createRegistryException(
|
||||
InvalidRequestExceptionType.class,
|
||||
"",
|
||||
"Invalid submit request",
|
||||
"The submitted id does not exist, yet the lid does. This is an invalid request",
|
||||
ErrorSeverity.ERROR, statusHandler);
|
||||
continue;
|
||||
}
|
||||
obj.setStatus(StatusTypes.APPROVED);
|
||||
obj.setVersionInfo(new VersionInfoType());
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] added to the registry.");
|
||||
|
||||
objsCreated.add(obj);
|
||||
objsCreated.add(versionAssociation);
|
||||
registryObjectDao.create(versionAssociation);
|
||||
registryObjectDao.create(obj);
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] versioned in the registry.");
|
||||
}
|
||||
break;
|
||||
case CREATE_ONLY:
|
||||
if (storedObjects.containsKey(objectId)) {
|
||||
final String message = "Object with id [" + objectId
|
||||
+ "] already exists";
|
||||
final String onlyAcceptsNewObjects = "The "
|
||||
+ Mode.CREATE_ONLY
|
||||
+ " submit mode only accepts new objects";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(message,
|
||||
ObjectExistsExceptionType.class, "",
|
||||
message, onlyAcceptsNewObjects,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(
|
||||
registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
|
||||
} else if (!storedObjects.isEmpty()) {
|
||||
final String message = "Object with lid [" + objectLid
|
||||
+ "] already exists";
|
||||
final String onlyAcceptsNewObjects = "The "
|
||||
+ Mode.CREATE_ONLY
|
||||
+ " submit mode only accepts new objects";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(message,
|
||||
ObjectExistsExceptionType.class, "",
|
||||
message, onlyAcceptsNewObjects,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(
|
||||
registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
|
||||
} else {
|
||||
obj.setVersionInfo(new VersionInfoType());
|
||||
obj.setStatus(StatusTypes.APPROVED);
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] added to the registry.");
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
if (registryObjectDao.lidExists(objectLid)) {
|
||||
throw EbxmlExceptionUtil
|
||||
.createObjectExistsException("Object already exists with lid: "
|
||||
+ objectId
|
||||
+ ". Cannot submit using CREATE_ONLY mode");
|
||||
}
|
||||
if (objectId == null) {
|
||||
objectId = RegistryUtil.generateRegistryObjectId();
|
||||
} else {
|
||||
if (registryObjectDao.idExists(objectId)) {
|
||||
throw EbxmlExceptionUtil
|
||||
.createObjectExistsException("Object already exists with id: "
|
||||
+ objectId
|
||||
+ ". Cannot submit using CREATE_ONLY mode");
|
||||
} else {
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] created in the registry.");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -608,18 +528,8 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
statusHandler.info("Submit objects successful");
|
||||
statusHandler.info("Creating auditable events....");
|
||||
try {
|
||||
Map<String, List<RegistryObjectType>> actionMap = new HashMap<String, List<RegistryObjectType>>();
|
||||
if (!objsCreated.isEmpty()) {
|
||||
actionMap.put(ActionTypes.create, objsCreated);
|
||||
}
|
||||
if (!objsVersioned.isEmpty()) {
|
||||
actionMap.put(ActionTypes.version, objsVersioned);
|
||||
}
|
||||
if (!objsUpdated.isEmpty()) {
|
||||
actionMap.put(ActionTypes.update, objsUpdated);
|
||||
}
|
||||
auditableEventService.createAuditableEventsFromObjects(request,
|
||||
actionMap, System.currentTimeMillis());
|
||||
auditableEventService.createAuditableEventFromObjects(request,
|
||||
objsCreated, objsUpdated, null, null);
|
||||
} catch (EbxmlRegistryException e) {
|
||||
response.getException()
|
||||
.add(EbxmlExceptionUtil
|
||||
|
@ -637,6 +547,18 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the service adheres to the spec when dealing with replicas
|
||||
*
|
||||
* @param request
|
||||
* The request
|
||||
* @param object1
|
||||
* The object being submitted
|
||||
* @param object2
|
||||
* The current object in the registry
|
||||
* @throws MsgRegistryException
|
||||
* If errors occur while checking for replicas
|
||||
*/
|
||||
private void checkReplica(SubmitObjectsRequest request,
|
||||
RegistryObjectType object1, RegistryObjectType object2)
|
||||
throws MsgRegistryException {
|
||||
|
@ -647,7 +569,8 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
String object2Home = object2
|
||||
.getSlotValue(EbxmlObjectUtil.HOME_SLOT_NAME);
|
||||
|
||||
if (object1.getOwner().equals(object2.getOwner())) {
|
||||
if (object1.getOwner() != null
|
||||
&& (object1.getOwner().equals(object2.getOwner()))) {
|
||||
return;
|
||||
}
|
||||
if (fromNotification) {
|
||||
|
@ -741,4 +664,8 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
this.registryObjectDao = registryObjectDao;
|
||||
}
|
||||
|
||||
public void setReferenceResolver(ObjectReferenceResolver referenceResolver) {
|
||||
this.referenceResolver = referenceResolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,288 @@
|
|||
/**
|
||||
* 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.lifecycle;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.xsd.query.v4.QueryRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DynamicObjectRefType;
|
||||
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.RegistryExceptionType;
|
||||
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.commons.validator.UrlValidator;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.raytheon.uf.common.registry.constants.ErrorSeverity;
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.annotations.RegistryObjectReference;
|
||||
import com.raytheon.uf.common.registry.services.RegistryRESTServices;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.DynamicObjectRefDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* Utility class used to resolve references contained in registry objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 7/2312013 2191 bphillip Initial implementation
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class ObjectReferenceResolver {
|
||||
|
||||
/** The logger */
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ObjectReferenceResolver.class);
|
||||
|
||||
/** Data access object for registry objects */
|
||||
private RegistryObjectDao registryObjectDao;
|
||||
|
||||
/** Data access object for dynamic reference objects */
|
||||
private DynamicObjectRefDao dynamicRefDao;
|
||||
|
||||
/** Query Manager service */
|
||||
private QueryManager queryManager;
|
||||
|
||||
/** Validator for validating REST endpoint addresses */
|
||||
private UrlValidator urlValidator = new UrlValidator();
|
||||
|
||||
/** Cache holding the fields in each class that are object references */
|
||||
private static LoadingCache<Class<?>, List<String>> OBJECT_REFERENCE_FIELD_CACHE = CacheBuilder
|
||||
.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES)
|
||||
.build(new CacheLoader<Class<?>, List<String>>() {
|
||||
@Override
|
||||
public List<String> load(Class<?> clazz) throws Exception {
|
||||
List<String> fields = new ArrayList<String>();
|
||||
while (!clazz.equals(Object.class)) {
|
||||
for (Field f : clazz.getDeclaredFields()) {
|
||||
if (f.isAnnotationPresent(RegistryObjectReference.class)) {
|
||||
fields.add(f.getName());
|
||||
}
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Validates the list of objects and makes sure all fields referencing
|
||||
* objects can be resolved.
|
||||
*
|
||||
* @param regObjs
|
||||
* The list of objects to check references for
|
||||
* @throws MsgRegistryException
|
||||
* If any or all of the objects in the list contain unresolved
|
||||
* references
|
||||
*/
|
||||
public void checkReferences(List<RegistryObjectType> regObjs)
|
||||
throws MsgRegistryException {
|
||||
for (RegistryObjectType regObj : regObjs) {
|
||||
statusHandler.info("Checking references for object: "
|
||||
+ regObj.getId() + "...");
|
||||
try {
|
||||
List<String> fields = OBJECT_REFERENCE_FIELD_CACHE.get(regObj
|
||||
.getClass());
|
||||
for (String field : fields) {
|
||||
String propertyValue = (String) PropertyUtils.getProperty(
|
||||
regObj, field);
|
||||
if (propertyValue == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for static reference first
|
||||
if (isStaticReference(regObj, propertyValue)
|
||||
|| isDynamicReference(regObj, field, propertyValue)
|
||||
|| isRESTReference(regObj, propertyValue)) {
|
||||
continue;
|
||||
}
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(
|
||||
"Object [" + regObj.getId()
|
||||
+ "] references unresolvable object ["
|
||||
+ propertyValue + "]", EbxmlExceptionUtil
|
||||
.createUnresolvedReferenceException(
|
||||
regObj.getClass(), regObj.getId(),
|
||||
statusHandler), statusHandler);
|
||||
}
|
||||
|
||||
} catch (MsgRegistryException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(
|
||||
"Error checking references", EbxmlExceptionUtil
|
||||
.createRegistryException(
|
||||
RegistryExceptionType.class, "",
|
||||
"Error checking references",
|
||||
"Error checking references",
|
||||
ErrorSeverity.ERROR, e, statusHandler),
|
||||
statusHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the object specified by ref on the object obj is a static
|
||||
* reference
|
||||
*
|
||||
* @param obj
|
||||
* The object being checked
|
||||
* @param ref
|
||||
* The string to check if it is a static reference
|
||||
* @return true if the item is a static reference and the object exists.
|
||||
* False if the object is not a static reference
|
||||
*/
|
||||
private boolean isStaticReference(RegistryObjectType obj, String ref) {
|
||||
return registryObjectDao.getById(ref) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the property is a dynamic reference
|
||||
*
|
||||
* @param obj
|
||||
* The object being checked
|
||||
* @param propertyName
|
||||
* The property on the object being checked
|
||||
* @param ref
|
||||
* The value of the property on the object being checked
|
||||
* @return True if this is a dynamic reference and the referenced object can
|
||||
* be resolved
|
||||
* @throws MsgRegistryException
|
||||
* If issues occur while executing the query via the query
|
||||
* manager
|
||||
* @throws EbxmlRegistryException
|
||||
* If too many results were returned by the dynamic reference
|
||||
* query
|
||||
*/
|
||||
private boolean isDynamicReference(RegistryObjectType obj,
|
||||
String propertyName, String ref) throws MsgRegistryException,
|
||||
EbxmlRegistryException {
|
||||
DynamicObjectRefType dynamicRef = dynamicRefDao.getById(ref);
|
||||
if (dynamicRef != null) {
|
||||
QueryType refQuery = dynamicRef.getQuery();
|
||||
if (refQuery != null) {
|
||||
QueryRequest queryRequest = new QueryRequest();
|
||||
queryRequest
|
||||
.setId("Dynamic reference resolution query request");
|
||||
queryRequest.setComment("Resolving property [" + propertyName
|
||||
+ " -> " + ref + "] on object [" + obj.getId() + "]");
|
||||
queryRequest.setQuery(refQuery);
|
||||
QueryResponse queryResponse = queryManager
|
||||
.executeQuery(queryRequest);
|
||||
return responseOk(queryResponse);
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a object reference which references a REST service
|
||||
*
|
||||
* @param obj
|
||||
* The object being checked
|
||||
* @param ref
|
||||
* The value being checked
|
||||
* @return True if this is a REST reference and the object being referenced
|
||||
* can be resolved, else false
|
||||
* @throws EbxmlRegistryException
|
||||
* If too many results were returned by the REST call or an
|
||||
* unexpected type was returned by the REST call
|
||||
*/
|
||||
private boolean isRESTReference(RegistryObjectType obj, String ref)
|
||||
throws EbxmlRegistryException {
|
||||
if (urlValidator.isValid(ref)) {
|
||||
Object restResponse = RegistryRESTServices
|
||||
.accessXMLRestService(ref);
|
||||
if (restResponse instanceof QueryResponse) {
|
||||
return responseOk((QueryResponse) restResponse);
|
||||
} else if (restResponse instanceof RegistryObjectType) {
|
||||
return true;
|
||||
} else {
|
||||
throw new EbxmlRegistryException("Unexpected response from "
|
||||
+ ref + ". Received response of type: "
|
||||
+ restResponse.getClass());
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a query response is ok. The response is ok if the query result
|
||||
* is of size 1
|
||||
*
|
||||
* @param queryResponse
|
||||
* The query response to check
|
||||
* @return True if the query returned a single result
|
||||
* @throws EbxmlRegistryException
|
||||
* If the query returned too many results
|
||||
*/
|
||||
private boolean responseOk(QueryResponse queryResponse)
|
||||
throws EbxmlRegistryException {
|
||||
if (queryResponse.isOk()) {
|
||||
List<RegistryObjectType> responseObjects = queryResponse
|
||||
.getRegistryObjects();
|
||||
if (responseObjects.isEmpty()) {
|
||||
return false;
|
||||
} else if (responseObjects.size() > 1) {
|
||||
throw new EbxmlRegistryException(
|
||||
"DynamicObjReference query returned too many results. Expected 1. Got "
|
||||
+ responseObjects.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
|
||||
this.registryObjectDao = registryObjectDao;
|
||||
}
|
||||
|
||||
public void setDynamicRefDao(DynamicObjectRefDao dynamicRefDao) {
|
||||
this.dynamicRefDao = dynamicRefDao;
|
||||
}
|
||||
|
||||
public void setQueryManager(QueryManager queryManager) {
|
||||
this.queryManager = queryManager;
|
||||
}
|
||||
|
||||
}
|
|
@ -94,6 +94,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.types.CanonicalEbxmlQu
|
|||
* 2/13/2012 #184 bphillip Initial creation
|
||||
* 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
|
||||
* 8/1/2013 1693 bphillip Fixed minor typo
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -188,7 +189,7 @@ public class BasicQuery extends CanonicalEbxmlQuery {
|
|||
query.append(conjunction);
|
||||
}
|
||||
if (name != null) {
|
||||
query.append("names.value='").append(description).append("'");
|
||||
query.append("names.value='").append(name).append("'");
|
||||
query.append(conjunction);
|
||||
}
|
||||
if (objectType != null) {
|
||||
|
|
|
@ -75,6 +75,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.types.CanonicalEbxmlQu
|
|||
* 2/13/2012 #184 bphillip Initial creation
|
||||
* 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
|
||||
* 8/1/2013 1693 bphilip Fixed minor typo
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -148,7 +149,7 @@ public class FindAssociations extends CanonicalEbxmlQuery {
|
|||
if (sourceObjectType != null) {
|
||||
List<String> ids = registryObjectDao
|
||||
.executeHQLQuery("select id from RegistryObjectType obj where obj.objectType = '"
|
||||
+ targetObjectType + "'");
|
||||
+ sourceObjectType + "'");
|
||||
if (ids.isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -26,6 +26,8 @@ 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.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.UnresolvedReferenceExceptionType;
|
||||
|
||||
|
@ -46,6 +48,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 19, 2012 184 bphillip Initial creation
|
||||
* Apr 23, 2013 1910 djohnson Add createUnresolvedReferenceException().
|
||||
* 8/1/2013 1693 bphillip Added methods to create exceptions
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -293,12 +296,25 @@ public class EbxmlExceptionUtil {
|
|||
Class<? extends RegistryObjectType> referencedObjectType,
|
||||
String id, IUFStatusHandler statusHandler) {
|
||||
final String ofType = (referencedObjectType == null) ? "" : "to type ["
|
||||
+ referencedObjectType.getCanonicalName()
|
||||
+ "] ";
|
||||
+ 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);
|
||||
}
|
||||
|
||||
public static MsgRegistryException createInvalidRequestException(
|
||||
String message) {
|
||||
InvalidRequestExceptionType invalidRequestException = new InvalidRequestExceptionType();
|
||||
invalidRequestException.setMessage(message);
|
||||
return new MsgRegistryException(message, invalidRequestException);
|
||||
}
|
||||
|
||||
public static MsgRegistryException createObjectExistsException(
|
||||
String message) {
|
||||
ObjectExistsExceptionType objectExistsException = new ObjectExistsExceptionType();
|
||||
objectExistsException.setMessage(message);
|
||||
return new MsgRegistryException(message, objectExistsException);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ 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.rim.v4.ValueType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.VersionInfoType;
|
||||
|
||||
import org.apache.cxf.headers.Header;
|
||||
import org.apache.cxf.helpers.CastUtils;
|
||||
|
@ -67,6 +66,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* Jan 18, 2012 184 bphillip Initial creation
|
||||
* 3/18/2013 1082 bphillip Removed utility methods for VersionInfoType
|
||||
* 4/9/2013 1802 bphillip Removed unused methods and addded a few new ones
|
||||
* 8/1/2013 1693 bphillip Removed increment version method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -277,16 +277,6 @@ public class EbxmlObjectUtil {
|
|||
return classes;
|
||||
}
|
||||
|
||||
public static VersionInfoType incrementVersion(
|
||||
VersionInfoType existingVersion) {
|
||||
String newVersion = String.valueOf(Integer.parseInt(existingVersion
|
||||
.getVersionName()) + 1);
|
||||
VersionInfoType versionObj = new VersionInfoType();
|
||||
versionObj.setVersionName(newVersion);
|
||||
versionObj.setUserVersionName(existingVersion.getUserVersionName());
|
||||
return versionObj;
|
||||
}
|
||||
|
||||
public static List<String> getIdsFromObjectRefListType(
|
||||
ObjectRefListType refList) {
|
||||
if (refList == null) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
|||
* Aug 21, 2012 jsanchez Initial creation
|
||||
* Mar 18, 2013 1082 bphillip Modified to extend sessionmanagedDao and use spring injection
|
||||
* May 22, 2013 1917 rjpeter Added query methods for retrieving data about aggregates.
|
||||
* 8/1/2013 1693 bphillip Fixed named parameters in queries
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
|
@ -143,11 +144,14 @@ public class AggregateRecordDao extends
|
|||
public List<AggregateRecord> getAggregates(final String eventType,
|
||||
final Date startDate, final Date endDate)
|
||||
throws DataAccessLayerException {
|
||||
String hql = "FROM AggregateRecord WHERE eventType = :eventType AND startDate >= minStart AND startDate < maxStart ORDER BY startDate";
|
||||
String hql = "FROM AggregateRecord WHERE eventType = :eventType AND startDate >= :minStart AND startDate < :maxStart ORDER BY startDate";
|
||||
try {
|
||||
Calendar start = Calendar.getInstance();
|
||||
start.setTime(startDate);
|
||||
Calendar end = Calendar.getInstance();
|
||||
end.setTime(endDate);
|
||||
List<AggregateRecord> results = this.executeHQLQuery(hql,
|
||||
"eventType", eventType, "minStart", startDate, "maxStart",
|
||||
endDate);
|
||||
"eventType", eventType, "minStart", start, "maxStart", end);
|
||||
return results;
|
||||
} catch (Exception e) {
|
||||
throw new DataAccessLayerException(
|
||||
|
|
Loading…
Add table
Reference in a new issue