package rhogenwizard.sdk.task;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.preference.IPreferenceStore;

import rhogenwizard.Activator;
import rhogenwizard.constants.ConfigurationConstants;

public abstract class RunRhoconnectAppTask extends RhoconnectTask 
{
	public void stopSyncApp() throws Exception
	{
		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
		String prevRunningRhoconnectApp = store.getString(ConfigurationConstants.lastSyncRunApp);

		if (prevRunningRhoconnectApp == null || prevRunningRhoconnectApp.length() == 0)
			return;

		StringBuilder sb = new StringBuilder();
		sb.append("rhoconnect:stop");
		
		m_executor.setWorkingDirectory(prevRunningRhoconnectApp);
		
		List<String> cmdLine = new ArrayList<String>();
		cmdLine.add(m_rakeExe);
		cmdLine.add(sb.toString());
		
		m_executor.runCommand(cmdLine);
		
		sb = new StringBuilder();
		sb.append("redis:stop");
		
		m_executor.setWorkingDirectory(prevRunningRhoconnectApp);
		
		cmdLine.clear();
		cmdLine.add(m_rakeExe);
		cmdLine.add(sb.toString());
		
		m_executor.runCommand(cmdLine);
	}
}

@@ -25,16 +25,37 @@
 .task;%0A%0A
+import java.io.File;%0A
 import j
@@ -74,16 +74,16 @@
 ayList;%0A
-
 import j
@@ -355,16 +355,68 @@
 tion%0A%09%7B%0A
+%09%09if (Activator.getDefault() == null)%0A%09%09%09return;%0A%09%09%0A
 %09%09IPrefe
@@ -479,16 +479,54 @@
 tore();%0A
+%09%09%0A%09%09if (store == null)%0A%09%09%09return;%0A%09%09%0A
 %09%09String
@@ -610,16 +610,16 @@
 nApp);%0A%0A
-
 %09%09if (pr
@@ -702,16 +702,115 @@
 %09return;
+%0A%09%09%0A%09%09File appFolder = new File(prevRunningRhoconnectApp);%0A%09%09%0A%09%09if (!appFolder.exists())%0A%09%09%09return;
 %0A%0A%09%09Stri

fix error messages in error console