home *** CD-ROM | disk | FTP | other *** search
- package netscape.softupdate;
-
- import java.text.MessageFormat;
- import netscape.security.AppletSecurity;
- import netscape.security.PrivilegeManager;
- import netscape.security.Target;
-
- final class InstallPatch extends InstallObject {
- private String vrName;
- private VersionInfo versionInfo;
- private String jarLocation;
- private String patchURL;
- private String targetfile;
- private String patchedfile;
-
- InstallPatch(SoftwareUpdate var1, String var2, VersionInfo var3, String var4) throws SoftUpdateException {
- super(var1);
- this.vrName = var2;
- this.versionInfo = var3;
- this.jarLocation = var4;
- this.targetfile = VersionRegistry.componentPath(this.vrName);
- if (this.targetfile == null) {
- throw new SoftUpdateException("", -213);
- } else {
- this.checkPrivileges();
- }
- }
-
- InstallPatch(SoftwareUpdate var1, String var2, VersionInfo var3, String var4, FolderSpec var5, String var6) throws SoftUpdateException {
- super(var1);
- this.vrName = var2;
- this.versionInfo = var3;
- this.jarLocation = var4;
- this.targetfile = var5.MakeFullPath(var6);
- this.checkPrivileges();
- }
-
- private void checkPrivileges() {
- PrivilegeManager var1 = AppletSecurity.getPrivilegeManager();
- Target var2 = Target.findTarget("Impersonator");
- Target var3 = Target.findTarget("SoftwareInstall");
- var1.enablePrivilege(var2);
- var1.enablePrivilege(var3, super.softUpdate.GetPrincipal());
- }
-
- protected void Prepare() throws SoftUpdateException {
- int var1 = 0;
- String var2 = null;
- boolean var3 = false;
- PrivilegeManager var4 = AppletSecurity.getPrivilegeManager();
- Target var5 = Target.findTarget("Impersonator");
- Target var6 = Target.findTarget("SoftwareInstall");
- var4.enablePrivilege(var5);
- var4.enablePrivilege(var6, super.softUpdate.GetPrincipal());
-
- try {
- ((InstallObject)this).NativeDoesFileExist(this.targetfile);
- } catch (SoftUpdateException var9) {
- var1 = var9.GetError();
- }
-
- if (var1 == 0) {
- this.patchURL = super.softUpdate.ExtractJARFile(this.jarLocation, this.targetfile);
- if (super.softUpdate.patchList.containsKey(this.targetfile)) {
- var2 = (String)super.softUpdate.patchList.get(this.targetfile);
- var3 = true;
- } else {
- var2 = this.targetfile;
- var3 = false;
- }
-
- try {
- this.patchedfile = this.NativePatch(var2, this.patchURL);
- } catch (SoftUpdateException var8) {
- var1 = var8.GetError();
- }
-
- if (this.patchedfile != null) {
- super.softUpdate.patchList.put(this.targetfile, this.patchedfile);
- }
- }
-
- if (var3) {
- this.NativeDeleteFile(var2);
- }
-
- if (var1 != 0) {
- Object[] var7 = new Object[]{this.targetfile};
- throw new SoftUpdateException(MessageFormat.format(Strings.error_PatchFailed(), var7), var1);
- }
- }
-
- protected void Complete() throws SoftUpdateException {
- this.checkPrivileges();
- String var2 = (String)super.softUpdate.patchList.get(this.targetfile);
- if (var2.compareTo(this.patchedfile) == 0) {
- int var1 = this.NativeReplace(this.targetfile, this.patchedfile);
- if (var1 != 0 && var1 != 999) {
- Object[] var3 = new Object[]{this.targetfile};
- throw new SoftUpdateException(MessageFormat.format(Strings.error_InstallFileUnexpected(), var3), var1);
- }
-
- VersionRegistry.installComponent(this.vrName, this.targetfile, this.versionInfo);
- if (var1 != 0) {
- throw new SoftUpdateException(this.targetfile, var1);
- }
- }
-
- }
-
- protected void Abort() {
- String var1 = (String)super.softUpdate.patchList.get(this.targetfile);
- if (var1.compareTo(this.patchedfile) == 0) {
- this.NativeDeleteFile(this.patchedfile);
- }
-
- }
-
- private native String NativePatch(String var1, String var2) throws SoftUpdateException;
-
- private native int NativeReplace(String var1, String var2);
-
- private native void NativeDeleteFile(String var1);
-
- public String toString() {
- Object[] var1 = new Object[]{this.targetfile};
- return MessageFormat.format(Strings.details_Patch(), var1);
- }
-
- protected boolean CanUninstall() {
- return true;
- }
-
- protected boolean RegisterPackageNode() {
- return true;
- }
- }
-