001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.desktop.dp.cli;
006:
007: import java.util.Map;
008: import java.util.List;
009: import java.util.logging.Level;
010: import java.util.logging.Logger;
011:
012: import com.sun.portal.desktop.context.AdminDPContext;
013: import com.sun.portal.desktop.context.DPContext;
014:
015: import com.sun.portal.desktop.dp.DPRoot;
016: import com.sun.portal.desktop.dp.DPPropertyHolder;
017:
018: import com.sun.portal.desktop.dp.xml.XMLDPFactory;
019: import com.sun.portal.desktop.dp.xml.XMLDPRoot;
020: import com.sun.portal.log.common.PortalLogger;
021:
022: import java.util.logging.Logger;
023: import java.util.logging.Level;
024:
025: class DPAList {
026:
027: private static Logger logger = PortalLogger
028: .getLogger(DPAList.class);
029: // XML DP Factory
030: XMLDPFactory dpf = XMLDPFactory.getInstance();
031:
032: public String process(AdminDPContext adc, String dn,
033: boolean global, String name, boolean verbose, Logger logger)
034: throws DPAException {
035:
036: if (verbose) {
037: Object[] tokens = { global ? DPAUtil
038: .getLocalizedString("msgGlobal") : dn };
039: logger.log(Level.FINEST, "PSDT_CSPDDC0001", tokens);
040: }
041:
042: String doc = null;
043: try {
044: if (!global) {
045: doc = adc.getDPDocument(dn);
046:
047: } else {
048: doc = adc.getGlobalDPDocument();
049:
050: }
051: if (doc == null || doc.length() == 0) {
052: return null;
053: }
054: if (name == null) {
055: return doc.toString();
056: }
057: } catch (Throwable ex) {
058: Object[] tokens = { global ? DPAUtil
059: .getLocalizedString("msgGlobal") : dn };
060: throw new DPAException("errorRetrieveDP", ex, tokens);
061: }
062:
063: if (verbose) {
064: Object[] tokens = { global ? DPAUtil
065: .getLocalizedString("msgGlobal") : dn };
066: logger.log(Level.FINEST, "PSDT_CSPDDC0002", tokens);
067: }
068: DPRoot dpr = null;
069: try {
070: dpr = dpf.createRoot(adc, doc);
071: } catch (Throwable ex) {
072: Object[] tokens = { global ? DPAUtil
073: .getLocalizedString("msgGlobal") : dn };
074: throw new DPAException("errorCreateDPRoot", ex, tokens);
075: }
076:
077: if (verbose) {
078: Object[] tokens = { name };
079: logger.log(Level.FINEST, "PSDT_CSPDDC0003", tokens);
080: }
081:
082: DPPropertyHolder ph = null;
083: try {
084: XMLDPRoot xdpr = (XMLDPRoot) dpr;
085: ph = xdpr.getChannelFromThis(name);
086: if (ph == null) {
087: ph = xdpr.getProviderFromThis(name);
088: }
089: } catch (Throwable ex) {
090: Object[] tokens = { name };
091: throw new DPAException("errorFindPropertyHolder", ex,
092: tokens);
093: }
094: if (ph != null) {
095: StringBuffer sb = new StringBuffer(256);
096: ph.toXML(sb, 0);
097: return sb.toString();
098: } else {
099: return null;
100: }
101: }
102:
103: }
|