001: /**
002: * Copyright 2003 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */package com.sun.portal.wsrp.consumer.cli;
013:
014: import java.util.logging.Level;
015: import java.util.logging.Logger;
016:
017: import com.sun.portal.wsrp.common.stubs.RegistrationContext;
018:
019: import com.sun.portal.wsrp.consumer.common.WSRPConsumerException;
020:
021: import com.sun.portal.wsrp.consumer.producermanager.ProducerEntityManager;
022: import com.sun.portal.wsrp.consumer.producermanager.ProducerEntity;
023: import com.sun.portal.wsrp.consumer.producermanager.InbandRegistrationNotSupportedException;
024: import com.sun.portal.log.common.PortalLogger;
025:
026: class PEARemove {
027:
028: private static Logger logger = PortalLogger
029: .getLogger(PEARemove.class);
030:
031: public void process(ProducerEntityManager pem, String dn,
032: String pid, boolean verbose) throws PEAException {
033:
034: if (logger.isLoggable(Level.FINEST)) {
035: Object[] tokens = { pid };
036: logger.log(Level.FINEST, "PSWS_CSPWCCL0020", tokens);
037: }
038:
039: ProducerEntity pe = null;
040: try {
041: pe = pem.getProducerEntity(pid);
042: } catch (WSRPConsumerException wce) {
043: Object[] tokens = { dn, pid };
044: throw new PEAException("errorGetPE", wce, tokens);
045: }
046:
047: if (pe == null) {
048: Object[] tokens = { dn, pid };
049: throw new PEAException("errorInvalidPID", tokens);
050: }
051:
052: boolean outofband = false;
053: try {
054: outofband = !pem.isInbandRegistrationSupported(pe.getURL());
055: } catch (WSRPConsumerException wce) {
056: throw new PEAException(wce);
057: }
058:
059: if (!outofband) {
060: //
061: // in-band mode
062: //
063: try {
064: pem.removeProducerEntity(pid);
065: } catch (InbandRegistrationNotSupportedException irnse) {
066: Object[] tokens = { dn, pe.getURL() };
067: throw new PEAException("errorNoInband", irnse, tokens);
068: } catch (WSRPConsumerException wce) {
069: Object[] tokens = { dn, pid };
070: throw new PEAException("errorRemovePE", wce, tokens);
071: }
072: } else {
073: //
074: // out-of-band mode: retrieve reghandle and remind user
075: // to manually deregister w/ the producer
076: //
077: RegistrationContext regContext = pe
078: .getRegistrationContext();
079:
080: if (regContext == null) {
081: Object[] tokens = { dn, pid };
082: throw new PEAException("errorGetRegContext", tokens);
083: }
084:
085: String regHandle = regContext.getRegistrationHandle();
086:
087: if (regHandle == null) {
088: Object[] tokens = { dn, pid };
089: throw new PEAException("errorGetRegHandle", tokens);
090: }
091:
092: try {
093: pem.eliminateProducerEntity(pid);
094: } catch (WSRPConsumerException wce) {
095: Object[] tokens = { dn, pid };
096: throw new PEAException("errorRemovePE", wce, tokens);
097: }
098:
099: //
100: // remind user to deregister
101: //
102: if (verbose) {
103: Object[] tokens = { dn, pe.getURL(), regHandle };
104: PEAUtil.warning("warnDeregister", tokens);
105: }
106: }
107:
108: //
109: // TBD: what to do w/ display profile?
110: //
111: }
112: }
|