Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't use secure storage anymore (password missing...:( ), run deploy…

… in background process,
  • Loading branch information...
commit 7388b78ba6b3e4e15012b676e7fe60c3eaa2065e 1 parent 62bd7a2
@cheleb authored
View
70 org.eclipse.alfresco.publisher.core/src/org/eclipse/alfresco/publisher/core/AlfrescoPreferenceHelper.java
@@ -14,6 +14,8 @@
public class AlfrescoPreferenceHelper {
+ private static final String PASSWORD = "server.reload.password";
+
private static final String DEPLOYMENT_MODE_WEBAPP = "Webapp";
private static final int TIMEOUT_30 = 30;
@@ -47,7 +49,10 @@
private Preferences preference;
+ private IProject project;
+
public AlfrescoPreferenceHelper(IProject project) {
+ this.project = project;
this.preference = getProjectPreferences(project);
}
@@ -76,10 +81,8 @@ public String getServerPath() {
return preference.get(SERVER_ABSOLUTE_PATH, null);
}
-
-
public String getServerReloadWebscriptURL(String serverUrl, boolean alfresco) {
-
+
if (serverUrl == null) {
return null;
}
@@ -90,8 +93,7 @@ public String getServerReloadWebscriptURL(String serverUrl, boolean alfresco) {
return serverUrl + "/page/index";
}
}
-
-
+
public String getServerReloadWebscriptURL() {
return getServerReloadWebscriptURL(getServerURL(), isAlfresco());
@@ -102,7 +104,7 @@ public String getServerLogin() {
}
public String getDeploymentMode() {
- //TODO Implement return preference.get(DEPLOYMENT_MODE, null);
+ // TODO Implement return preference.get(DEPLOYMENT_MODE, null);
return DEPLOYMENT_MODE_WEBAPP;
}
@@ -120,29 +122,42 @@ public static Preferences getProjectPreferences(IProject project) {
return preferences;
}
- public static void storePassword(String projectName, String password)
+ private static boolean isSecuredStorage() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void storePassword(String password)
throws StorageException {
- ISecurePreferences root = SecurePreferencesFactory.getDefault();
- ISecurePreferences node = root.node("/org/eclipse/alfresco/"
- + projectName);
- node.put("password", password, true /* encrypt */);
+ if (isSecuredStorage()) {
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ ISecurePreferences node = root.node("/org/eclipse/alfresco/"
+ + project.getName());
+ node.put(PASSWORD, password, true /* encrypt */);
+ }else {
+ preference.put(PASSWORD, password);
+ }
}
- public static String getPassword(String projectName)
+
+ public String getPassword()
throws StorageException {
- ISecurePreferences root = SecurePreferencesFactory.getDefault();
- ISecurePreferences node = root.node("/org/eclipse/alfresco/"
- + projectName);
- return node.get("password", null);
+ if(isSecuredStorage()) {
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ ISecurePreferences node = root.node("/org/eclipse/alfresco/"
+ + project.getName());
+ return node.get(PASSWORD, null);
+ }else {
+ return preference.get(PASSWORD, null);
+ }
}
public boolean isAlfresco() {
return isAlfresco(getWebappName());
}
-
-
+
public boolean isAlfresco(String webappName) {
// TODO Auto-generated method stub
return "alfresco".equals(webappName);
@@ -217,8 +232,6 @@ public String getAmpLib() {
return null;
}
-
-
public boolean ignoreClasses() {
// TODO Auto-generated method stub
return true;
@@ -252,21 +265,20 @@ private String getSharedAbsolutePath() {
}
public void setVanillaWarAbsolutePath(String vanillaWar) {
- preference.put(AlfrescoPreferenceHelper.VANILLA_WAR_ABSOLUTE_PATH, vanillaWar);
-
+ preference.put(AlfrescoPreferenceHelper.VANILLA_WAR_ABSOLUTE_PATH,
+ vanillaWar);
+
}
-
+
public String getVanillaWarAbsolutePath() {
- return preference.get(AlfrescoPreferenceHelper.VANILLA_WAR_ABSOLUTE_PATH, null);
+ return preference.get(
+ AlfrescoPreferenceHelper.VANILLA_WAR_ABSOLUTE_PATH, null);
}
public int getStopTimeout() {
- return preference.getInt(AlfrescoPreferenceHelper.SERVER_STOP_TIMEOUT, TIMEOUT_30);
+ return preference.getInt(AlfrescoPreferenceHelper.SERVER_STOP_TIMEOUT,
+ TIMEOUT_30);
}
-
-
-
-
}
View
1  org.eclipse.alfresco.publisher.core/src/org/eclipse/alfresco/publisher/core/helper/ServerHelper.java
@@ -279,7 +279,6 @@ private static int waitProcess(final Process start,
Thread thread = new Thread() {
public void run() {
try {
- monitor.subTask(name);
start.waitFor();
} catch (InterruptedException e) {
View
3  org.eclipse.alfresco.publisher.ui/src/org/eclipse/alfresco/publisher/ui/handlers/AlfrescoDeployHandler.java
@@ -60,8 +60,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
final String login = preferences.getServerLogin();
final String password;
try {
- password = AlfrescoPreferenceHelper.getPassword(project
- .getName());
+ password = preferences.getPassword();
} catch (StorageException e) {
MessageDialog.openError(window.getShell(), "Error",
e.getMessage());
View
25 ...eclipse.alfresco.publisher.ui/src/org/eclipse/alfresco/publisher/ui/popup/actions/AMPDeployRunnable.java
@@ -16,9 +16,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class AMPDeployRunnable implements IRunnableWithProgress {
+public class AMPDeployRunnable {
- private static final int DEPLOY_N_TASK = 4;
+
private static final Logger LOGGER = LoggerFactory
.getLogger(AMPDeployRunnable.class);
@@ -44,16 +44,13 @@ public AMPDeployRunnable(AlfrescoDeploy alfrescoDeploy,
this.deploymentIncrementalCanceled = deploymentIncrementalCanceled;
}
- @Override
+
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- if (preferences.isAlfresco()) {
- monitor.beginTask("Stopping alfresco",
- DEPLOY_N_TASK + preferences.getStopTimeout());
- } else {
- monitor.beginTask("Reloading share", DEPLOY_N_TASK);
- }
+
+
+ monitor.worked(1);
IFile logFile = project.getFile("target/deployed.log");
if (logFile.exists()) {
try {
@@ -92,25 +89,25 @@ private void doDeploy(IProgressMonitor monitor)
preferences.setIncrementalDeploy(false);
preferences.flush();
}
-
- monitor.subTask("Stopping server");
+ monitor.worked(1);
+ // monitor.subTask("Stopping server");
ServerHelper.stopServer(preferences, monitor);
if (monitor.isCanceled()) {
LOGGER.info("Canceled");
return;
}
monitor.worked(1);
- monitor.subTask("Invoking build");
+ // monitor.subTask("Invoking build");
alfrescoDeploy.build(project, monitor);
monitor.worked(1);
if (monitor.isCanceled()) {
LOGGER.info("Canceled");
return;
}
- monitor.subTask("Deploy AMP");
+ // monitor.subTask("Deploy AMP ");
alfrescoDeploy.deploy(project, alfrescoFileUtils, preferences, monitor);
monitor.worked(1);
- monitor.subTask("Starting server");
+// monitor.subTask("Starting server");
if (monitor.isCanceled()) {
LOGGER.info("Canceled");
return;
View
82 org.eclipse.alfresco.publisher.ui/src/org/eclipse/alfresco/publisher/ui/popup/actions/AlfrescoDeploy.java
@@ -16,6 +16,9 @@
import org.eclipse.alfresco.publisher.core.OperationCanceledException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
@@ -35,6 +38,8 @@
public abstract class AlfrescoDeploy implements IObjectActionDelegate {
+ private static final int DEPLOY_N_TASK = 4;
+
private static final int THREAD_SLEEP_1000 = 1000;
private static final int DEFAULT_WAR_BACKUP_FILE_KEEP_4 = 4;
@@ -66,19 +71,74 @@ public void run(IAction action) {
final AlfrescoFileUtils alfrescoFileUtils = new AlfrescoFileUtils(
preferences.getServerPath(), preferences.getWebappName());
- try {
- new ProgressMonitorDialog(shell).run(true, true,
- new AMPDeployRunnable(this, alfrescoFileUtils, project,
+ Job job = new Job("Deploy") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+
+// monitor.beginTask("My job is working...", 100);
+// for (int i = 0; i < 100; i++) {
+// try {
+// Thread.sleep(100);
+// } catch (InterruptedException e) {} // ignore
+// monitor.worked(1);
+// }
+// monitor.done();
+// return new Status(IStatus.OK, "org.eclipse.alfresco.publisher.core", "Job finished");
+//
+ String taskName;
+ int totalWork;
+ if (preferences.isAlfresco()) {
+ taskName = "Stopping alfresco";
+ totalWork = DEPLOY_N_TASK + preferences.getStopTimeout();
+ } else {
+ taskName="Reloading share";
+ totalWork=DEPLOY_N_TASK;
+ }
+ monitor.beginTask(taskName + " " + totalWork, totalWork);
+
+ try {
+ new AMPDeployRunnable(AlfrescoDeploy.this, alfrescoFileUtils, project,
preferences,
shoulDeactivateIncrementalDeployement()
- && preferences.isIncrementalDeploy()));
- } catch (InvocationTargetException e) {
- LOGGER.error(e.getLocalizedMessage(), e.getCause());
- MessageDialog.openError(shell, "Error", e.getLocalizedMessage());
- } catch (InterruptedException e) {
- LOGGER.error(e.getLocalizedMessage(), e.getCause());
- MessageDialog.openError(shell, "Error", e.getLocalizedMessage());
- }
+ && preferences.isIncrementalDeploy()).run(monitor);
+ } catch (InvocationTargetException e) {
+ LOGGER.error(e.getLocalizedMessage(), e.getCause());
+ MessageDialog.openError(shell, "Error", e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ LOGGER.error(e.getLocalizedMessage(), e.getCause());
+ MessageDialog.openError(shell, "Error", e.getLocalizedMessage());
+ }
+
+
+
+
+ return Status.OK_STATUS;
+ }
+ };
+
+
+
+ job.setUser(true);
+
+ job.schedule();
+
+
+
+// try {
+// new ProgressMonitorDialog(shell).run(true, true,
+// new AMPDeployRunnable(this, alfrescoFileUtils, project,
+// preferences,
+// shoulDeactivateIncrementalDeployement()
+// && preferences.isIncrementalDeploy()));
+// } catch (InvocationTargetException e) {
+// LOGGER.error(e.getLocalizedMessage(), e.getCause());
+// MessageDialog.openError(shell, "Error", e.getLocalizedMessage());
+// } catch (InterruptedException e) {
+// LOGGER.error(e.getLocalizedMessage(), e.getCause());
+// MessageDialog.openError(shell, "Error", e.getLocalizedMessage());
+// }
}
View
81 ...e.alfresco.publisher.ui/src/org/eclipse/alfresco/publisher/ui/properties/AlfrescoServerPropertyPage.java
@@ -33,13 +33,13 @@
import org.osgi.service.prefs.BackingStoreException;
public class AlfrescoServerPropertyPage extends PropertyPage implements
-IWorkbenchPropertyPage {
+ IWorkbenchPropertyPage {
private Composite pathComposite;
private Text serverPathText;
private Label lblServerPath;
-
- //private String alfrescoHome;
+
+ // private String alfrescoHome;
private String serverPath;
private String webappName;
private Text serverUrlText;
@@ -57,19 +57,19 @@ public AlfrescoServerPropertyPage() {
super();
}
-
-
-
private void addFirstSection(final Composite parent) {
-
+
IProject project = ProjectHelper.getProject(getElement());
-
- final AlfrescoPreferenceHelper pref = new AlfrescoPreferenceHelper(project);
-
+
+ final AlfrescoPreferenceHelper pref = new AlfrescoPreferenceHelper(
+ project);
+
serverPath = pref.getServerPath();
String alfrescoHome = pref.getAlfrescoHome();
- if(StringUtils.isBlank(alfrescoHome)) {
- alfrescoHome = AlfrescoPublisherUIActivator.getDefault().getPreferenceStore().getString(PreferenceConstants.ALFRESCO_PATH);
+ if (StringUtils.isBlank(alfrescoHome)) {
+ alfrescoHome = AlfrescoPublisherUIActivator.getDefault()
+ .getPreferenceStore()
+ .getString(PreferenceConstants.ALFRESCO_PATH);
}
webappName = pref.getWebappName();
@@ -124,8 +124,8 @@ public void widgetSelected(SelectionEvent e) {
group = new Group(pathComposite, SWT.NONE);
{
group.setLayout(new FillLayout(SWT.HORIZONTAL));
- GridData gdGroup = new GridData(SWT.LEFT, SWT.CENTER, false,
- false, 1, 1);
+ GridData gdGroup = new GridData(SWT.LEFT, SWT.CENTER, false, false,
+ 1, 1);
gdGroup.heightHint = 47;
gdGroup.widthHint = 143;
group.setLayoutData(gdGroup);
@@ -140,17 +140,19 @@ public void widgetSelected(SelectionEvent e) {
if (StringUtils.isEmpty(serverPathText.getText())
&& StringUtils.isNotEmpty(alfrescoHomeText
.getText())) {
- serverPathText.setText(alfrescoHomeText.getText() + File.separator + "tomcat");
+ serverPathText.setText(alfrescoHomeText.getText()
+ + File.separator + "tomcat");
}
- if(StringUtils.isBlank(serverUrlText.getText())){
- serverUrlText.setText("http://localhost:8080/alfresco");
+ if (StringUtils.isBlank(serverUrlText.getText())) {
+ serverUrlText
+ .setText("http://localhost:8080/alfresco");
}
- if(StringUtils.isBlank(login.getText())) {
+ if (StringUtils.isBlank(login.getText())) {
login.setText("admin");
}
}
-
+
});
}
{
@@ -163,15 +165,17 @@ public void widgetSelected(SelectionEvent e) {
if (StringUtils.isEmpty(serverPathText.getText())
&& StringUtils.isNotEmpty(alfrescoHomeText
.getText())) {
- serverPathText.setText(alfrescoHomeText.getText() + File.separator + "tomcat");
+ serverPathText.setText(alfrescoHomeText.getText()
+ + File.separator + "tomcat");
}
- if(StringUtils.isBlank(serverUrlText.getText())){
- serverUrlText.setText("http://localhost:8080/share");
+ if (StringUtils.isBlank(serverUrlText.getText())) {
+ serverUrlText
+ .setText("http://localhost:8080/share");
}
- if(StringUtils.isBlank(login.getText())) {
+ if (StringUtils.isBlank(login.getText())) {
login.setText("admin");
}
-
+
}
});
}
@@ -202,8 +206,8 @@ public void widgetSelected(SelectionEvent e) {
lblServerUrl.setText("Server URL");
}
serverUrlText = new Text(pathComposite, SWT.BORDER);
- serverUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
- 3, 1));
+ serverUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+ false, 3, 1));
{
String urlSaved = pref.getServerURL();
if (urlSaved != null) {
@@ -236,8 +240,9 @@ public void widgetSelected(SelectionEvent e) {
@Override
public void widgetSelected(SelectionEvent e) {
- String reloadURL = pref
- .getServerReloadWebscriptURL(serverUrlText.getText(), pref.isAlfresco(webappNameText.getText()));
+ String reloadURL = pref.getServerReloadWebscriptURL(
+ serverUrlText.getText(),
+ pref.isAlfresco(webappNameText.getText()));
if (ServerHelper.reload(reloadURL, login.getText(),
password.getText(), new NullProgressMonitor())) {
@@ -262,8 +267,7 @@ public void widgetSelected(SelectionEvent e) {
{
try {
- String pwd = AlfrescoPreferenceHelper.getPassword(project
- .getName());
+ String pwd = pref.getPassword();
if (StringUtils.isNotBlank(pwd)) {
password.setText(pwd);
}
@@ -319,18 +323,18 @@ public Control createContents(Composite parent) {
setErrorMessage("Maven update project configuration must be run on project.");
}
-
+
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL);
data.grabExcessHorizontalSpace = true;
composite.setLayoutData(data);
-
+
addFirstSection(composite);
addSeparator(composite);
addSecondSection(composite);
-
+
return composite;
}
@@ -355,8 +359,6 @@ protected void performDefaults() {
}
-
-
public boolean performOk() {
// store the value in the owner text field
StringBuilder errorMessage = new StringBuilder();
@@ -364,7 +366,7 @@ public boolean performOk() {
IProject project = ProjectHelper.getProject(getElement());
AlfrescoPreferenceHelper preferences = new AlfrescoPreferenceHelper(
project);
-
+
if (StringUtils.isBlank(serverPathText.getText())) {
errorMessage.append("ServerPath must be set\n");
} else {
@@ -375,8 +377,6 @@ public boolean performOk() {
} else {
preferences.stageWebappName(webappNameText.getText());
}
-
- String projectName = project.getName();
if (StringUtils.isBlank(alfrescoHomeText.getText())) {
errorMessage.append("Alfresco Home must be set.\n");
@@ -392,8 +392,7 @@ public boolean performOk() {
preferences.stageServerLogin(login.getText());
}
if (StringUtils.isNotBlank(password.getText())) {
- AlfrescoPreferenceHelper.storePassword(projectName,
- password.getText());
+ preferences.storePassword(password.getText());
}
if (errorMessage.length() > 0) {
@@ -403,8 +402,6 @@ public boolean performOk() {
preferences.flush();
-
-
} catch (BackingStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Please sign in to comment.
Something went wrong with that request. Please try again.