use of org.jaffa.qm.apis.data.QueueAdminResponse in project jaffa-framework by jaffa-projects.
the class TransactionAdmin method toggleQueueStatus.
/**
* NOTE: Each graph is expected to contain type. It may also contain the optional queueMetaData.queueSystemId, which may help optimize the process.
*/
public QueueAdminResponse[] toggleQueueStatus(QueueGraph[] graphs) {
if (log.isDebugEnabled()) {
log.debug("Input to toggleQueueStatus: " + Arrays.toString(graphs));
}
Collection<QueueAdminResponse> output = null;
String[] types = TransactionEngine.getInstance().getAccessibleTypeNames();
Arrays.sort(types);
for (QueueGraph graph : graphs) {
if (graph.getQueueMetaData() == null || graph.getQueueMetaData().getQueueSystemId() == null || graph.getQueueMetaData().getQueueSystemId().equals(QUEUE_SYSTEM_ID)) {
if (types != null && Arrays.binarySearch(types, graph.getType()) >= 0) {
try {
if (!TransactionEngine.getInstance().hasAdminAccess(graph.getType())) {
throw new ApplicationExceptions(new ApplicationException("error.Jaffa.Transaction.Transaction.noAdminAccess", new Object[] { graph.getType() }));
}
} catch (Exception e) {
QueueAdminResponse response = new QueueAdminResponse();
response.setSource(graph);
ApplicationExceptions appExps = ExceptionHelper.extractApplicationExceptions(e);
if (appExps != null) {
if (log.isDebugEnabled()) {
log.debug("Error while toggling status of queue " + graph.getType(), appExps);
}
response.setErrors(ServiceError.generate(appExps));
} else {
log.error("Internal Error while toggling status of queue " + graph.getType(), e);
response.setErrors(ServiceError.generate(e));
}
if (output == null) {
output = new LinkedList<QueueAdminResponse>();
}
output.add(response);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Status of queue " + graph.getType() + " will not be toggled by this implementation, since the queue does not belong to this system");
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Status of queue " + graph.getType() + " will not be toggled by this implementation, since the input queueSystemId does not match this system");
}
}
}
if (log.isDebugEnabled()) {
log.debug("Output from toggleQueueStatus: " + output);
}
return output != null && output.size() > 0 ? output.toArray(new QueueAdminResponse[output.size()]) : null;
}
use of org.jaffa.qm.apis.data.QueueAdminResponse in project jaffa-framework by jaffa-projects.
the class JmsQueueAdmin method toggleQueueStatus.
/**
* NOTE: Each graph is expected to contain type. It may also contain the optional queueMetaData.queueSystemId, which may help optimize the process.
*/
public QueueAdminResponse[] toggleQueueStatus(QueueGraph[] graphs) {
if (log.isDebugEnabled())
log.debug("Input to toggleQueueStatus: " + Arrays.toString(graphs));
Collection<QueueAdminResponse> output = null;
String[] queueNames = null;
for (QueueGraph graph : graphs) {
if (graph.getQueueMetaData() == null || graph.getQueueMetaData().getQueueSystemId() == null || graph.getQueueMetaData().getQueueSystemId().equals(QUEUE_SYSTEM_ID)) {
// Initialize and sort the queueNames array; if not already done
if (queueNames == null) {
queueNames = ConfigurationService.getInstance().getQueueNames();
Arrays.sort(queueNames);
}
if (Arrays.binarySearch(queueNames, graph.getType()) >= 0) {
try {
if (!JmsBrowser.hasAdminMessageAccess(graph.getType()))
throw new JaffaMessagingApplicationException(JaffaMessagingApplicationException.NO_ADMIN_MESSAGE_ACESSS, new Object[] { graph.getType() });
if (ConfigurationService.getInstance().getQueueInfo(graph.getType()).getConsumerPolicy() == ConsumerPolicy.NONE) {
if (log.isDebugEnabled())
log.debug("ConsumerPolicy of queue " + graph.getType() + " is NONE. It's status cannnot be toggled");
}
} catch (Exception e) {
QueueAdminResponse response = new QueueAdminResponse();
response.setSource(graph);
ApplicationExceptions appExps = ExceptionHelper.extractApplicationExceptions(e);
if (appExps != null) {
if (log.isDebugEnabled())
log.debug("Error while toggling status of queue " + graph.getType(), appExps);
response.setErrors(ServiceError.generate(appExps));
} else {
log.error("Internal Error while toggling status of queue " + graph.getType(), e);
response.setErrors(ServiceError.generate(e));
}
if (output == null)
output = new LinkedList<QueueAdminResponse>();
output.add(response);
}
} else {
if (log.isDebugEnabled())
log.debug("Status of queue " + graph.getType() + " will not be toggled by this implementation, since the queue does not belong to this system");
}
} else {
if (log.isDebugEnabled())
log.debug("Status of queue " + graph.getType() + " will not be toggled by this implementation, since the input queueSystemId does not match this system");
}
}
if (log.isDebugEnabled())
log.debug("Output from toggleQueueStatus: " + output);
return output != null && output.size() > 0 ? output.toArray(new QueueAdminResponse[output.size()]) : null;
}
use of org.jaffa.qm.apis.data.QueueAdminResponse in project jaffa-framework by jaffa-projects.
the class QueueManager method toggleQueueStatus.
public QueueAdminResponse[] toggleQueueStatus(QueueGraph[] graphs) {
try {
if (log.isDebugEnabled())
log.debug("Input to toggleQueueStatus: " + graphs);
QueueAdminResponse[] aggregateResponse = null;
IQueueAdmin[] implementations = findImplementations();
if (implementations != null && implementations.length > 0) {
for (IQueueAdmin implementation : implementations) {
QueueAdminResponse[] response = implementation.toggleQueueStatus(graphs);
if (response != null && response.length > 0)
aggregateResponse = concatenate(aggregateResponse, response);
}
}
if (log.isDebugEnabled())
log.debug("Response from toggleQueueStatus: " + aggregateResponse);
return aggregateResponse;
} catch (Exception e) {
log.error("Error in obtaining IQueueAdmin implementations", e);
return new QueueAdminResponse[] { new QueueAdminResponse(null, ServiceError.generate(e)) };
}
}
Aggregations