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 enable-robot-sites subcommand. The
024: * enable-robot-sites subcommand calls the PortalDomainMBean and performs
025: * the following tasks:
026: * <UL>
027: * <LI>enable robot sites
028: * <UL>
029: */
030:
031: public class EnableRobotSitesCommand extends GenericCommand {
032:
033: //public Logger logger = super.getLogger();
034:
035: //command error messages
036:
037: //command options
038:
039: List siteIDs = null;
040:
041: public void runCommand() throws CommandException,
042: CommandValidationException {
043:
044: validateOptions();
045: validateSearchServerID();
046:
047: siteIDs = getMultiValueOption("sites");
048:
049: Boolean result = null;
050: try {
051: LinkedList path = new LinkedList();
052: //path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
053: path.addFirst(getDomainId());
054: path.addFirst(getSearchServerId());
055: path.addFirst("robot");
056: ObjectName objName = AdminUtil.getResourceMBeanObjectName(
057: AdminUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
058:
059: ArrayList ids = (ArrayList) siteIDs;
060:
061: Object[] params = { ids };
062: String[] signature = { "java.util.ArrayList" };
063:
064: MBeanServerConnection msc = getMBeanServerConnection(
065: getUserId(), getPassword(), getHost());
066:
067: result = (Boolean) msc.invoke(objName, "enableSites",
068: params, signature);
069: } catch (InstanceNotFoundException ie) {
070: //logger.logp(Level.SEVERE, "EnableRobotSitesCommand",
071: //"runCommand()", ie.getMessage(), ie);
072: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ie);
073: throw new CommandException(getLocalizedString(
074: ERROR_MBEAN_INSTANCE_NOT_FOUND,
075: new Object[] { "enableSites" }), ie);
076: } catch (MBeanException me) {
077: //logger.logp(Level.SEVERE, "EnableRobotSitesCommand",
078: // "runCommand()", me.getMessage(), me);
079: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", me);
080: throw new CommandException(getLocalizedString(
081: ERROR_JMX_INVOKE, new Object[] { "enableSites" }),
082: me);
083: } catch (ReflectionException re) {
084: //logger.logp(Level.SEVERE, "EnableRobotSitesCommand",
085: // "runCommand()", re.getMessage(), re);
086: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", re);
087: throw new CommandException(getLocalizedString(
088: ERROR_MBEAN_REFLECTION_ERROR,
089: new Object[] { "enableSites" }), re);
090: } catch (CommandException ce) {
091: //logger.logp(Level.SEVERE, "EnableRobotSitesCommand",
092: // "runCommand()", ce.getMessage(), ce);
093: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ce);
094: throw ce;
095: } catch (Exception ex) {
096: ex.printStackTrace();
097: //logger.logp(Level.SEVERE, "EnableRobotSitesCommand",
098: // "runCommand()", ex.getMessage(), ex);
099: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ex);
100: throw new CommandException(
101: getLocalizedString(COMMAND_FAILED), ex);
102: } finally {
103: closeMBeanServerConnection();
104: }
105: }
106:
107: }
|