Source Code Cross Referenced for ProvisionSRACommand.java in  » Portal » Open-Portal » com » sun » portal » admin » cli » commands » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.admin.cli.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ProvisionSRACommand.java
003:         *
004:         * Created on September 5, 2006, 10:06 AM
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package com.sun.portal.admin.cli.commands;
011:
012:        import javax.management.ObjectName;
013:        import javax.management.InstanceNotFoundException;
014:        import javax.management.MBeanException;
015:        import javax.management.MBeanServerConnection;
016:        import javax.management.MalformedObjectNameException;
017:
018:        import com.sun.portal.admin.common.util.AdminUtil;
019:        import com.sun.portal.admin.common.util.AdminClientUtil;
020:        import com.sun.portal.admin.common.PSMBeanException;
021:        import com.sun.portal.admin.common.PortalAttributes;
022:        import com.sun.portal.admin.common.InstanceAttributes;
023:        import com.sun.portal.admin.common.AttrOptionConstants;
024:
025:        import java.util.Collections;
026:        import java.util.Map;
027:        import java.util.HashMap;
028:        import java.util.List;
029:        import java.util.LinkedList;
030:        import java.util.ArrayList;
031:        import java.util.Set;
032:        import java.util.HashSet;
033:        import java.util.Iterator;
034:        import java.util.logging.Level;
035:        import java.util.Vector;
036:
037:        import com.sun.enterprise.cli.framework.CommandException;
038:        import com.sun.enterprise.cli.framework.CommandValidationException;
039:        import com.sun.enterprise.cli.framework.CLILogger;
040:
041:        /**
042:         *
043:         * @author root
044:         */
045:        public class ProvisionSRACommand extends AdminBaseCommand {
046:
047:            private static final String OPT_NAME = "gateway-profile";
048:            private static final String OPT_PORTAL = "portal";
049:            private static final String OPT_LB = "loadbalancer-url";
050:            private static final String OPT_CONSOLE = "console";
051:            private static final String OPT_CONSOLE_URL = "console-url";
052:            private static final String OPT_ENABLE = "enable";
053:            private static final String OPT_DISABLE = "disable";
054:            private static final String DEFAULT = "default";
055:            private static final String ERROR_PROFILE_NAME = "error.psadmin.invalid.profilename";
056:            private static final String ERROR_PROVISIONSRA_OPERAND = "error.psadmin.invalid.provision.sra.operand";
057:            private static final String ERROR_INSUFFICIENT_OPTIONS = "error.psadmin.insufficient.options";
058:            private static final String ERROR_INSTANCE_WITHOUT_PORTAL = "error.psadmin.provisionsra.invalid.usage1";
059:            private static final String ERROR_LB_AND_PORTAL = "error.psadmin.provisionsra.invalid.usage2";
060:            private static final String ERROR_CONSOLE = "error.psadmin.provisionsra.invalid.usage3";
061:            private static final String ERROR_CONSOLEURL_WITHOUT_CONSOLE = "error.psadmin.provisionsra.invalid.usage4";
062:            private static final String ERROR_SRA_STATUS_OFF = "error.psadmin.sra.status.off";
063:            private static final String ERROR_GET_SRA_STATUS = "error.psadmin.sra.status";
064:            private static final String ERROR_REQUIRED_OPTION = "error.psadmin.provisionsra.requiredoption";
065:            private static final String ERROR_ENABLE_DISABLE = "error.psadmin.provisionsra.invalid.usage5";
066:            private static final String ERROR_SET_COOKIEMANAGEMENT = "error.psadmin.set.cookiemanagement";
067:            private static final String ERROR_SET_FWDCOOKIEURL = "error.psadmin.set.fwdcookieurl";
068:            private static final String ERROR_SET_GWDOMAIN = "error.psadmin.set.gwdomain";
069:            private static final String ERROR_SET_NONAUTHURL = "error.psadmin.set.nonauthurl";
070:            private static final String ERROR_INVALID_CHOICE = "error.psadmin.provisionsra.invalid.usage6";
071:
072:            public void runCommand() throws CommandException,
073:                    CommandValidationException {
074:
075:                String instanceId = getInstanceId();
076:                String host = null;
077:                String port = null;
078:                String scheme = null;
079:                String instanceurl = null;
080:                String deployuri = null;
081:                Set urls = new HashSet();
082:                Set rulesetdata = new HashSet();
083:                Set fwdcookieurls = new HashSet();
084:                String portalId = getOption(OPT_PORTAL);
085:                String lburl = getOption(OPT_LB);
086:                String consoleurl = getOption(OPT_CONSOLE_URL);
087:                validateOptions();
088:
089:                if (!getBooleanOption(OPT_ENABLE)
090:                        && !getBooleanOption(OPT_DISABLE)) {
091:                    throw new CommandException(
092:                            getLocalizedString(ERROR_REQUIRED_OPTION));
093:                } else if (getBooleanOption(OPT_ENABLE)
094:                        && getBooleanOption(OPT_DISABLE)) {
095:                    throw new CommandException(
096:                            getLocalizedString(ERROR_ENABLE_DISABLE));
097:                }
098:
099:                if (lburl != null && portalId != null) {
100:                    throw new CommandException(
101:                            getLocalizedString(ERROR_LB_AND_PORTAL));
102:                }
103:
104:                if ((portalId == null) && (lburl == null)
105:                        && !getBooleanOption(OPT_CONSOLE)) {
106:                    throw new CommandException(
107:                            getLocalizedString(ERROR_INSUFFICIENT_OPTIONS));
108:                }
109:
110:                if (getBooleanOption(OPT_CONSOLE)) {
111:                    if ((portalId == null) && (lburl == null)
112:                            && (consoleurl == null)) {
113:                        throw new CommandException(
114:                                getLocalizedString(ERROR_CONSOLE));
115:                    }
116:                }
117:
118:                if (portalId != null) {
119:                    validatePortalId();
120:                }
121:
122:                if (instanceId != null) {
123:                    if (portalId == null) {
124:                        throw new CommandException(
125:                                getLocalizedString(ERROR_INSTANCE_WITHOUT_PORTAL));
126:                    }
127:                    validateInstance();
128:                }
129:
130:                if (consoleurl != null) {
131:                    if (!getBooleanOption(OPT_CONSOLE)) {
132:                        throw new CommandException(
133:                                getLocalizedString(ERROR_CONSOLEURL_WITHOUT_CONSOLE));
134:                    }
135:                }
136:                Vector v = getOperands();
137:
138:                try {
139:                    // Get the MBean server connection
140:                    MBeanServerConnection msc = getMBeanServerConnection(
141:                            getUserId(), getPassword(), getHost());
142:                    checkSRAStatus(msc);
143:                    validateProfileName(msc);
144:                    portalId = getPortalId();
145:                    //If the load balancer url is specified, populate values corresponding
146:                    //to that url
147:                    if (lburl != null) {
148:                        urls.addAll(getPortalURLs(lburl));
149:                        host = lburl.substring(lburl.indexOf("/") + 2, lburl
150:                                .lastIndexOf(":"));
151:                        String tmpstr = lburl
152:                                .substring(lburl.lastIndexOf(":") + 1);
153:                        port = tmpstr.substring(0, tmpstr.indexOf("/"));
154:                        deployuri = tmpstr.substring(tmpstr.indexOf("/") + 1);
155:                        rulesetdata.addAll(getDomainsAndRulesets(host, port,
156:                                deployuri));
157:                        fwdcookieurls.add(lburl + "/");
158:                        if (getBooleanOption(OPT_CONSOLE)) {
159:                            if (consoleurl != null) {
160:                                urls.addAll(getConsoleURLs(consoleurl));
161:                                rulesetdata
162:                                        .addAll(getConsoleDomainsAndRulesets(consoleurl));
163:                            } else {
164:                                String curl = lburl.substring(0, lburl
165:                                        .lastIndexOf("/"));
166:                                curl = curl + "/psconsole";
167:                                urls.addAll(getConsoleURLs(curl));
168:                                rulesetdata
169:                                        .addAll(getConsoleDomainsAndRulesets(curl));
170:                            }
171:                        }
172:                        doEnablePortal(msc, urls, rulesetdata, fwdcookieurls);
173:                    }
174:                    //If portalId alone is specified,
175:                    //thn populate values corresponding to all instances
176:                    else if (portalId != null && instanceId == null) {
177:                        List instances = getInstanceNames(portalId);
178:                        boolean flag = true;
179:                        Iterator it = instances.iterator();
180:                        urls = new HashSet();
181:                        rulesetdata = new HashSet();
182:                        fwdcookieurls = new HashSet();
183:                        //If console url is specified then use only that url
184:                        if (getBooleanOption(OPT_CONSOLE) && consoleurl != null) {
185:                            urls.addAll(getConsoleURLs(consoleurl));
186:                            rulesetdata
187:                                    .addAll(getConsoleDomainsAndRulesets(consoleurl));
188:                            flag = false;
189:                        }
190:                        while (it.hasNext()) {
191:                            instanceId = it.next().toString();
192:                            Map instancedetails = getInstanceDetails(msc,
193:                                    portalId, instanceId);
194:                            instanceurl = instancedetails.get("instanceurl")
195:                                    .toString();
196:                            urls.addAll(getPortalURLs(instanceurl));
197:                            host = instancedetails.get("host").toString();
198:                            port = instancedetails.get("port").toString();
199:                            deployuri = instancedetails.get("deployuri")
200:                                    .toString();
201:                            scheme = instancedetails.get("scheme").toString();
202:                            rulesetdata.addAll(getDomainsAndRulesets(host,
203:                                    port, deployuri));
204:                            fwdcookieurls.add(instanceurl + "/");
205:                            //If consoleurl is not present the populate console
206:                            //values corresponding to all instances
207:                            if (getBooleanOption(OPT_CONSOLE) && flag) {
208:                                String url = scheme + "://" + host + ":" + port
209:                                        + "/psconsole";
210:                                urls.addAll(getConsoleURLs(url));
211:                                rulesetdata
212:                                        .addAll(getConsoleDomainsAndRulesets(url));
213:                            }
214:                        }
215:                        doEnablePortal(msc, urls, rulesetdata, fwdcookieurls);
216:
217:                    }
218:                    //If both portalId and instanceId are present then populate values
219:                    //corresponding only to that instance
220:                    else if (portalId != null && instanceId != null) {
221:                        urls = new HashSet();
222:                        rulesetdata = new HashSet();
223:                        fwdcookieurls = new HashSet();
224:                        Map instancedetails = getInstanceDetails(msc, portalId,
225:                                instanceId);
226:                        instanceurl = instancedetails.get("instanceurl")
227:                                .toString();
228:                        urls.addAll(getPortalURLs(instanceurl));
229:                        host = instancedetails.get("host").toString();
230:                        port = instancedetails.get("port").toString();
231:                        deployuri = instancedetails.get("deployuri").toString();
232:                        scheme = instancedetails.get("scheme").toString();
233:                        rulesetdata.addAll(getDomainsAndRulesets(host, port,
234:                                deployuri));
235:                        fwdcookieurls.add(instanceurl + "/");
236:
237:                        if (getBooleanOption(OPT_CONSOLE)) {
238:                            if (consoleurl != null) {
239:                                urls.addAll(getConsoleURLs(consoleurl));
240:                                rulesetdata
241:                                        .addAll(getConsoleDomainsAndRulesets(consoleurl));
242:                            } else {
243:                                String url = scheme + "://" + host + ":" + port
244:                                        + "/psconsole";
245:                                urls.addAll(getConsoleURLs(url));
246:                                rulesetdata
247:                                        .addAll(getConsoleDomainsAndRulesets(url));
248:                            }
249:                        }
250:                        doEnablePortal(msc, urls, rulesetdata, fwdcookieurls);
251:                    } else if (getBooleanOption(OPT_CONSOLE)
252:                            && consoleurl != null) {
253:                        urls = new HashSet(getConsoleURLs(consoleurl));
254:                        rulesetdata = new HashSet(
255:                                getConsoleDomainsAndRulesets(consoleurl));
256:                        doEnablePortal(msc, urls, rulesetdata, fwdcookieurls);
257:                    } else {
258:                        throw new CommandException(
259:                                getLocalizedString(ERROR_INVALID_CHOICE));
260:                    }
261:
262:                } catch (CommandException ce) {
263:                    logger.log(Level.SEVERE, "PSALI_CSPACC0008", ce);
264:                    throw ce;
265:                } catch (MalformedObjectNameException mle) {
266:                    logger.log(Level.SEVERE, "PSALI_CSPACC0004", mle);
267:                    throw new CommandException(
268:                            getLocalizedString(ERROR_OBJECT_NAME), mle);
269:                } catch (Exception e) {
270:                    logger.log(Level.SEVERE, "PSALI_CSPACC0010", e);
271:                    throw new CommandException(
272:                            getLocalizedString(COMMAND_FAILED), e);
273:                }
274:            }
275:
276:            private void doEnablePortal(MBeanServerConnection msc, Set urls,
277:                    Set rulesetdata, Set fwdcookieurls) throws CommandException {
278:                try {
279:                    setNonAuthURLs(msc, urls);
280:                    setGatewayDomainsAndRulesets(msc, rulesetdata);
281:                    if (!fwdcookieurls.isEmpty()) {
282:                        setGatewayForwardCookieURL(msc, fwdcookieurls);
283:                    }
284:                    if (getBooleanOption(OPT_CONSOLE)) {
285:                        enableCookieManagement(msc);
286:                    }
287:                } catch (Exception e) {
288:                    throw new CommandException(e);
289:                }
290:            }
291:
292:            //This method sets the Non Authenticated URLs list of the SRA profile with
293:            //the portal and/or psconsole URLs.
294:            private void setNonAuthURLs(MBeanServerConnection mbsc, Set urls)
295:                    throws CommandException {
296:                try {
297:                    Map options = new HashMap();
298:                    options.put("adminuser", getOption("adminuser"));
299:                    options.put("password", getOption("password"));
300:                    options.put("component", "gateway");
301:                    options.put("gateway-profile", getOption(OPT_NAME));
302:                    options.put("attribute-name",
303:                            "sunPortalGatewayNonAuthenticatedURLPath");
304:                    if (getBooleanOption(OPT_ENABLE)) {
305:                        options.put(AttrOptionConstants.OPT_ADD, new ArrayList(
306:                                urls));
307:                    } else {
308:                        options.put(AttrOptionConstants.OPT_REMOVE,
309:                                new ArrayList(urls));
310:                    }
311:                    List values = Collections.EMPTY_LIST;
312:                    ObjectName objname = AdminUtil
313:                            .getPortalDomainMBeanObjectName(getDomainId());
314:                    Object[] params = { values, options };
315:                    String[] signature = { "java.util.List", "java.util.Map" };
316:                    String operation = "setAttribute";
317:                    Object returnValue = mbsc.invoke(objname, operation,
318:                            params, signature);
319:                } catch (MBeanException me) {
320:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", me);
321:                    boolean psmbe = me.getCause() instanceof  PSMBeanException;
322:                    if (psmbe) {
323:                        throw new CommandException(
324:                                getLocalizedString(((PSMBeanException) me
325:                                        .getCause()).getErrorKey()), me);
326:                    } else {
327:                        throw new CommandException(
328:                                getLocalizedString(ERROR_JMX_INVOKE), me);
329:                    }
330:                } catch (Exception e) {
331:                    throw new CommandException(
332:                            getLocalizedString(ERROR_SET_NONAUTHURL), e);
333:                }
334:            }
335:
336:            private void setGatewayDomainsAndRulesets(
337:                    MBeanServerConnection mbsc, Set data)
338:                    throws CommandException {
339:                try {
340:                    Map options = new HashMap();
341:                    options.put("adminuser", getOption("adminuser"));
342:                    options.put("password", getOption("password"));
343:                    options.put("component", "gateway");
344:                    options.put("gateway-profile", getOption(OPT_NAME));
345:                    options.put("attribute-name",
346:                            "sunPortalGatewayDomainsAndRulesets");
347:                    if (getBooleanOption(OPT_ENABLE)) {
348:                        options.put(AttrOptionConstants.OPT_ADD, new ArrayList(
349:                                data));
350:                    } else {
351:                        options.put(AttrOptionConstants.OPT_REMOVE,
352:                                new ArrayList(data));
353:                    }
354:                    List values = Collections.EMPTY_LIST;
355:                    ObjectName objname = AdminUtil
356:                            .getPortalDomainMBeanObjectName(getDomainId());
357:                    Object[] params = { values, options };
358:                    String[] signature = { "java.util.List", "java.util.Map" };
359:                    String operation = "setAttribute";
360:                    Object returnValue = mbsc.invoke(objname, operation,
361:                            params, signature);
362:                } catch (MBeanException me) {
363:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", me);
364:                    boolean psmbe = me.getCause() instanceof  PSMBeanException;
365:                    if (psmbe) {
366:                        throw new CommandException(
367:                                getLocalizedString(((PSMBeanException) me
368:                                        .getCause()).getErrorKey()), me);
369:                    } else {
370:                        throw new CommandException(
371:                                getLocalizedString(ERROR_JMX_INVOKE), me);
372:                    }
373:                } catch (Exception e) {
374:                    throw new CommandException(
375:                            getLocalizedString(ERROR_SET_GWDOMAIN), e);
376:                }
377:            }
378:
379:            private void setGatewayForwardCookieURL(MBeanServerConnection mbsc,
380:                    Set fwdcookieurls) throws CommandException {
381:                try {
382:                    Map options = new HashMap();
383:                    options.put("adminuser", getOption("adminuser"));
384:                    options.put("password", getOption("password"));
385:                    options.put("component", "gateway");
386:                    options.put("gateway-profile", getOption(OPT_NAME));
387:                    options.put("attribute-name",
388:                            "sunPortalGatewayForwardCookieURL");
389:                    if (getBooleanOption(OPT_ENABLE)) {
390:                        options.put(AttrOptionConstants.OPT_ADD, new ArrayList(
391:                                fwdcookieurls));
392:                    } else {
393:                        options.put(AttrOptionConstants.OPT_REMOVE,
394:                                new ArrayList(fwdcookieurls));
395:                    }
396:                    List values = Collections.EMPTY_LIST;
397:                    ObjectName objname = AdminUtil
398:                            .getPortalDomainMBeanObjectName(getDomainId());
399:                    Object[] params = { values, options };
400:                    String[] signature = { "java.util.List", "java.util.Map" };
401:                    String operation = "setAttribute";
402:                    Object returnValue = mbsc.invoke(objname, operation,
403:                            params, signature);
404:                } catch (MBeanException me) {
405:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", me);
406:                    boolean psmbe = me.getCause() instanceof  PSMBeanException;
407:                    if (psmbe) {
408:                        throw new CommandException(
409:                                getLocalizedString(((PSMBeanException) me
410:                                        .getCause()).getErrorKey()), me);
411:                    } else {
412:                        throw new CommandException(
413:                                getLocalizedString(ERROR_JMX_INVOKE), me);
414:                    }
415:                } catch (Exception e) {
416:                    throw new CommandException(
417:                            getLocalizedString(ERROR_SET_FWDCOOKIEURL), e);
418:                }
419:            }
420:
421:            private List getPortalURLs(String instanceurl) {
422:                List urls = new ArrayList();
423:                urls.add(instanceurl + "/images");
424:                urls.add(instanceurl + "/desktop/images");
425:                urls.add(instanceurl + "/desktop/tabs/images");
426:                urls.add(instanceurl + "/desktop/css");
427:                urls.add(instanceurl + "/console/images");
428:                urls.add(instanceurl + "/netlet/jnlpclient.jar");
429:                urls.add(instanceurl + "/netlet/netletjsse.jar");
430:                urls.add(instanceurl + "/proxylet/jnlpclient.jar");
431:                urls.add(instanceurl + "/proxylet/regx-win32-native.jar");
432:                return urls;
433:            }
434:
435:            private List getDomainsAndRulesets(String host, String port,
436:                    String uri) {
437:                List data = new ArrayList();
438:                String domain = host.substring(host.indexOf(".") + 1);
439:                data.add("*://*." + domain + "*" + uri
440:                        + "/*|default_gateway_ruleset");
441:                data.add("*" + uri + "/NetFileOpenFileServlet*|null_ruleset");
442:                data
443:                        .add("http*://*" + uri
444:                                + "/NetFileController*|null_ruleset");
445:                return data;
446:            }
447:
448:            private List getConsoleDomainsAndRulesets(String url) {
449:                List data = new ArrayList();
450:                data.add("*://" + url.substring(url.indexOf("/") + 2)
451:                        + "/*|default_gateway_ruleset");
452:                return data;
453:            }
454:
455:            private List getConsoleURLs(String instanceurl) {
456:                List urls = new ArrayList();
457:                urls.add(instanceurl + "/faces/js");
458:                urls.add(instanceurl + "/faces/css");
459:                urls.add(instanceurl + "/theme");
460:                urls.add(instanceurl
461:                        + "/theme/com/sun/web/ui/defaulttheme/javascript");
462:                urls.add(instanceurl + "/faces");
463:                urls.add(instanceurl + "/faces/fabric");
464:                urls.add(instanceurl + "/faces/desktop");
465:                urls.add(instanceurl
466:                        + "/theme/com/sun/web/ui/defaulttheme/images/masthead");
467:                urls.add(instanceurl + "/faces/common");
468:                urls.add(instanceurl
469:                        + "/theme/com/sun/web/ui/suntheme/images/favicon");
470:                urls.add(instanceurl + "/faces/logging");
471:                urls.add(instanceurl
472:                        + "/theme/com/sun/web/ui/defaulttheme/images/tabs");
473:                urls.add(instanceurl + "/faces/sra");
474:                urls.add(instanceurl);
475:                urls.add(instanceurl + "/faces/images");
476:                urls
477:                        .add(instanceurl
478:                                + "/theme/com/sun/web/ui/defaulttheme/css");
479:                urls.add(instanceurl
480:                        + "/theme/com/sun/web/ui/defaulttheme/images");
481:                return urls;
482:            }
483:
484:            private void enableCookieManagement(MBeanServerConnection mbsc)
485:                    throws CommandException {
486:                try {
487:                    Map options = new HashMap();
488:                    List values = new ArrayList();
489:                    options.put("adminuser", getOption("adminuser"));
490:                    options.put("password", getOption("password"));
491:                    options.put("component", "gateway");
492:                    options.put("gateway-profile", getOption(OPT_NAME));
493:                    options.put("attribute-name",
494:                            "sunPortalGatewayCookieManagement");
495:                    if (getBooleanOption(OPT_ENABLE)) {
496:                        values.add("true");
497:                    } else {
498:                        values.add("false");
499:                    }
500:                    ObjectName objname = AdminUtil
501:                            .getPortalDomainMBeanObjectName(getDomainId());
502:                    Object[] params = { values, options };
503:                    String[] signature = { "java.util.List", "java.util.Map" };
504:                    String operation = "setAttribute";
505:                    Object returnValue = mbsc.invoke(objname, operation,
506:                            params, signature);
507:                } catch (MBeanException me) {
508:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", me);
509:                    boolean psmbe = me.getCause() instanceof  PSMBeanException;
510:                    if (psmbe) {
511:                        throw new CommandException(
512:                                getLocalizedString(((PSMBeanException) me
513:                                        .getCause()).getErrorKey()), me);
514:                    } else {
515:                        throw new CommandException(
516:                                getLocalizedString(ERROR_JMX_INVOKE), me);
517:                    }
518:                } catch (Exception e) {
519:                    throw new CommandException(
520:                            getLocalizedString(ERROR_SET_COOKIEMANAGEMENT), e);
521:                }
522:            }
523:
524:            private Map getInstanceDetails(MBeanServerConnection msc,
525:                    String portalId, String instanceId) throws CommandException {
526:                String host = null;
527:                String port = null;
528:                String deployuri = null;
529:                String scheme = null;
530:                Map instancedetails = new HashMap();
531:
532:                try {
533:                    ObjectName objectName = AdminClientUtil
534:                            .getPortalMBeanObjectName(getDomainId(), portalId);
535:                    String[] signature = { "java.lang.String",
536:                            "java.lang.String" };
537:                    Object[] params = { AdminClientUtil.PORTAL_MBEAN_TYPE,
538:                            PortalAttributes.PORTAL_URI };
539:                    deployuri = (String) msc.invoke(objectName,
540:                            "getAttributeValue", params, signature);
541:                    instancedetails.put("deployuri", deployuri);
542:
543:                    ObjectName iObjectName = AdminClientUtil
544:                            .getInstanceMBeanObjectName(getDomainId(),
545:                                    portalId, instanceId);
546:                    Object[] params2 = {
547:                            AdminClientUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE,
548:                            InstanceAttributes.SCHEME };
549:                    scheme = (String) msc.invoke(iObjectName,
550:                            "getAttributeValue", params2, signature);
551:                    instancedetails.put("scheme", scheme);
552:                    Object[] params3 = {
553:                            AdminClientUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE,
554:                            InstanceAttributes.HOST };
555:                    host = (String) msc.invoke(iObjectName,
556:                            "getAttributeValue", params3, signature);
557:                    instancedetails.put("host", host);
558:                    Object[] params4 = {
559:                            AdminClientUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE,
560:                            InstanceAttributes.PORT };
561:                    port = (String) msc.invoke(iObjectName,
562:                            "getAttributeValue", params4, signature);
563:                    instancedetails.put("port", port);
564:                    instancedetails.put("instanceurl", scheme + "://" + host
565:                            + ":" + port + deployuri);
566:
567:                    return instancedetails;
568:                } catch (Exception ex) {
569:                    logger.log(Level.SEVERE, "PSALI_CSPACC0010", ex);
570:                    Object tokens[] = { portalId };
571:                    throw new CommandException(getLocalizedString(
572:                            ERROR_MBEAN_REFLECTION_ERROR, tokens));
573:                }
574:            }
575:
576:            private void validateProfileName(MBeanServerConnection msc)
577:                    throws MalformedObjectNameException, CommandException {
578:                try {
579:                    String profilename = getOption(OPT_NAME);
580:                    String host = getHost();
581:                    // Setting the params and signature and invoke validate method
582:                    Object[] params = { host, profilename };
583:                    String[] signature = { "java.lang.String",
584:                            "java.lang.String" };
585:                    LinkedList path = new LinkedList();
586:                    path.addFirst(getDomainId());
587:                    path.addFirst("sra");
588:                    ObjectName objName = AdminClientUtil
589:                            .getResourceMBeanObjectName(
590:                                    AdminClientUtil.SRA_MBEAN_TYPE, path);
591:                    String method = "checkProfileExists";
592:                    Object returnValue = msc.invoke(objName, method, params,
593:                            signature);
594:                } catch (Exception e) {
595:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", e);
596:                    throw new CommandException(
597:                            getLocalizedString(ERROR_PROFILE_NAME), e);
598:                }
599:            }
600:
601:            private void checkSRAStatus(MBeanServerConnection msc)
602:                    throws CommandException {
603:                try {
604:                    Object[] params = new Object[] {};
605:                    String[] signature = new String[] {};
606:                    String method = "retrieveSRAStatus";
607:                    LinkedList path = new LinkedList();
608:                    path.addFirst(getDomainId());
609:                    path.addFirst("sra");
610:                    ObjectName objName = AdminClientUtil
611:                            .getResourceMBeanObjectName(
612:                                    AdminClientUtil.SRA_MBEAN_TYPE, path);
613:                    Object returnValue = msc.invoke(objName, method, params,
614:                            signature);
615:                    if (returnValue.toString().equals("off")) {
616:                        throw new CommandException(
617:                                getLocalizedString(ERROR_SRA_STATUS_OFF));
618:                    }
619:                } catch (Exception e) {
620:                    throw new CommandException(
621:                            getLocalizedString(ERROR_GET_SRA_STATUS));
622:                }
623:            }
624:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.