KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > servermgmt > pe > PEWebCoreDomainsManager


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.servermgmt.pe;
25 import java.util.Map JavaDoc;
26 import java.util.Vector JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.io.File JavaDoc;
29
30 import com.iplanet.ias.installer.core.installConfig;
31 import com.iplanet.ias.installer.core.ServerConfig;
32 import com.sun.enterprise.admin.servermgmt.DomainsManager;
33 import com.sun.enterprise.admin.servermgmt.InstancesManager;
34 import com.sun.enterprise.admin.servermgmt.DomainConfig;
35 import com.sun.enterprise.admin.servermgmt.DomainException;
36
37 public class PEWebCoreDomainsManager extends DomainsManager
38 {
39     private static final String JavaDoc SERVER_ID = "server";
40
41     public PEWebCoreDomainsManager()
42     {
43     }
44
45     public void createDomain(String JavaDoc domainName, Map JavaDoc domainConfig)
46         throws DomainException
47     {
48         // validate(domainConfig);
49

50         // construct the ServerConfig obj, since validation succeeded
51
ServerConfig sc = createServerConfig(domainConfig);
52         
53         // create the actual domain directory, under the domain root
54
File JavaDoc domainDir = new File JavaDoc(sc.domainRoot);
55         domainDir.mkdirs();
56
57         // Assuming that the native libraries have been loaded by the installer
58
installConfig instconf = new installConfig();
59         
60         // invoke the createDomain on installConfig
61
instconf.createServerInstance(sc);
62     }
63
64     private void validate(Map JavaDoc domainConfig) throws DomainException
65     {
66         final String JavaDoc domainRoot =
67             (String JavaDoc)domainConfig.get(DomainConfig.K_DOMAIN_ROOT);
68         if ((domainRoot == null) || (domainRoot.length() == 0))
69         {
70             throw new DomainException("Invalid domain root");
71         }
72         /* Do we need this?
73         if (!(new File(domainRoot).exists()))
74         {
75             throw new DomainException("Domain root doesnot exist");
76         }
77          **/

78     }
79
80     public void deleteDomain(String JavaDoc domainName, Map JavaDoc domainConfig)
81         throws DomainException
82     {
83         String JavaDoc domainRoot = (String JavaDoc) domainConfig.get(DomainConfig.K_DOMAIN_ROOT);
84         try {
85             installConfig instconf = new installConfig();
86             instconf.deleteDomain(domainName, domainRoot);
87         } catch(java.io.IOException JavaDoc ioe) {
88             throw new DomainException("Error deleting domain: "+domainName);
89         }
90     }
91
92     public void startDomain(String JavaDoc domainName, Map JavaDoc domainConfig)
93         throws DomainException
94     {
95     }
96
97     public void stopDomain(String JavaDoc domainName, Map JavaDoc domainConfig)
98         throws DomainException
99     {
100     }
101
102     /**
103      * Lists all the domains.
104      */

105     public String JavaDoc[] listDomains()
106     {
107         String JavaDoc[] domains = new String JavaDoc[0];
108         return domains;
109     }
110
111     public InstancesManager getInstancesManager(String JavaDoc domainName)
112     {
113         throw new UnsupportedOperationException JavaDoc("Not Supported for PE");
114     }
115
116     public boolean isDomainExists(String JavaDoc domainName, String JavaDoc domainRoot)
117     {
118         return new File JavaDoc(domainRoot, domainName).exists();
119     }
120
121     private ServerConfig createServerConfig(Map JavaDoc domainConfig)
122     {
123         ServerConfig sc = new ServerConfig();
124         sc.defaultLocale = (String JavaDoc) domainConfig.get(DomainConfig.K_DEFAULTLOCALE);
125         sc.icuLib = (String JavaDoc) domainConfig.get(DomainConfig.K_ICULIB);
126         sc.webServicesLib = (String JavaDoc) domainConfig.get(DomainConfig.K_WEBSVCSLIB);
127         sc.perlRoot = (String JavaDoc) domainConfig.get(DomainConfig.K_PERLROOT);
128         sc.serverID = PEWebCoreDomainsManager.SERVER_ID;
129         sc.serverPort = ((Integer JavaDoc) domainConfig.get(DomainConfig.K_INSTANCE_PORT)).intValue();
130         sc.adminPort = ((Integer JavaDoc) domainConfig.get(DomainConfig.K_ADMIN_PORT)).intValue();
131         sc.serverRoot = (String JavaDoc) domainConfig.get(DomainConfig.K_INSTALL_ROOT);
132         sc.domainRoot = (String JavaDoc) domainConfig.get(DomainConfig.K_DOMAIN_ROOT);
133         sc.serverUser = (String JavaDoc) domainConfig.get(DomainConfig.K_SVRUSER);
134         sc.serverUserFlag = ((Boolean JavaDoc) domainConfig.get(DomainConfig.K_SVRUSERFLAG)).booleanValue();
135         sc.serverName = (String JavaDoc) domainConfig.get(DomainConfig.K_SVRNAME);
136         sc.domainName = (String JavaDoc) domainConfig.get(DomainConfig.K_DOMAIN_NAME);
137         sc.mailHost = (String JavaDoc) domainConfig.get(DomainConfig.K_MAIL_HOST);
138         sc.docRoot = sc.domainRoot + File.separator + "docroot";
139
140         sc.jmsPort = ((Integer JavaDoc) domainConfig.get(DomainConfig.K_JMS_PORT)).intValue();
141         sc.jmsUser = (String JavaDoc) domainConfig.get(DomainConfig.K_JMS_USER);
142         sc.jmsPasswd = (String JavaDoc) domainConfig.get(DomainConfig.K_JMS_PASSWORD);
143         sc.imqBin = (String JavaDoc) domainConfig.get(DomainConfig.K_IMQ_BIN);
144         sc.imqLib = (String JavaDoc) domainConfig.get(DomainConfig.K_IMQ_LIB);
145         sc.javaHome = (String JavaDoc) domainConfig.get(DomainConfig.K_JAVA_HOME);
146         sc.orbListenerPort = ((Integer JavaDoc) domainConfig.get(DomainConfig.K_ORB_LISTENER_PORT)).intValue();
147         sc.configRoot = (String JavaDoc) domainConfig.get(DomainConfig.K_CFG_ROOT);
148         sc.adminName = (String JavaDoc) domainConfig.get(DomainConfig.K_USER);
149         sc.adminPasswd = (String JavaDoc) domainConfig.get(DomainConfig.K_PASSWORD);
150         sc.ldapUser = (String JavaDoc) domainConfig.get(DomainConfig.K_LDAP_USER);
151         sc.ldapURL = (String JavaDoc) domainConfig.get(DomainConfig.K_LDAP_URL);
152         sc.ldapPasswd = (String JavaDoc) domainConfig.get(DomainConfig.K_LDAP_PASSWD);
153         sc.ldapDN = (String JavaDoc) domainConfig.get(DomainConfig.K_LDAP_DN);
154         
155         return sc;
156     }
157 }
158
Popular Tags