Issue #2385 Fixed subscription backup web service. Restored subscriptions are now scheduled in the bandwidth manager
Change-Id: I7e0e98517ff7d2213957004c6a94e38cf7063cce Former-commit-id: 40fec1c49a0a4aa2ecb4afdf4cf225e6359efd28
This commit is contained in:
parent
b5072746fe
commit
0905d6ffdd
7 changed files with 170 additions and 100 deletions
|
@ -22,7 +22,6 @@ package com.raytheon.uf.common.registry.services.rest;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.registry.RegistryException;
|
import com.raytheon.uf.common.registry.RegistryException;
|
||||||
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
|
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
|
||||||
|
@ -40,6 +39,7 @@ import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResp
|
||||||
* 7/29/2013 2191 bphillip Initial implementation
|
* 7/29/2013 2191 bphillip Initial implementation
|
||||||
* 9/20/2013 2385 bphillip Added subscription backup functions
|
* 9/20/2013 2385 bphillip Added subscription backup functions
|
||||||
* 10/8/2013 1682 bphillip Added rest functions for use with the query web interface
|
* 10/8/2013 1682 bphillip Added rest functions for use with the query web interface
|
||||||
|
* 10/23/2013 2385 bphillip restoreSubscriptions throws JAXBException
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bphillip
|
* @author bphillip
|
||||||
|
@ -111,25 +111,20 @@ public interface IRegistryDataAccessService {
|
||||||
* @param subscriptionName
|
* @param subscriptionName
|
||||||
* The subscription to be backed up
|
* The subscription to be backed up
|
||||||
* @return Status message about whether the backup was successful
|
* @return Status message about whether the backup was successful
|
||||||
* @throws JAXBException
|
|
||||||
* If marshalling/unmarshalling errors are encountered
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}")
|
@Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}")
|
||||||
public String backupSubscription(
|
public String backupSubscription(
|
||||||
@PathParam("subscriptionName") String subscriptionName)
|
@PathParam("subscriptionName") String subscriptionName);
|
||||||
throws JAXBException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Backs up all subscriptions currently in the registry
|
* Backs up all subscriptions currently in the registry
|
||||||
*
|
*
|
||||||
* @return Status message about whether the backup was successful
|
* @return Status message about whether the backup was successful
|
||||||
* @throws JAXBException
|
|
||||||
* If marshalling/unmarshalling errors are encountered
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/")
|
@Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/")
|
||||||
public String backupAllSubscriptions() throws JAXBException;
|
public String backupAllSubscriptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores the specified subscription
|
* Restores the specified subscription
|
||||||
|
@ -137,13 +132,11 @@ public interface IRegistryDataAccessService {
|
||||||
* @param subscriptionName
|
* @param subscriptionName
|
||||||
* The name of the subscription to restore
|
* The name of the subscription to restore
|
||||||
* @return Status message about whether the backup was successful
|
* @return Status message about whether the backup was successful
|
||||||
* @throws JAXBException
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}")
|
@Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}")
|
||||||
public String restoreSubscription(
|
public String restoreSubscription(
|
||||||
@PathParam("subscriptionName") String subscriptionName)
|
@PathParam("subscriptionName") String subscriptionName);
|
||||||
throws JAXBException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores any subscriptions that were previously backed up
|
* Restores any subscriptions that were previously backed up
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
|
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||||
|
|
||||||
<bean id="propertyPlaceholderConfigurer"
|
<bean id="propertyPlaceholderConfigurer"
|
||||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||||
|
@ -87,4 +88,14 @@
|
||||||
<property name="retrievalPlans" ref="retrievalPlans" />
|
<property name="retrievalPlans" ref="retrievalPlans" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<camelContext id="datadelivery-bandwidth" xmlns="http://camel.apache.org/schema/spring"
|
||||||
|
errorHandlerRef="errorHandler">
|
||||||
|
<endpoint id="scheduleBandwidthQueue"
|
||||||
|
uri="vm://scheduleBandwidth" />
|
||||||
|
<route id="scheduleSubscription">
|
||||||
|
<from uri="scheduleBandwidthQueue" />
|
||||||
|
<bean ref="bandwidthManager" method="schedule"/>
|
||||||
|
</route>
|
||||||
|
</camelContext>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -122,14 +122,15 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||||
* case for no matching dataset metadata for an
|
* case for no matching dataset metadata for an
|
||||||
* adhoc subscription.
|
* adhoc subscription.
|
||||||
* Sept 25, 2013 1797 dhladky separated time from gridded time
|
* Sept 25, 2013 1797 dhladky separated time from gridded time
|
||||||
|
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author dhladky
|
* @author dhladky
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public abstract class BandwidthManager<T extends Time, C extends Coverage> extends
|
public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
||||||
AbstractPrivilegedRequestHandler<IBandwidthRequest<T, C>> implements
|
extends AbstractPrivilegedRequestHandler<IBandwidthRequest<T, C>>
|
||||||
IBandwidthManager<T, C> {
|
implements IBandwidthManager<T, C> {
|
||||||
|
|
||||||
protected static final IUFStatusHandler statusHandler = UFStatus
|
protected static final IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(BandwidthManager.class);
|
.getHandler(BandwidthManager.class);
|
||||||
|
@ -141,7 +142,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
|
|
||||||
private BandwidthInitializer initializer;
|
private BandwidthInitializer initializer;
|
||||||
|
|
||||||
protected final BandwidthDaoUtil<T,C> bandwidthDaoUtil;
|
protected final BandwidthDaoUtil<T, C> bandwidthDaoUtil;
|
||||||
|
|
||||||
private final IBandwidthDbInit dbInit;
|
private final IBandwidthDbInit dbInit;
|
||||||
|
|
||||||
|
@ -154,8 +155,9 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
final RetrievalManager retrievalManager;
|
final RetrievalManager retrievalManager;
|
||||||
|
|
||||||
public BandwidthManager(IBandwidthDbInit dbInit,
|
public BandwidthManager(IBandwidthDbInit dbInit,
|
||||||
IBandwidthDao<T, C> bandwidthDao, RetrievalManager retrievalManager,
|
IBandwidthDao<T, C> bandwidthDao,
|
||||||
BandwidthDaoUtil<T,C> bandwidthDaoUtil) {
|
RetrievalManager retrievalManager,
|
||||||
|
BandwidthDaoUtil<T, C> bandwidthDaoUtil) {
|
||||||
this.dbInit = dbInit;
|
this.dbInit = dbInit;
|
||||||
this.bandwidthDao = bandwidthDao;
|
this.bandwidthDao = bandwidthDao;
|
||||||
this.retrievalManager = retrievalManager;
|
this.retrievalManager = retrievalManager;
|
||||||
|
@ -244,8 +246,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
return unscheduled;
|
return unscheduled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<BandwidthAllocation> schedule(Subscription<T, C> subscription,
|
protected List<BandwidthAllocation> schedule(
|
||||||
BandwidthSubscription dao) {
|
Subscription<T, C> subscription, BandwidthSubscription dao) {
|
||||||
Calendar retrievalTime = dao.getBaseReferenceTime();
|
Calendar retrievalTime = dao.getBaseReferenceTime();
|
||||||
|
|
||||||
// Retrieve all the current subscriptions by provider, dataset name and
|
// Retrieve all the current subscriptions by provider, dataset name and
|
||||||
|
@ -440,7 +442,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<BandwidthAllocation> schedule(AdhocSubscription<T, C> subscription) {
|
public List<BandwidthAllocation> scheduleAdhoc(
|
||||||
|
AdhocSubscription<T, C> subscription) {
|
||||||
|
|
||||||
List<BandwidthSubscription> subscriptions = new ArrayList<BandwidthSubscription>();
|
List<BandwidthSubscription> subscriptions = new ArrayList<BandwidthSubscription>();
|
||||||
Calendar now = BandwidthUtil.now();
|
Calendar now = BandwidthUtil.now();
|
||||||
|
@ -453,8 +456,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* and time.
|
* and time.
|
||||||
*/
|
*/
|
||||||
AdhocSubscription<T, C> subscriptionUpdated = bandwidthDaoUtil
|
AdhocSubscription<T, C> subscriptionUpdated = bandwidthDaoUtil
|
||||||
.setAdhocMostRecentUrlAndTime(
|
.setAdhocMostRecentUrlAndTime(subscription, true);
|
||||||
subscription, true);
|
|
||||||
if (subscriptionUpdated != null) {
|
if (subscriptionUpdated != null) {
|
||||||
subscription = subscriptionUpdated;
|
subscription = subscriptionUpdated;
|
||||||
}
|
}
|
||||||
|
@ -558,7 +560,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* the subscription
|
* the subscription
|
||||||
* @return the list of unscheduled subscriptions
|
* @return the list of unscheduled subscriptions
|
||||||
*/
|
*/
|
||||||
private List<BandwidthAllocation> handlePoint(Subscription<T, C> subscription) {
|
private List<BandwidthAllocation> handlePoint(
|
||||||
|
Subscription<T, C> subscription) {
|
||||||
return schedule(subscription,
|
return schedule(subscription,
|
||||||
((PointTime) subscription.getTime()).getInterval());
|
((PointTime) subscription.getTime()).getInterval());
|
||||||
}
|
}
|
||||||
|
@ -570,8 +573,10 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* the subscription
|
* the subscription
|
||||||
* @return the list of unscheduled subscriptions
|
* @return the list of unscheduled subscriptions
|
||||||
*/
|
*/
|
||||||
private List<BandwidthAllocation> handleGridded(Subscription<T, C> subscription) {
|
private List<BandwidthAllocation> handleGridded(
|
||||||
final List<Integer> cycles = ((GriddedTime)subscription.getTime()).getCycleTimes();
|
Subscription<T, C> subscription) {
|
||||||
|
final List<Integer> cycles = ((GriddedTime) subscription.getTime())
|
||||||
|
.getCycleTimes();
|
||||||
final boolean subscribedToCycles = !CollectionUtil
|
final boolean subscribedToCycles = !CollectionUtil
|
||||||
.isNullOrEmpty(cycles);
|
.isNullOrEmpty(cycles);
|
||||||
final boolean useMostRecentDataSetUpdate = !subscribedToCycles;
|
final boolean useMostRecentDataSetUpdate = !subscribedToCycles;
|
||||||
|
@ -599,7 +604,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
+ "No adhoc requested.",
|
+ "No adhoc requested.",
|
||||||
subscription.getName()));
|
subscription.getName()));
|
||||||
} else {
|
} else {
|
||||||
unscheduled = schedule(adhoc);
|
unscheduled = scheduleAdhoc(adhoc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statusHandler
|
statusHandler
|
||||||
|
@ -614,10 +619,11 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<BandwidthAllocation> adhocSubscription(AdhocSubscription<T, C> adhoc) {
|
public List<BandwidthAllocation> adhocSubscription(
|
||||||
|
AdhocSubscription<T, C> adhoc) {
|
||||||
statusHandler.info("Scheduling adhoc subscription [" + adhoc.getName()
|
statusHandler.info("Scheduling adhoc subscription [" + adhoc.getName()
|
||||||
+ "]");
|
+ "]");
|
||||||
return schedule(adhoc);
|
return scheduleAdhoc(adhoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -660,7 +666,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object handleRequest(IBandwidthRequest<T, C> request) throws Exception {
|
public Object handleRequest(IBandwidthRequest<T, C> request)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
ITimer timer = TimeUtil.getTimer();
|
ITimer timer = TimeUtil.getTimer();
|
||||||
timer.start();
|
timer.start();
|
||||||
|
@ -670,7 +677,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
final Network requestNetwork = request.getNetwork();
|
final Network requestNetwork = request.getNetwork();
|
||||||
final int bandwidth = request.getBandwidth();
|
final int bandwidth = request.getBandwidth();
|
||||||
|
|
||||||
final List<Subscription<T, C>> subscriptions = request.getSubscriptions();
|
final List<Subscription<T, C>> subscriptions = request
|
||||||
|
.getSubscriptions();
|
||||||
final RequestType requestType = request.getRequestType();
|
final RequestType requestType = request.getRequestType();
|
||||||
switch (requestType) {
|
switch (requestType) {
|
||||||
case GET_ESTIMATED_COMPLETION:
|
case GET_ESTIMATED_COMPLETION:
|
||||||
|
@ -797,7 +805,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
*/
|
*/
|
||||||
protected abstract Set<String> scheduleSbnSubscriptions(
|
protected abstract Set<String> scheduleSbnSubscriptions(
|
||||||
List<Subscription<T, C>> subscriptions) throws SerializationException;
|
List<Subscription<T, C>> subscriptions)
|
||||||
|
throws SerializationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proposes scheduling a list of subscriptions.
|
* Proposes scheduling a list of subscriptions.
|
||||||
|
@ -808,7 +817,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
*/
|
*/
|
||||||
protected ProposeScheduleResponse proposeScheduleSubscriptions(
|
protected ProposeScheduleResponse proposeScheduleSubscriptions(
|
||||||
List<Subscription<T, C>> subscriptions) throws SerializationException {
|
List<Subscription<T, C>> subscriptions)
|
||||||
|
throws SerializationException {
|
||||||
final ProposeScheduleResponse proposeResponse = proposeSchedule(subscriptions);
|
final ProposeScheduleResponse proposeResponse = proposeSchedule(subscriptions);
|
||||||
Set<String> subscriptionsUnscheduled = proposeResponse
|
Set<String> subscriptionsUnscheduled = proposeResponse
|
||||||
.getUnscheduledSubscriptions();
|
.getUnscheduledSubscriptions();
|
||||||
|
@ -907,7 +917,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @return the set of subscription names unscheduled
|
* @return the set of subscription names unscheduled
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
*/
|
*/
|
||||||
protected Set<String> scheduleSubscriptions(List<Subscription<T, C>> subscriptions)
|
protected Set<String> scheduleSubscriptions(
|
||||||
|
List<Subscription<T, C>> subscriptions)
|
||||||
throws SerializationException {
|
throws SerializationException {
|
||||||
Set<String> unscheduledSubscriptions = new TreeSet<String>();
|
Set<String> unscheduledSubscriptions = new TreeSet<String>();
|
||||||
|
|
||||||
|
@ -993,7 +1004,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
*/
|
*/
|
||||||
private ProposeScheduleResponse proposeSchedule(
|
private ProposeScheduleResponse proposeSchedule(
|
||||||
List<Subscription<T, C>> subscriptions) throws SerializationException {
|
List<Subscription<T, C>> subscriptions)
|
||||||
|
throws SerializationException {
|
||||||
BandwidthMap copyOfCurrentMap = BandwidthMap
|
BandwidthMap copyOfCurrentMap = BandwidthMap
|
||||||
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
|
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
|
||||||
|
|
||||||
|
@ -1100,7 +1112,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
BandwidthManager<T, C> startProposedBandwidthManager(BandwidthMap bandwidthMap) {
|
BandwidthManager<T, C> startProposedBandwidthManager(
|
||||||
|
BandwidthMap bandwidthMap) {
|
||||||
|
|
||||||
InMemoryBandwidthContextFactory
|
InMemoryBandwidthContextFactory
|
||||||
.setInMemoryBandwidthConfigFile(bandwidthMap);
|
.setInMemoryBandwidthConfigFile(bandwidthMap);
|
||||||
|
@ -1137,8 +1150,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* @param type
|
* @param type
|
||||||
* @return the reference to the bandwidth manager
|
* @return the reference to the bandwidth manager
|
||||||
*/
|
*/
|
||||||
private BandwidthManager<T, C> startBandwidthManager(final String[] springFiles,
|
private BandwidthManager<T, C> startBandwidthManager(
|
||||||
boolean close, String type) {
|
final String[] springFiles, boolean close, String type) {
|
||||||
ITimer timer = TimeUtil.getTimer();
|
ITimer timer = TimeUtil.getTimer();
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
|
@ -1146,8 +1159,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
try {
|
try {
|
||||||
ctx = new ClassPathXmlApplicationContext(springFiles,
|
ctx = new ClassPathXmlApplicationContext(springFiles,
|
||||||
EDEXUtil.getSpringContext());
|
EDEXUtil.getSpringContext());
|
||||||
final BandwidthManager<T, C> bwManager = ctx.getBean("bandwidthManager",
|
final BandwidthManager<T, C> bwManager = ctx.getBean(
|
||||||
BandwidthManager.class);
|
"bandwidthManager", BandwidthManager.class);
|
||||||
try {
|
try {
|
||||||
bwManager.initializer.executeAfterRegistryInit();
|
bwManager.initializer.executeAfterRegistryInit();
|
||||||
return bwManager;
|
return bwManager;
|
||||||
|
@ -1218,11 +1231,11 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public List<BandwidthAllocation> copyState(BandwidthManager<T,C> copyFrom) {
|
public List<BandwidthAllocation> copyState(BandwidthManager<T, C> copyFrom) {
|
||||||
IPerformanceTimer timer = TimeUtil.getPerformanceTimer();
|
IPerformanceTimer timer = TimeUtil.getPerformanceTimer();
|
||||||
timer.start();
|
timer.start();
|
||||||
List<BandwidthAllocation> unscheduled = Collections.emptyList();
|
List<BandwidthAllocation> unscheduled = Collections.emptyList();
|
||||||
IBandwidthDao<T,C> fromDao = copyFrom.bandwidthDao;
|
IBandwidthDao<T, C> fromDao = copyFrom.bandwidthDao;
|
||||||
|
|
||||||
final boolean proposingBandwidthChange = retrievalManager
|
final boolean proposingBandwidthChange = retrievalManager
|
||||||
.isProposingBandwidthChanges(copyFrom.retrievalManager);
|
.isProposingBandwidthChanges(copyFrom.retrievalManager);
|
||||||
|
@ -1239,10 +1252,10 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
subscriptionNames.add(subscription.getName());
|
subscriptionNames.add(subscription.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Subscription<T,C>> actualSubscriptions = Sets.newHashSet();
|
Set<Subscription<T, C>> actualSubscriptions = Sets.newHashSet();
|
||||||
for (String subName : subscriptionNames) {
|
for (String subName : subscriptionNames) {
|
||||||
try {
|
try {
|
||||||
Subscription<T,C> actualSubscription = DataDeliveryHandlers
|
Subscription<T, C> actualSubscription = DataDeliveryHandlers
|
||||||
.getSubscriptionHandler().getByName(subName);
|
.getSubscriptionHandler().getByName(subName);
|
||||||
actualSubscriptions.add(actualSubscription);
|
actualSubscriptions.add(actualSubscription);
|
||||||
} catch (RegistryHandlerException e) {
|
} catch (RegistryHandlerException e) {
|
||||||
|
@ -1332,7 +1345,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* the subscription
|
* the subscription
|
||||||
* @return the required dataset size
|
* @return the required dataset size
|
||||||
*/
|
*/
|
||||||
private long determineRequiredDataSetSize(final Subscription<T, C> subscription) {
|
private long determineRequiredDataSetSize(
|
||||||
|
final Subscription<T, C> subscription) {
|
||||||
return determineRequiredValue(subscription,
|
return determineRequiredValue(subscription,
|
||||||
new FindSubscriptionRequiredDataSetSize());
|
new FindSubscriptionRequiredDataSetSize());
|
||||||
}
|
}
|
||||||
|
@ -1430,7 +1444,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
* the subscription
|
* the subscription
|
||||||
* @return true if able to be cleanly scheduled, false otherwise
|
* @return true if able to be cleanly scheduled, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean isSchedulableWithoutConflict(final Subscription<T, C> subscription) {
|
private boolean isSchedulableWithoutConflict(
|
||||||
|
final Subscription<T, C> subscription) {
|
||||||
BandwidthMap copyOfCurrentMap = BandwidthMap
|
BandwidthMap copyOfCurrentMap = BandwidthMap
|
||||||
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
|
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
|
||||||
|
|
||||||
|
@ -1458,15 +1473,17 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special handling for Gridded Times with cycles and time indicies
|
* Special handling for Gridded Times with cycles and time indicies
|
||||||
|
*
|
||||||
* @param subTime
|
* @param subTime
|
||||||
* @param dataSetMetaDataTime
|
* @param dataSetMetaDataTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected static Time handleCyclesAndSequences(Time subTime, Time dataSetMetaDataTime) {
|
protected static Time handleCyclesAndSequences(Time subTime,
|
||||||
|
Time dataSetMetaDataTime) {
|
||||||
|
|
||||||
if (subTime instanceof GriddedTime) {
|
if (subTime instanceof GriddedTime) {
|
||||||
GriddedTime time = (GriddedTime)subTime;
|
GriddedTime time = (GriddedTime) subTime;
|
||||||
GriddedTime dsmTime = (GriddedTime)dataSetMetaDataTime;
|
GriddedTime dsmTime = (GriddedTime) dataSetMetaDataTime;
|
||||||
dsmTime.setSelectedTimeIndices(time.getSelectedTimeIndices());
|
dsmTime.setSelectedTimeIndices(time.getSelectedTimeIndices());
|
||||||
dsmTime.setCycleTimes(time.getCycleTimes());
|
dsmTime.setCycleTimes(time.getCycleTimes());
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,13 +96,15 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||||
* Add throws to updatePointDataSetMetaData.
|
* Add throws to updatePointDataSetMetaData.
|
||||||
* Oct 1 2013 1797 dhladky Time and GriddedTime separation
|
* Oct 1 2013 1797 dhladky Time and GriddedTime separation
|
||||||
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
|
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
|
||||||
|
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author djohnson
|
* @author djohnson
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> extends BandwidthManager<T, C> {
|
public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
||||||
|
extends BandwidthManager<T, C> {
|
||||||
|
|
||||||
private static final Pattern RAP_PATTERN = Pattern
|
private static final Pattern RAP_PATTERN = Pattern
|
||||||
.compile(".*rap_f\\d\\d$");
|
.compile(".*rap_f\\d\\d$");
|
||||||
|
@ -135,8 +137,9 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
* @param bandwidthDaoUtil
|
* @param bandwidthDaoUtil
|
||||||
*/
|
*/
|
||||||
public EdexBandwidthManager(IBandwidthDbInit dbInit,
|
public EdexBandwidthManager(IBandwidthDbInit dbInit,
|
||||||
IBandwidthDao<T,C> bandwidthDao, RetrievalManager retrievalManager,
|
IBandwidthDao<T, C> bandwidthDao,
|
||||||
BandwidthDaoUtil<T,C> bandwidthDaoUtil,
|
RetrievalManager retrievalManager,
|
||||||
|
BandwidthDaoUtil<T, C> bandwidthDaoUtil,
|
||||||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||||
ISubscriptionHandler subscriptionHandler) {
|
ISubscriptionHandler subscriptionHandler) {
|
||||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
|
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
|
||||||
|
@ -393,11 +396,11 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
GriddedDataSetMetaData dataSetMetaData) throws ParseException {
|
GriddedDataSetMetaData dataSetMetaData) throws ParseException {
|
||||||
// Daily/Hourly/Monthly datasets
|
// Daily/Hourly/Monthly datasets
|
||||||
if (dataSetMetaData.getCycle() == GriddedDataSetMetaData.NO_CYCLE) {
|
if (dataSetMetaData.getCycle() == GriddedDataSetMetaData.NO_CYCLE) {
|
||||||
updateDataSetMetaDataWithoutCycle((DataSetMetaData<T>)dataSetMetaData);
|
updateDataSetMetaDataWithoutCycle((DataSetMetaData<T>) dataSetMetaData);
|
||||||
}
|
}
|
||||||
// Regular cycle containing datasets
|
// Regular cycle containing datasets
|
||||||
else {
|
else {
|
||||||
updateDataSetMetaDataWithCycle((DataSetMetaData<T>)dataSetMetaData);
|
updateDataSetMetaDataWithCycle((DataSetMetaData<T>) dataSetMetaData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +468,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
try {
|
try {
|
||||||
// Update the retrieval times on the subscription object
|
// Update the retrieval times on the subscription object
|
||||||
// which goes through the retrieval process
|
// which goes through the retrieval process
|
||||||
final SubscriptionRetrievalAttributes<T,C> subscriptionRetrievalAttributes = bandwidthDao
|
final SubscriptionRetrievalAttributes<T, C> subscriptionRetrievalAttributes = bandwidthDao
|
||||||
.getSubscriptionRetrievalAttributes(retrieval);
|
.getSubscriptionRetrievalAttributes(retrieval);
|
||||||
final Subscription<T, C> subscription = subscriptionRetrievalAttributes
|
final Subscription<T, C> subscription = subscriptionRetrievalAttributes
|
||||||
.getSubscription();
|
.getSubscription();
|
||||||
|
@ -480,7 +483,8 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
subTime.setRequestStart(earliestRetrievalDataTime);
|
subTime.setRequestStart(earliestRetrievalDataTime);
|
||||||
subTime.setRequestEnd(latestRetrievalDataTime);
|
subTime.setRequestEnd(latestRetrievalDataTime);
|
||||||
subTime.setTimes(time.getTimes());
|
subTime.setTimes(time.getTimes());
|
||||||
subscriptionRetrievalAttributes.setSubscription(subscription);
|
subscriptionRetrievalAttributes
|
||||||
|
.setSubscription(subscription);
|
||||||
|
|
||||||
bandwidthDao.update(subscriptionRetrievalAttributes);
|
bandwidthDao.update(subscriptionRetrievalAttributes);
|
||||||
|
|
||||||
|
@ -533,13 +537,14 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
dataSetMetaData.getUrl()));
|
dataSetMetaData.getUrl()));
|
||||||
|
|
||||||
// Create an adhoc for each one, and schedule it
|
// Create an adhoc for each one, and schedule it
|
||||||
for (Subscription<T,C> subscription : subscriptions) {
|
for (Subscription<T, C> subscription : subscriptions) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Subscription<T,C> sub = updateSubscriptionWithDataSetMetaData(
|
Subscription<T, C> sub = updateSubscriptionWithDataSetMetaData(
|
||||||
subscription, dataSetMetaData);
|
subscription, dataSetMetaData);
|
||||||
|
|
||||||
if (sub instanceof SiteSubscription) {
|
if (sub instanceof SiteSubscription) {
|
||||||
schedule(new AdhocSubscription<T,C>((SiteSubscription<T,C>) sub));
|
scheduleAdhoc(new AdhocSubscription<T, C>(
|
||||||
|
(SiteSubscription<T, C>) sub));
|
||||||
} else {
|
} else {
|
||||||
statusHandler
|
statusHandler
|
||||||
.warn("Unable to create adhoc queries for shared subscriptions at this point. This functionality should be added in the future...");
|
.warn("Unable to create adhoc queries for shared subscriptions at this point. This functionality should be added in the future...");
|
||||||
|
@ -583,10 +588,10 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
// SubscriptionRetrieval with the current DataSetMetaData
|
// SubscriptionRetrieval with the current DataSetMetaData
|
||||||
// URL and time Object
|
// URL and time Object
|
||||||
|
|
||||||
SubscriptionRetrievalAttributes<T,C> attributes = bandwidthDao
|
SubscriptionRetrievalAttributes<T, C> attributes = bandwidthDao
|
||||||
.getSubscriptionRetrievalAttributes(retrieval);
|
.getSubscriptionRetrievalAttributes(retrieval);
|
||||||
|
|
||||||
Subscription<T,C> sub;
|
Subscription<T, C> sub;
|
||||||
try {
|
try {
|
||||||
sub = updateSubscriptionWithDataSetMetaData(
|
sub = updateSubscriptionWithDataSetMetaData(
|
||||||
attributes.getSubscription(), dataSetMetaData);
|
attributes.getSubscription(), dataSetMetaData);
|
||||||
|
@ -608,12 +613,12 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
|
|
||||||
bandwidthDaoUtil.update(retrieval);
|
bandwidthDaoUtil.update(retrieval);
|
||||||
|
|
||||||
statusHandler
|
statusHandler.info(String.format(
|
||||||
.info(String.format("Updated retrieval [%s] for "
|
"Updated retrieval [%s] for "
|
||||||
+ "subscription [%s] to use "
|
+ "subscription [%s] to use "
|
||||||
+ "url [%s] and "
|
+ "url [%s] and "
|
||||||
+ "base reference time [%s]", retrieval
|
+ "base reference time [%s]",
|
||||||
.getIdentifier(), sub.getName(),
|
retrieval.getIdentifier(), sub.getName(),
|
||||||
dataSetMetaData.getUrl(),
|
dataSetMetaData.getUrl(),
|
||||||
BandwidthUtil.format(sub.getTime().getStart())));
|
BandwidthUtil.format(sub.getTime().getStart())));
|
||||||
}
|
}
|
||||||
|
@ -647,14 +652,14 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Subscription<T,C>> subscriptions = new HashSet<Subscription<T,C>>();
|
Set<Subscription<T, C>> subscriptions = new HashSet<Subscription<T, C>>();
|
||||||
for (SubscriptionRetrieval retrieval : retrievals) {
|
for (SubscriptionRetrieval retrieval : retrievals) {
|
||||||
try {
|
try {
|
||||||
final SubscriptionRetrievalAttributes<T,C> sra = bandwidthDao
|
final SubscriptionRetrievalAttributes<T, C> sra = bandwidthDao
|
||||||
.getSubscriptionRetrievalAttributes(retrieval);
|
.getSubscriptionRetrievalAttributes(retrieval);
|
||||||
if (sra != null) {
|
if (sra != null) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Subscription<T,C> sub = sra.getSubscription();
|
Subscription<T, C> sub = sra.getSubscription();
|
||||||
if (sub != null) {
|
if (sub != null) {
|
||||||
subscriptions.add(sub);
|
subscriptions.add(sub);
|
||||||
}
|
}
|
||||||
|
@ -666,7 +671,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Subscription<T,C> subscription : subscriptions) {
|
for (Subscription<T, C> subscription : subscriptions) {
|
||||||
subscription.setUnscheduled(true);
|
subscription.setUnscheduled(true);
|
||||||
subscriptionUpdated(subscription);
|
subscriptionUpdated(subscription);
|
||||||
}
|
}
|
||||||
|
@ -700,7 +705,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
|
||||||
* reinitialize operation.
|
* reinitialize operation.
|
||||||
*/
|
*/
|
||||||
private void bandwidthMapConfigurationUpdated() {
|
private void bandwidthMapConfigurationUpdated() {
|
||||||
IBandwidthRequest<T,C> request = new IBandwidthRequest<T,C>();
|
IBandwidthRequest<T, C> request = new IBandwidthRequest<T, C>();
|
||||||
request.setRequestType(RequestType.REINITIALIZE);
|
request.setRequestType(RequestType.REINITIALIZE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggre
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 30, 2012 1286 djohnson Initial creation
|
* Oct 30, 2012 1286 djohnson Initial creation
|
||||||
* Jul 10, 2013 2106 djohnson Remove EDEX instance specific methods.
|
* Jul 10, 2013 2106 djohnson Remove EDEX instance specific methods.
|
||||||
|
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -66,7 +67,7 @@ public interface IBandwidthManager<T extends Time, C extends Coverage> {
|
||||||
* @param b
|
* @param b
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<BandwidthAllocation> schedule(AdhocSubscription<T, C> subscription);
|
List<BandwidthAllocation> scheduleAdhoc(AdhocSubscription<T, C> subscription);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a Subscription is updated in the Registry, update the retrieval plan
|
* When a Subscription is updated in the Registry, update the retrieval plan
|
||||||
|
@ -76,8 +77,8 @@ public interface IBandwidthManager<T extends Time, C extends Coverage> {
|
||||||
* @return
|
* @return
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
*/
|
*/
|
||||||
List<BandwidthAllocation> subscriptionUpdated(Subscription<T, C> subscription)
|
List<BandwidthAllocation> subscriptionUpdated(
|
||||||
throws SerializationException;
|
Subscription<T, C> subscription) throws SerializationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,7 +34,8 @@ Require-Bundle: com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1.
|
||||||
com.raytheon.uf.common.datadelivery.request;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",
|
org.apache.commons.validator;bundle-version="1.2.0",
|
||||||
com.sun.xml.bind;bundle-version="1.0.0"
|
com.sun.xml.bind;bundle-version="1.0.0",
|
||||||
|
org.reflections;bundle-version="0.9.9"
|
||||||
Export-Package: com.raytheon.uf.edex.registry.ebxml.acp,
|
Export-Package: com.raytheon.uf.edex.registry.ebxml.acp,
|
||||||
com.raytheon.uf.edex.registry.ebxml.dao,
|
com.raytheon.uf.edex.registry.ebxml.dao,
|
||||||
com.raytheon.uf.edex.registry.ebxml.exception,
|
com.raytheon.uf.edex.registry.ebxml.exception,
|
||||||
|
|
|
@ -21,12 +21,14 @@ package com.raytheon.uf.edex.registry.ebxml.services.rest;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.xml.bind.JAXB;
|
import javax.xml.bind.JAXB;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||||
|
@ -40,21 +42,29 @@ 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.RegistryObjectType;
|
||||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType;
|
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType;
|
||||||
|
|
||||||
|
import org.reflections.Reflections;
|
||||||
|
import org.reflections.scanners.TypeAnnotationsScanner;
|
||||||
|
import org.reflections.util.ClasspathHelper;
|
||||||
|
import org.reflections.util.ConfigurationBuilder;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.raytheon.uf.common.registry.RegistryException;
|
import com.raytheon.uf.common.registry.RegistryException;
|
||||||
import com.raytheon.uf.common.registry.services.rest.IRegistryDataAccessService;
|
import com.raytheon.uf.common.registry.services.rest.IRegistryDataAccessService;
|
||||||
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
|
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
|
||||||
|
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.util.CollectionUtil;
|
import com.raytheon.uf.common.util.CollectionUtil;
|
||||||
import com.raytheon.uf.common.util.StringUtil;
|
import com.raytheon.uf.common.util.StringUtil;
|
||||||
|
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||||
|
import com.raytheon.uf.edex.core.EdexException;
|
||||||
import com.raytheon.uf.edex.registry.ebxml.dao.QueryDefinitionDao;
|
import com.raytheon.uf.edex.registry.ebxml.dao.QueryDefinitionDao;
|
||||||
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Implementation of the registry data access service interface
|
* Implementation of the registry data access service interface <br>
|
||||||
|
* TODO: This class really needs to be moved to a data delivery specific plugin
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -66,6 +76,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||||
* 9/20/2013 2385 bphillip Added subscription backup functions
|
* 9/20/2013 2385 bphillip Added subscription backup functions
|
||||||
* 10/2/2013 2385 bphillip Fixed subscription backup queries
|
* 10/2/2013 2385 bphillip Fixed subscription backup queries
|
||||||
* 10/8/2013 1682 bphillip Added query queries
|
* 10/8/2013 1682 bphillip Added query queries
|
||||||
|
* 10/23/2013 2385 bphillip Restored subscriptions are now scheduled in the bandwidth manager
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bphillip
|
* @author bphillip
|
||||||
|
@ -91,6 +102,8 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
+ "where obj.objectType like '%SiteSubscription' "
|
+ "where obj.objectType like '%SiteSubscription' "
|
||||||
+ "OR obj.objectType like '%SharedSubscription' order by obj.id asc";
|
+ "OR obj.objectType like '%SharedSubscription' order by obj.id asc";
|
||||||
|
|
||||||
|
private static final JAXBManager subscriptionJaxbManager = initJaxbManager();
|
||||||
|
|
||||||
/** Data access object for registry objects */
|
/** Data access object for registry objects */
|
||||||
private RegistryObjectDao registryObjectDao;
|
private RegistryObjectDao registryObjectDao;
|
||||||
|
|
||||||
|
@ -234,8 +247,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
@GET
|
@GET
|
||||||
@Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}")
|
@Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}")
|
||||||
public String backupSubscription(
|
public String backupSubscription(
|
||||||
@PathParam("subscriptionName") String subscriptionName)
|
@PathParam("subscriptionName") String subscriptionName) {
|
||||||
throws JAXBException {
|
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
List<RegistryObjectType> result = registryObjectDao.executeHQLQuery(
|
List<RegistryObjectType> result = registryObjectDao.executeHQLQuery(
|
||||||
GET_SINGLE_SUBSCRIPTIONS_QUERY, "id", subscriptionName);
|
GET_SINGLE_SUBSCRIPTIONS_QUERY, "id", subscriptionName);
|
||||||
|
@ -277,7 +289,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
@Override
|
@Override
|
||||||
@GET
|
@GET
|
||||||
@Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/")
|
@Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/")
|
||||||
public String backupAllSubscriptions() throws JAXBException {
|
public String backupAllSubscriptions() {
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
List<RegistryObjectType> subs = registryObjectDao
|
List<RegistryObjectType> subs = registryObjectDao
|
||||||
.executeHQLQuery(GET_SUBSCRIPTIONS_QUERY);
|
.executeHQLQuery(GET_SUBSCRIPTIONS_QUERY);
|
||||||
|
@ -300,16 +312,32 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
@GET
|
@GET
|
||||||
@Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}")
|
@Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}")
|
||||||
public String restoreSubscription(
|
public String restoreSubscription(
|
||||||
@PathParam("subscriptionName") String subscriptionName)
|
@PathParam("subscriptionName") String subscriptionName) {
|
||||||
throws JAXBException {
|
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
File subscriptionFile = new File(SUBSCRIPTION_BACKUP_DIR
|
File subscriptionFile = new File(SUBSCRIPTION_BACKUP_DIR
|
||||||
+ File.separator + subscriptionName);
|
+ File.separator + subscriptionName);
|
||||||
if (subscriptionFile.exists()) {
|
if (subscriptionFile.exists()) {
|
||||||
SubmitObjectsRequest submitRequest = JAXB.unmarshal(
|
SubmitObjectsRequest submitRequest = JAXB.unmarshal(
|
||||||
subscriptionFile, SubmitObjectsRequest.class);
|
subscriptionFile, SubmitObjectsRequest.class);
|
||||||
|
String subscriptionXML = submitRequest.getRegistryObjects().get(0)
|
||||||
|
.getSlotByName("content").getSlotValue().getValue();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Object subObj = subscriptionJaxbManager
|
||||||
|
.unmarshalFromXml(subscriptionXML);
|
||||||
|
EDEXUtil.getMessageProducer().sendSync("scheduleSubscription",
|
||||||
|
subObj);
|
||||||
lcm.submitObjects(submitRequest);
|
lcm.submitObjects(submitRequest);
|
||||||
|
subscriptionFile.delete();
|
||||||
|
response.append(
|
||||||
|
"Subscription successfully restored from file [")
|
||||||
|
.append(subscriptionFile).append("]<br>");
|
||||||
|
} catch (EdexException e1) {
|
||||||
|
statusHandler.error("Error submitting subscription", e1);
|
||||||
|
response.append("Subscription from file [")
|
||||||
|
.append(subscriptionFile)
|
||||||
|
.append("] failed to be restored: ")
|
||||||
|
.append(e1.getLocalizedMessage()).append("<br>");
|
||||||
} catch (MsgRegistryException e) {
|
} catch (MsgRegistryException e) {
|
||||||
response.append("Error restoring subscription from file [")
|
response.append("Error restoring subscription from file [")
|
||||||
.append(subscriptionFile).append("] ")
|
.append(subscriptionFile).append("] ")
|
||||||
|
@ -317,10 +345,13 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
statusHandler.error("Error restoring subscription from file ["
|
statusHandler.error("Error restoring subscription from file ["
|
||||||
+ subscriptionFile + "]", e);
|
+ subscriptionFile + "]", e);
|
||||||
return response.toString();
|
return response.toString();
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
response.append("Error restoring subscription from file [")
|
||||||
|
.append(subscriptionFile).append("] ")
|
||||||
|
.append(e.getMessage()).append("<br>");
|
||||||
|
statusHandler.error("Error restoring subscription from file ["
|
||||||
|
+ subscriptionFile + "]", e);
|
||||||
}
|
}
|
||||||
subscriptionFile.delete();
|
|
||||||
response.append("Subscription successfully restored from file [")
|
|
||||||
.append(subscriptionFile).append("]<br>");
|
|
||||||
} else {
|
} else {
|
||||||
response.append("No backup file exists for subscription[")
|
response.append("No backup file exists for subscription[")
|
||||||
.append(subscriptionName).append("]<br>");
|
.append(subscriptionName).append("]<br>");
|
||||||
|
@ -345,18 +376,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
response.append("No subscriptions found to restore<br>");
|
response.append("No subscriptions found to restore<br>");
|
||||||
} else {
|
} else {
|
||||||
for (File subscription : filesToRestore) {
|
for (File subscription : filesToRestore) {
|
||||||
|
response.append(restoreSubscription(subscription.getName()));
|
||||||
try {
|
|
||||||
response.append(restoreSubscription(subscription
|
|
||||||
.getName()));
|
|
||||||
} catch (JAXBException e) {
|
|
||||||
statusHandler.error("Error restoring subscription ["
|
|
||||||
+ subscription + "]", e);
|
|
||||||
response.append("Error restoring subscription [")
|
|
||||||
.append(subscription).append("] ")
|
|
||||||
.append(e.getMessage()).append("<br>");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -394,6 +414,28 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
||||||
return response.toString();
|
return response.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the JAXBManager for datadelivery classes.
|
||||||
|
*
|
||||||
|
* @return JAXBManager for datadelivery classes
|
||||||
|
*/
|
||||||
|
private static JAXBManager initJaxbManager() {
|
||||||
|
ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||||
|
cb.addUrls(ClasspathHelper
|
||||||
|
.forPackage("com.raytheon.uf.common.datadelivery.registry"));
|
||||||
|
cb.setScanners(new TypeAnnotationsScanner());
|
||||||
|
Reflections reflecs = cb.build();
|
||||||
|
Set<Class<?>> classes = reflecs
|
||||||
|
.getTypesAnnotatedWith(XmlRootElement.class);
|
||||||
|
try {
|
||||||
|
return new JAXBManager(
|
||||||
|
classes.toArray(new Class<?>[classes.size()]));
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Error initializing subscription jaxb Manager!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
|
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
|
||||||
this.registryObjectDao = registryObjectDao;
|
this.registryObjectDao = registryObjectDao;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue