Search in sources :

Example 6 with AlarmCacheException

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

Example 7 with AlarmCacheException

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");
}
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) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException)

Example 8 with AlarmCacheException

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;
}
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 9 with AlarmCacheException

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;
}
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 10 with AlarmCacheException

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

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