1 /* 2 * #%L 3 * Bitrepository Integration 4 * 5 * $Id: AlarmDispatcher.java 627 2011-12-09 15:13:13Z jolf $ 6 * $HeadURL: https://sbforge.org/svn/bitrepository/bitrepository-reference/trunk/bitrepository-reference-pillar/src/main/java/org/bitrepository/pillar/messagehandler/AlarmDispatcher.java $ 7 * %% 8 * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark 9 * %% 10 * This program is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as 12 * published by the Free Software Foundation, either version 2.1 of the 13 * License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Lesser Public License for more details. 19 * 20 * You should have received a copy of the GNU General Lesser Public 21 * License along with this program. If not, see 22 * <http://www.gnu.org/licenses/lgpl-2.1.html>. 23 * #L% 24 */ 25 package org.bitrepository.integrityservice.alerter; 26 27 import org.bitrepository.bitrepositoryelements.Alarm; 28 import org.bitrepository.bitrepositoryelements.AlarmCode; 29 import org.bitrepository.common.settings.Settings; 30 import org.bitrepository.protocol.messagebus.MessageSender; 31 import org.bitrepository.service.AlarmDispatcher; 32 import org.bitrepository.settings.referencesettings.AlarmLevel; 33 34 /** 35 * The class for dispatching alarms in the integrity service. 36 */ 37 public class IntegrityAlarmDispatcher extends AlarmDispatcher implements IntegrityAlerter { 38 39 /** 40 * Delegates to the AlarmDispatcher dispatcher. 41 * @param settings The settings to use. 42 * @param sender Used for sending the alarms. 43 * @param alarmLevel Only send alarms at this alarms level or higher. 44 */ 45 public IntegrityAlarmDispatcher(Settings settings, MessageSender sender, AlarmLevel alarmLevel) { 46 super(settings, sender, alarmLevel); 47 } 48 49 @Override 50 public void operationFailed(String issue, String collectionID) { 51 Alarm ad = new Alarm(); 52 ad.setAlarmCode(AlarmCode.FAILED_OPERATION); 53 ad.setAlarmText(issue); 54 ad.setCollectionID(collectionID); 55 error(ad); 56 } 57 58 @Override 59 public void integrityFailed(String summary, String collectionID) { 60 Alarm ad = new Alarm(); 61 ad.setAlarmCode(AlarmCode.INTEGRITY_ISSUE); 62 ad.setAlarmText(summary); 63 ad.setCollectionID(collectionID); 64 error(ad); 65 } 66 }