1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package org.openoffice.setup.Util; 25 26 import java.io.File; 27 import java.util.Enumeration; 28 import java.util.Vector; 29 import org.openoffice.setup.InstallData; 30 import org.openoffice.setup.Installer.Installer; 31 import org.openoffice.setup.Installer.InstallerFactory; 32 import org.openoffice.setup.Panel.ChooseDirectory; 33 import org.openoffice.setup.ResourceManager; 34 import org.openoffice.setup.SetupData.PackageDescription; 35 import org.openoffice.setup.SetupData.SetupDataProvider; 36 import org.openoffice.setup.Util.Informer; 37 38 public class ModuleCtrl { 39 ModuleCtrl()40 private ModuleCtrl() { 41 } 42 setModuleSize(PackageDescription packageData)43 static public void setModuleSize(PackageDescription packageData) { 44 // Setting the package size for visible node modules, that have hidden children 45 // -> Java module has three hidden children and 0 byte size 46 47 if (( ! packageData.isLeaf() ) && ( ! packageData.isHidden() )) { 48 boolean setNewSize = false; 49 int size = packageData.getSize(); 50 51 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 52 PackageDescription child = (PackageDescription) e.nextElement(); 53 // if (( child.isHidden() ) && ( child.getSelectionState() == PackageDescription.DONT_KNOW )) { 54 if ( child.isHidden() ) { 55 setNewSize = true; 56 size = size + child.getSize(); 57 } 58 } 59 60 if ( setNewSize ) { 61 packageData.setSize(size); 62 } 63 } 64 65 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 66 PackageDescription child = (PackageDescription) e.nextElement(); 67 setModuleSize(child); 68 } 69 70 } 71 setDefaultModuleSettings(PackageDescription data)72 static public void setDefaultModuleSettings(PackageDescription data) { 73 // Setting default module settings for modules, that are not hidden 74 // Hidden modules do not get a defined state now 75 boolean isInstalled = false; 76 InstallData installdata = InstallData.getInstance(); 77 boolean isUninstall = installdata.isUninstallationMode(); 78 79 if (isUninstall) { 80 isInstalled = true; 81 } 82 83 if (isUninstall) { 84 if (isInstalled) { 85 data.setSelectionState(PackageDescription.REMOVE); 86 } else { 87 data.setSelectionState(PackageDescription.IGNORE); 88 System.err.println("NEVER"); 89 } 90 } else { 91 if (isInstalled) { 92 data.setSelectionState(PackageDescription.IGNORE); 93 System.err.println("NEVER"); 94 } else if (data.isDefault()) { 95 data.setSelectionState(PackageDescription.INSTALL); 96 } else if ( ! data.isDefault()) { 97 data.setSelectionState(PackageDescription.DONT_INSTALL); 98 } else { 99 data.setSelectionState(PackageDescription.DONT_INSTALL); 100 } 101 } 102 } 103 setParentDefaultModuleSettings(PackageDescription packageData)104 static public void setParentDefaultModuleSettings(PackageDescription packageData) { 105 // Setting the module states of parent modules. 106 // Called after ChooseDirectoryCtrl.java, because 107 // the database has to be known. In user installation it is important, 108 // that the installation directory is known, to find the database. 109 // Called during uninstallation in UninstallationPrologueCtrl.java 110 111 // Iteration before setting the module states. Because of this, all children 112 // get their final setting before the parent. 113 114 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 115 PackageDescription child = (PackageDescription) e.nextElement(); 116 setParentDefaultModuleSettings(child); 117 } 118 119 if ( ! packageData.isLeaf() ) { 120 // System.err.println("setParentDefaultModuleSettings: " + packageData.getName()); 121 int state = packageData.getSelectionState(); 122 InstallData installdata = InstallData.getInstance(); 123 boolean allChildrenIgnored = true; 124 boolean atLeastOneInstalled = false; 125 boolean allChildrenHidden = true; 126 127 // System.err.println(" STATE before iterating over children: " + state); 128 129 for (Enumeration e = packageData.children(); e.hasMoreElements();) { 130 PackageDescription child = (PackageDescription) e.nextElement(); 131 int childState = child.getSelectionState(); 132 133 // System.err.println(" Child: " + child.getName() + " : " + childState); 134 135 if ( childState != PackageDescription.IGNORE) { 136 allChildrenIgnored = false; 137 } 138 139 if (( childState == PackageDescription.INSTALL) || ( childState == PackageDescription.INSTALL_SOME)) { 140 atLeastOneInstalled = true; 141 } 142 143 if ( ! child.isHidden() ) { 144 allChildrenHidden = false; 145 } 146 147 if ((state == PackageDescription.DONT_KNOW) || (state == PackageDescription.IGNORE)) { 148 state = childState; 149 // } else if ((state != childState) && (childState != PackageDescription.IGNORE)) { 150 } else if ((state != childState) && (childState != PackageDescription.IGNORE) && (childState != PackageDescription.DONT_KNOW)) { 151 if ( installdata.isUninstallationMode() ) { 152 state = PackageDescription.REMOVE_SOME; 153 } else { 154 state = PackageDescription.INSTALL_SOME; 155 } 156 } 157 158 // System.err.println(" NEW state after child: " + state); 159 } 160 161 if ( allChildrenIgnored ) { 162 state = PackageDescription.IGNORE; 163 } 164 165 if ( installdata.isInstallationMode() ) { 166 if (( state == PackageDescription.INSTALL_SOME ) && ( ! atLeastOneInstalled )) { 167 state = PackageDescription.DONT_INSTALL; 168 } 169 } 170 171 if ( allChildrenHidden ) { 172 packageData.setAllChildrenHidden(true); 173 // System.err.println("Setting allChildrenHidden for module " + packageData.getName() ); 174 } 175 176 // If older version exist, only modules without packages shall be updated, 177 // because all packages are already determined by querying the database. 178 if ( installdata.olderVersionExists() ) { 179 if ( packageData.getPackageName().equals("") ) { 180 packageData.setSelectionState(state); 181 } 182 } else { 183 packageData.setSelectionState(state); 184 } 185 } 186 } 187 setHiddenModuleSettingsInstall(PackageDescription packageData)188 static public void setHiddenModuleSettingsInstall(PackageDescription packageData) { 189 // update selection states for hidden modules during installation 190 if (( packageData.isHidden() ) && ( packageData.getSelectionState() != packageData.IGNORE )) { 191 PackageDescription parent = (PackageDescription)packageData.getParent(); 192 if ( parent != null ) { 193 packageData.setSelectionState(parent.getSelectionState()); 194 // hidden modules at root module always have to be installed, if they are not already installed 195 if ( parent.getName() == "" ) { 196 packageData.setSelectionState(packageData.INSTALL); 197 // System.err.println("Setting 1 INSTALL flag to: " + packageData.getName()); 198 } 199 } 200 201 // INSTALL_SOME is not valid for leaves 202 if (( packageData.getSelectionState() == packageData.INSTALL_SOME ) && ( packageData.isLeaf() )) { 203 packageData.setSelectionState(packageData.INSTALL); 204 // System.err.println("Setting 2 INSTALL flag to: " + packageData.getName()); 205 } 206 } 207 208 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 209 PackageDescription child = (PackageDescription) e.nextElement(); 210 setHiddenModuleSettingsInstall(child); 211 } 212 } 213 setHiddenModuleSettingsUninstall(PackageDescription packageData)214 static public void setHiddenModuleSettingsUninstall(PackageDescription packageData) { 215 InstallData data = InstallData.getInstance(); 216 // update selection states for hidden modules during uninstallation 217 if (( packageData.isHidden() ) && ( packageData.getSelectionState() != packageData.IGNORE )) { 218 // System.err.println("Package name: " + packageData.getName()); 219 // System.err.println("Selection: " + packageData.getSelectionState()); 220 221 PackageDescription parent = (PackageDescription)packageData.getParent(); 222 if ( parent != null ) { 223 packageData.setSelectionState(parent.getSelectionState()); 224 // Hidden modules at root module have to be uninstalled at complete uninstallation 225 // In Uninstallation the complete is the typical installation type 226 if (( parent.getName() == "" ) && ( data.isTypicalInstallation() )) { 227 packageData.setSelectionState(packageData.REMOVE); 228 } 229 // Hidden modules at root module must not be uninstalled at custom uninstallation 230 // But if all visible modules are selected for uninstallation, this shall be handled 231 // as complete uninstallation. 232 if ( ! data.isMaskedCompleteUninstallation() ) 233 { 234 if (( parent.getName() == "" ) && ( data.isCustomInstallation() )) { 235 packageData.setSelectionState(packageData.IGNORE); 236 } 237 } 238 } 239 240 // REMOVE_SOME is not valid for leaves 241 // if ( data.isTypicalInstallation() ) { 242 if (( packageData.getSelectionState() == packageData.REMOVE_SOME ) && ( packageData.isLeaf() )) { 243 packageData.setSelectionState(packageData.REMOVE); 244 } 245 // } 246 247 } 248 249 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 250 PackageDescription child = (PackageDescription) e.nextElement(); 251 setHiddenModuleSettingsUninstall(child); 252 } 253 } 254 checkRequiredCoreModule(PackageDescription packageData)255 static private boolean checkRequiredCoreModule(PackageDescription packageData) { 256 257 // This function uses a similar mechanism to determine 258 // core modules as function "setHiddenModuleSettingsInstall" 259 // -> only hidden parents, until there is a module without name (getName) 260 // Only searching until grandpa. 261 262 boolean requiredCoreModule = false; 263 264 // if packageData.getSelectionState() DONT_KNOW && parent auch DONT_KNOW 265 if (( packageData.isHidden() ) && 266 ( packageData.getSelectionState() != packageData.IGNORE ) && 267 ( packageData.getPackageName() != null )) { 268 //( packageData.isLeaf() )) { 269 PackageDescription parent = (PackageDescription)packageData.getParent(); 270 if ( parent != null ) { 271 if (( parent.getName().equals("") ) || ( parent.getName() == null )) { 272 requiredCoreModule = true; 273 } else { 274 if ( parent.isHidden() ) { 275 PackageDescription grandpa = (PackageDescription)parent.getParent(); 276 if ( grandpa != null ) { 277 if (( grandpa.getName().equals("") ) || ( grandpa.getName() == null )) { 278 requiredCoreModule = true; 279 } 280 } 281 } 282 } 283 } 284 } 285 286 return requiredCoreModule; 287 } 288 setDatabaseSettings(PackageDescription packageData, InstallData installData, Installer installer)289 static public void setDatabaseSettings(PackageDescription packageData, InstallData installData, Installer installer) { 290 // Analyzing the system database and setting the module states. 291 // Called during installation in ChooseInstallationTypeCtrl.java, because 292 // the database has to be known. In user installation it is important, 293 // that the installation directory is known, to find the database. 294 // Called during uninstallation in UninstallationPrologueCtrl.java 295 296 boolean isUninstall = installData.isUninstallationMode(); 297 boolean isInstalled = installer.isPackageInstalled(packageData, installData); 298 299 if (isUninstall) { 300 if (isInstalled) { 301 packageData.setSelectionState(PackageDescription.REMOVE); 302 // The following is no longer required !? (IS, 06/05/08) 303 // PackageDescription parent = packageData.getParent(); 304 // if ( parent != null ) { 305 // if ( parent.getSelectionState() != PackageDescription.REMOVE ) { 306 // parent.setSelectionState(PackageDescription.REMOVE); 307 // System.err.println("Setting remove to " + parent.getName()); 308 // } 309 // } 310 } else { 311 // Attention: Setting all nodes to ignore! If a children gets REMOVE, 312 // then REMOVE is also set to the parent. Setting REMOVE happens after 313 // setting IGNORE, because children are evaluated after the parents. 314 // The default for uninstallation is set in setDefaultModuleSettings to REMOVE. 315 packageData.setSelectionState(PackageDescription.IGNORE); 316 } 317 } else { 318 boolean goodDepends = true; 319 if ( installData.getOSType().equalsIgnoreCase("SunOS") ) { 320 if (( installData.isRootInstallation() ) && ( packageData.getCheckSolaris() != null ) && ( ! packageData.getCheckSolaris().equals("") )) { 321 // the package has to be installed. Creating a new package with only packagename 322 if ( ! installer.isPackageNameInstalled(packageData.getCheckSolaris(), installData) ) { 323 goodDepends = false; 324 } 325 } 326 } 327 328 if ( ! goodDepends ) { 329 // The package dependencies are not valid -> ignoring package. 330 packageData.setSelectionState(PackageDescription.IGNORE); 331 // too late to hide the module 332 // packageData.setIsHidden(true); 333 } 334 else { 335 if ( isInstalled ) { 336 // Maybe a required core module is installed in an older version from another product 337 boolean isRequiredCoreModule = checkRequiredCoreModule(packageData); 338 if (( packageData.isJavaPackage() ) || ( isRequiredCoreModule )) { // only selected checks, because of performance reasons 339 boolean installedPackageIsOlder = installer.isInstalledPackageOlder(packageData, installData); 340 if ( ! installedPackageIsOlder ) { 341 // The package is already installed in the same or in a newer version 342 packageData.setSelectionState(PackageDescription.IGNORE); 343 } else { 344 // This is also something like migrating feature states 345 packageData.setSelectionState(PackageDescription.INSTALL); 346 LogManager.addLogfileComment("<b>Adding required older installed package:</b> " + packageData.getPackageName() + "</br>"); 347 } 348 } else { // no version check done -> so what is a good setting for already installed packages? 349 if ( installData.olderVersionExists() ) { // should never be the case in this function 350 packageData.setSelectionState(PackageDescription.INSTALL); 351 } else { 352 packageData.setSelectionState(PackageDescription.IGNORE); 353 } 354 } 355 } 356 else { 357 // Special handling for core modules, which are required, but not installed. 358 // This can be deinstalled by hand for example. 359 boolean isRequiredCoreModule = checkRequiredCoreModule(packageData); 360 if ( isRequiredCoreModule ) { 361 if ( packageData.getSelectionState() != PackageDescription.INSTALL ) { 362 packageData.setSelectionState(PackageDescription.INSTALL); 363 LogManager.addLogfileComment("<b>Adding required package:</b> " + packageData.getPackageName() + "</br>"); 364 } 365 // This package has to exist! 366 if ( ! packageExists(packageData, installData) ) { 367 368 String packagePath = installData.getPackagePath(); 369 if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) { 370 File completePackageFile = new File(packagePath, packageData.getPkgSubdir()); 371 packagePath = completePackageFile.getPath(); 372 } 373 String packageName = packageData.getPackageName(); 374 File packageFile = new File(packagePath, packageName); 375 376 String log = "<b>Error: Missing required package " + packageFile.getPath() + "</b><br>"; 377 System.err.println(log); 378 String message = ResourceManager.getString("String_File_Not_Found") + ": " + packageFile.getPath(); 379 String title = ResourceManager.getString("String_Error"); 380 Informer.showErrorMessage(message, title); 381 System.exit(1); 382 } 383 } 384 } 385 } 386 } 387 388 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 389 PackageDescription child = (PackageDescription) e.nextElement(); 390 setDatabaseSettings(child, installData, installer); 391 } 392 } 393 setShowInUserInstallFlags(PackageDescription packageData)394 static public void setShowInUserInstallFlags(PackageDescription packageData) { 395 396 // This function is not needed during deinstallation, because a 397 // module that could not be selected during installation, is always 398 // not installed during deinstallation and therefore gets "IGNORE" 399 // in function setDatabaseSettings 400 401 if ( ! packageData.showInUserInstall() ) { 402 packageData.setSelectionState(PackageDescription.IGNORE); 403 // too late to hide the module 404 // packageData.setIsHidden(true); 405 // packageData.setAllChildrenHidden(true); 406 } 407 408 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 409 PackageDescription child = (PackageDescription) e.nextElement(); 410 setShowInUserInstallFlags(child); 411 } 412 } 413 setForcedUpdateProductSettings(PackageDescription packageData)414 static public void setForcedUpdateProductSettings(PackageDescription packageData) { 415 416 if ( packageData.forceIntoUpdate() ) { 417 packageData.setSelectionState(PackageDescription.INSTALL); 418 } 419 420 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 421 PackageDescription child = (PackageDescription) e.nextElement(); 422 setForcedUpdateProductSettings(child); 423 } 424 } 425 setShowInUserInstallOnlyFlags(PackageDescription packageData)426 static public void setShowInUserInstallOnlyFlags(PackageDescription packageData) { 427 428 // This function is not needed during deinstallation, because a 429 // module that could not be selected during installation, is always 430 // not installed during deinstallation and therefore gets "IGNORE" 431 // in function setDatabaseSettings 432 433 if ( packageData.showInUserInstallOnly() ) { 434 packageData.setSelectionState(PackageDescription.IGNORE); 435 // too late to hide the module 436 // packageData.setIsHidden(true); 437 // packageData.setAllChildrenHidden(true); 438 } 439 440 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 441 PackageDescription child = (PackageDescription) e.nextElement(); 442 setShowInUserInstallOnlyFlags(child); 443 } 444 } 445 setIgnoreNonRelocatablePackages(PackageDescription packageData)446 static public void setIgnoreNonRelocatablePackages(PackageDescription packageData) { 447 if ( ! packageData.isRelocatable() ) { 448 packageData.setSelectionState(PackageDescription.IGNORE); 449 System.err.println("Ignoring package " + packageData.getName() + " " + packageData.getPackageName()); 450 } 451 452 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 453 PackageDescription child = (PackageDescription) e.nextElement(); 454 setIgnoreNonRelocatablePackages(child); 455 } 456 } 457 setHiddenLanguageModuleDefaultSettings(PackageDescription packageData)458 static public void setHiddenLanguageModuleDefaultSettings(PackageDescription packageData) { 459 460 // This function is needed during installation for the language modules, 461 // if there is only one language in the installation set. In this case the language 462 // modules are hidden (no selection possible) and therefore get no value in 463 // setDefaultModuleSettings(). This default value is set now. 464 465 if ( packageData.showMultiLingualOnly() ) { 466 packageData.setSelectionState(PackageDescription.INSTALL); 467 } 468 469 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 470 PackageDescription child = (PackageDescription) e.nextElement(); 471 setHiddenLanguageModuleDefaultSettings(child); 472 } 473 } 474 packageExists(PackageDescription packageData, InstallData installData)475 static private boolean packageExists(PackageDescription packageData, InstallData installData) { 476 boolean fileExists = false; 477 String packagePath = installData.getPackagePath(); 478 479 if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) { 480 File completePackageFile = new File(packagePath, packageData.getPkgSubdir()); 481 packagePath = completePackageFile.getPath(); 482 } 483 484 String packageName = packageData.getPackageName(); 485 File packageFile = new File(packagePath, packageName); 486 487 if ( packageFile.exists() ) { 488 fileExists = true; 489 } 490 491 return fileExists; 492 } 493 disableNonExistingPackages(PackageDescription packageData, InstallData installData)494 static public void disableNonExistingPackages(PackageDescription packageData, InstallData installData) { 495 if ((( packageData.getPackageName() == null ) || ( packageData.getPackageName().equals("") )) 496 && packageData.isLeaf() ) { 497 packageData.setSelectionState(PackageDescription.IGNORE); 498 } else if ( ! packageExists(packageData, installData) ) { 499 packageData.setSelectionState(PackageDescription.IGNORE); 500 } 501 502 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 503 PackageDescription child = (PackageDescription) e.nextElement(); 504 disableNonExistingPackages(child, installData); 505 } 506 } 507 setDontUninstallFlags(PackageDescription packageData)508 static public void setDontUninstallFlags(PackageDescription packageData) { 509 if ( packageData.dontUninstall() ) { 510 packageData.setSelectionState(PackageDescription.IGNORE); 511 } 512 513 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 514 PackageDescription child = (PackageDescription) e.nextElement(); 515 setDontUninstallFlags(child); 516 } 517 } 518 setDontUninstallUserInstallOnylFlags(PackageDescription packageData)519 static public void setDontUninstallUserInstallOnylFlags(PackageDescription packageData) { 520 if ( packageData.showInUserInstallOnly() ) { 521 packageData.setSelectionState(PackageDescription.IGNORE); 522 } 523 524 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 525 PackageDescription child = (PackageDescription) e.nextElement(); 526 setDontUninstallUserInstallOnylFlags(child); 527 } 528 } 529 checkVisibleModulesInstall(PackageDescription packageData, InstallData data)530 static public void checkVisibleModulesInstall(PackageDescription packageData, InstallData data) { 531 boolean setToTrue = false; 532 533 if (( ! packageData.isHidden() ) && ( packageData.getSelectionState() == packageData.INSTALL )) { 534 setToTrue = true; 535 data.setVisibleModulesChecked(true); 536 } 537 538 if ( ! setToTrue ) { 539 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 540 PackageDescription child = (PackageDescription) e.nextElement(); 541 checkVisibleModulesInstall(child, data); 542 } 543 } 544 } 545 checkApplicationSelection(PackageDescription packageData, InstallData data)546 static public void checkApplicationSelection(PackageDescription packageData, InstallData data) { 547 boolean setToTrue = false; 548 549 if (( packageData.isApplicationPackage() ) && 550 ( ! packageData.isHidden() ) && 551 ( packageData.getSelectionState() == packageData.INSTALL )) { 552 setToTrue = true; 553 data.setApplicationModulesChecked(true); 554 } 555 556 if ( ! setToTrue ) { 557 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 558 PackageDescription child = (PackageDescription) e.nextElement(); 559 checkApplicationSelection(child, data); 560 } 561 } 562 } 563 checkLanguageSelection(PackageDescription packageData, InstallData data)564 static public void checkLanguageSelection(PackageDescription packageData, InstallData data) { 565 boolean setToTrue = false; 566 567 if (( packageData.showMultiLingualOnly() ) && 568 ( ! packageData.isHidden() ) && 569 ( packageData.getSelectionState() == packageData.INSTALL )) { 570 setToTrue = true; 571 data.setLanguageModulesChecked(true); 572 } 573 574 if ( ! setToTrue ) { 575 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 576 PackageDescription child = (PackageDescription) e.nextElement(); 577 checkLanguageSelection(child, data); 578 } 579 } 580 } 581 checkVisibleModulesUninstall(PackageDescription packageData, InstallData data)582 static public void checkVisibleModulesUninstall(PackageDescription packageData, InstallData data) { 583 boolean setToTrue = false; 584 585 if (( ! packageData.isHidden() ) && ( packageData.getSelectionState() == packageData.REMOVE )) { 586 // ignoring the top level module, that has the state REMOVE (but no name) 587 if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { 588 setToTrue = true; 589 data.setVisibleModulesChecked(true); 590 } 591 } 592 593 if ( ! setToTrue ) { 594 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 595 PackageDescription child = (PackageDescription) e.nextElement(); 596 checkVisibleModulesUninstall(child, data); 597 } 598 } 599 } 600 checkApplicationModulesUninstall(PackageDescription packageData, InstallData data)601 static public void checkApplicationModulesUninstall(PackageDescription packageData, InstallData data) { 602 boolean setToTrue = false; 603 604 // At least one language module should not be uninstalled. Then this function returns true. 605 // An exeption is the complete uninstallation or the masked complete uninstallation. 606 607 if (( packageData.isApplicationPackage() ) && 608 ( ! packageData.isHidden() ) && 609 ( packageData.getSelectionState() != packageData.IGNORE ) && 610 ( packageData.getSelectionState() != packageData.REMOVE )) { 611 setToTrue = true; 612 data.setApplicationModulesChecked(true); 613 } 614 615 if ( ! setToTrue ) { 616 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 617 PackageDescription child = (PackageDescription) e.nextElement(); 618 checkApplicationModulesUninstall(child, data); 619 } 620 } 621 } 622 checkLanguageModulesUninstall(PackageDescription packageData, InstallData data)623 static public void checkLanguageModulesUninstall(PackageDescription packageData, InstallData data) { 624 boolean setToTrue = false; 625 626 // At least one language module should not be uninstalled. Then this function returns true. 627 // An exeption is the complete uninstallation or the masked complete uninstallation. 628 629 if (( packageData.showMultiLingualOnly() ) && 630 ( ! packageData.isHidden() ) && 631 ( packageData.getSelectionState() != packageData.IGNORE ) && 632 ( packageData.getSelectionState() != packageData.REMOVE )) { 633 setToTrue = true; 634 data.setLanguageModulesChecked(true); 635 } 636 637 if ( ! setToTrue ) { 638 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 639 PackageDescription child = (PackageDescription) e.nextElement(); 640 checkLanguageModulesUninstall(child, data); 641 } 642 } 643 } 644 checkMaskedCompleteUninstallation(PackageDescription packageData, InstallData data)645 static public void checkMaskedCompleteUninstallation(PackageDescription packageData, InstallData data) { 646 boolean setToFalse = false; 647 648 // If there is at least one visible module, that is not selected for removal 649 // this is no masked complete uninstallation 650 651 if (( ! packageData.isHidden() ) 652 && ( packageData.getSelectionState() != packageData.REMOVE ) 653 && ( packageData.getSelectionState() != packageData.IGNORE )) { 654 // ignoring the top level module, that has no name 655 if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { 656 setToFalse = true; 657 data.setMaskedCompleteUninstallation(false); 658 // System.err.println("This is no masked complete uninstallation!"); 659 // System.err.println("Caused by: " + packageData.getName() + " with " + packageData.getSelectionState()); 660 } 661 } 662 663 if ( ! setToFalse ) { 664 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 665 PackageDescription child = (PackageDescription) e.nextElement(); 666 checkMaskedCompleteUninstallation(child, data); 667 } 668 } 669 } 670 saveTypicalSelectionStates(PackageDescription packageData)671 static public void saveTypicalSelectionStates(PackageDescription packageData) { 672 packageData.setTypicalSelectionState(packageData.getSelectionState()); 673 674 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 675 PackageDescription child = (PackageDescription) e.nextElement(); 676 saveTypicalSelectionStates(child); 677 } 678 } 679 saveCustomSelectionStates(PackageDescription packageData)680 static public void saveCustomSelectionStates(PackageDescription packageData) { 681 packageData.setCustomSelectionState(packageData.getSelectionState()); 682 683 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 684 PackageDescription child = (PackageDescription) e.nextElement(); 685 saveCustomSelectionStates(child); 686 } 687 } 688 saveStartSelectionStates(PackageDescription packageData)689 static public void saveStartSelectionStates(PackageDescription packageData) { 690 packageData.setStartSelectionState(packageData.getSelectionState()); 691 692 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 693 PackageDescription child = (PackageDescription) e.nextElement(); 694 saveStartSelectionStates(child); 695 } 696 } 697 restoreTypicalSelectionStates(PackageDescription packageData)698 static public void restoreTypicalSelectionStates(PackageDescription packageData) { 699 packageData.setSelectionState(packageData.getTypicalSelectionState()); 700 701 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 702 PackageDescription child = (PackageDescription) e.nextElement(); 703 restoreTypicalSelectionStates(child); 704 } 705 } 706 restoreCustomSelectionStates(PackageDescription packageData)707 static public void restoreCustomSelectionStates(PackageDescription packageData) { 708 packageData.setSelectionState(packageData.getCustomSelectionState()); 709 710 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 711 PackageDescription child = (PackageDescription) e.nextElement(); 712 restoreCustomSelectionStates(child); 713 } 714 } 715 restoreStartSelectionStates(PackageDescription packageData)716 static public void restoreStartSelectionStates(PackageDescription packageData) { 717 packageData.setSelectionState(packageData.getStartSelectionState()); 718 719 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 720 PackageDescription child = (PackageDescription) e.nextElement(); 721 restoreStartSelectionStates(child); 722 } 723 } 724 setUpdateOlderProductSettings(PackageDescription packageData, InstallData data, Installer installer)725 static public void setUpdateOlderProductSettings(PackageDescription packageData, InstallData data, Installer installer) { 726 if (( packageData.getPackageName() != null ) && ( ! packageData.getPackageName().equals(""))) { 727 if ( installer.isPackageInstalled(packageData, data) ) { 728 packageData.setSelectionState(PackageDescription.INSTALL); 729 730 // Special handling for jre package, because this is not necessarily older, if an older product is updated. 731 if ( packageData.isJavaPackage() ) { 732 if ( ! installer.isInstalledPackageOlder(packageData, data) ) { 733 packageData.setSelectionState(PackageDescription.DONT_INSTALL); 734 } 735 } 736 } else { 737 packageData.setSelectionState(PackageDescription.DONT_INSTALL); 738 // Special handling for Major Upgrade 739 if ( data.isMajorUpgrade() ) { 740 String basis = "ooobasis3"; 741 if ( data.getOSType().equalsIgnoreCase("Linux") ) { basis = basis + "."; } 742 String search = basis + data.getProductMinor(); 743 String replacestring = basis + data.getInstalledProductMinor(); 744 int pos = packageData.getPackageName().indexOf(search); 745 if ( pos > -1 ) { 746 // Check if this package is installed with a lower product minor 747 // Creating new package for removal, very simple PackageDescription 748 PackageDescription localPackage = new PackageDescription(); 749 localPackage.setUninstallCanFail(true); 750 localPackage.setIsRelocatable(packageData.isRelocatable()); 751 String localName = packageData.getPackageName(); 752 localName = localName.replace(search, replacestring); 753 localPackage.setPackageName(localName); 754 755 if ( ( packageData.getPkgRealName() != null ) && ( ! packageData.getPkgRealName().equals("") )) { 756 localName = packageData.getPkgRealName(); 757 localName = localName.replace(search, replacestring); 758 localPackage.setPkgRealName(localName); 759 } 760 761 if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { 762 localName = packageData.getName(); 763 localName = localName.replace(search, replacestring); 764 localPackage.setName(localName); 765 } 766 767 // saving also the order, needed for order of uninstallation 768 localPackage.setOrder(packageData.getOrder()); 769 770 // If the old package is installed, the new package can be installed, too, 771 // and the old package can be marked for removal (with dependency check). 772 if ( installer.isPackageInstalled(localPackage, data) ) { 773 packageData.setSelectionState(PackageDescription.INSTALL); 774 775 // Collecting all installed older packages for uninstallation 776 Vector oldPackages = data.getOldPackages(); 777 oldPackages.add(localPackage); 778 data.setOldPackages(oldPackages); 779 } 780 } 781 } 782 } 783 } 784 785 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 786 PackageDescription child = (PackageDescription) e.nextElement(); 787 setUpdateOlderProductSettings(child, data, installer); 788 } 789 } 790 checkLanguagesPackages(PackageDescription packageData, InstallData installData)791 static public void checkLanguagesPackages(PackageDescription packageData, InstallData installData) { 792 if (( packageData.getPkgLanguage() != null ) && ( ! packageData.getPkgLanguage().equals(""))) { 793 // This is a package with a specific language. 794 // pkgLanguage can be a comma separated list, for example "ja,ja_JP.PCK,ja_JP.UTF-8" 795 String allLang = packageData.getPkgLanguage(); 796 String[] allLangs = allLang.split(","); 797 798 Vector systemLanguages = installData.getSystemLanguages(); 799 800 boolean foundLang = false; 801 for (int i = 0; i < allLangs.length; i++) { 802 String oneLang = allLangs[i]; 803 oneLang = oneLang.trim(); 804 if ( systemLanguages.contains(oneLang)) { 805 foundLang = true; 806 int count = installData.getPreselectedLanguages(); 807 count++; 808 installData.setPreselectedLanguages(count); 809 break; 810 } 811 } 812 813 if ( ! foundLang ) { 814 packageData.setSelectionState(PackageDescription.DONT_INSTALL); 815 } 816 } 817 818 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 819 PackageDescription child = (PackageDescription) e.nextElement(); 820 checkLanguagesPackages(child, installData); 821 } 822 } 823 setLanguagesPackages(PackageDescription packageData)824 static public void setLanguagesPackages(PackageDescription packageData) { 825 if (( packageData.getPkgLanguage() != null ) && ( ! packageData.getPkgLanguage().equals(""))) { 826 // This is a package with a specific language. 827 packageData.setSelectionState(PackageDescription.INSTALL); 828 } 829 830 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 831 PackageDescription child = (PackageDescription) e.nextElement(); 832 setLanguagesPackages(child); 833 } 834 } 835 setRequiredNewCoreModules(PackageDescription packageData, InstallData installData)836 static public void setRequiredNewCoreModules(PackageDescription packageData, InstallData installData) { 837 // Special handling for core modules, which are required, but not installed. 838 boolean isRequiredCoreModule = checkRequiredCoreModule(packageData); 839 if ( isRequiredCoreModule ) { 840 if ( packageData.getSelectionState() != PackageDescription.INSTALL ) { 841 packageData.setSelectionState(PackageDescription.INSTALL); 842 LogManager.addLogfileComment("<b>Adding required package:</b> " + packageData.getPackageName() + "</br>"); 843 } 844 // This package has to exist! 845 if ( ! packageExists(packageData, installData) ) { 846 847 String packagePath = installData.getPackagePath(); 848 if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) { 849 File completePackageFile = new File(packagePath, packageData.getPkgSubdir()); 850 packagePath = completePackageFile.getPath(); 851 } 852 String packageName = packageData.getPackageName(); 853 File packageFile = new File(packagePath, packageName); 854 855 String log = "<b>Error: Missing required package " + packageFile.getPath() + "</b><br>"; 856 System.err.println(log); 857 String message = ResourceManager.getString("String_File_Not_Found") + ": " + packageFile.getPath(); 858 String title = ResourceManager.getString("String_Error"); 859 Informer.showErrorMessage(message, title); 860 System.exit(1); 861 } 862 } 863 864 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 865 PackageDescription child = (PackageDescription) e.nextElement(); 866 setRequiredNewCoreModules(child, installData); 867 } 868 } 869 defaultDatabaseAnalysis(InstallData data)870 static public void defaultDatabaseAnalysis(InstallData data) { 871 872 PackageDescription packageData = SetupDataProvider.getPackageDescription(); 873 Installer installer = InstallerFactory.getInstance(); 874 875 // restore default settings 876 if ( data.startSelectionStateSaved() ) { 877 // System.err.println("Restoring start selection states"); 878 ModuleCtrl.restoreStartSelectionStates(packageData); 879 } else { 880 ModuleCtrl.saveStartSelectionStates(packageData); 881 data.setStartSelectionStateSaved(true); 882 } 883 884 // Special ToDos, if this is an update installation of an older product. 885 // In this case, "chooseInstallationType" and "chooseComponents" are not called. 886 // Is it necessary to call "analyzeDatabase" ? 887 if ( data.olderVersionExists() ) { 888 // Calculation of size is not necessary, because only 889 // already installed packages will be updated. 890 891 if ( data.logModuleStates() ) { 892 Dumper.logModuleStates(packageData, "ChooseDirectory: Before setUpdateOlderProductSettings"); 893 } 894 895 // Updating only those packages that are installed. 896 ModuleCtrl.setUpdateOlderProductSettings(packageData, data, installer); 897 898 if ( data.logModuleStates() ) { 899 Dumper.logModuleStates(packageData, "ChooseDirectory: After setUpdateOlderProductSettings"); 900 } 901 902 // Setting packages that are forced into update, because they did not exist in older version. 903 ModuleCtrl.setForcedUpdateProductSettings(packageData); 904 905 if ( data.logModuleStates() ) { 906 Dumper.logModuleStates(packageData, "ChooseDirectory: After setForcedUpdateProductSettings"); 907 } 908 909 // Setting required root module packages (that are new in the update product). 910 ModuleCtrl.setRequiredNewCoreModules(packageData, data); 911 912 if ( data.logModuleStates() ) { 913 Dumper.logModuleStates(packageData, "ChooseDirectory: After setRequiredNewCoreModules"); 914 } 915 916 // Checking, if all packages are available 917 ModuleCtrl.disableNonExistingPackages(packageData, data); 918 919 if ( data.logModuleStates() ) { 920 Dumper.logModuleStates(packageData, "ChooseDirectory: After disableNonExistingPackages"); 921 } 922 923 // disable packages, that are not valid in user installation 924 if ( data.isUserInstallation() ) { 925 ModuleCtrl.setShowInUserInstallFlags(packageData); 926 927 if ( data.logModuleStates() ) { 928 Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallFlags"); 929 } 930 } 931 else { // disable packages, that are not valid in root installation 932 ModuleCtrl.setShowInUserInstallOnlyFlags(packageData); 933 934 if ( data.logModuleStates() ) { 935 Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallOnlyFlags"); 936 } 937 } 938 939 // Setting parent module settings. Only required for displaying correct module settings before starting installation. 940 ModuleCtrl.setParentDefaultModuleSettings(packageData); 941 942 if ( data.logModuleStates() ) { 943 Dumper.logModuleStates(packageData, "ChooseDirectory: After setParentDefaultModuleSettings"); 944 } 945 946 // Collecting packages to install 947 // This has to be done here, because "ChooseInstallationType" and "ChooseComponents" 948 // are not called. 949 Vector installPackages = new Vector(); 950 PackageCollector.collectInstallPackages(packageData, installPackages); 951 data.setInstallPackages(installPackages); 952 953 } else { // same version exists or no version exists 954 955 // database changed -> ignore saved states 956 data.setTypicalSelectionStateSaved(false); 957 data.setCustomSelectionStateSaved(false); 958 959 if ( data.logModuleStates() ) { 960 Dumper.logModuleStates(packageData, "analyzeDatabase: Start"); 961 } 962 963 // searching in the database for already installed packages 964 LogManager.setCommandsHeaderLine("Analyzing system database"); 965 ModuleCtrl.setDatabaseSettings(packageData, data, installer); 966 967 if ( data.logModuleStates() ) { 968 Dumper.logModuleStates(packageData, "analyzeDatabase: After setDatabaseSettings"); 969 } 970 971 // ModuleCtrl.analyzeDatabase(); 972 ModuleCtrl.disableNonExistingPackages(packageData, data); 973 974 if ( data.logModuleStates() ) { 975 Dumper.logModuleStates(packageData, "ChooseDirectory: After disableNonExistingPackages"); 976 } 977 978 // disable packages, that are not valid in user installation 979 if ( data.isUserInstallation() ) { 980 ModuleCtrl.setShowInUserInstallFlags(packageData); 981 982 if ( data.logModuleStates() ) { 983 Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallFlags"); 984 } 985 } else { // disable packages, that are not valid in root installation 986 ModuleCtrl.setShowInUserInstallOnlyFlags(packageData); 987 988 if ( data.logModuleStates() ) { 989 Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallOnlyFlags"); 990 } 991 } 992 993 // Problem: If all submodules have flag IGNORE, the parent can also get IGNORE 994 // That is interesting for language packs with three submodules. 995 ModuleCtrl.setParentDefaultModuleSettings(packageData); 996 997 if ( data.logModuleStates() ) { 998 Dumper.logModuleStates(packageData, "ChooseDirectory: After setParentDefaultModuleSettings"); 999 } 1000 } 1001 } 1002 1003 } 1004