1 /* 2 * This file is part of *** M y C o R e *** 3 * See http://www.mycore.de/ for details. 4 * 5 * MyCoRe is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * MyCoRe is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with MyCoRe. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 package org.mycore.datamodel.common; 20 21 import java.util.Collection; 22 import java.util.Map; 23 import java.util.concurrent.ConcurrentHashMap; 24 import java.util.concurrent.ConcurrentLinkedQueue; 25 26 import org.mycore.common.MCRCatchException; 27 28 /** 29 * This exception holds information about a link condition that did not allow a 30 * certain action to be performed. 31 * 32 * As this exception does not extend RuntimeException it has to be caught for 33 * data integrity reasons. 34 * 35 * @author Thomas Scheffler (yagee) 36 */ 37 public class MCRActiveLinkException extends MCRCatchException { 38 39 /** 40 * 41 */ 42 private static final long serialVersionUID = 1L; 43 44 Map<String, Collection<String>> linkTable = new ConcurrentHashMap<>(); 45 46 /** 47 * 48 * @return a Hashtable with destinations (key) and List of sources (value) 49 */ 50 public Map<String, Collection<String>> getActiveLinks() { 51 return linkTable; 52 } 53 54 /** 55 * collects information on active links that do not permit a certain action 56 * on the repository. 57 * 58 * @param source 59 * the source of a link 60 * @param dest 61 * the destination of a link 62 */ 63 public void addLink(String source, String dest) { 64 if (!linkTable.containsKey(dest)) { 65 linkTable.put(dest, new ConcurrentLinkedQueue<>()); 66 } 67 linkTable.get(dest).add(source); 68 } 69 70 /** 71 * @see MCRCatchException#MCRCatchException(String) 72 */ 73 public MCRActiveLinkException(String message) { 74 super(message); 75 } 76 77 /** 78 * @see MCRCatchException#MCRCatchException(String, Throwable) 79 */ 80 public MCRActiveLinkException(String message, Throwable cause) { 81 super(message, cause); 82 } 83 84 }