KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > common > CommonInfoModel


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.tools.upgrade.common;
25
26 import java.io.*;
27 import java.util.*;
28 import java.util.logging.*;
29 import com.sun.enterprise.tools.upgrade.logging.*;
30 import com.sun.enterprise.util.i18n.StringManager;
31 import com.sun.enterprise.tools.upgrade.certconversion.ProcessAdaptor;
32 import com.sun.enterprise.tools.upgrade.cluster.*;
33
34 /**
35  *
36  * author : Gautam Borah
37  *
38  */

39
40 public class CommonInfoModel{
41     public static final String JavaDoc DOMAINS = "domains";
42     public static final String JavaDoc CONFIG = "config";
43     private static final String JavaDoc CERT_FILE_NAME = "keystore.jks";
44     private static final String JavaDoc TRUSTED_KEY_STORE = "cacerts.jks";
45     private static final String JavaDoc LICENSE_FILE = "LICENSE.txt";
46     private static final String JavaDoc NUMBERSTRING = "0123456789";
47     
48     private StringManager stringManager = StringManager.getManager(LogService.UPGRADE_LOGGER);
49     /**
50      * Information specific to the certificate transformation module
51      **/

52     private static Logger logger=LogService.getLogger(LogService.UPGRADE_LOGGER);
53     private String JavaDoc[] CERT_ALIASES;
54     private String JavaDoc SOURCE_INSTALL_DIR;
55     private boolean sourceInputAsDomainRoot;
56     private boolean enlistDomain;
57     private String JavaDoc TARGET_INSTALL_DIR;
58     private String JavaDoc InstallConfig70;
59     private boolean certificateConversionFlag=false;
60     private List domainList;
61     private List domainOptionList;
62     private String JavaDoc targetDomainRoot;
63     private String JavaDoc sourceDomainRoot="";
64     private String JavaDoc currentDomain;
65     private String JavaDoc currentSourceServerInstance = "";
66     private String JavaDoc osName;
67     
68     // This is filled in only for EE
69
private String JavaDoc currentCluster;
70     
71     // domainMapping stores domain name as key and domain path (..../domains/domain1) as value
72
private Hashtable domainMapping;
73     private Map domainNSSPwdMapping;
74     private Map domainTargetNSSPwdMapping;
75     private Map domainJKSPwdMapping;
76     private Map domainJKSCAPwdMapping;
77     private Map domainssPwdFileMapping;
78     private Map domainTargetnssPwdFileMapping;
79     private Map domainNameMapping;
80     private String JavaDoc sourceVersionEdition;
81     private String JavaDoc targetVersionEdition;
82     
83     // These are needed to create instances.
84
private String JavaDoc adminUserName = null;
85     private String JavaDoc adminPassword = null;
86     private File passwordFile = null;
87     private String JavaDoc passwordFilePath = null;
88     private String JavaDoc masterPassword = "changeit";
89     
90     public CommonInfoModel(){
91         domainList = new ArrayList();
92         domainOptionList = new ArrayList();
93         domainNSSPwdMapping = new HashMap();
94         domainTargetNSSPwdMapping = new HashMap();
95         domainJKSPwdMapping = new HashMap();
96         domainJKSCAPwdMapping = new HashMap();
97         domainssPwdFileMapping= new HashMap();
98         domainTargetnssPwdFileMapping= new HashMap();
99         domainNameMapping= new HashMap();
100     }
101     
102     public void setTargetDomainRoot(String JavaDoc targetDomainsRoot) {
103         if(targetDomainRoot != null && targetDomainRoot.equals(targetDomainsRoot))
104             return;
105         this.targetDomainRoot=targetDomainsRoot;
106         try {
107             String JavaDoc logPath = targetDomainRoot+File.separator+"upgrade.log";
108             logger.info(stringManager.getString("common.log.redirect") + logPath);
109             LogService.initialize(logPath);
110         } catch(Exception JavaDoc e) {
111             logger.warning(e.getLocalizedMessage());
112         }
113     }
114     
115     public String JavaDoc getTargetDomainRoot() {
116         return targetDomainRoot;
117     }
118     
119     public void setSourceDomainRoot(String JavaDoc sourceDomainRoot) {
120         this.sourceDomainRoot=sourceDomainRoot;
121     }
122     
123     public String JavaDoc getSourceDomainRoot() {
124         return sourceDomainRoot;
125     }
126     public String JavaDoc getSourceDomainPath(){
127         //String path = SOURCE_INSTALL_DIR + File.separator + DOMAINS + File.separator + currentDomain;
128
return ((DomainInfo)getDomainMapping().get(currentDomain)).getDomainPath();
129     }
130     
131     public String JavaDoc getSourceInstancePath(){
132         //return getSourceDomainPath() + File.separator + getCurrentSourceInstance();
133
return ((DomainInfo)this.getDomainMapping().get(this.getCurrentDomain())).getInstancePath(this.getCurrentSourceInstance());
134     }
135     
136     public String JavaDoc getCurrentSourceInstance() {
137         return currentSourceServerInstance;
138     }
139     
140     public void setCurrentSourceInstance(String JavaDoc server) {
141         currentSourceServerInstance = server;
142     }
143     
144     public String JavaDoc getTargetConfig() {
145         String JavaDoc config = getTargetDomainRoot() + File.separator + (String JavaDoc)domainNameMapping.get(currentDomain) + File.separator + CONFIG;
146         return config;
147     }
148     
149     public String JavaDoc getTargetJKSKeyStorePath(){
150         String JavaDoc path = getTargetDomainRoot() + File.separator + (String JavaDoc)domainNameMapping.get(currentDomain) + File.separator + CONFIG + File.separator + CERT_FILE_NAME;
151         return path;
152     }
153     
154     public String JavaDoc getTargetTrustedJKSKeyStorePath(){
155         String JavaDoc path = getTargetDomainRoot() + File.separator + (String JavaDoc)domainNameMapping.get(currentDomain) + File.separator + CONFIG + File.separator + TRUSTED_KEY_STORE;
156         return path;
157     }
158     
159     public String JavaDoc getSourceJKSKeyStorePath(){
160         String JavaDoc path = getSourceDomainPath() + File.separator + CONFIG + File.separator + CERT_FILE_NAME;
161         return path;
162     }
163     
164     public String JavaDoc getSourceTrustedJKSKeyStorePath(){
165         String JavaDoc path = getSourceDomainPath() + File.separator + CONFIG + File.separator + TRUSTED_KEY_STORE;
166         return path;
167     }
168     
169     public String JavaDoc getDestinationDomainPath(){
170         return getDestinationDomainPath(this.currentDomain);
171     }
172     public String JavaDoc getDestinationDomainPath(String JavaDoc domainName){
173         String JavaDoc path = getTargetDomainRoot() + File.separator + (String JavaDoc)domainNameMapping.get(domainName);
174         return path;
175     }
176     
177     public void addDomainName(String JavaDoc domainName){
178         domainList.add(domainName);
179     }
180     
181     public List getDomainList(){
182         return domainList;
183     }
184     
185     public void addDomainOptionName(String JavaDoc domainName){
186         domainOptionList.add(domainName);
187     }
188     
189     public List getDomainOptionList(){
190         return domainOptionList;
191     }
192     
193     public String JavaDoc getCurrentDomain(){
194         return currentDomain;
195     }
196     public void setCurrentDomain(String JavaDoc domainName){
197         currentDomain=domainName;
198     }
199     
200     public boolean getCertificateConversionFlag() {
201         return certificateConversionFlag;
202     }
203     
204     public void setCertificateConversionFlag(boolean flag){
205         certificateConversionFlag=flag;
206     }
207     
208     public String JavaDoc getSourceInstallDir() {
209         return SOURCE_INSTALL_DIR;
210     }
211     
212     public String JavaDoc getTargetInstallDir() {
213         return TARGET_INSTALL_DIR;
214     }
215     
216     public void setSourceInstallDir(String JavaDoc src) {
217         SOURCE_INSTALL_DIR = src;
218     }
219     
220     public void setTargetInstallDir(String JavaDoc tgt) {
221         TARGET_INSTALL_DIR = tgt;
222     }
223     
224     /**
225      * Get the password for the NSS certificate database. If this is an NSS to NSS or NSS to JKS migration, the
226      * String returned will be the source server password and getTargetCertDbPassword() will return
227      * the target db password. If JKS to NSS, returns the target certificate db password.
228      * @return String certpassword - the certificate password for the current domain and instance or null if the current
229      * instance does not have a password, and should not be included in the cert migration.
230      */

231     public String JavaDoc getCertDbPassword() {
232         Map instanceNSSPwdMap = (Map)domainNSSPwdMapping.get(currentDomain);
233         return (String JavaDoc)instanceNSSPwdMap.get(currentSourceServerInstance);
234     }
235     
236     public void setCertDbPassword(String JavaDoc pwd) {
237         setCertDbPassword(currentDomain, currentSourceServerInstance, pwd);
238     }
239     
240     public void setCertDbPassword(String JavaDoc domain, String JavaDoc pwd) {
241         setCertDbPassword(domain, currentSourceServerInstance, pwd);
242     }
243     
244     public void setCertDbPassword(String JavaDoc domain, String JavaDoc instance, String JavaDoc pwd) {
245         Map instanceNssPwdMap = (Map)domainNSSPwdMapping.get(domain);
246         if(instanceNssPwdMap == null) {
247             instanceNssPwdMap = new HashMap();
248         }
249         instanceNssPwdMap.put(instance, pwd);
250         domainNSSPwdMapping.put(domain,instanceNssPwdMap);
251     }
252     
253     public String JavaDoc getTargetCertDbPassword() {
254         return (String JavaDoc)domainTargetNSSPwdMapping.get(currentDomain);
255     }
256     
257     public void setTargetCertDbPassword(String JavaDoc pwd) {
258         domainTargetNSSPwdMapping.put(currentDomain,pwd);
259         //NSS_DB_PASSWORD=pwd;
260
}
261     public void setTargetCertDbPassword(String JavaDoc domain, String JavaDoc pwd) {
262         domainTargetNSSPwdMapping.put(domain,pwd);
263     }
264     
265     public String JavaDoc[] getCertAliases() {
266         return CERT_ALIASES;
267     }
268     
269     public String JavaDoc getJksKeystorePassword() {
270         return (String JavaDoc)domainJKSPwdMapping.get((String JavaDoc)domainNameMapping.get(currentDomain));
271     }
272     
273     public void setJksKeystorePassword(String JavaDoc pwd) {
274         domainJKSPwdMapping.put((String JavaDoc)domainNameMapping.get(currentDomain),pwd);
275         //JKS_DB_PASSWORD=pwd;
276
}
277     public void setJksKeystorePassword(String JavaDoc domain, String JavaDoc pwd) {
278         domainJKSPwdMapping.put((String JavaDoc)domainNameMapping.get(currentDomain),pwd);
279     }
280     
281     public String JavaDoc getJksCAKeystorePassword() {
282         return (String JavaDoc)domainJKSCAPwdMapping.get((String JavaDoc)domainNameMapping.get(currentDomain));
283     }
284     
285     public void setJksCAKeystorePassword(String JavaDoc pwd) {
286         domainJKSCAPwdMapping.put((String JavaDoc)domainNameMapping.get(currentDomain),pwd);
287     }
288     
289     public void setJksCAKeystorePassword(String JavaDoc domain, String JavaDoc pwd) {
290         domainJKSCAPwdMapping.put((String JavaDoc)domainNameMapping.get(currentDomain),pwd);
291     }
292     
293     public Hashtable getDomainMapping() {
294         return domainMapping;
295     }
296     
297     public void setDomainMapping(Hashtable domainMapping) {
298         this.domainMapping = domainMapping;
299     }
300     
301     public String JavaDoc getOSName() {
302         return osName;
303     }
304     
305     public void setOSName(String JavaDoc osName){
306         this.osName = osName;
307     }
308     
309     public String JavaDoc getNSSPwdFile() {
310         return (String JavaDoc)domainssPwdFileMapping.get(currentDomain);
311     }
312     
313     public void setNSSPwdFile(String JavaDoc pwdFile){
314         domainTargetnssPwdFileMapping.put(currentDomain,pwdFile);
315     }
316     
317     public String JavaDoc getTargetNSSPwdFile() {
318         return (String JavaDoc)domainTargetnssPwdFileMapping.get(currentDomain);
319     }
320     
321     public void setTargetNSSPwdFile(String JavaDoc pwdFile){
322         domainTargetnssPwdFileMapping.put(currentDomain,pwdFile);
323     }
324     
325     public void setInstallConfig70(String JavaDoc config) {
326         InstallConfig70 = config;
327     }
328     
329     public String JavaDoc getInstallConfig70() {
330         return InstallConfig70;
331     }
332     public Map getTargetDomainNameMapping(){
333         return domainNameMapping;
334     }
335     /**
336      * @return a logger to use in the Module implementation classes
337      */

338     public static Logger getDefaultLogger() {
339         if (logger==null) {
340             logger = LogService.getLogger(LogService.UPGRADE_LOGGER);
341         }
342         return logger;
343     }
344     
345     public boolean isUpgradeJKStoJKS() {
346         if (getTargetEdition().equals(UpgradeConstants.EDITION_PE)) {
347             if (getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS80_PE) ||
348                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS81_PE)) {
349                 return true;
350             }
351         }
352         return false;
353     }
354     
355     public boolean isUpgradeJKStoNSS() {
356         if (getTargetEdition().equals(UpgradeConstants.EDITION_EE) ||
357                 getTargetEdition().equals(UpgradeConstants.EDITION_SE)) {
358             if (getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS80_PE) ||
359                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS81_PE) ||
360                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)) {
361                 return true;
362             }
363         }
364         return false;
365     }
366     
367     public boolean isUpgradeNSStoNSS() {
368         if (getTargetEdition().equals(UpgradeConstants.EDITION_EE) ||
369                 getTargetEdition().equals(UpgradeConstants.EDITION_SE)) {
370             if (getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_PE) ||
371                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_SE) ||
372                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_EE) ||
373                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS81_EE)) {
374                 return true;
375             }
376         }
377         return false;
378     }
379     
380     public boolean isUpgradeNSStoJKS() {
381         if (getTargetEdition().equals(UpgradeConstants.EDITION_PE)) {
382             if (getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_PE) ||
383                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_SE) ||
384                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_EE) ||
385                     getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS81_EE)){
386                 return true;
387             }
388         }
389         return false;
390     }
391     
392     public boolean checkUpgradefrom7xeeto9xee() {
393         boolean checkUpgradefrom7xeeto8xee = false;
394         if(this.getSourceInstallDir() != null && this.getTargetInstallDir() != null) {
395             checkUpgradefrom7xeeto8xee = this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_EE) && this.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_EE);
396         }
397         return checkUpgradefrom7xeeto8xee;
398     }
399     
400     //START CR 6397215
401
public boolean checkUpgradefrom8xpeto90pe() {
402         boolean checkUpgradefrom8xpeto90pe = false;
403         if(this.getSourceInstallDir() != null && this.getTargetInstallDir() != null) {
404             checkUpgradefrom8xpeto90pe = (this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS80_PE) ||
405                                           this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS81_PE) ||
406                                           this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS82_PE)) &&
407                                           this.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE);
408         }
409         return checkUpgradefrom8xpeto90pe;
410     }
411     //END CR 6397215
412

