| package org.eclipse.epp.installer.internal.linux.core; |
| |
| import java.text.MessageFormat; |
| |
| import org.eclipse.core.runtime.IStatus; |
| import org.eclipse.core.runtime.Status; |
| import org.eclipse.epp.installer.core.IErrorConstants; |
| import org.eclipse.epp.installer.core.Linux; |
| import org.eclipse.epp.installer.core.model.IRollbackAction; |
| import org.eclipse.epp.installer.internal.core.InstallLogEntry; |
| import org.eclipse.epp.installer.internal.linux.core.Markers.MarkerKey; |
| |
| |
| public class RemoveRegistryKeyAction implements IRollbackAction { |
| |
| public IStatus rollback(InstallLogEntry entry) { |
| String arg = entry.getArgument(); |
| |
| if( !Markers.checkWriteRootPermissions(arg) ) { |
| return new MarkersComparableWarning(arg, IStatus.WARNING, |
| Linux.PLUGIN_ID, 0, "Failed to access Markers registry at:" |
| + arg, null); |
| } |
| MarkerKey[] subKeys = Markers.openKeys( arg ); |
| if (subKeys == null) { |
| return new Status(IStatus.INFO, Linux.PLUGIN_ID, |
| IErrorConstants.ERROR_REGISTRY_ERROR, "Registry error", |
| null); |
| } |
| if (subKeys.length == 0) |
| if( !Markers.removeKey( arg ) ) { |
| return new Status(IStatus.INFO, Linux.PLUGIN_ID, |
| IErrorConstants.ERROR_REGISTRY_ERROR, "Registry error", |
| null); |
| } |
| return Status.OK_STATUS; |
| } |
| |
| public String getDescription(InstallLogEntry entry) { |
| return MessageFormat.format("Removing registry value: {0}", |
| new Object[] { entry.getArgument() }); |
| } |
| } |