blob: 773e9caf80c60ea0625f2ef69c6592715c06dc92 [file] [log] [blame]
package org.eclipse.epp.installer.internal.linux.core.operations;
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.Context;
import org.eclipse.epp.installer.core.model.InstallOperation;
import org.eclipse.epp.installer.internal.core.InstallLogEntry;
import org.eclipse.epp.installer.internal.linux.core.Markers;
import org.eclipse.epp.installer.internal.linux.core.MarkersComparableWarning;
public class CreateRegistryKeyOperation extends InstallOperation {
/**
* Log entry opcode for this operation.
*/
public final static int REGISTRY_CREATE_KEY = (int) 'K';
/**
* Registry path in HKEY_LOCAL_MACHINE.
*/
private String path;
/**
* Registry key name.
*/
private String name;
/**
* Construct new instance of CreateRegistryKeyOperation, with path and key
* name.
*
* @param path
* registry path, in HKEY_LOCAL_MACHINE section of registry.
* @param name
* key name.
*/
public CreateRegistryKeyOperation(String path, String name) {
this.path = path;
this.name = name;
}
protected IStatus run(Context installer) {
if (!Markers.checkWriteRootPermissions(path)) {
String atPath = Markers.checkWriteRootPermissionsAt(path);
return new MarkersComparableWarning(atPath, IStatus.WARNING,
Linux.PLUGIN_ID, 0, "Failed to access Markers registry at:"
+ path, null);
}
Markers.MarkerKey key = Markers.openKey(path, name);
if (key != null) {
installer.getInstallLog()
.addEntry(
new InstallLogEntry(REGISTRY_CREATE_KEY, path + "/"
+ name));
return Status.OK_STATUS;
} else {
return new Status(IStatus.ERROR, Linux.PLUGIN_ID,
IErrorConstants.ERROR_REGISTRY_ERROR,
"Can't create marker key: " + name, null);
}
}
}