home *** CD-ROM | disk | FTP | other *** search
/ Popular Software (Pearl Edition) / 98CD05.iso / NET / NETSCAP4.50 / CP32E45.EXE / comm.z / java40.jar / netscape / softupdate / InstallFile.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-07-13  |  4.0 KB  |  117 lines

  1. package netscape.softupdate;
  2.  
  3. import netscape.security.AppletSecurity;
  4. import netscape.security.PrivilegeManager;
  5. import netscape.security.Target;
  6.  
  7. final class InstallFile extends InstallObject {
  8.    private String vrName;
  9.    private VersionInfo versionInfo;
  10.    private String jarLocation;
  11.    private String tempFile = null;
  12.    private String finalFile;
  13.    private String regPackageName;
  14.    private String userPackageName;
  15.    private Target target;
  16.    private boolean force;
  17.    private boolean replace = false;
  18.    private boolean bChild = false;
  19.    private boolean bUpgrade = false;
  20.  
  21.    InstallFile(SoftwareUpdate var1, String var2, VersionInfo var3, String var4, FolderSpec var5, String var6, boolean var7) throws SoftUpdateException {
  22.       super(var1);
  23.       this.vrName = var2;
  24.       this.versionInfo = var3;
  25.       this.jarLocation = var4;
  26.       this.force = var7;
  27.       this.finalFile = var5.MakeFullPath(var6);
  28.       PrivilegeManager var8 = AppletSecurity.getPrivilegeManager();
  29.       Target var9 = Target.findTarget("Impersonator");
  30.       var8.enablePrivilege(var9);
  31.       this.target = Target.findTarget("SoftwareInstall");
  32.       var8.enablePrivilege(this.target, super.softUpdate.GetPrincipal());
  33.       this.userPackageName = var1.GetUserPackageName();
  34.       this.regPackageName = var1.GetRegPackageName();
  35.       if (this.regPackageName.length() == 0) {
  36.          this.bChild = this.vrName.charAt(0) != '/';
  37.       } else {
  38.          this.bChild = this.vrName.startsWith(this.regPackageName);
  39.       }
  40.  
  41.       this.replace = this.NativeDoesFileExist();
  42.    }
  43.  
  44.    protected void Prepare() throws SoftUpdateException {
  45.       PrivilegeManager var1 = AppletSecurity.getPrivilegeManager();
  46.       Target var2 = Target.findTarget("Impersonator");
  47.       var1.enablePrivilege(var2);
  48.       var1.enablePrivilege(this.target, super.softUpdate.GetPrincipal());
  49.       this.tempFile = super.softUpdate.ExtractJARFile(this.jarLocation, this.finalFile);
  50.    }
  51.  
  52.    protected void Complete() throws SoftUpdateException {
  53.       PrivilegeManager var4 = AppletSecurity.getPrivilegeManager();
  54.       Target var5 = Target.findTarget("Impersonator");
  55.       var4.enablePrivilege(var5);
  56.       var4.enablePrivilege(this.target, super.softUpdate.GetPrincipal());
  57.       int var1 = this.NativeComplete();
  58.       var4.revertPrivilege(this.target);
  59.       if (var1 == 0 || var1 == 999) {
  60.          if (!this.bChild) {
  61.             int var6 = VersionRegistry.uninstallFileExists(this.regPackageName, this.vrName);
  62.             if (var6 != 0) {
  63.                this.bUpgrade = false;
  64.             } else {
  65.                this.bUpgrade = true;
  66.             }
  67.          } else if (VersionRegistry.inRegistry(this.vrName) == 0) {
  68.             this.bUpgrade = true;
  69.          } else {
  70.             this.bUpgrade = false;
  71.          }
  72.  
  73.          Integer var2 = VersionRegistry.getRefCount(this.vrName);
  74.          if (!this.bUpgrade) {
  75.             if (var2 != null) {
  76.                int var3 = 1 + var2;
  77.                VersionRegistry.installComponent(this.vrName, this.finalFile, this.versionInfo, var3);
  78.             } else if (this.replace) {
  79.                VersionRegistry.installComponent(this.vrName, this.finalFile, this.versionInfo, 2);
  80.             } else {
  81.                VersionRegistry.installComponent(this.vrName, this.finalFile, this.versionInfo, 1);
  82.             }
  83.          } else if (this.bUpgrade) {
  84.             if (var2 == null) {
  85.                VersionRegistry.installComponent(this.vrName, this.finalFile, this.versionInfo, 1);
  86.             } else {
  87.                VersionRegistry.installComponent(this.vrName, this.finalFile, this.versionInfo);
  88.             }
  89.          }
  90.  
  91.          if (!this.bChild && !this.bUpgrade) {
  92.             VersionRegistry.uninstallAddFile(this.regPackageName, this.vrName);
  93.          }
  94.       }
  95.  
  96.       if (var1 == 999) {
  97.          throw new SoftUpdateException(this.finalFile, var1);
  98.       } else if (var1 != 0) {
  99.          throw new SoftUpdateException(Strings.error_InstallFileUnexpected() + this.finalFile, var1);
  100.       }
  101.    }
  102.  
  103.    protected void Abort() {
  104.       this.NativeAbort();
  105.    }
  106.  
  107.    private native void NativeAbort();
  108.  
  109.    private native int NativeComplete();
  110.  
  111.    private native boolean NativeDoesFileExist();
  112.  
  113.    public String toString() {
  114.       return this.replace ? Strings.details_ReplaceFile() + this.finalFile : Strings.details_InstallFile() + this.finalFile;
  115.    }
  116. }
  117.