01: /*
02: * RegistryPublishCommand.java
03: *
04: * Copyright 2005 Sun Microsystems, Inc. All
05: * rights reserved. Use of this product is subject
06: * to license terms. Federal Acquisitions:
07: * Commercial Software -- Government Users
08: * Subject to Standard License Terms and
09: * Conditions.
10: *
11: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
12: * are trademarks or registered trademarks of Sun Microsystems,
13: * Inc. in the United States and other countries.
14: *
15: */
16:
17: package com.sun.portal.admin.cli.commands.wsrp;
18:
19: import com.sun.portal.admin.cli.commands.GenericCommand;
20: import java.util.Properties;
21: import java.util.List;
22: import java.util.ArrayList;
23:
24: import com.sun.enterprise.cli.framework.*;
25:
26: public class RegistryPublishCommand extends GenericCommand {
27:
28: private static final String OPT_PUBLISH_ALL_PORTLETS = "allportlets";
29: private static final String OPT_PORTLETS = "portlets";
30: private static final String OPT_COMPONENT = "component";
31: private static final String OPT_COMPONENT_VALUE = "producer";
32: private static final String LIST_PORTLETS_CLASS_NAME = ArrayList.class
33: .getName();
34:
35: public boolean validateOptions() throws CommandValidationException {
36: if (super .validateOptions() == false) {
37: return false;
38: }
39:
40: String component = getOption(OPT_COMPONENT);
41:
42: if (!component.equals(OPT_COMPONENT_VALUE)) {
43: return false;
44: }
45:
46: return true;
47: }
48:
49: protected Object[] getParamsInfo() throws CommandException,
50: CommandValidationException {
51:
52: Object[] params = super .getParamsInfo();
53: boolean publishAllPortlets = getBooleanOption(OPT_PUBLISH_ALL_PORTLETS);
54:
55: int i = getIndexOfPortletsParam(params);
56: if (publishAllPortlets && i != -1) {
57: List portlets = new ArrayList();
58: //Constant defined in common.registry.RegistryConstants
59: //TODO : Check if its fine to introduce dependency
60: portlets.add("com.sun.portal.wsrp.portlets.publish.all");
61: params[i] = portlets;
62: }
63: return params;
64: }
65:
66: private int getIndexOfPortletsParam(Object[] params) {
67: Object param = null;
68: for (int i = 0; i < params.length; i++) {
69: param = params[i];
70: //This is serious hack. If the return class name changes this will fail
71: //TODO : Find betterway to handle this.
72: if ((param != null)
73: && (param.getClass().getName()
74: .equals(LIST_PORTLETS_CLASS_NAME))) {
75: return i;
76: }
77: }
78: return -1;
79: }
80: }
|