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