001: /*
002: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.admin.cli.commands.search;
006:
007: import java.util.*;
008: import java.util.logging.Logger;
009: import java.util.logging.Level;
010:
011: import javax.management.MBeanServerConnection;
012: import javax.management.ObjectName;
013: import javax.management.InstanceNotFoundException;
014: import javax.management.MBeanException;
015: import javax.management.ReflectionException;
016:
017: import com.sun.enterprise.cli.framework.*;
018:
019: import com.sun.portal.admin.cli.commands.GenericCommand;
020: import com.sun.portal.admin.common.util.AdminUtil;
021:
022: /**
023: * This class implements the psadmin disable-robot-sites subcommand. The
024: * disable-robot-sites subcommand calls the PortalDomainMBean and performs
025: * the following tasks:
026: * <UL>
027: * <LI>disable robot sites
028: * <UL>
029: */
030:
031: public class DisableRobotSitesCommand extends GenericCommand {
032:
033: //command error messages
034:
035: //command options
036:
037: List siteIDs = null;
038:
039: public void runCommand() throws CommandException,
040: CommandValidationException {
041:
042: validateOptions();
043: validateSearchServerID();
044:
045: siteIDs = getMultiValueOption("sites");
046:
047: Boolean result = null;
048: try {
049: LinkedList path = new LinkedList();
050: //path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
051: path.addFirst(getDomainId());
052: path.addFirst(getSearchServerId());
053: path.addFirst("robot");
054: ObjectName objName = AdminUtil.getResourceMBeanObjectName(
055: AdminUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
056:
057: ArrayList ids = (ArrayList) siteIDs;
058:
059: Object[] params = { ids };
060: String[] signature = { "java.util.ArrayList" };
061:
062: MBeanServerConnection msc = getMBeanServerConnection(
063: getUserId(), getPassword(), getHost());
064:
065: result = (Boolean) msc.invoke(objName, "disableSites",
066: params, signature);
067: } catch (InstanceNotFoundException ie) {
068: //logger.logp(Level.SEVERE, "DisableRobotSitesCommand",
069: // "runCommand()", ie.getMessage(), ie);
070: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ie);
071: throw new CommandException(getLocalizedString(
072: ERROR_MBEAN_INSTANCE_NOT_FOUND,
073: new Object[] { "disableSites" }), ie);
074: } catch (MBeanException me) {
075: //logger.logp(Level.SEVERE, "DisableRobotSitesCommand",
076: // "runCommand()", me.getMessage(), me);
077: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", me);
078: throw new CommandException(getLocalizedString(
079: ERROR_JMX_INVOKE, new Object[] { "disableSites" }),
080: me);
081: } catch (ReflectionException re) {
082: //logger.logp(Level.SEVERE, "DisableRobotSitesCommand",
083: // "runCommand()", re.getMessage(), re);
084: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", re);
085: throw new CommandException(getLocalizedString(
086: ERROR_MBEAN_REFLECTION_ERROR,
087: new Object[] { "disableSites" }), re);
088: } catch (CommandException ce) {
089: //logger.logp(Level.SEVERE, "DisableRobotSitesCommand",
090: // "runCommand()", ce.getMessage(), ce);
091: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ce);
092: throw ce;
093: } catch (Exception ex) {
094: ex.printStackTrace();
095: //logger.logp(Level.SEVERE, "DisableRobotSitesCommand",
096: // "runCommand()", ex.getMessage(), ex);
097: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ex);
098: throw new CommandException(
099: getLocalizedString(COMMAND_FAILED), ex);
100: } finally {
101: closeMBeanServerConnection();
102: }
103: }
104:
105: }
|