}
}
public void undeployService (String type) throws ADCException {
DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
// check if there are already created Subscriptions for this type
Collection<CartridgeSubscription> cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(type);
if (cartridgeSubscriptions != null) {
if (!cartridgeSubscriptions.isEmpty()) {
// can't undeploy; there are existing Subscriptions
String errorMsg = "Cannot undeploy Service since existing Subscriptions are found";
log.error(errorMsg);
throw new ADCException(errorMsg);
}
}
if (log.isDebugEnabled()) {
log.debug("No subscriptions found for service type: " + type + " , proceeding with undeploying service");
}
Service service;
try {
service = dataInsertionAndRetrievalManager.getService(type);
} catch (PersistenceManagerException e) {
String errorMsg = "Error in checking if Service is available is PersistenceManager";
log.error(errorMsg, e);
throw new ADCException(errorMsg, e);
}
if (service == null) {
String errorMsg = "No service found for type " + type;
log.error(errorMsg);
throw new ADCException(errorMsg);
}
// if service is found, undeploy
try {
service.undeploy();
} catch (NotSubscribedException e) {
String errorMsg = "Undeploying Service Cluster failed for " + type;
log.error(errorMsg, e);
throw new ADCException(errorMsg, e);
}
try {
dataInsertionAndRetrievalManager.removeService(type);
} catch (PersistenceManagerException e) {
String errorMsg = "Error in removing Service from PersistenceManager";
log.error(errorMsg, e);
throw new ADCException(errorMsg, e);