Issue #2022 Modifications to subscription last run time

and notificationservers

Change-Id: Ia11e639249ef7fd769e6e3baae2b09b966b3caea

Former-commit-id: 0862f2b7d3 [formerly f00d8ae721] [formerly 1cec0fab74 [formerly 4118d4e3888a5feb9bbc39036a8ceeb70d66e375]]
Former-commit-id: 1cec0fab74
Former-commit-id: 6e8314475e
This commit is contained in:
Benjamin Phillippe 2013-06-04 11:30:14 -05:00
parent 86b88922da
commit 49ec0363c3
13 changed files with 134 additions and 42 deletions

View file

@ -20,6 +20,8 @@
package oasis.names.tc.ebxml.regrep.xsd.rim.v4; package oasis.names.tc.ebxml.regrep.xsd.rim.v4;
import java.util.GregorianCalendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
@ -29,6 +31,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.Cache;
@ -90,6 +94,18 @@ public class DateTimeValueType extends ValueType {
this.dateTimeValue = dateTimeValue; this.dateTimeValue = dateTimeValue;
} }
public DateTimeValueType(long time) {
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(time);
try {
this.dateTimeValue = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(cal);
} catch (DatatypeConfigurationException e) {
throw new RuntimeException("Error creating XMLGregorianCalendar!",
e);
}
}
@Override @Override
public String getColumnName() { public String getColumnName() {
return COLUMN_NAME; return COLUMN_NAME;

View file

@ -160,13 +160,21 @@ public abstract class ExtensibleObjectType {
} }
public void updateSlot(String slotName, Object slotValue) { public void updateSlot(String slotName, Object slotValue) {
SlotType slot = getSlotByName(slotName);
if (slot == null) {
addSlot(slotName, slotValue);
} else {
slot.getSlotValue().setValue(slotValue);
}
}
public SlotType getSlotByName(String slotName) {
for (SlotType slot : getSlot()) { for (SlotType slot : getSlot()) {
if (slot.getName().equals(slotName)) { if (slot.getName().equals(slotName)) {
slot.getSlotValue().setValue(slotValue); return slot;
return;
} }
} }
addSlot(slotName, slotValue); return null;
} }
/** /**

View file

@ -116,6 +116,15 @@ public class ExtrinsicObjectType extends RegistryObjectType {
@DynamicSerializeElement @DynamicSerializeElement
protected String mimeType; protected String mimeType;
public ExtrinsicObjectType() {
}
public ExtrinsicObjectType(String id, String lid, String objectType,
String owner, String status, String name, String description) {
super(id, lid, objectType, owner, status, name, description);
}
/** /**
* Gets the value of the contentVersionInfo property. * Gets the value of the contentVersionInfo property.
* *

View file

@ -20,6 +20,8 @@
package oasis.names.tc.ebxml.regrep.xsd.rim.v4; package oasis.names.tc.ebxml.regrep.xsd.rim.v4;
import java.util.Collection;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@ -76,6 +78,15 @@ public abstract class IdentifiableType extends ExtensibleObjectType implements
@DynamicSerializeElement @DynamicSerializeElement
protected String id; protected String id;
protected IdentifiableType() {
}
protected IdentifiableType(Collection<SlotType> slots, String id) {
super(slots);
this.id = id;
}
/** /**
* Gets the value of the id property. * Gets the value of the id property.
* *

View file

@ -103,11 +103,11 @@ public class InternationalStringType implements Serializable {
} }
public InternationalStringType(String lang, String value) { public InternationalStringType(String lang, String value) {
this.localizedString.add(new LocalizedStringType(lang, value)); this.getLocalizedString().add(new LocalizedStringType(lang, value));
} }
public InternationalStringType(String value) { public InternationalStringType(String value) {
this.localizedString.add(new LocalizedStringType(value)); this.getLocalizedString().add(new LocalizedStringType(value));
} }
/** /**

View file

@ -77,6 +77,14 @@ public class ObjectRefType extends ExtensibleObjectType implements
@DynamicSerializeElement @DynamicSerializeElement
protected String id; protected String id;
public ObjectRefType() {
}
public ObjectRefType(String id) {
this.id = id;
}
/** /**
* Gets the value of the id property. * Gets the value of the id property.
* *

View file

@ -178,6 +178,17 @@ public class RegistryObjectType extends IdentifiableType {
this.lid = lid; this.lid = lid;
} }
public RegistryObjectType(String id, String lid, String objectType,
String owner, String status, String name, String description) {
this(id, lid);
this.objectType = objectType;
this.owner = owner;
this.status = status;
this.name = new InternationalStringType(name);
this.description = new InternationalStringType(description);
}
/** /**
* Gets the value of the name property. * Gets the value of the name property.
* *

View file

@ -114,6 +114,16 @@ public class SubscriptionType extends RegistryObjectType {
@Type(type = "com.raytheon.uf.common.registry.schemas.ebxml.util.DurationType") @Type(type = "com.raytheon.uf.common.registry.schemas.ebxml.util.DurationType")
protected Duration notificationInterval; protected Duration notificationInterval;
public SubscriptionType() {
}
public SubscriptionType(String id, String lid, String objectType,
String owner, String status, String name, String description) {
super(id, lid, objectType, owner, status, name, description);
}
/** /**
* Gets the value of the deliveryInfo property. * Gets the value of the deliveryInfo property.
* *

View file

@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ActionType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ActionType;
@ -249,13 +248,8 @@ public class AuditableEventTypeDao extends
event.setOwner(RegistryUtil.DEFAULT_OWNER); event.setOwner(RegistryUtil.DEFAULT_OWNER);
event.setObjectType(RegistryObjectTypes.AUDITABLE_EVENT); event.setObjectType(RegistryObjectTypes.AUDITABLE_EVENT);
event.setRequestId(request.getId()); event.setRequestId(request.getId());
try { event.setTimestamp(EbxmlObjectUtil
event.setTimestamp(EbxmlObjectUtil .getTimeAsXMLGregorianCalendar(currentTime));
.getTimeAsXMLGregorianCalendar(currentTime));
} catch (DatatypeConfigurationException e) {
throw new EbxmlRegistryException(
"Error creating timestamp for auditable event", e);
}
event.setUser("Client"); event.setUser("Client");
event.setStatus(StatusTypes.APPROVED); event.setStatus(StatusTypes.APPROVED);
event.setVersionInfo(new VersionInfoType()); event.setVersionInfo(new VersionInfoType());

View file

@ -23,6 +23,7 @@ import java.util.List;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
/** /**
@ -36,6 +37,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 3/13/2013 1082 bphillip Initial creation * 3/13/2013 1082 bphillip Initial creation
* 4/9/2013 1802 bphillip Removed exception catching * 4/9/2013 1802 bphillip Removed exception catching
* 6/4/2013 2022 bphillip Added delete objects of type method
* *
* </pre> * </pre>
* *
@ -45,9 +47,28 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
public class RegistryObjectDao extends public class RegistryObjectDao extends
RegistryObjectTypeDao<RegistryObjectType> { RegistryObjectTypeDao<RegistryObjectType> {
/** Delete object type parameterized statement */
private static final String DELETE_OBJECT_TYPE = "DELETE RegistryObjectType regObj where regObj.objectType=:objectType";
public RegistryObjectDao() { public RegistryObjectDao() {
} }
/**
* Deletes objects of a specific type from the registry
*
* @param objectType
* The object type to delete
* @throws DataAccessLayerException
* If errors occur on the delete
*/
public void deleteObjectsOfType(String objectType)
throws DataAccessLayerException {
int objectsDeleted = this.executeHQLStatement(DELETE_OBJECT_TYPE,
"objectType", objectType);
statusHandler.info(objectsDeleted + " objects of type " + objectType
+ " deleted from registry");
}
/** /**
* Retrieves all registry objects from the registry * Retrieves all registry objects from the registry
* *

View file

@ -19,7 +19,6 @@
**/ **/
package com.raytheon.uf.edex.registry.ebxml.services.notification; package com.raytheon.uf.edex.registry.ebxml.services.notification;
import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
@ -39,10 +38,12 @@ import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.NotificationListene
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse; 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.query.v4.ResponseOptionType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AuditableEventType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AuditableEventType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DateTimeValueType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DeliveryInfoType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DeliveryInfoType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.NotificationType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.NotificationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -83,6 +84,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
* Apr 17, 2013 1672 djohnson Keeps track of the notification listeners. * Apr 17, 2013 1672 djohnson Keeps track of the notification listeners.
* 5/21/2013 2022 bphillip Made logging less verbose. added running boolean so subscriptions are not process on every single * 5/21/2013 2022 bphillip Made logging less verbose. added running boolean so subscriptions are not process on every single
* event. * event.
* 6/4/2013 2022 bphillip Changed slot type of subscription last run time. Longs were being truncated when casting to ints
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
@ -306,8 +308,6 @@ public class RegistrySubscriptionManager implements
SubscriptionType sub = subNotificationListener.subscription; SubscriptionType sub = subNotificationListener.subscription;
try { try {
if (subscriptionShouldRun(sub)) { if (subscriptionShouldRun(sub)) {
updateLastRunTime(sub,
new Integer((int) TimeUtil.currentTimeMillis()));
try { try {
processSubscription(subNotificationListener); processSubscription(subNotificationListener);
} catch (EbxmlRegistryException e) { } catch (EbxmlRegistryException e) {
@ -375,11 +375,19 @@ public class RegistrySubscriptionManager implements
* @throws EbxmlRegistryException * @throws EbxmlRegistryException
* if errors occur accessing the slot on the subscription * if errors occur accessing the slot on the subscription
*/ */
private void updateLastRunTime(SubscriptionType subscription, Integer time) private void updateLastRunTime(SubscriptionType subscription, long time)
throws EbxmlRegistryException { throws EbxmlRegistryException {
try { try {
subscription.updateSlot( SlotType lastRunTimeSlot = subscription
EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME, time); .getSlotByName(EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME);
if (lastRunTimeSlot == null) {
lastRunTimeSlot = new SlotType(
EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME,
new DateTimeValueType(time));
subscription.getSlot().add(lastRunTimeSlot);
} else {
lastRunTimeSlot.setSlotValue(new DateTimeValueType(time));
}
} catch (Exception e) { } catch (Exception e) {
throw new EbxmlRegistryException( throw new EbxmlRegistryException(
"Error getting subscription run time", e); "Error getting subscription run time", e);
@ -398,15 +406,13 @@ public class RegistrySubscriptionManager implements
*/ */
private Calendar getLastRunTime(SubscriptionType subscription) private Calendar getLastRunTime(SubscriptionType subscription)
throws EbxmlRegistryException { throws EbxmlRegistryException {
BigInteger lastRunTime = subscription XMLGregorianCalendar lastRunTime = subscription
.getSlotValue(EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME); .getSlotValue(EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME);
if (lastRunTime == null) { if (lastRunTime == null) {
updateLastRunTime(subscription, 0); updateLastRunTime(subscription, 0);
lastRunTime = BigInteger.valueOf(0); lastRunTime = EbxmlObjectUtil.getTimeAsXMLGregorianCalendar(0);
} }
Calendar subRunTime = TimeUtil.newCalendar(); return lastRunTime.toGregorianCalendar();
subRunTime.setTimeInMillis(lastRunTime.longValue());
return subRunTime;
} }
/** /**
@ -422,6 +428,8 @@ public class RegistrySubscriptionManager implements
private void processSubscription( private void processSubscription(
final SubscriptionNotificationListeners subscriptionNotificationsListeners) final SubscriptionNotificationListeners subscriptionNotificationsListeners)
throws MsgRegistryException, EbxmlRegistryException { throws MsgRegistryException, EbxmlRegistryException {
updateLastRunTime(subscriptionNotificationsListeners.subscription,
TimeUtil.currentTimeMillis());
SubscriptionType subscription = subscriptionNotificationsListeners.subscription; SubscriptionType subscription = subscriptionNotificationsListeners.subscription;
statusHandler.info("Processing subscription [" + subscription.getId() statusHandler.info("Processing subscription [" + subscription.getId()
+ "]..."); + "]...");

View file

@ -19,11 +19,9 @@
**/ **/
package com.raytheon.uf.edex.registry.ebxml.services.query.types.canonical; package com.raytheon.uf.edex.registry.ebxml.services.query.types.canonical;
import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
@ -113,22 +111,13 @@ public class GetNotification extends CanonicalEbxmlQuery {
"Subscription does not define any push delivery addresses. Start time must be defined."); "Subscription does not define any push delivery addresses. Start time must be defined.");
} }
try { if (startTime == null) {
startTime = subscription
.getSlotValue(EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME);
if (startTime == null) { if (startTime == null) {
BigInteger lastRunTime = subscription startTime = EbxmlObjectUtil.getTimeAsXMLGregorianCalendar(0);
.getSlotValue(EbxmlObjectUtil.SUBSCRIPTION_LAST_RUN_TIME_SLOT_NAME);
if (lastRunTime == null) {
startTime = EbxmlObjectUtil
.getTimeAsXMLGregorianCalendar(0);
} else {
startTime = EbxmlObjectUtil
.getTimeAsXMLGregorianCalendar(lastRunTime
.longValue());
}
} }
} catch (DatatypeConfigurationException e) {
throw new EbxmlRegistryException("Error determining start time!", e);
} }
try { try {

View file

@ -53,6 +53,7 @@ import org.apache.cxf.helpers.CastUtils;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil; import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
/** /**
* General utility class containing the ebXML object factories. * General utility class containing the ebXML object factories.
@ -184,9 +185,10 @@ public class EbxmlObjectUtil {
* @return XMLGregorianCalendar representation of the current time * @return XMLGregorianCalendar representation of the current time
* @throws DatatypeConfigurationException * @throws DatatypeConfigurationException
* if the time cannot be constructed properly * if the time cannot be constructed properly
* @throws EbxmlRegistryException
*/ */
public static XMLGregorianCalendar getCurrentTimeAsXMLGregorianCalendar() public static XMLGregorianCalendar getCurrentTimeAsXMLGregorianCalendar()
throws DatatypeConfigurationException { throws EbxmlRegistryException {
return getTimeAsXMLGregorianCalendar(System.currentTimeMillis()); return getTimeAsXMLGregorianCalendar(System.currentTimeMillis());
} }
@ -202,10 +204,15 @@ public class EbxmlObjectUtil {
* if the time cannot be constructed properly * if the time cannot be constructed properly
*/ */
public static XMLGregorianCalendar getTimeAsXMLGregorianCalendar( public static XMLGregorianCalendar getTimeAsXMLGregorianCalendar(
long timeInMillis) throws DatatypeConfigurationException { long timeInMillis) throws EbxmlRegistryException {
GregorianCalendar cal = new GregorianCalendar(); GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(timeInMillis); cal.setTimeInMillis(timeInMillis);
return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); try {
return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
} catch (DatatypeConfigurationException e) {
throw new EbxmlRegistryException(
"Error creating XMLGregorianCalendar!", e);
}
} }
/** /**