Better, Faster, Freer

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: i386 ]
Version: HEAD ]

001 /*************************************************************************
002  *
003  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004  * 
005  * Copyright 2008 by Sun Microsystems, Inc.
006  *
007  * OpenOffice.org - a multi-platform office productivity suite
008  *
009  * $RCSfile: InstallChangeCtrl.java,v $
010  * $Revision: 1.5 $
011  *
012  * This file is part of OpenOffice.org.
013  *
014  * OpenOffice.org is free software: you can redistribute it and/or modify
015  * it under the terms of the GNU Lesser General Public License version 3
016  * only, as published by the Free Software Foundation.
017  *
018  * OpenOffice.org is distributed in the hope that it will be useful,
019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
021  * GNU Lesser General Public License version 3 for more details
022  * (a copy is included in the LICENSE file that accompanied this code).
023  *
024  * You should have received a copy of the GNU Lesser General Public License
025  * version 3 along with OpenOffice.org.  If not, see
026  * <http://www.openoffice.org/license.html>
027  * for a copy of the LGPLv3 License.
028  *
029  ************************************************************************/
030 
031 package org.openoffice.setup.Util;
032 
033 import org.openoffice.setup.InstallData;
034 import org.openoffice.setup.Installer.Installer;
035 import org.openoffice.setup.Installer.InstallerFactory;
036 import org.openoffice.setup.Panel.ChooseDirectory;
037 import org.openoffice.setup.ResourceManager;
038 import org.openoffice.setup.SetupData.PackageDescription;
039 import org.openoffice.setup.SetupData.SetupDataProvider;
040 import java.util.Enumeration;
041 
042 
043 public class InstallChangeCtrl {
044     
045     private InstallChangeCtrl() {
046     }
047 
048     static private void setUpdatePackage(PackageDescription packageData, InstallData installData) {
049         if (( packageData.isUpdatePackage() == true )) {
050             installData.setUpdatePackage(packageData);
051         } else {
052             for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
053                 PackageDescription child = (PackageDescription) e.nextElement();
054                 setUpdatePackage(child, installData);
055             }
056         }
057     }
058     
059     static private void setChangeInstallDir(InstallData installData, Installer installer) {
060         // setting the new install dir after analyzing the installation directory
061         // of the installed update package.
062         if ( installData.isRootInstallation() ) {
063             String changeInstallDir = "/";
064             installData.setInstallDir(changeInstallDir);
065         } else {
066             String changeInstallDir = installer.getChangeInstallDir(installData.getUpdatePackage());
067             installData.setInstallDir(changeInstallDir);
068         }
069     }
070 
071     // static public void checkInstallChange(InstallData data, ChooseDirectory panel) {
072     static public void checkInstallChange(InstallData data) {
073 
074         Installer installer = InstallerFactory.getInstance();            
075         PackageDescription packageData = SetupDataProvider.getPackageDescription();
076 
077         if ( data.getUpdatePackage() == null ) {
078             setUpdatePackage(packageData, data);
079         }
080 
081         if ( data.getUpdatePackage() != null ) {
082 
083             // resetting values, if database was changed during user installation
084             data.setOlderVersionExists(false);
085             data.setNewerVersionExists(false);
086             data.setSameVersionExists(false);           
087 
088             boolean packageIsInstalled = installer.isPackageInstalled(data.getUpdatePackage(), data);
089             if ( packageIsInstalled ) {
090 
091                 // Checking version of installed package:
092                 // If installed package is older: Force update mode, no selection of packages
093                 // If installed package is equal: Force maintenance mode, only selection of packages
094                 // If installed package is newer: Abort installation with message
095 
096                 // Setting specific values for the different update scenarios
097                 if ( installer.isInstalledPackageOlder(data.getUpdatePackage(), data) ) {
098                     data.setOlderVersionExists(true);
099                     // All installed packages will be updated -> determining which packages are installed
100                     System.err.println("An older product is installed");
101                 } else if ( installer.isInstallSetPackageOlder(data.getUpdatePackage(), data) ) {
102                     data.setNewerVersionExists(true);
103                     System.err.println("A newer product is installed");
104                 } else {
105                     data.setSameVersionExists(true);            
106                     System.err.println("Same product is installed");
107                 }
108 
109                 // If installed package is older or equal, the installdir has to be fixed
110                 // if this is a root installation
111                 if ( data.isRootInstallation() ) {
112                     setChangeInstallDir(data, installer);
113                     data.setIsChangeInstallation(true);
114                 }
115 
116                 // Exit installation, if update is not wanted and this is a root installation.
117                 // In installations without root privileges, the user can choose another installation
118                 // directory (ChooseDirectoryCtrl.java).
119                 if ( data.isRootInstallation() && data.dontUpdate() && data.olderVersionExists() ) {
120                     System.err.println("Error: An older version is already installed in directory " + data.getInstallDir() + "!");
121                     String message1 = ResourceManager.getString("String_Older_Version_Installed_Found") 
122                                     + "\n" + data.getInstallDir() + "\n";
123                     String message2 = ResourceManager.getString("String_Older_Version_Installed_Remove");
124                     String message = message1 + "\n" + message2;
125                     String title = ResourceManager.getString("String_Error");
126                     Informer.showErrorMessage(message, title);
127                     System.exit(1);
128                 }
129             }
130         }   
131     }
132 
133 }

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!