use of cern.laser.business.definition.LaserDefinitionException in project ACS by ACS-Community.
the class CategoryDefinitionServiceImpl method updateCategory.
public void updateCategory(String userId, CategoryDefinition categoryDefinition) throws LaserDefinitionException {
if (categoryDefinition == null) {
throw new LaserDefinitionNotValidException("category is null");
}
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
Category category = categoryDAO.findCategoryByPath(categoryDefinition.getPath());
if (!admin_user.administersCategory(category.getCategoryId())) {
throw new LaserDefinitionNotAllowedException("not in category administrators : " + categoryDefinition);
}
try {
LOGGER.info("user " + admin_user.getName() + " updating category : " + categoryDefinition);
Category old_parent_category = categoryDAO.findCategoryByPath(categoryDefinition.getParentPath());
if (!category.getParentId().equals(old_parent_category.getCategoryId())) {
if (!admin_user.administersCategory(old_parent_category.getCategoryId()) || !admin_user.administersCategory(category.getParentId())) {
throw new LaserDefinitionNotAllowedException("not in category parent administrators : " + categoryDefinition);
}
old_parent_category.removeChildCategory(category);
Category new_parent_category = categoryDAO.findCategoryByPath(categoryDefinition.getParentPath());
new_parent_category.addChildCategory(category);
}
category.setDefinition(categoryDefinition);
categoryDAO.updateCategory(category);
LOGGER.info("category updated");
} catch (Exception e) {
throw new LaserDefinitionException("unable to update category " + categoryDefinition + " : " + e.getMessage(), e);
}
}
use of cern.laser.business.definition.LaserDefinitionException in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method removeAlarm.
public void removeAlarm(String userId, AlarmDefinition alarm) throws LaserDefinitionException {
removeAlarmInternal(userId, alarm);
Alarm alarm_obj = null;
try {
alarm_obj = alarmCache.getCopy(alarm.getAlarmId());
invalidateAlarm(alarm_obj);
propagateRemovedAlarm(alarm_obj);
} catch (Exception e) {
LOGGER.warn("unable to handle removed alarm " + alarm_obj.getTriplet() + " : " + e.getMessage());
}
}
use of cern.laser.business.definition.LaserDefinitionException in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method setMultiplicityThresholds.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.DefinitionServiceSessionEJB#setMultiplicityThresholds(java.lang.Integer,
* java.util.Collection)
*/
public void setMultiplicityThresholds(String userId, Collection thresholds) throws LaserDefinitionException {
if ((thresholds == null) || (thresholds.size() == 0)) {
return;
}
LOGGER.info("setting " + thresholds.size() + " multiplicity thresholds");
Iterator iterator = thresholds.iterator();
while (iterator.hasNext()) {
setMultiplicityThresholdEJB(userId, (MultiplicityThreshold) iterator.next());
}
LOGGER.info("multiplicity thresholds set");
iterator = thresholds.iterator();
while (iterator.hasNext()) {
try {
propagateMultiplicityThreshold((MultiplicityThreshold) iterator.next());
} catch (Exception e) {
LOGGER.error("unable to propagate multiplicity threshold", e);
}
}
LOGGER.info("multiplicity thresholds propagated");
}
use of cern.laser.business.definition.LaserDefinitionException in project ACS by ACS-Community.
the class SourceDefinitionServiceImpl method updateSource.
public void updateSource(String userId, SourceDefinition sourceDefinition) throws LaserDefinitionException {
if (sourceDefinition == null) {
throw new LaserDefinitionNotValidException("source is null");
}
Source source = null;
source = sourceDAO.findSource(sourceDefinition.getSourceId());
if (!sourceDefinition.getName().equals(source.getName())) {
throw new LaserDefinitionNotValidException("source name cannot be changed");
}
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
if (!admin_user.administersSource(source)) {
throw new LaserDefinitionNotAllowedException("not an administrator for source : " + sourceDefinition);
}
try {
LOGGER.info("user " + admin_user.getName() + " updating source : " + sourceDefinition);
source.setDefinition(sourceDefinition);
sourceDAO.updateSource(source);
String[] alarms = sourceDAO.getAlarms(source.getSourceId());
for (int i = 0; i < alarms.length; i++) {
try {
alarmCache.invalidate(alarms[i]);
} catch (Exception e) {
LOGGER.error("unable to propagate alarm source update", e);
}
}
LOGGER.info("source updated");
} catch (Exception e) {
throw new LaserDefinitionException("unable to update source " + sourceDefinition + " : " + e.getMessage(), e);
}
}
use of cern.laser.business.definition.LaserDefinitionException in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method createNodeLinkInternal.
private void createNodeLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
Alarm[] parent_child = validateReductionLink(link);
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
try {
LOGGER.info("user " + admin_user.getName() + " creating node link : " + link);
//alarmDAO.findAlarm(link.getParent().getAlarmId());
Alarm parent = parent_child[0];
//alarmDAO.findAlarm(link.getChild().getAlarmId());
Alarm child = parent_child[1];
parent.addNodeChild(child);
alarmDAO.updateAlarm(parent);
LOGGER.info("node link created");
} catch (Exception e) {
throw new LaserRuntimeException("unable to create the node link " + link + " : " + e.getMessage(), e);
}
}
Aggregations