Search in sources :

Example 56 with Alarm

use of cern.laser.business.data.Alarm in project ACS by ACS-Community.

the class AlarmDefinitionServiceImpl method propagateRemovedAlarm.

private void propagateRemovedAlarm(Alarm alarm) {
    try {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("propagating removed alarm : " + alarm.getTriplet());
        if (alarm.getStatus().getActive().booleanValue()) {
            Alarm terminated = (Alarm) ((AlarmImpl) alarm).clone();
            terminated.getStatus().setActive(Boolean.FALSE);
            terminated.getStatus().setSourceHostname("LASER");
            Timestamp now = new Timestamp(System.currentTimeMillis());
            terminated.getStatus().setSourceTimestamp(now);
            terminated.getStatus().setSystemTimestamp(now);
            terminated.getStatus().setUserTimestamp(now);
            terminated.getStatus().getProperties().clear();
            terminated.getStatus().getProperties().setProperty("REMOVED_BOOL", "TRUE");
            alarmPublisher.publish(new AlarmChange(terminated, alarm));
            alarmMessageProcessor.notifyReductionRelatives(alarm);
        }
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("propagated");
    } catch (Exception e) {
        LOGGER.error("unable to propagate removed alarm " + alarm.getTriplet() + " : " + e.getMessage());
    }
}
Also used : AlarmChange(cern.laser.business.data.AlarmChange) Alarm(cern.laser.business.data.Alarm) Timestamp(java.sql.Timestamp) 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 57 with Alarm

use of cern.laser.business.data.Alarm 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 58 with Alarm

use of cern.laser.business.data.Alarm 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 59 with Alarm

use of cern.laser.business.data.Alarm 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 60 with Alarm

use of cern.laser.business.data.Alarm 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

Alarm (cern.laser.business.data.Alarm)91 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)24 LaserRuntimeException (cern.laser.business.LaserRuntimeException)21 ArrayList (java.util.ArrayList)21 Category (cern.laser.business.data.Category)16 Collection (java.util.Collection)14 AlarmImpl (cern.laser.business.data.AlarmImpl)13 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)12 AdminUser (cern.laser.business.data.AdminUser)11 AlarmDefinition (alma.alarmsystem.alarmmessage.generated.AlarmDefinition)10 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)10 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)10 Iterator (java.util.Iterator)10 LaserProcessingException (cern.laser.business.LaserProcessingException)9 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)9 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)7 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)7 FaultCode (alma.acs.alarmsystem.generated.FaultCode)6 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)6 FaultMember (alma.acs.alarmsystem.generated.FaultMember)6