Search in sources :

Example 1 with LaserDefinitionException

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);
    }
}
Also used : LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) Category(cern.laser.business.data.Category) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) AdminUser(cern.laser.business.data.AdminUser) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 2 with LaserDefinitionException

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());
    }
}
Also used : Alarm(cern.laser.business.data.Alarm) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 3 with LaserDefinitionException

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");
}
Also used : Iterator(java.util.Iterator) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 4 with LaserDefinitionException

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);
    }
}
Also used : LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) AdminUser(cern.laser.business.data.AdminUser) Source(cern.laser.business.data.Source) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException)

Example 5 with LaserDefinitionException

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);
    }
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Aggregations

LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)11 LaserDefinitionException (cern.laser.business.definition.LaserDefinitionException)11 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)11 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)10 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)10 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)8 AdminUser (cern.laser.business.data.AdminUser)8 LaserRuntimeException (cern.laser.business.LaserRuntimeException)6 Alarm (cern.laser.business.data.Alarm)5 Category (cern.laser.business.data.Category)4 Source (cern.laser.business.data.Source)3 Iterator (java.util.Iterator)2 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)1 AlarmDefinition (cern.laser.business.definition.data.AlarmDefinition)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1