use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CategoryDefinitionServiceImpl method createCategoryLink.
public void createCategoryLink(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 exists");
}
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 with id " + link.getAlarm().getAlarmId() + " does not exist");
}
Alarm surveillance_alarm = alarmDAO.findAlarm(alarm.getSource().getSurveillanceAlarmId());
if (category.containsAlarm(alarm)) {
throw new LaserDefinitionDuplicationException("alarm/category link already defined : " + link);
}
LOGGER.info("user " + admin_user.getName() + " creating alarm/category link : " + link);
category.addAlarm(alarm);
category.addAlarm(surveillance_alarm);
categoryDAO.updateCategory(category);
try {
alarmCache.invalidate(alarm.getAlarmId());
alarmCache.invalidate(surveillance_alarm.getAlarmId());
} catch (AlarmCacheException e) {
LOGGER.error("unable to propagate category link : " + link, e);
}
LOGGER.info("link created");
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class ACSAlarmCacheImpl method updateCategoryActiveLists.
/**
* Update the CategoryActiveList for the alarm: all the CategoryActiveLists
* of the categories of the alarm will be updated.
* The alarmId is inserted or removed in the CategoryActiveList depending
* of the status of the alarm
*
* @param alarm The alarm whose id must be inserted or removed for the
* CategoryActiveLists of its categories
*/
private void updateCategoryActiveLists(Alarm alarm) {
if (alarm.getStatus() == null || alarm.getStatus().getActive() == null) {
throw new IllegalArgumentException("Invalid alarm: status and/or status.active null");
}
boolean status = alarm.getStatus().getActive().booleanValue();
String alarmId = alarm.getAlarmId();
Iterator categoryIterator = alarm.getCategories().iterator();
while (categoryIterator.hasNext()) {
Integer categoryId = (Integer) ((Category) categoryIterator.next()).getCategoryId();
CategoryActiveList catList = null;
try {
catList = getActiveListReference(categoryId);
} catch (AlarmCacheException ace) {
// In this implementation no exception can be thrown
// by getActiveListReference
// I write a message in case someone changes the things
System.err.println("Exception " + ace.getMessage());
ace.printStackTrace();
continue;
}
if (status) {
catList.addAlarm(alarmId);
} else {
catList.removeAlarm(alarmId);
}
}
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method getMultiplicityChildren.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getMultiplicityChildren(java.lang.Integer)
*/
public Collection getMultiplicityChildren(String parentId) {
Collection result = null;
try {
Alarm parent = alarmCache.getReference(parentId);
String[] children = parent.getMultiplicityChildren();
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("multiplicity parent " + parentId + " not found");
result = new ArrayList();
} catch (Exception e) {
LOGGER.error("unable to get multiplicity children for " + parentId, e);
//throw new EJBException("unable to get multiplicity children for " + parentId, e);
}
return result;
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method getMultiplicityParents.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getMultiplicityParents(java.lang.Integer)
*/
public Collection getMultiplicityParents(String childId) {
Collection result = null;
try {
Alarm child = alarmCache.getReference(childId);
String[] parents = child.getMultiplicityParents();
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("multiplicity child " + childId + " not found");
result = new ArrayList();
} catch (Exception e) {
LOGGER.error("unable to get multiplicity parents for child " + childId, e);
//throw new EJBException("unable to get multiplicity parents for child " + childId, e);
}
return result;
}
use of cern.laser.business.cache.AlarmCacheException in project ACS by ACS-Community.
the class CoreServiceImpl method getActiveMultiplicityChildren.
public Collection getActiveMultiplicityChildren(String parentId) {
Collection result = null;
try {
Alarm parent = alarmCache.getReference(parentId);
String[] children = parent.getMultiplicityChildren();
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("multiplicity parent " + parentId + " not found");
result = new ArrayList();
}
return result;
}
Aggregations