Search in sources :

Example 1 with AlarmCacheException

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

Example 2 with AlarmCacheException

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);
        }
    }
}
Also used : CategoryActiveList(cern.laser.business.data.CategoryActiveList) Iterator(java.util.Iterator) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 3 with AlarmCacheException

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;
}
Also used : Alarm(cern.laser.business.data.Alarm) ArrayList(java.util.ArrayList) Collection(java.util.Collection) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserProcessingException(cern.laser.business.LaserProcessingException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 4 with AlarmCacheException

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;
}
Also used : Alarm(cern.laser.business.data.Alarm) ArrayList(java.util.ArrayList) Collection(java.util.Collection) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserProcessingException(cern.laser.business.LaserProcessingException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 5 with AlarmCacheException

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;
}
Also used : Alarm(cern.laser.business.data.Alarm) ArrayList(java.util.ArrayList) Collection(java.util.Collection) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Aggregations

AlarmCacheException (cern.laser.business.cache.AlarmCacheException)15 Alarm (cern.laser.business.data.Alarm)14 Collection (java.util.Collection)10 ArrayList (java.util.ArrayList)9 LaserRuntimeException (cern.laser.business.LaserRuntimeException)8 LaserProcessingException (cern.laser.business.LaserProcessingException)6 Category (cern.laser.business.data.Category)3 Iterator (java.util.Iterator)3 AdminUser (cern.laser.business.data.AdminUser)2 CategoryActiveList (cern.laser.business.data.CategoryActiveList)2 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)2 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)2 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)2 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)1 ProcessingController (cern.laser.business.ProcessingController)1 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)1 HashSet (java.util.HashSet)1