413     public void enlistDomainsFromSource(java.util.List JavaDoc domains){
414         if(domains == null)
415             this.enlistDomainsFromSource();
416         if(enlistDomain)
417             return;
418         this.setDomainMapping(UpgradeUtils.getUpgradeUtils(this).enlistDomainsFromUserDefinedDirectories(domains));
419         this.enlistDomain=true;
420     }
421     
422     public void enlistDomainsFromSource(){
423         if( getSourceInstallDir() == null) {
424             return;
425         }
426         if(enlistDomain)
427             return;
428         if(this.getSourceVersion().equals(UpgradeConstants.VERSION_7X)){
429             this.setDomainMapping(UpgradeUtils.getUpgradeUtils(this).enlist70DomainsFromSource(this));
430         }else{
431             // Determine domains from domains directory....
432
if(sourceIsDomain()){
433                 String JavaDoc source = getSourceInstallDir();
434                 if(source.endsWith(File.separator)) {
435                     source = source.substring(0,source.length() - File.separator.length());
436                 }
437                 String JavaDoc domainName = source.substring(source.lastIndexOf(File.separator) + File.separator.length(), source.length());
438                 String JavaDoc domainRoot = source.substring(0,source.lastIndexOf(domainName) - File.separator.length());
439                 setSourceDomainRoot(domainRoot);
440                 setTargetDomainRoot(domainRoot);
441                 setSourceDomainRootFlag(true);
442                 setDomainMapping(UpgradeUtils.getUpgradeUtils(this).enlistDomains(this, new String JavaDoc [] {domainName}, domainRoot));
443             } else {
444                 if(this.getSourceDomainRootFlag()) {
445                     setSourceDomainRoot(this.getSourceInstallDir());
446                 } else {
447                     setSourceDomainRoot(this.getSourceInstallDir()+File.separator+"domains");
448                 }
449                 this.setDomainMapping(UpgradeUtils.getUpgradeUtils(this).enlistDomainsFromDomainsDirectory(this,this.getSourceDomainRoot()));
450             }
451             enlistDomain=true;
452         }
453     }
454     
455     private boolean sourceIsDomain() {
456         return UpgradeUtils.getUpgradeUtils(this).checkSourceInputAsDomain();
457     }
458     public boolean checkSourceInputAsDomainRoot(String JavaDoc source) {
459         return UpgradeUtils.getUpgradeUtils(this).checkSourceInputAsDomainRoot(source,this);
460     }
461     public boolean isValid70Domain(String JavaDoc domainPath) {
462         return UpgradeUtils.getUpgradeUtils(this).isValid70Domain(domainPath);
463     }
464     
465     //Added by Prasad
466
public boolean isDomain(String JavaDoc domainPath) {
467        return UpgradeUtils.getUpgradeUtils(this).isDomain(domainPath);
468     }
469     
470     public boolean getSourceDomainRootFlag() {
471         return sourceInputAsDomainRoot;
472     }
473     // This method is called by UpgradeUtils
474
public void setSourceDomainRootFlag(boolean fl) {
475         this.sourceInputAsDomainRoot = fl;
476     }
477     public void printInfo(){
478         
479         getDefaultLogger().finest("SOURCE_INSTALL_DIR=="+SOURCE_INSTALL_DIR);
480         getDefaultLogger().finest("SOURCE_INSTALL_DIR=="+TARGET_INSTALL_DIR);
481         int size = domainList.size();
482         for(int i=0;i<size;i++) {
483             String JavaDoc domainName = (String JavaDoc)domainList.get(i);
484             getDefaultLogger().finest("**********" + domainName + "****************");
485             getDefaultLogger().finest("NSSPWD=="+ domainNSSPwdMapping.get(domainName));
486             getDefaultLogger().finest("JKSPWD=="+ domainJKSPwdMapping.get(domainName));
487             getDefaultLogger().finest("********************************************");
488         }
489         
490     }
491     public String JavaDoc getSourceServerPolicyFileName(){
492         if(this.getSourceVersion().equals(UpgradeConstants.VERSION_7X)){
493             return getSourceInstancePath()+File.separator+"config"+File.separator+"server.policy" ;
494         }else{
495             return getSourceDomainPath()+File.separator+"config"+File.separator+"server.policy" ;
496         }
497         // return getSourceInstancePath()+File.separator+"config"+File.separator+"server.policy" ;
498
}
499     public String JavaDoc getTargetServerPolicyFileName(){
500         return getDestinationDomainPath()+File.separator+"config"+File.separator+"server.policy" ;
501     }
502     public String JavaDoc getSourceDefaultWebXMLFileName(){
503         if(this.getSourceVersion().equals(UpgradeConstants.VERSION_7X) || this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS80_SE)){
504             return getSourceInstancePath()+File.separator+"config"+File.separator+"default-web.xml" ;
505         }else{
506             return getSourceDomainPath()+File.separator+"config"+File.separator+"default-web.xml" ;
507         }
508         //return getSourceInstancePath()+File.separator+"config"+File.separator+"default-web.xml" ;
509
}
510     public String JavaDoc getTargetDefaultWebXMLFileName(){
511         return getDestinationDomainPath()+File.separator+"config"+File.separator+"default-web.xml" ;
512     }
513     public String JavaDoc getSourceSunACCFileName(){
514         if(this.getSourceVersion().equals(UpgradeConstants.VERSION_7X) || this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS80_SE)){
515             return getSourceInstancePath()+File.separator+"config"+File.separator+"sun-acc.xml" ;
516         }else{
517             return getSourceDomainPath()+File.separator+"config"+File.separator+"sun-acc.xml" ;
518         }
519         //return getSourceInstancePath()+File.separator+"config"+File.separator+"sun-acc.xml" ;
520
}
521     public String JavaDoc getTargetSunACCFileName(){
522         return getDestinationDomainPath()+File.separator+"config"+File.separator+"sun-acc.xml" ;
523     }
524     public String JavaDoc getSourceConfigXMLFile(){
525         if(this.getSourceVersion().equals(UpgradeConstants.VERSION_7X) || this.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS80_SE)){
526             return getSourceInstancePath()+File.separator+"config"+File.separator+"server.xml" ;
527         }else{
528             return getSourceDomainPath()+File.separator+"config"+File.separator+"domain.xml" ;
529         }
530     }
531     public String JavaDoc getTargetConfigXMLFile(){
532         return getDestinationDomainPath()+File.separator+"config"+File.separator+"domain.xml" ;
533     }
534     
535     public String JavaDoc getSourceVersionAndEdition(){
536         if(this.sourceVersionEdition == null){
537             if(getSourceInstallDir() != null){
538                 this.sourceVersionEdition = new VersionExtracter(this.getSourceInstallDir(),this).getVersion();
539             } else {
540                 return "UNKNOWN";
541             }
542         }
543         return this.sourceVersionEdition;
544     }
545     public String JavaDoc getTargetVersionAndEdition(){
546         /*if(this.targetVersionEdition == null){
547             this.targetVersionEdition = new VersionExtracter(this.getTargetInstallDir(),this).getVersion();
548         }*/

549         return this.targetVersionEdition;
550     }
551     public void setTargetVersionAndEdition(String JavaDoc verEd){
552         // This method is called from UpgradeToolMain
553
if(verEd.equals("AS90PE")){
554             this.targetVersionEdition = UpgradeConstants.VERSION_AS90_PE;
555         }else{
556             // There is no difference between SE and EE
557
this.targetVersionEdition = UpgradeConstants.VERSION_AS90_EE;
558         }
559     }
560     public void clearSourceAndTargetVersions(){
561         // this method is called from MainFrame.java. Need to set this to null after validation is done.
562
this.sourceVersionEdition = null;
563         //this.targetVersionEdition = null;
564
}
565     public String JavaDoc getSourceVersion(){
566         return UpgradeUtils.getUpgradeUtils(this).versionString(this.getSourceVersionAndEdition());
567     }
568     public String JavaDoc getTargetVersion(){
569         return UpgradeUtils.getUpgradeUtils(this).versionString(this.getTargetVersionAndEdition());
570     }
571     public String JavaDoc getSourceEdition(){
572         return UpgradeUtils.getUpgradeUtils(this).editionString(this.getSourceVersionAndEdition());
573     }
574     public String JavaDoc getTargetEdition(){
575         return UpgradeUtils.getUpgradeUtils(this).editionString(this.getTargetVersionAndEdition());
576     }
577     public boolean isUpgradeSupported(){
578         if (getSourceVersionAndEdition().equals(getTargetVersionAndEdition())) {
579             logger.info(stringManager.getString("sameVersionUpgradeNotRequired"));
580             return false;
581         }
582         return ((java.util.HashSet JavaDoc)UpgradeConstants.supportMap.get(getSourceVersionAndEdition())).contains(getTargetVersionAndEdition());
583     }
584     public boolean isUpgradeSupported(String JavaDoc src, String JavaDoc targ){
585         if(src.equals(targ)) return false;
586         return ((java.util.HashSet JavaDoc)UpgradeConstants.supportMap.get(src)).contains(targ);
587     }
588     public boolean extractVersionDetails(){
589         this.sourceVersionEdition = new VersionExtracter(this.getSourceInstallDir(),this).getVersion();
590         //this.targetVersionEdition = new VersionExtracter(this.getTargetInstallDir(),this).getVersion();
591
if((this.sourceVersionEdition == null) || (this.targetVersionEdition == null))
592             return false;
593         return true;
594     }
595     public String JavaDoc getCurrentCluster(){
596         return this.currentCluster;
597     }
598     public void setCurrentCluster(String JavaDoc clu){
599         this.currentCluster = clu;
600     }
601     public String JavaDoc findLatestDomainDir(String JavaDoc domainRoot) {
602         return UpgradeUtils.getUpgradeUtils(this).findLatestDomainDir(domainRoot,currentDomain);
603     }
604     public String JavaDoc getAdminUserName(){
605         return this.adminUserName;
606     }
607     
608     public void setAdminUserName(String JavaDoc adminUserName){
609         this.adminUserName=adminUserName ;
610     }
611     
612     public String JavaDoc getAdminPassword(){
613         return this.adminPassword;
614     }
615     
616     public void setAdminPassword(String JavaDoc adminPassword){
617         this.adminPassword = adminPassword;
618     }
619     
620     public String JavaDoc getPasswordFile() {
621         if (passwordFilePath == null) {
622             try {
623                 passwordFile = java.io.File.createTempFile("ugpw", null);
624                 FileWriter writer = new FileWriter(passwordFile);
625                 writer.write("AS_ADMIN_PASSWORD=" + getAdminPassword() +"\n");
626                 writer.write("AS_ADMIN_ADMINPASSWORD=" + getAdminPassword() +"\n");
627                 writer.write("AS_ADMIN_MASTERPASSWORD=" + getMasterPassword() + "\n");
628                 writer.close();
629                 passwordFilePath = passwordFile.getAbsolutePath();
630             } catch (IOException ioe) {
631                 logger.severe(stringManager.getString("command.generalException") + " " + ioe.getMessage());
632                 
633             }
634         }
635         return passwordFilePath;
636     }
637     
638     public void setPasswordsFromFile(String JavaDoc path) {
639         try {
640             File userPasswordFile = new File(path);
641             BufferedReader reader = new BufferedReader(new FileReader(userPasswordFile));
642             while( reader.ready() ) {
643                 String JavaDoc line = reader.readLine();
644                 if ( line.startsWith("AS_ADMIN_PASSWORD=") ) {
645                     setAdminPassword(line.substring(line.indexOf("=") + 1));
646                 } else if ( line.startsWith("AS_ADMIN_ADMINPASSWORD=") ) {
647                     setAdminPassword(line.substring(line.indexOf("=") + 1));
648                 } else if ( line.startsWith("AS_ADMIN_MASTERPASSWORD=") ) {
649                     setMasterPassword(line.substring(line.indexOf("=") + 1));
650                 }
651             }
652             reader.close();
653         } catch (Exception JavaDoc e) {
654             logger.severe(stringManager.getString("command.generalException") + " " + e.getMessage());
655         }
656     }
657     
658     public void setMasterPassword(String JavaDoc pw) {
659         masterPassword = pw;
660     }
661     public String JavaDoc getMasterPassword() {
662         return masterPassword;
663     }
664     
665     public void deletePasswordFile() {
666         if (passwordFile != null) {
667             passwordFile.delete();
668         }
669     }
670     
671     public String JavaDoc getSourceInitConfFileName(){
672         if(this.getSourceVersion().equals(UpgradeConstants.VERSION_7X)) {
673             return getSourceInstancePath()+File.separator+"config"+File.separator+"init.conf" ;
674         }else{
675             return null;
676         }
677     }
678     
679     public void recover() {
680         UpgradeUtils.getUpgradeUtils(this).recover();
681     }
682     public boolean processClinstnceConfFiles(Vector files){
683         return ClustersInfoManager.getClusterInfoManager().processClinstanceConfFiles(files);
684     }
685 }
686
Popular Tags