001 /**
002 *
003 * $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
004 *
005 * This file is part of ** M y C o R e **
006 * Visit our homepage at http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, normally in the file license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 *
023 **/
024
025 package org.mycore.datamodel.common;
026
027 import java.util.Collection;
028 import java.util.Map;
029 import java.util.concurrent.ConcurrentHashMap;
030 import java.util.concurrent.ConcurrentLinkedQueue;
031
032 import org.mycore.common.MCRCatchException;
033
034 /**
035 * This exception holds information about a link condition that did not allow a
036 * certain action to be performed.
037 *
038 * As this exception does not extend RuntimeException it has to be caught for
039 * data integrity reasons.
040 *
041 * @author Thomas Scheffler (yagee)
042 */
043 public class MCRActiveLinkException extends MCRCatchException {
044
045 /**
046 *
047 */
048 private static final long serialVersionUID = 1L;
049
050 Map<String, Collection<String>> linkTable = new ConcurrentHashMap<String, Collection<String>>();
051
052 /**
053 *
054 * @return a Hashtable with destinations (key) and List of sources (value)
055 */
056 public Map<String, Collection<String>> getActiveLinks() {
057 return linkTable;
058 }
059
060 /**
061 * collects information on active links that do not permit a certain action
062 * on the repository.
063 *
064 * @param source
065 * the source of a link
066 * @param dest
067 * the destination of a link
068 */
069 public void addLink(String source, String dest) {
070 if (!linkTable.containsKey(dest)) {
071 linkTable.put(dest, new ConcurrentLinkedQueue<String>());
072 }
073 linkTable.get(dest).add(source);
074 }
075
076 /**
077 * @see MCRCatchException#MCRCatchException(String)
078 */
079 public MCRActiveLinkException(String message) {
080 super(message);
081 }
082
083 /**
084 * @see MCRCatchException#MCRCatchException(String, Throwable)
085 */
086 public MCRActiveLinkException(String message, Throwable cause) {
087 super(message, cause);
088 }
089
090 }