01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.admin.cli.commands.search;
06:
07: import java.util.*;
08: import java.util.logging.Logger;
09: import java.util.logging.Level;
10:
11: import javax.management.MBeanServerConnection;
12: import javax.management.ObjectName;
13: import javax.management.InstanceNotFoundException;
14: import javax.management.MBeanException;
15: import javax.management.ReflectionException;
16:
17: import com.sun.enterprise.cli.framework.*;
18:
19: import com.sun.portal.admin.cli.commands.GenericCommand;
20: import com.sun.portal.admin.common.util.AdminUtil;
21:
22: /**
23: * This class implements the psadmin delete-robot-sites subcommand. The
24: * delete-robot-sites subcommand calls the PortalDomainMBean and performs
25: * the following tasks:
26: * <UL>
27: * <LI>delete robot sites
28: * <UL>
29: */
30:
31: public class DeleteRobotSitesCommand extends GenericCommand {
32:
33: List siteIDs = null;
34:
35: public void runCommand() throws CommandException,
36: CommandValidationException {
37:
38: validateOptions();
39: validateSearchServerID();
40:
41: siteIDs = getMultiValueOption("sites");
42:
43: Boolean result = null;
44: try {
45: LinkedList path = new LinkedList();
46: //path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
47: path.addFirst(getDomainId());
48: path.addFirst(getSearchServerId());
49: path.addFirst("robot");
50: ObjectName objName = AdminUtil.getResourceMBeanObjectName(
51: AdminUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
52:
53: ArrayList ids = (ArrayList) siteIDs;
54:
55: Object[] params = { ids };
56: String[] signature = { "java.util.ArrayList" };
57:
58: MBeanServerConnection msc = getMBeanServerConnection(
59: getUserId(), getPassword(), getHost());
60:
61: result = (Boolean) msc.invoke(objName, "deleteSites",
62: params, signature);
63: } catch (InstanceNotFoundException ie) {
64: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ie);
65: throw new CommandException(getLocalizedString(
66: ERROR_MBEAN_INSTANCE_NOT_FOUND,
67: new Object[] { "deleteSites" }), ie);
68: } catch (MBeanException me) {
69: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", me);
70: throw new CommandException(getLocalizedString(
71: ERROR_JMX_INVOKE, new Object[] { "deleteSites" }),
72: me);
73: } catch (ReflectionException re) {
74: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", re);
75: throw new CommandException(getLocalizedString(
76: ERROR_MBEAN_REFLECTION_ERROR,
77: new Object[] { "deleteSites" }), re);
78: } catch (CommandException ce) {
79: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ce);
80: throw ce;
81: } catch (Exception ex) {
82: ex.printStackTrace();
83: logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ex);
84: throw new CommandException(
85: getLocalizedString(COMMAND_FAILED), ex);
86: } finally {
87: closeMBeanServerConnection();
88: }
89: }
90:
91: }
|