001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * any nuclear facility.
035: */
036:
037: package com.sun.portal.community;
038:
039: import java.util.Iterator;
040: import java.util.List;
041: import java.util.ArrayList;
042: import java.util.Set;
043: import java.util.LinkedHashSet;
044: import java.util.Map;
045: import java.util.HashMap;
046:
047: public class CommunityServiceException extends Exception {
048:
049: private List entries = null;
050: private Map dpMap = null;
051:
052: public CommunityServiceException(Map dpRoots) {
053:
054: // clone
055: if (dpRoots != null) {
056: dpMap = new HashMap();
057: for (Iterator i = dpRoots.keySet().iterator(); i.hasNext();) {
058: Object key = i.next();
059: dpMap.put(key, dpRoots.get(key));
060: }
061: }
062: }
063:
064: public List getEntries() {
065: return entries;
066: }
067:
068: public Map getDPRoots() {
069: return dpMap;
070: }
071:
072: public Set getServiceNames() {
073: Set names = new LinkedHashSet();
074: if (entries != null) {
075: for (Iterator i = entries.iterator(); i.hasNext();) {
076: CommunityServiceExceptionEntry cse = (CommunityServiceExceptionEntry) i
077: .next();
078: names.add(cse.getServiceName());
079: }
080: }
081: return names;
082: }
083:
084: public void addEntry(CommunityServiceExceptionEntry entry) {
085: if (entries == null) {
086: entries = new ArrayList();
087: }
088: entries.add(entry);
089: }
090:
091: public void addEntry(String communityId, String serviceName,
092: Throwable t) {
093: if (entries == null) {
094: entries = new ArrayList();
095: }
096: entries.add(new CommunityServiceExceptionEntry(communityId,
097: serviceName, t));
098: }
099:
100: public void addEntries(List entries) {
101: if (entries == null) {
102: this.entries = entries;
103: } else {
104: this.entries.add(entries);
105: }
106: }
107: }
|