use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method getActiveNodeChildren.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getActiveNodeChildren(java.lang.Integer)
*/
public Collection getActiveNodeChildren(String parentId) {
Collection result = null;
try {
Alarm parent = alarmCache.getReference(parentId);
String[] children = parent.getNodeChildren();
result = new ArrayList(children.length);
for (int i = 0; i < children.length; i++) {
Alarm alarm = alarmCache.getReference(children[i]);
if (alarm.getStatus().getActive().booleanValue())
result.add(alarm);
}
} catch (AlarmCacheException onf) {
LOGGER.warn("node parent " + parentId + " not found");
result = new ArrayList();
}
return result;
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CategoryDefinitionServiceImpl method removeCategoryLink.
public void removeCategoryLink(String userId, CategoryLink link) throws LaserDefinitionException {
if (link == null) {
throw new LaserDefinitionNotValidException("category/alarm link is null");
}
if (link.getCategory() == null) {
throw new LaserDefinitionNotValidException("malformed category/alarm link: category is null");
}
if (link.getAlarm() == null) {
throw new LaserDefinitionNotValidException("malformed category/alarm link: alarm is null");
}
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
Category category = categoryDAO.getCategoryByPath(link.getCategory().getPath());
if (category == null) {
throw new LaserDefinitionNotFoundException("category with path " + link.getCategory().getPath() + " does not exist");
}
if (!admin_user.administersCategory(category.getCategoryId())) {
throw new LaserDefinitionNotAllowedException("not an administrators for the category : " + link.getCategory());
}
Alarm alarm = alarmDAO.getAlarm(link.getAlarm().getAlarmId());
if (alarm == null) {
throw new LaserDefinitionNotFoundException("alarm " + link.getAlarm().getAlarmId() + " does not exist");
}
if (!category.containsAlarm(alarm)) {
throw new LaserDefinitionNotFoundException("category/alarm link not defined : " + link);
}
try {
LOGGER.info("user " + admin_user.getName() + " removing category link : " + link);
category.removeAlarm(alarm);
categoryDAO.flushCategory();
alarmCache.invalidate(alarm.getAlarmId());
// Alarm surveillance_alarm = alarmDAO.findAlarm(alarm.getSource().getSurveillanceAlarmId());
// if (!categoryDAO.hasAlarmsForSource(category.getCategoryId(), alarm.getSource().getSourceId())) {
// category.removeAlarm(surveillance_alarm);
// alarmCache.invalidate(surveillance_alarm.getAlarmId());
// }
// categoryDAO.updateCategory(category);
} catch (AlarmCacheException e) {
LOGGER.error("unable to propagate category/alarm link : " + link, e);
}
LOGGER.info("category/alarm link removed");
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method getNodeParents.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getNodeParents(java.lang.Integer)
*/
public Collection getNodeParents(String childId) {
Collection result = null;
try {
Alarm child = alarmCache.getReference(childId);
String[] parents = child.getNodeParents();
result = new ArrayList(parents.length);
for (int i = 0; i < parents.length; i++) {
Alarm alarm = alarmCache.getReference(parents[i]);
result.add(alarm);
}
} catch (AlarmCacheException onf) {
LOGGER.warn("node child " + childId + " not found");
result = new ArrayList();
} catch (Exception e) {
LOGGER.error("unable to get node parents for child " + childId, e);
//throw new EJBException("unable to get node parents for child " + childId, e);
}
return result;
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method getNodeChildren.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getNodeChildren(java.lang.Integer)
*/
public Collection getNodeChildren(String parentId) {
Collection result = null;
try {
Alarm parent = alarmCache.getReference(parentId);
String[] children = parent.getNodeChildren();
result = new ArrayList(children.length);
for (int i = 0; i < children.length; i++) {
Alarm alarm = alarmCache.getReference(children[i]);
result.add(alarm);
}
} catch (AlarmCacheException onf) {
LOGGER.warn("node parent " + parentId + " not found");
result = new ArrayList();
} catch (Exception e) {
LOGGER.error("unable to get node children for parent " + parentId, e);
//throw new EJBException("unable to get node children for parent " + parentId, e);
}
return result;
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method search.
/**
* @param categoryIds
* @param sql
* @param clientId
*/
public void search(Integer[] categoryIds, String sql, String clientId) {
String destination = getSearchRootTopic() + "." + clientId;
String category_constraints = buildCategorySQLFilter(categoryIds);
String select_sql = "select alarm_id from alarm_definition where " + sql + " and alarm_id in " + "(select alarm_id from alarm_category where " + category_constraints + ")";
if (LOGGER.isDebugEnabled())
LOGGER.debug("search sql : " + select_sql);
Collection search_result = alarmDAO.search(select_sql);
if (LOGGER.isDebugEnabled())
LOGGER.debug("found " + search_result.size() + " alarms");
Collection found_alarms = new ArrayList(search_result.size());
try {
for (Iterator iter = search_result.iterator(); iter.hasNext(); ) {
Alarm alarm = alarmCache.getReference((String) iter.next());
found_alarms.add(alarm);
}
} catch (AlarmCacheException e) {
throw new LaserRuntimeException("unable to search alarms", e);
}
alarmPublisher.sendSearch(found_alarms, destination);
}
Aggregations