# HG changeset patch
# User dadubrow
# Date 1280854253 18000
# Node ID 34e87e5741a104b26c3905876999aa1c644fc646
# Parent 4a0d736ba6a0a14e7b68dbd1a0b17847dcc8193b
add pulsar touchpoint code to portal
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF
--- a/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF Tue Aug 03 11:50:05 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF Tue Aug 03 11:50:53 2010 -0500
@@ -21,7 +21,8 @@
org.eclipse.ui.editors,
org.eclipse.ui.forms;bundle-version="3.5.0",
com.nokia.cpp.utils.ui;bundle-version="1.0.0",
- com.nokia.cpp.utils.core;bundle-version="1.0.0"
+ com.nokia.cpp.utils.core;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.touchpoint.natives;bundle-version="1.0.200"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Nokia
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/plugin.xml
--- a/core/com.nokia.carbide.discovery.ui/plugin.xml Tue Aug 03 11:50:05 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/plugin.xml Tue Aug 03 11:50:53 2010 -0500
@@ -118,5 +118,25 @@
title="Install SDKs">
+
+
+
+
+
+
+
+
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Tue Aug 03 11:50:05 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Tue Aug 03 11:50:53 2010 -0500
@@ -123,6 +123,7 @@
}
public static void setBusyCursor(final Control control, final boolean isBusy) {
+ System.out.println("control="+control);
if (control == null)
return;
final Display display = control.getDisplay();
@@ -196,4 +197,8 @@
return (String) properties.get(key);
}
+ public static IStatus makeErrorStatus(String message, Throwable t) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, message, t);
+ }
+
}
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/ExecuteAction.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/ExecuteAction.java Tue Aug 03 11:50:53 2010 -0500
@@ -0,0 +1,86 @@
+/**
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Contributors:
+ * David Dubrow
+ * Gustavo de Paula (Motorola) - Add change permission in a linux OS
+ */
+
+package org.eclipse.sequoyah.pulsar.internal.core.action;
+
+import java.text.MessageFormat;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.sequoyah.pulsar.internal.core.action.execution.ExecutionFactory;
+import org.eclipse.sequoyah.pulsar.internal.core.action.execution.ExecutionHandler;
+
+import com.nokia.carbide.discovery.ui.Activator;
+
+public class ExecuteAction extends ProvisioningAction {
+
+ public static final String ACTION_EXECUTE = "execute"; //$NON-NLS-1$
+ private static final String PARM_EXECUTABLE = "executable"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction#execute(java.util.Map)
+ */
+ @Override
+ public IStatus execute(Map parameters) {
+ String executable = (String) parameters.get(PARM_EXECUTABLE);
+ if (executable == null)
+ return Activator.makeErrorStatus(MessageFormat.format(
+ "The \"{0}\" parameter was not set in the \"{1}\" action", PARM_EXECUTABLE,
+ ACTION_EXECUTE), null);
+
+// IInstallableUnit iu = (IInstallableUnit) parameters
+// .get(ActionConstants.PARM_IU);
+// if (executable.equals(ActionConstants.PARM_ARTIFACT)) {
+// IArtifactKey artifactKey = iu.getArtifacts();
+//
+// IFileArtifactRepository downloadCache;
+// try {
+// downloadCache = Util.getDownloadCacheRepo();
+// } catch (ProvisionException e) {
+// return e.getStatus();
+// }
+// File fileLocation = downloadCache.getArtifactFile(artifactKey);
+// if ((fileLocation == null) || !fileLocation.exists())
+// return Activator.makeErrorStatus(MessageFormat.format(
+// Messages.ExecuteAction_MissingArtifactError,
+// artifactKey), null);
+// executable = fileLocation.getAbsolutePath();
+// }
+ try {
+ ExecutionHandler handler = ExecutionFactory.getExecutionHandler(
+ System.getProperty("os.name"), executable);
+
+ IStatus status = handler.handleExecution();
+
+ if (!status.isOK()) {
+ return status;
+ }
+ } catch (Exception e) {
+ return Activator.makeErrorStatus(MessageFormat.format(
+ "could not execute \"{0}\"", executable), e);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction#undo(java.util.Map)
+ */
+ @Override
+ public IStatus undo(Map parameters) {
+ return Activator.makeErrorStatus(
+ "undo not supported for exectutables", null);
+ }
+}
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/UnzipAndExecuteAction.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/UnzipAndExecuteAction.java Tue Aug 03 11:50:53 2010 -0500
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Contributors:
+ * David Dubrow
+ * Euclides Neto (Motorola) - Externalize strings.
+ * Gustavo de Paula (Motorola) - Add change permission in a linux OS
+ */
+
+package org.eclipse.sequoyah.pulsar.internal.core.action;
+
+import java.text.MessageFormat;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.Util;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.UnzipAction;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.sequoyah.pulsar.internal.core.action.execution.ExecutionFactory;
+import org.eclipse.sequoyah.pulsar.internal.core.action.execution.ExecutionHandler;
+
+import com.nokia.carbide.discovery.ui.Activator;
+
+@SuppressWarnings("restriction")
+public class UnzipAndExecuteAction extends UnzipAction {
+
+ public static final String ACTION_UNZIPANDEXECUTE = "unzipAndExecute"; //$NON-NLS-1$
+ private static final String PARM_EXECUTABLE = "executable"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.internal.p2.touchpoint.natives.actions.UnzipAction#execute(java.util.Map)
+ */
+ @Override
+ public IStatus execute(Map parameters) {
+ IStatus status = super.execute(parameters);
+ if (!status.isOK()) {
+ return status;
+ }
+
+ String executable = (String) parameters.get(PARM_EXECUTABLE);
+ if (executable == null) {
+ return Activator.makeErrorStatus(MessageFormat.format(
+ "The \"{0}\" parameter was not set in the \"{1}\" action", PARM_EXECUTABLE,
+ ACTION_UNZIPANDEXECUTE), null);
+ }
+
+ IProfile profile = (IProfile) parameters
+ .get(ActionConstants.PARM_PROFILE);
+ String installFolder = Util.getInstallFolder(profile);
+ if (installFolder == null) {
+ return Activator.makeErrorStatus(
+ "The profile did not have an install folder", null);
+ } else {
+ IPath path = new Path(installFolder);
+ path = path.append(executable);
+ executable = path.toOSString();
+ try {
+ ExecutionHandler handler = ExecutionFactory.getExecutionHandler(
+ System.getProperty("os.name"), executable);
+
+ IStatus status2 = handler.handleExecution();
+
+ if (!status2.isOK()) {
+ return status;
+ }
+ } catch (Exception e) {
+ return Activator.makeErrorStatus(MessageFormat.format(
+ "could not execute \"{0}\"", executable), e);
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.internal.p2.touchpoint.natives.actions.UnzipAction#undo(java.util.Map)
+ */
+ @Override
+ public IStatus undo(Map parameters) {
+ return Activator.makeErrorStatus(
+ "undo not supported for exectutables", null);
+ }
+}
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/ExecutionFactory.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/ExecutionFactory.java Tue Aug 03 11:50:53 2010 -0500
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2009 Motorola
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Diego Madruga (Motorola) - Initial implementation
+ */
+package org.eclipse.sequoyah.pulsar.internal.core.action.execution;
+
+/**
+ *
+ */
+public class ExecutionFactory {
+
+ /**
+ * @param osName
+ * @param executable
+ * @return
+ */
+ public static ExecutionHandler getExecutionHandler(final String osName,
+ final String executable) {
+
+ String lcOsName = osName.toLowerCase();
+ if (lcOsName.startsWith("mac")) {
+ if (executable.endsWith(".dmg")) {
+ return new MacDmgExecutionHandler(executable);
+ }
+ } else if (lcOsName.startsWith("linux")) {
+ return new LinuxBinaryExecutionHandler(executable);
+ }
+ return new ExecutionHandler(executable);
+ }
+
+}
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/ExecutionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/ExecutionHandler.java Tue Aug 03 11:50:53 2010 -0500
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2009 Motorola
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Diego Madruga (Motorola) - Initial implementation
+ */
+package org.eclipse.sequoyah.pulsar.internal.core.action.execution;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+
+import com.nokia.carbide.discovery.ui.Activator;
+
+/**
+ *
+ */
+public class ExecutionHandler {
+
+ protected String executable;
+
+ /**
+ * @noreference This constructor is not intended to be referenced by
+ * clients.
+ */
+ public ExecutionHandler(String executable) {
+ this.executable = executable;
+ }
+
+ /**
+ * @return
+ */
+ public IStatus handleExecution() {
+
+ MultiStatus multiStatus;
+
+ IStatus preExecuteStatus;
+ IStatus executeStatus;
+ IStatus posExecuteStatus;
+
+ preExecuteStatus = preExecute();
+ executeStatus = execute();
+ posExecuteStatus = posExecute();
+
+ if (preExecuteStatus.isOK() && executeStatus.isOK()
+ && posExecuteStatus.isOK()) {
+ multiStatus = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK,
+ new IStatus[] { preExecuteStatus, executeStatus,
+ posExecuteStatus },
+ "The process was executed correctly.", null);
+ } else {
+ multiStatus = new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR,
+ new IStatus[] { preExecuteStatus, executeStatus,
+ posExecuteStatus },
+ "Some errors were found durig the execution.", null);
+ }
+
+ return multiStatus;
+
+ }
+
+ /**
+ * @return
+ */
+ protected IStatus execute() {
+ IStatus status = new Status(IStatus.OK, Activator.PLUGIN_ID, "");
+
+ ProcessBuilder processBuilder = new ProcessBuilder(executable);
+ Process process;
+ try {
+ process = processBuilder.start();
+ process.waitFor();
+ } catch (IOException e) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "An I/O error has occurred", e);
+ } catch (InterruptedException e) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "The execution process was interrupted", e);
+ }
+
+ return status;
+ }
+
+ /**
+ * @return
+ */
+ protected IStatus posExecute() {
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, "");
+ }
+
+ /**
+ * @return
+ */
+ protected IStatus preExecute() {
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, "");
+ }
+}
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/LinuxBinaryExecutionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/LinuxBinaryExecutionHandler.java Tue Aug 03 11:50:53 2010 -0500
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2009 Motorola
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Diego Madruga (Motorola) - Initial implementation
+ */
+package org.eclipse.sequoyah.pulsar.internal.core.action.execution;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ChmodAction;
+
+/**
+ *
+ */
+@SuppressWarnings("restriction")
+public class LinuxBinaryExecutionHandler extends ExecutionHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.sequoyah.pulsar.internal.core.action.execution.ExecutionHandler#preExecute()
+ */
+ @Override
+ public IStatus preExecute() {
+ Map parameters = new HashMap();
+ parameters.put(ActionConstants.PARM_TARGET_DIR, executable.substring(0,
+ executable.lastIndexOf('/')));
+ parameters.put(ActionConstants.PARM_TARGET_FILE, executable.substring(
+ executable.lastIndexOf('/') + 1, executable.length()));
+ parameters.put(ActionConstants.PARM_PERMISSIONS, "777");
+
+ ChmodAction ca = new ChmodAction();
+
+ return ca.execute(parameters);
+ }
+
+ /**
+ * @param executable
+ */
+ public LinuxBinaryExecutionHandler(String executable) {
+ super(executable);
+ }
+
+}
diff -r 4a0d736ba6a0 -r 34e87e5741a1 core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/MacDmgExecutionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/org/eclipse/sequoyah/pulsar/internal/core/action/execution/MacDmgExecutionHandler.java Tue Aug 03 11:50:53 2010 -0500
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2009 Motorola
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Diego Madruga (Motorola) - Initial implementation
+ */
+package org.eclipse.sequoyah.pulsar.internal.core.action.execution;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import com.nokia.carbide.discovery.ui.Activator;
+
+/**
+ *
+ */
+public class MacDmgExecutionHandler extends ExecutionHandler {
+
+ /**
+ * @param executable
+ */
+ public MacDmgExecutionHandler(String executable) {
+ super(executable);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.sequoyah.pulsar.internal.core.action.execution.ExecutionHandler#execute()
+ */
+ @Override
+ protected IStatus execute() {
+ IStatus status = new Status(IStatus.OK, Activator.PLUGIN_ID, "");
+
+ ProcessBuilder processBuilder = new ProcessBuilder("open", executable);
+ Process process;
+ try {
+ process = processBuilder.start();
+ process.waitFor();
+ } catch (IOException e) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "An I/O error has occurred", e);
+ } catch (InterruptedException e) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "The execution process was interrupted", e);
+ }
+
+ return status;
+ }
+
+}