JBoss Tools SVN: r25941 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui: reporting and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-10-20 08:40:28 -0400 (Wed, 20 Oct 2010)
New Revision: 25941
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/UIMessages.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/messages.properties
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
Log:
JBDS-1206
https://jira.jboss.org/browse/JBDS-1206
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/UIMessages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/UIMessages.java 2010-10-20 11:12:54 UTC (rev 25940)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/UIMessages.java 2010-10-20 12:40:28 UTC (rev 25941)
@@ -26,4 +26,8 @@
public static String PROPERTIES_EDITOR_EXPRESSION;
public static String PROPERTIES_EDITOR_ILLEGAL_NAME_EXPRESSION;
public static String PROPERTIES_EDITOR_ILLEGAL_VALUE_EXPRESSION;
+
+ public static String REPORT_PROBLEM_DESCRIPTION;
+ public static String REPORT_PROBLEM_NO_DESCRIPTION;
+ public static String REPORT_PROBLEM_RESULT;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/messages.properties 2010-10-20 11:12:54 UTC (rev 25940)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/messages/messages.properties 2010-10-20 12:40:28 UTC (rev 25941)
@@ -3,4 +3,8 @@
PROPERTIES_EDITOR_EXPRESSION=Expression
PROPERTIES_EDITOR_ILLEGAL_NAME_EXPRESSION=Illegal name expression: {0}
PROPERTIES_EDITOR_ILLEGAL_VALUE_EXPRESSION=Illegal value expression: {0}
-PROPERTIES_EDITOR_FILTER_MATCHES=Filter matched {0} out of {1} items.
\ No newline at end of file
+PROPERTIES_EDITOR_FILTER_MATCHES=Filter matched {0} out of {1} items.
+
+REPORT_PROBLEM_DESCRIPTION=This wizard takes the description and info below and in addition collects various logs from eclipse and creates a zipped file which can be attached to issues or emails when reporting problems.
+REPORT_PROBLEM_NO_DESCRIPTION=Description must be set.
+REPORT_PROBLEM_RESULT=Logs and your entered information have been gathered and stored at: \n{0},\n now attach this to your issue or email discussing the problem.
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2010-10-20 11:12:54 UTC (rev 25940)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2010-10-20 12:40:28 UTC (rev 25941)
@@ -37,6 +37,8 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -57,6 +59,7 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.about.ISystemSummarySection;
@@ -74,18 +77,21 @@
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.attribute.XAttributeSupport;
import org.jboss.tools.common.model.ui.attribute.adapter.IModelPropertyEditorAdapter;
+import org.jboss.tools.common.model.ui.messages.UIMessages;
import org.jboss.tools.common.model.ui.widgets.ReferenceListener;
import org.jboss.tools.common.model.ui.widgets.TextAndReferenceComponent;
import org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizard;
import org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView;
+import org.jboss.tools.common.model.ui.wizards.query.IQueryDialog;
import org.jboss.tools.common.reporting.ProblemReportingHelper;
public class ReportProblemWizard extends AbstractQueryWizard {
public ReportProblemWizard() {
setView(new ReportProblemWizardView());
-
+ getView().setMessage(UIMessages.REPORT_PROBLEM_DESCRIPTION);
}
+
}
/**
@@ -192,11 +198,22 @@
getCommandBar().setEnabled(OK, !isMessageEmpty());
}
+ void validate() {
+ if(problemDescription == null || problemDescription.isDisposed()) return;
+ String text = problemDescription.getText();
+ if(text == null || text.trim().length() == 0) {
+ setErrorMessage(UIMessages.REPORT_PROBLEM_NO_DESCRIPTION);
+ } else {
+ setErrorMessage(null);
+ setMessage(UIMessages.REPORT_PROBLEM_DESCRIPTION);
+ }
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getPreferredSize()
*/
public Point getPreferredSize() {
- return new Point(400, 500);
+ return new Point(750, 500);
}
/* (non-Javadoc)
@@ -456,6 +473,7 @@
problemDescription.setLayoutData(new GridData(GridData.FILL_BOTH));
problemDescription.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
+ validate();
updateBar();
}
});
@@ -471,6 +489,11 @@
infoSupport.setLayout(getDefaultSupportLayout());
Control c = infoSupport.createControl(g);
c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ infoSupport.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ validate();
+ }
+ });
}
private void createStackTracesLabelControl(Composite parent) {
@@ -529,6 +552,7 @@
// Submit.getInstance().submit(reportText, addRedHatLog);
// ProblemReportingHelper.buffer.report(text, email, other,
// addRedHatLog);
+ showConfirmDialog();
} catch (IOException e) {
ModelUIPlugin.getPluginLog().logError(e);
}
@@ -540,6 +564,11 @@
}
}
+ private void showConfirmDialog() {
+ String filename = logFileName.getText();
+ String message = NLS.bind(UIMessages.REPORT_PROBLEM_RESULT, filename);
+ MessageDialog.openInformation(problemDescription.getShell(), "Info", message);
+ }
private String formatContent(String content) {
StringBuffer sb = new StringBuffer();
14 years, 2 months
JBoss Tools SVN: r25940 - trunk/vpe/plugins/org.jboss.tools.vpe.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-10-20 07:12:54 -0400 (Wed, 20 Oct 2010)
New Revision: 25940
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/about.html
Log:
Fix copyright info/dates (https://jira.jboss.org/browse/JBDS-1254)
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/about.html
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/about.html 2010-10-20 11:11:25 UTC (rev 25939)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/about.html 2010-10-20 11:12:54 UTC (rev 25940)
@@ -10,7 +10,7 @@
<H3>About This Content</H3>
-<P>©2007 Red Hat, Inc. All rights reserved</P>
+<P>©2010 Red Hat, Inc. All rights reserved</P>
<H3>License</H3>
14 years, 2 months
JBoss Tools SVN: r25939 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/internal/deltacloud/ui/wizards and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-10-20 07:11:25 -0400 (Wed, 20 Oct 2010)
New Revision: 25939
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/UrlToCloudTypeConverter.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-7371] moved deltacloud url checking to deltacloud client, added tests
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-20 11:10:48 UTC (rev 25938)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-20 11:11:25 UTC (rev 25939)
@@ -1,3 +1,12 @@
+2010-10-20 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/UrlToCloudTypeConverter.java:
+ [JBIDE-7371] moved cloud type checking to DeltaCloudClient, converter now delegates to deltacloud client
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java:
+ [JBIDE-7371] switched validator to check enum type instead of string messages
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java:
+ [JBIDE-7371] moved cloud type checking to DeltaCloudClient, removed converter and validator
+
2010-10-19 Jeff Johnston <jjohnstn(a)redhat.com>
[JBIDE-7366]
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java 2010-10-20 11:10:48 UTC (rev 25938)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java 2010-10-20 11:11:25 UTC (rev 25939)
@@ -10,42 +10,19 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.databinding.conversion.IConverter;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.ValidationStatus;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClient;
import org.jboss.tools.internal.deltacloud.ui.common.databinding.ObservablePojo;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
* @author Andre Dietisheim
*/
public class CloudConnectionModel extends ObservablePojo {
- public static final String PROPERTY_URL = "url";
- public static final String PROPERTY_NAME = "name";
- public static final String PROPERTY_PASSWORD = "password";
- public static final String PROPERTY_USERNAME = "username";
- public static final String PROPERTY_TYPE = "type";
+ public static final String PROPERTY_URL = "url"; //$NON-NLS-1$
+ public static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
+ public static final String PROPERTY_PASSWORD = "password"; //$NON-NLS-1$
+ public static final String PROPERTY_USERNAME = "username"; //$NON-NLS-1$
+ public static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
public static final String UNKNOWN_TYPE_LABEL = "UnknownType.label"; //$NON-NLS-1$
public static final String INVALID_URL = "ErrorInvalidURL.text"; //$NON-NLS-1$
@@ -56,107 +33,8 @@
private String username;
private String password;
- private String cloudType;
+ private DeltaCloudClient.DeltaCloudType cloudType;
- public static class CloudTypeConverter implements IConverter {
-
- private static final String HTTPHEADER_KEY_ACCEPT = "Accept"; //$NON-NLS-1$
- private static final String HTTPHEADER_VALUE_ACCEPTXML = "application/xml;q=1.0"; //$NON-NLS-1$
- private static final String DOCUMENT_ELEMENT_DRIVER = "driver"; //$NON-NLS-1$
- private static final String DOCUMENT_ELEMENT_API = "api"; //$NON-NLS-1$
- private static final String URLCONNECTION_ENCODING = "UTF-8"; //$NON-NLS-1$
-
- @Override
- public Object getFromType() {
- return String.class;
- }
-
- @Override
- public Object getToType() {
- return String.class;
- }
-
- @Override
- public Object convert(final Object fromObject) {
- return getCloudType((String) fromObject);
- }
-
- private String getCloudType(String url) {
- String cloudType = UNKNOWN_TYPE_LABEL;
- try {
- Object o = getURLContent(url + "/api?format=xml"); //$NON-NLS-1$
- if (o instanceof InputStream) {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document document = db.parse(
- new InputSource(new StringReader(getXML((InputStream) o))));
-
- NodeList elements = document.getElementsByTagName(DOCUMENT_ELEMENT_API);
- if (elements.getLength() > 0) {
- Node n = elements.item(0);
- Node driver = n.getAttributes().getNamedItem(DOCUMENT_ELEMENT_DRIVER);
- if (driver != null) {
- String driverValue = driver.getNodeValue();
- cloudType = driverValue.toUpperCase();
- }
- }
- }
- } catch (MalformedURLException e) {
- cloudType = WizardMessages.getString(INVALID_URL);
- } catch (IOException e) {
- cloudType = WizardMessages.getString(NONCLOUD_URL);
- } catch (ParserConfigurationException e) {
- cloudType = WizardMessages.getString(NONCLOUD_URL);
- } catch (SAXException e) {
- cloudType = WizardMessages.getString(NONCLOUD_URL);
- } catch (Exception e) {
- cloudType = WizardMessages.getString(INVALID_URL);
- }
- return cloudType;
- }
-
- private String getXML(InputStream is) throws UnsupportedEncodingException, IOException {
- try {
- if (is == null) {
- return "";
- }
- StringBuilder sb = new StringBuilder();
- String line = "";
- BufferedReader reader = new BufferedReader(new InputStreamReader(is, URLCONNECTION_ENCODING));
- while ((line = reader.readLine()) != null) {
- sb.append(line).append("\n"); //$NON-NLS-1$
- }
- return sb.toString();
- } finally {
- is.close();
- }
- }
-
- private Object getURLContent(String url) throws IOException {
- URL u = new URL(url);
- URLConnection connection = u.openConnection();
- connection.setRequestProperty(HTTPHEADER_KEY_ACCEPT, HTTPHEADER_VALUE_ACCEPTXML);
- return connection.getContent();
- }
- }
-
- public static class CloudTypeValidator implements IValidator {
-
- @Override
- public IStatus validate(Object value) {
- Assert.isTrue(value instanceof String);
- if (value != null
- && !WizardMessages.getString(UNKNOWN_TYPE_LABEL).equals(value)
- && !WizardMessages.getString(INVALID_URL).equals(value)
- && !WizardMessages.getString(NONCLOUD_URL).equals(value)) {
- return ValidationStatus.ok();
- } else {
- return ValidationStatus.error((String) value);
- }
- }
- }
-
-
public CloudConnectionModel(String name, String url, String username, String password) {
this.name = name;
this.url = url;
@@ -196,11 +74,11 @@
getPropertyChangeSupport().firePropertyChange(PROPERTY_URL, this.url, this.url = url);
}
- public String getType() {
+ public DeltaCloudClient.DeltaCloudType getType() {
return cloudType;
}
- public void setType(String cloudType) {
+ public void setType(DeltaCloudClient.DeltaCloudType cloudType) {
getPropertyChangeSupport().firePropertyChange(PROPERTY_TYPE, this.cloudType, this.cloudType = cloudType);
}
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-20 11:10:48 UTC (rev 25938)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-20 11:11:25 UTC (rev 25939)
@@ -149,7 +149,6 @@
// cloud type
Label typeLabel = new Label(container, SWT.NULL);
typeLabel.setText(WizardMessages.getString(CLOUDTYPE_LABEL));
-
Label computedTypeLabel = new Label(container, SWT.NULL);
Binding urlBinding = bindCloudTypeLabel(dbc, urlText, computedTypeLabel);
@@ -313,7 +312,7 @@
public void handleValueChange(ValueChangeEvent event) {
IStatus status = (IStatus) event.diff.getNewValue();
if (status.isOK()) {
- typeLabel.setText(connectionModel.getType());
+ typeLabel.setText(connectionModel.getType().toString());
} else {
typeLabel.setText("");
}
@@ -336,8 +335,8 @@
*/
private Binding bindCloudTypeLabel(DataBindingContext dbc, Text urlText, final Label typeLabel) {
UpdateValueStrategy updateStrategy = new UpdateValueStrategy();
- updateStrategy.setConverter(new CloudConnectionModel.CloudTypeConverter());
- updateStrategy.setBeforeSetValidator(new CloudConnectionModel.CloudTypeValidator());
+ updateStrategy.setConverter(new UrlToCloudTypeConverter());
+ updateStrategy.setBeforeSetValidator(new CloudTypeValidator());
Binding binding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(100, urlText),
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java 2010-10-20 11:11:25 UTC (rev 25939)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClient;
+
+public class CloudTypeValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value != null
+ && !DeltaCloudClient.DeltaCloudType.UNKNOWN.equals(value)
+ && !DeltaCloudClient.DeltaCloudType.INVALID_URL.equals(value)) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus.error(WizardMessages.getString("IllegalCloudUrl.msg")); //$NON-NLS-1$
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java 2010-10-20 11:10:48 UTC (rev 25938)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java 2010-10-20 11:11:25 UTC (rev 25939)
@@ -79,7 +79,7 @@
String url = mainPage.getModel().getUrl();
String username = mainPage.getModel().getUsername();
String password = mainPage.getModel().getPassword();
- String type = mainPage.getModel().getType();
+ String type = mainPage.getModel().getType().toString();
try {
String oldName = cloud.getName();
cloud.editCloud(name, url, username, password, type);
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java 2010-10-20 11:10:48 UTC (rev 25938)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java 2010-10-20 11:11:25 UTC (rev 25939)
@@ -64,7 +64,7 @@
String url = mainPage.getModel().getUrl();
String username = mainPage.getModel().getUsername();
String password = mainPage.getModel().getPassword();
- String type = mainPage.getModel().getType();
+ String type = mainPage.getModel().getType().toString();
try {
DeltaCloud newCloud = new DeltaCloud(name, url, username, password, type, true);
DeltaCloudManager.getDefault().addCloud(newCloud);
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/UrlToCloudTypeConverter.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/UrlToCloudTypeConverter.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/UrlToCloudTypeConverter.java 2010-10-20 11:11:25 UTC (rev 25939)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+import org.eclipse.core.databinding.conversion.IConverter;
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClient;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class UrlToCloudTypeConverter implements IConverter {
+
+ @Override
+ public Object getFromType() {
+ return String.class;
+ }
+
+ @Override
+ public Object getToType() {
+ return DeltaCloudClient.DeltaCloudType.class;
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ String deltaCloudUrl = (String) fromObject;
+ return DeltaCloudClient.getDeltaCloudType(deltaCloudUrl);
+ }
+
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/UrlToCloudTypeConverter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-10-20 11:10:48 UTC (rev 25938)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-10-20 11:11:25 UTC (rev 25939)
@@ -23,6 +23,7 @@
Password.label=Password:
TestButton.label=Test
UnknownType.label=Unknown
+IllegalCloudUrl.msg=Invalid url or non-deltacloud url.
Id.label=ID:
ImageId.label=Image ID:
OwnerId.label=Owner ID:
14 years, 2 months
JBoss Tools SVN: r25938 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-10-20 07:10:48 -0400 (Wed, 20 Oct 2010)
New Revision: 25938
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
Log:
[JBIDE-7371] moved deltacloud url checking to deltacloud client, added tests
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-10-20 11:10:19 UTC (rev 25937)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-10-20 11:10:48 UTC (rev 25938)
@@ -1,3 +1,7 @@
+2010-10-20 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (getDeltaCloudType): moved from UI to deltacloud client
+
2010-10-12 Jeff Johnston <jjohnstn(a)redhat.com>
* build.properties: Remove lib/deltacloudclient jar specification as it
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2010-10-20 11:10:19 UTC (rev 25937)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2010-10-20 11:10:48 UTC (rev 25938)
@@ -10,7 +10,8 @@
org.jboss.tools.usage;bundle-version="1.0.0";resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.jboss.tools.deltacloud.core;x-friends:="org.jboss.tools.deltacloud.ui"
+Export-Package: org.jboss.tools.deltacloud.core;x-friends:="org.jboss.tools.deltacloud.ui",
+ org.jboss.tools.deltacloud.core.client
Bundle-ClassPath: .,
lib/apache-mime4j-0.6.jar,
lib/commons-codec-1.3.jar,
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-10-20 11:10:19 UTC (rev 25937)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-10-20 11:10:48 UTC (rev 25938)
@@ -18,8 +18,10 @@
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -50,83 +52,81 @@
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-public class DeltaCloudClient implements API
-{
+public class DeltaCloudClient implements API {
+
+ private static final String REQUEST_URL_API = "/api?format=xml";
+
+ private static final String HTTPHEADER_KEY_ACCEPT = "Accept"; //$NON-NLS-1$
+ private static final String HTTPHEADER_VALUE_ACCEPTXML = "application/xml;q=1.0"; //$NON-NLS-1$
+ private static final String DOCUMENT_ELEMENT_DRIVER = "driver"; //$NON-NLS-1$
+ private static final String DOCUMENT_ELEMENT_API = "api"; //$NON-NLS-1$
+ private static final String URLCONNECTION_ENCODING = "UTF-8"; //$NON-NLS-1$
+
+ public static enum DeltaCloudType {
+ INVALID_URL, UNKNOWN, MOCK, EC2
+ }
+
+
public static Logger logger = Logger.getLogger(DeltaCloudClient.class);
-
- private static enum DCNS
- {
+
+ private static enum DCNS {
INSTANCES, REALMS, IMAGES, HARDWARE_PROFILES, KEYS, START, STOP, REBOOT, DESTROY;
-
+
@Override
- public String toString()
- {
+ public String toString() {
return "/" + name().toLowerCase();
}
- }
-
- private static enum RequestType { POST, GET, DELETE };
-
+ }
+
+ private static enum RequestType {
+ POST, GET, DELETE
+ };
+
private URL baseUrl;
-
private String username;
-
private String password;
-
- public DeltaCloudClient(URL url, String username, String password) throws MalformedURLException
- {
-
+
+ public DeltaCloudClient(URL url, String username, String password) throws MalformedURLException {
+
logger.debug("Creating new Delta Cloud Client for Server: " + url);
-
+
this.baseUrl = url;
-
this.username = username;
-
this.password = password;
}
- private String sendRequest(String path, RequestType requestType) throws DeltaCloudClientException
- {
+ private String sendRequest(String path, RequestType requestType) throws DeltaCloudClientException {
DefaultHttpClient httpClient = new DefaultHttpClient();
- httpClient.getCredentialsProvider().setCredentials(new AuthScope(baseUrl.getHost(), baseUrl.getPort()), new UsernamePasswordCredentials(username, password));
-
+ httpClient.getCredentialsProvider().setCredentials(new AuthScope(baseUrl.getHost(), baseUrl.getPort()),
+ new UsernamePasswordCredentials(username, password));
+
String requestUrl = baseUrl.toString() + path;
logger.debug("Sending Request to: " + requestUrl);
-
- try
- {
+
+ try {
HttpUriRequest request = null;
- if(requestType == RequestType.POST)
- {
+ if (requestType == RequestType.POST) {
request = new HttpPost(requestUrl);
- }
- else if (requestType == RequestType.DELETE)
- {
+ } else if (requestType == RequestType.DELETE) {
request = new HttpDelete(requestUrl);
- }
- else
- {
+ } else {
request = new HttpGet(requestUrl);
}
-
+
request.setHeader("Accept", "application/xml");
HttpResponse httpResponse = httpClient.execute(request);
-
+
HttpEntity entity = httpResponse.getEntity();
-
-
- if (entity != null)
- {
+
+ if (entity != null) {
InputStream is = entity.getContent();
String xml = readInputStreamToString(is);
httpClient.getConnectionManager().shutdown();
-
+
logger.debug("Response\n" + xml);
return xml;
}
- }
- catch(IOException e)
- {
+ } catch (IOException e) {
logger.error("Error processing request to: " + requestUrl, e);
throw new DeltaCloudClientException("Error processing request to: " + requestUrl, e);
} catch (Exception e) {
@@ -134,58 +134,100 @@
}
throw new DeltaCloudClientException("Could not execute request to:" + requestUrl);
}
-
- private static String readInputStreamToString(InputStream is) throws DeltaCloudClientException
- {
- try
- {
- try
- {
- if (is != null)
- {
+
+ private static String readInputStreamToString(InputStream is) throws DeltaCloudClientException {
+ try {
+ try {
+ if (is != null) {
StringBuilder sb = new StringBuilder();
String line;
-
+
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- while ((line = reader.readLine()) != null)
- {
- sb.append(line).append("\n");
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n");
}
return sb.toString();
}
- }
- finally
- {
+ } finally {
is.close();
}
- }
- catch(Exception e)
- {
+ } catch (Exception e) {
throw new DeltaCloudClientException("Error converting Response to String", e);
}
return "";
}
-
+
+ public static DeltaCloudType getDeltaCloudType(String url) {
+ DeltaCloudType cloudType = DeltaCloudType.UNKNOWN;
+ try {
+ Object o = getURLContent(url + REQUEST_URL_API); //$NON-NLS-1$
+ if (o instanceof InputStream) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document document = db.parse(
+ new InputSource(new StringReader(getXML((InputStream) o))));
+
+ NodeList elements = document.getElementsByTagName(DOCUMENT_ELEMENT_API);
+ if (elements.getLength() > 0) {
+ Node n = elements.item(0);
+ Node driver = n.getAttributes().getNamedItem(DOCUMENT_ELEMENT_DRIVER);
+ if (driver != null) {
+ String driverValue = driver.getNodeValue();
+ cloudType = DeltaCloudType.valueOf(driverValue.toUpperCase());
+ }
+ }
+ }
+ } catch (MalformedURLException e) {
+ cloudType = DeltaCloudType.INVALID_URL;
+ } catch (Exception e) {
+ cloudType = DeltaCloudType.UNKNOWN;
+ }
+ return cloudType;
+ }
+
+ private static Object getURLContent(String url) throws IOException {
+ URL u = new URL(url);
+ URLConnection connection = u.openConnection();
+ connection.setRequestProperty(HTTPHEADER_KEY_ACCEPT, HTTPHEADER_VALUE_ACCEPTXML);
+ return connection.getContent();
+ }
+
+ private static String getXML(InputStream is) throws UnsupportedEncodingException, IOException {
+ try {
+ if (is == null) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder();
+ String line = "";
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is, URLCONNECTION_ENCODING));
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n"); //$NON-NLS-1$
+ }
+ return sb.toString();
+ } finally {
+ is.close();
+ }
+ }
+
@Override
- public Instance createInstance(String imageId) throws DeltaCloudClientException
- {
+ public Instance createInstance(String imageId) throws DeltaCloudClientException {
String query = "?image_id=" + imageId;
return buildInstance(sendRequest(DCNS.INSTANCES + query, RequestType.POST));
}
@Override
- public Instance createInstance(String imageId, String profileId, String realmId, String name) throws DeltaCloudClientException
- {
+ public Instance createInstance(String imageId, String profileId, String realmId, String name)
+ throws DeltaCloudClientException {
return createInstance(imageId, profileId, realmId, name, null, null, null);
}
- public Instance createInstance(String imageId, String profileId, String realmId, String name, String memory, String storage) throws DeltaCloudClientException
- {
+ public Instance createInstance(String imageId, String profileId, String realmId, String name, String memory,
+ String storage) throws DeltaCloudClientException {
return createInstance(imageId, profileId, realmId, name, null, memory, storage);
}
- public Instance createInstance(String imageId, String profileId, String realmId, String name, String keyname, String memory, String storage) throws DeltaCloudClientException
- {
+ public Instance createInstance(String imageId, String profileId, String realmId, String name, String keyname,
+ String memory, String storage) throws DeltaCloudClientException {
String query = "?image_id=" + imageId + "&hwp_id=" + profileId + "&realm_id=" + realmId + "&name=" + name;
if (memory != null)
query += "&hwp_memory=" + memory;
@@ -198,52 +240,44 @@
}
@Override
- public HardwareProfile listProfile(String profileId) throws DeltaCloudClientException
- {
+ public HardwareProfile listProfile(String profileId) throws DeltaCloudClientException {
String request = DCNS.HARDWARE_PROFILES + "/" + profileId;
return JAXB.unmarshal(sendRequest(request, RequestType.GET), HardwareProfile.class);
}
@Override
- public List<HardwareProfile> listProfiles() throws DeltaCloudClientException
- {
+ public List<HardwareProfile> listProfiles() throws DeltaCloudClientException {
return listDeltaCloudObjects(HardwareProfile.class, DCNS.HARDWARE_PROFILES.toString(), "hardware_profile");
}
-
+
@Override
- public List<Image> listImages() throws DeltaCloudClientException
- {
+ public List<Image> listImages() throws DeltaCloudClientException {
return listDeltaCloudObjects(Image.class, DCNS.IMAGES.toString(), "image");
}
@Override
- public Image listImages(String imageId) throws DeltaCloudClientException
- {
+ public Image listImages(String imageId) throws DeltaCloudClientException {
return JAXB.unmarshal(sendRequest(DCNS.IMAGES + "/" + imageId, RequestType.GET), Image.class);
}
@Override
- public List<Instance> listInstances() throws DeltaCloudClientException
- {
-
+ public List<Instance> listInstances() throws DeltaCloudClientException {
+
return listDeltaCloudObjects(Instance.class, DCNS.INSTANCES.toString(), "instance");
}
@Override
- public Instance listInstances(String instanceId) throws DeltaCloudClientException
- {
+ public Instance listInstances(String instanceId) throws DeltaCloudClientException {
return buildInstance(sendRequest(DCNS.INSTANCES + "/" + instanceId, RequestType.GET));
}
-
+
@Override
- public List<Realm> listRealms() throws DeltaCloudClientException
- {
+ public List<Realm> listRealms() throws DeltaCloudClientException {
return listDeltaCloudObjects(Realm.class, DCNS.REALMS.toString(), "realm");
}
@Override
- public Realm listRealms(String realmId) throws DeltaCloudClientException
- {
+ public Realm listRealms(String realmId) throws DeltaCloudClientException {
return JAXB.unmarshal(sendRequest(DCNS.REALMS + "/" + realmId, RequestType.GET), Realm.class);
}
@@ -263,13 +297,12 @@
StringBuffer sb = new StringBuffer();
String line;
BufferedReader reader = new BufferedReader(new StringReader(keyText.get(0)));
- while ((line = reader.readLine()) != null)
- {
+ while ((line = reader.readLine()) != null) {
// We must trim off the white-space from the xml
// Complete white-space lines are to be ignored.
String trimmedLine = line.trim();
if (trimmedLine.length() > 0)
- sb.append(trimmedLine).append("\n");
+ sb.append(trimmedLine).append("\n");
}
FileWriter w = new FileWriter(keyFile);
w.write(sb.toString());
@@ -282,108 +315,95 @@
public void deleteKey(String keyname) throws DeltaCloudClientException {
sendRequest(DCNS.KEYS + "/" + keyname, RequestType.DELETE);
}
-
+
@Override
- public void rebootInstance(String instanceId) throws DeltaCloudClientException
- {
+ public void rebootInstance(String instanceId) throws DeltaCloudClientException {
sendRequest(DCNS.INSTANCES + "/" + instanceId + DCNS.REBOOT, RequestType.GET);
}
@Override
- public void shutdownInstance(String instanceId) throws DeltaCloudClientException
- {
+ public void shutdownInstance(String instanceId) throws DeltaCloudClientException {
sendRequest(DCNS.INSTANCES + "/" + instanceId + DCNS.STOP, RequestType.GET);
}
-
+
@Override
- public void startInstance(String instanceId) throws DeltaCloudClientException
- {
+ public void startInstance(String instanceId) throws DeltaCloudClientException {
sendRequest(DCNS.INSTANCES + "/" + instanceId + DCNS.START, RequestType.GET);
}
@Override
- public void destroyInstance(String instanceId) throws DeltaCloudClientException
- {
+ public void destroyInstance(String instanceId) throws DeltaCloudClientException {
sendRequest(DCNS.INSTANCES + "/" + instanceId, RequestType.DELETE);
}
-
- private void checkForErrors(Document d) throws DeltaCloudClientException
- {
+
+ private void checkForErrors(Document d) throws DeltaCloudClientException {
NodeList n = d.getElementsByTagName("error");
- for (int i = 0; i < n.getLength(); ++i)
- {
+ for (int i = 0; i < n.getLength(); ++i) {
Node node = n.item(i);
Node statusNode = node.getAttributes().getNamedItem("status");
if (statusNode != null) {
- String status = node.getAttributes().getNamedItem("status").getNodeValue();
- if (status.equals("403"))
- throw new DeltaCloudAuthException("Authorization error");
- else if (status.equals("404"))
- throw new DeltaCloudClientException("Not found");
- else
- throw new DeltaCloudClientException("Connection error");
+ String status = node.getAttributes().getNamedItem("status").getNodeValue();
+ if (status.equals("403"))
+ throw new DeltaCloudAuthException("Authorization error");
+ else if (status.equals("404"))
+ throw new DeltaCloudClientException("Not found");
+ else
+ throw new DeltaCloudClientException("Connection error");
}
}
}
-
- private Instance buildInstance(String xml) throws DeltaCloudClientException
- {
- try
- {
+
+ private Instance buildInstance(String xml) throws DeltaCloudClientException {
+ try {
Instance instance = JAXB.unmarshal(new StringReader(xml), Instance.class);
-
+
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(xml)));
-
+
checkForErrors(document);
-
+
instance.setImageId(getIdFromHref(getAttributeValues(document, "image", "href").get(0))); //$NON-NLS-1$ //$NON-NLS-2$
instance.setProfileId(getIdFromHref(getAttributeValues(document, "hardware_profile", "href").get(0))); //$NON-NLS-1$ //$NON-NLS-2$
getProfileProperties(instance, getPropertyNodes(document, "hardware_profile")); //$NON-NLS-1$
instance.setRealmId(getIdFromHref(getAttributeValues(document, "realm", "href").get(0))); //$NON-NLS-1$ //$NON-NLS-2$
instance.setState(getElementText(document, "state").get(0)); //$NON-NLS-1$
getAuthentication(document, instance);
-
+
ArrayList<Instance.Action> actions = new ArrayList<Instance.Action>();
- for(String s : getAttributeValues(document, "link", "rel")) //$NON-NLS-1$ //$NON-NLS-2$
+ for (String s : getAttributeValues(document, "link", "rel")) //$NON-NLS-1$ //$NON-NLS-2$
{
actions.add(Instance.Action.valueOf(s.toUpperCase()));
}
instance.setActions(actions);
-
+
return instance;
- }
- catch (DeltaCloudClientException e) {
+ } catch (DeltaCloudClientException e) {
throw e;
- }
- catch(Exception e)
- {
+ } catch (Exception e) {
DeltaCloudClientException newException = new DeltaCloudClientException(e.getLocalizedMessage());
throw newException;
}
}
- private HardwareProfile buildHardwareProfile(String xml) throws DeltaCloudClientException
- {
- try
- {
+ private HardwareProfile buildHardwareProfile(String xml) throws DeltaCloudClientException {
+ try {
HardwareProfile profile = JAXB.unmarshal(new StringReader(xml), HardwareProfile.class);
-
+
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(xml)));
-
+
checkForErrors(document);
-
+
List<Node> nodes = getPropertyNodes(document, "hardware_profile"); //$NON-NLS-1$
-
+
for (Node n : nodes) {
Property p = new Property();
p.setName(n.getAttributes().getNamedItem("name").getNodeValue()); //$NON-NLS-1$
p.setValue(n.getAttributes().getNamedItem("value").getNodeValue()); //$NON-NLS-1$
p.setUnit(n.getAttributes().getNamedItem("unit").getNodeValue()); //$NON-NLS-1$
- p.setKind(n.getAttributes().getNamedItem("kind").getNodeValue()) ; //$NON-NLS-1$
+ p.setKind(n.getAttributes().getNamedItem("kind").getNodeValue()); //$NON-NLS-1$
if (p.getKind().equals("range")) { //$NON-NLS-1$
NodeList children = n.getChildNodes();
for (int i = 0; i < children.getLength(); ++i) {
@@ -394,8 +414,7 @@
p.setRange(first, last);
}
}
- }
- else if (p.getKind().equals("enum")) { //$NON-NLS-1$
+ } else if (p.getKind().equals("enum")) { //$NON-NLS-1$
ArrayList<String> enums = new ArrayList<String>();
NodeList children = n.getChildNodes();
for (int i = 0; i < children.getLength(); ++i) {
@@ -415,45 +434,36 @@
profile.getProperties().add(p);
}
return profile;
- }
- catch(Exception e)
- {
+ } catch (Exception e) {
e.printStackTrace();
}
return null;
}
- private List<String> getAttributeValues(Document document, String elementName, String attributeName)
- {
+ private List<String> getAttributeValues(Document document, String elementName, String attributeName) {
NodeList elements = document.getElementsByTagName(elementName);
ArrayList<String> values = new ArrayList<String>();
- for(int i = 0; i < elements.getLength(); i++)
- {
+ for (int i = 0; i < elements.getLength(); i++) {
values.add(elements.item(i).getAttributes().getNamedItem(attributeName).getTextContent());
}
return values;
}
-
- private List<String> getElementText(Document document, String elementName)
- {
+
+ private List<String> getElementText(Document document, String elementName) {
NodeList elements = document.getElementsByTagName(elementName);
ArrayList<String> values = new ArrayList<String>();
- for(int i = 0; i < elements.getLength(); i++)
- {
+ for (int i = 0; i < elements.getLength(); i++) {
values.add(elements.item(i).getTextContent());
}
return values;
}
-
- private List<Node> getPropertyNodes(Document document, String elementName)
- {
+
+ private List<Node> getPropertyNodes(Document document, String elementName) {
NodeList elements = document.getElementsByTagName(elementName);
ArrayList<Node> values = new ArrayList<Node>();
- for(int i = 0; i < elements.getLength(); i++)
- {
+ for (int i = 0; i < elements.getLength(); i++) {
NodeList children = elements.item(i).getChildNodes();
- for (int j = 0; j < children.getLength(); ++j)
- {
+ for (int j = 0; j < children.getLength(); ++j) {
Node child = children.item(j);
if (child.getNodeName().equals("property")) { //$NON-NLS-1$
values.add(child);
@@ -462,11 +472,10 @@
}
return values;
}
-
+
private void getAuthentication(Document document, Instance instance) {
NodeList elements = document.getElementsByTagName("authentication");
- for (int i = 0; i < elements.getLength(); i++)
- {
+ for (int i = 0; i < elements.getLength(); i++) {
Node element = elements.item(i);
NamedNodeMap attrs = element.getAttributes();
Node type = attrs.getNamedItem("type"); //$NON-NLS-1$
@@ -487,7 +496,7 @@
}
}
}
-
+
private void getProfileProperties(Instance instance, List<Node> propertyNodes) {
if (propertyNodes != null) {
for (Iterator<Node> i = propertyNodes.iterator(); i.hasNext();) {
@@ -496,13 +505,13 @@
String name = attrs.getNamedItem("name").getNodeValue(); //$NON-NLS-1$
if (name.equals("memory")) { //$NON-NLS-1$
String memory = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
- if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
+ if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
memory += " " + attrs.getNamedItem("unit").getNodeValue(); //$NON-NLS-1$
}
instance.setMemory(memory);
} else if (name.equals("storage")) { //$NON-NLS-1$
String storage = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
- if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
+ if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
storage += " " + attrs.getNamedItem("unit").getNodeValue(); //$NON-NLS-1$
}
instance.setStorage(storage);
@@ -513,86 +522,68 @@
}
}
}
-
- private String getIdFromHref(String href)
- {
+
+ private String getIdFromHref(String href) {
return href.substring(href.lastIndexOf("/") + 1, href.length());
}
-
- private <T extends DeltaCloudObject> List<T> listDeltaCloudObjects(Class<T> clazz, String path, String elementName) throws DeltaCloudClientException
- {
- try
- {
+
+ private <T extends DeltaCloudObject> List<T> listDeltaCloudObjects(Class<T> clazz, String path, String elementName)
+ throws DeltaCloudClientException {
+ try {
InputSource is = new InputSource(new StringReader(sendRequest(path, RequestType.GET)));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(is);
-
+
checkForErrors(document);
-
- document.getElementsByTagName(path).toString();
-
+
+ document.getElementsByTagName(path).toString();
+
ArrayList<T> dco = new ArrayList<T>();
-
+
NodeList nodeList = document.getElementsByTagName(elementName);
- for(int i = 0; i < nodeList.getLength(); i ++)
- {
+ for (int i = 0; i < nodeList.getLength(); i++) {
dco.add(buildDeltaCloudObject(clazz, nodeList.item(i)));
}
return dco;
- } catch (DeltaCloudClientException e)
- {
+ } catch (DeltaCloudClientException e) {
throw e;
- }
- catch(Exception e)
- {
+ } catch (Exception e) {
throw new DeltaCloudClientException("Could not list object of type " + clazz, e);
}
}
-
+
@SuppressWarnings("unchecked")
- private <T extends Object> T buildDeltaCloudObject(Class<T> clazz, Node node) throws DeltaCloudClientException
- {
- if(clazz.equals(Instance.class))
- {
+ private <T extends Object> T buildDeltaCloudObject(Class<T> clazz, Node node) throws DeltaCloudClientException {
+ if (clazz.equals(Instance.class)) {
return (T) buildInstance(nodeToString(node));
- }
- else if (clazz.equals(HardwareProfile.class))
- {
+ } else if (clazz.equals(HardwareProfile.class)) {
return (T) buildHardwareProfile(nodeToString(node));
- }
- else
- {
+ } else {
return JAXB.unmarshal(new StringReader(nodeToString(node)), clazz);
}
}
- public boolean performInstanceAction(String instanceId, String action) throws DeltaCloudClientException
- {
- Instance instance = listInstances(instanceId);
- if(instance.getActionNames().contains(action))
- {
- String request = DCNS.INSTANCES + "/" + instanceId + "/" + action.toLowerCase();
- sendRequest(request, RequestType.POST);
- return true;
- }
- return false;
- }
-
- private String nodeToString(Node node) throws DeltaCloudClientException
- {
- try
- {
+ public boolean performInstanceAction(String instanceId, String action) throws DeltaCloudClientException {
+ Instance instance = listInstances(instanceId);
+ if (instance.getActionNames().contains(action)) {
+ String request = DCNS.INSTANCES + "/" + instanceId + "/" + action.toLowerCase();
+ sendRequest(request, RequestType.POST);
+ return true;
+ }
+ return false;
+ }
+
+ private String nodeToString(Node node) throws DeltaCloudClientException {
+ try {
StringWriter writer = new StringWriter();
Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(new DOMSource(node), new StreamResult(writer));
return writer.toString();
- }
- catch (TransformerException e)
- {
+ } catch (TransformerException e) {
throw new DeltaCloudClientException("Error transforming node to string", e);
}
-
+
}
}
14 years, 2 months
JBoss Tools SVN: r25937 - in trunk/deltacloud/tests/org.jboss.tools.deltacloud.test: META-INF and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-10-20 07:10:19 -0400 (Wed, 20 Oct 2010)
New Revision: 25937
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/.classpath
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/META-INF/MANIFEST.MF
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/deltacloud-dependencies.jar
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltacloudIntegrationTest.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudClientTest.java
Log:
[JBIDE-7371] moved deltacloud url checking to deltacloud client, added tests
Modified: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/.classpath
===================================================================
--- trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/.classpath 2010-10-20 11:09:13 UTC (rev 25936)
+++ trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/.classpath 2010-10-20 11:10:19 UTC (rev 25937)
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="jruby-complete-1.5.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="lib" path="deltacloud-dependencies.jar"/>
+ <classpathentry kind="lib" path="jruby-complete-1.5.3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/META-INF/MANIFEST.MF 2010-10-20 11:09:13 UTC (rev 25936)
+++ trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/META-INF/MANIFEST.MF 2010-10-20 11:10:19 UTC (rev 25937)
@@ -4,7 +4,8 @@
Bundle-SymbolicName: org.jboss.tools.deltacloud.test
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.junit;bundle-version="4.8.1",
- org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)"
+Require-Bundle: org.jboss.tools.deltacloud.core;bundle-version="0.0.1",
+ org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
+ org.junit;bundle-version="4.8.1"
Bundle-ClassPath: jruby-complete-1.5.3.jar,
.
Modified: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/deltacloud-dependencies.jar
===================================================================
(Binary files differ)
Modified: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltacloudIntegrationTest.java
===================================================================
--- trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltacloudIntegrationTest.java 2010-10-20 11:09:13 UTC (rev 25936)
+++ trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltacloudIntegrationTest.java 2010-10-20 11:10:19 UTC (rev 25937)
@@ -10,11 +10,9 @@
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.javasupport.JavaEmbedUtils;
-import org.junit.Test;
public class DeltacloudIntegrationTest {
- @Test
public void runDeltaCloud() throws IOException {
RubyInstanceConfig config = new RubyInstanceConfig();
Modified: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudClientTest.java
===================================================================
--- trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudClientTest.java 2010-10-20 11:09:13 UTC (rev 25936)
+++ trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudClientTest.java 2010-10-20 11:10:19 UTC (rev 25937)
@@ -1,5 +1,43 @@
package org.jboss.tools.internal.deltacloud.test.core;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClient;
+import org.junit.Before;
+import org.junit.Test;
+
public class DeltaCloudClientTest {
+ private static final String DELTACLOUD_URL = "http://localhost:3001";
+ private static final String DELTACLOUD_USER = "user";
+ private static final String DELTACLOUD_PASSWORD = "password";
+
+ private DeltaCloudClient client;
+
+ @Before
+ public void createDeltaCloudClient() throws MalformedURLException {
+ this.client = new DeltaCloudClient(new URL(DELTACLOUD_URL), DELTACLOUD_USER, DELTACLOUD_PASSWORD);
+ }
+
+ @Test
+ public void isDeltaCloudRunning() throws MalformedURLException, IOException {
+ URLConnection connection = new URL(DELTACLOUD_URL).openConnection();
+ connection.connect();
+ }
+
+ @Test
+ public void canRecognizeMockDeltaCloud() throws IOException {
+ Process process = launchDeltaCloudMock();
+ assertEquals(DeltaCloudClient.DeltaCloudType.MOCK, DeltaCloudClient.getDeltaCloudType(DELTACLOUD_URL));
+ process.destroy();
+ }
+
+ private Process launchDeltaCloudMock() throws IOException {
+ return Runtime.getRuntime().exec("/usr/bin/deltacloudd -i mock");
+ }
}
14 years, 2 months
JBoss Tools SVN: r25936 - trunk/deltacloud/tests/org.jboss.tools.deltacloud.test.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-10-20 07:09:13 -0400 (Wed, 20 Oct 2010)
New Revision: 25936
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/bootstrap-deltacloud.rb
Log:
[JBIDE-7371] moved deltacloud url checking to deltacloud client, added tests
Modified: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/bootstrap-deltacloud.rb
===================================================================
--- trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/bootstrap-deltacloud.rb 2010-10-20 11:08:41 UTC (rev 25935)
+++ trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/bootstrap-deltacloud.rb 2010-10-20 11:09:13 UTC (rev 25936)
@@ -1,5 +1,7 @@
require 'rubygems'
+#require 'deltacloud-dependencies.jar'
require 'deltacloud-dependencies.jar'
+#require 'steamcannon-deltacloud-core'
# Force Rubygems to reload the gem paths
Gem.clear_paths
14 years, 2 months
JBoss Tools SVN: r25935 - trunk/deltacloud/tests/org.jboss.tools.deltacloud.test.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-10-20 07:08:41 -0400 (Wed, 20 Oct 2010)
New Revision: 25935
Added:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/build-deltacloud-dependencies.sh
Log:
[JBIDE-7371] moved deltacloud url checking to deltacloud client, added tests
Added: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/build-deltacloud-dependencies.sh
===================================================================
--- trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/build-deltacloud-dependencies.sh (rev 0)
+++ trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/build-deltacloud-dependencies.sh 2010-10-20 11:08:41 UTC (rev 25935)
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+java -jar jruby-complete-1.5.3.jar -S gem install -i ./deltacloud-dependencies \
+activesupport \
+amazon-ec2 \
+daemons \
+eventmachine \
+haml \
+highline hoe \
+http_connection \
+json \
+json_pure \
+mime-types \
+nokogiri \
+rack \
+rack-accept \
+rerun \
+rest-client \
+right_aws \
+right_http_connection \
+rubyforge \
+sinatra \
+steamcannon-deltacloud-core \
+uuidtools \
+xml-simple --no-rdoc --no-ri
+
+jar cf deltacloud-dependencies.jar -C deltacloud-dependencies .
+
Property changes on: trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/build-deltacloud-dependencies.sh
___________________________________________________________________
Name: svn:executable
+ *
14 years, 2 months
JBoss Tools SVN: r25934 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config.
by jbosstools-commits@lists.jboss.org
Author: jpeterka
Date: 2010-10-20 05:26:18 -0400 (Wed, 20 Oct 2010)
New Revision: 25934
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
Log:
Loading default configuration slightly modified
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-10-20 09:13:46 UTC (rev 25933)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-10-20 09:26:18 UTC (rev 25934)
@@ -43,6 +43,8 @@
public static Properties multiProperties = new Properties();
public static TestConfiguration currentConfig;
static {
+ boolean loadDefault = true;
+
try {
// try to load from file first
String propFile = System.getProperty(SWTBOT_TEST_PROPERTIES_FILE,
@@ -55,6 +57,7 @@
.info("Loading exeternaly provided multi-configuration file '"
+ propMultiFile + "'");
multiProperties.load(new FileInputStream(propMultiFile));
+ loadDefault = false;
}
else {
throw new IOException(SWTBOT_TEST_PROPERTIES_MULTI_FILE + " "
@@ -67,6 +70,7 @@
.info("Loading exeternaly configuration file '"
+ propFile + "'");
multiProperties.put("Default", propFile);
+ loadDefault = false;
}
else {
throw new IOException(SWTBOT_TEST_PROPERTIES_FILE + " "
@@ -75,27 +79,27 @@
}
else {
log.info("No configuration property passed, using default");
- multiProperties.put(SWTBOT_TEST_PROPERTIES_FILE, "");
-
+ multiProperties.put(SWTBOT_TEST_PROPERTIES_FILE, "");
}
} catch (Exception ex) {
ex.printStackTrace();
}
- // load default config by default
- /*
- try {
- log.info(" * Loading default configuration first");
- currentConfig = new TestConfiguration("default", "");
-
- } catch (Exception e) {
- // log only message, nothing
- log.error(e.getMessage());
+
+ if (loadDefault) {
+ // load default config by default
+ try {
+ log.info(" * Loading default configuration first");
+ currentConfig = new TestConfiguration("default", "");
+
+ } catch (Exception e) {
+ // log only message, nothing
+ log.error(e.getMessage());
+ }
+ finally {
+ log.info(" * Defaults loaded");
+ }
}
- finally {
- log.info(" * Defaults loaded");
- }
- */
}
/**
14 years, 2 months
JBoss Tools SVN: r25933 - in trunk/runtime/plugins/org.jboss.tools.runtime: src/org/jboss/tools/runtime and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2010-10-20 05:13:46 -0400 (Wed, 20 Oct 2010)
New Revision: 25933
Added:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/IJBossRuntimePluginConstants.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties
trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Activator.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Messages.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java
Log:
JBIDE-7373 - code cleanup on runtimes plugin.
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties 2010-10-20 09:13:46 UTC (rev 25933)
@@ -1,4 +1,5 @@
#Properties file for org.jboss.tools.runtime
BundleVendor = JBoss by Red Hat
BundleName = JBoss Runtime Initializer
-JBoss_Runtimes = JBoss Runtimes
\ No newline at end of file
+JBoss_Runtimes = JBoss Runtimes
+ImportExportJBossRuntimes = Import / Export JBoss Runtimes
\ No newline at end of file
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml 2010-10-20 09:13:46 UTC (rev 25933)
@@ -28,7 +28,7 @@
<transfer
id="org.jboss.tools.runtime.jbossruntime"
icon="$nl$/icons/jboss.gif"
- name="JBoss Runtimes">
+ name="%JBoss_Runtimes">
<mapping
scope="instance">
<entry
@@ -56,9 +56,7 @@
node="org.jboss.ide.eclipse.as.ui">
</entry>
</mapping>
- <description>
- Export JBoss Runtimes
- </description>
+ <description>%ImportExportJBossRuntimes</description>
</transfer>
</extension>
<!--
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Activator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Activator.java 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Activator.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.runtime;
import org.eclipse.core.runtime.IStatus;
@@ -62,4 +72,10 @@
.getLocalizedMessage(), e);
Activator.getDefault().getLog().log(status);
}
+
+ public static void log(Throwable e, String message) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ Activator.getDefault().getLog().log(status);
+ }
+
}
Added: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/IJBossRuntimePluginConstants.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/IJBossRuntimePluginConstants.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/IJBossRuntimePluginConstants.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.runtime;
+
+public interface IJBossRuntimePluginConstants {
+ public static final String DEFAULT_DS = "DefaultDS";
+ public static final String RUNTIME = Messages.JBossRuntimeStartup_Runtime;
+ public static final String EAP = "EAP"; //$NON-NLS-1$
+ public static final String SOA_P = "SOA-P"; //$NON-NLS-1$
+ public static final String SOA_P_STD = "SOA-P-STD"; //$NON-NLS-1$
+ public static final String EPP = "EPP"; //$NON-NLS-1$
+ public static final String EWP = "EWP"; //$NON-NLS-1$
+ public static final String SEAM = "SEAM"; // NON-NLS-1$
+ public static final String DROOLS = "DROOLS"; // NON-NLS-1$
+ public static final String AS = "AS"; //$NON-NLS-1$
+ public static final String JBOSS_EAP_HOME = "../../../../jboss-eap/jboss-as"; // JBoss AS home directory (relative to plugin)- <RHDS_HOME>/jbossas. //$NON-NLS-1$
+ public static final String JBOSS_EAP_HOME_CONFIGURATION = "../../jboss-eap/jboss-as"; // JBoss AS home directory (relative to plugin)- <RHDS_HOME>/jbossas. //$NON-NLS-1$
+ public static final String SERVERS_FILE_NAME = "application_platforms.properties"; //$NON-NLS-1$
+ public static final String SERVERS_FILE = "../../../../studio/" + SERVERS_FILE_NAME; //$NON-NLS-1$
+ public static final String SERVERS_FILE_CONFIGURATION = "../../studio/" + SERVERS_FILE_NAME; //$NON-NLS-1$
+ public static String RUNTIME_CONFIG_FORMAT_VERSION = "1.0"; //$NON-NLS-1$
+
+ public static final String SEAM_1_2_HOME = "../../../../jboss-eap/seam"; //$NON-NLS-1$
+ public static final String SEAM_1_2_HOME_CONFIGURATION = "../../jboss-eap/seam"; //$NON-NLS-1$
+ public static final String SEAM_1_2_HOME_CP = "../../../../jboss-eap/seam1"; //$NON-NLS-1$
+ public static final String SEAM_1_2_HOME_CONFIGURATION_CP = "../../jboss-eap/seam1"; //$NON-NLS-1$
+
+ public static final String SEAM_2_0_HOME = "../../../../jboss-eap/seamfp"; //$NON-NLS-1$
+ public static final String SEAM_2_0_HOME_CONFIGURATION = "../../jboss-eap/seamfp"; //$NON-NLS-1$
+ public static final String SEAM_2_0_HOME_CP = "../../../../jboss-eap/seam2"; //$NON-NLS-1$
+ public static final String SEAM_2_0_HOME_CONFIGURATION_CP = "../../jboss-eap/seam2"; //$NON-NLS-1$
+
+ public static final String[] SEAM_HOME_FOLDER_OPTIONS = {"seam","seam1","seam2","seamfp"};
+
+ // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
+ public static final String JBOSS_AS_RUNTIME_TYPE_ID[] = {
+ "org.jboss.ide.eclipse.as.runtime.32", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.40", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.42", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.50", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.51", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.60", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.eap.43", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.runtime.eap.50" //$NON-NLS-1$
+ };
+
+ public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar"; //$NON-NLS-1$
+
+ public static final String HSQLDB_DRIVER_3X_4X_LOCATION = "/server/default/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
+
+ public static final String HSQLDB_DRIVER_5X_LOCATION = "/common/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
+
+ // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
+ public static final String JBOSS_AS_HSQL_DRIVER_LOCATION[] = {
+ HSQLDB_DRIVER_3X_4X_LOCATION,
+ HSQLDB_DRIVER_3X_4X_LOCATION,
+ HSQLDB_DRIVER_3X_4X_LOCATION,
+ HSQLDB_DRIVER_5X_LOCATION,
+ HSQLDB_DRIVER_5X_LOCATION,
+ HSQLDB_DRIVER_5X_LOCATION,
+ HSQLDB_DRIVER_3X_4X_LOCATION,
+ HSQLDB_DRIVER_5X_LOCATION
+ };
+
+ public static final String JBOSS_AS_TYPE_ID[] = {
+ "org.jboss.ide.eclipse.as.32", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.40", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.42", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.50", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.51", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.60", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.eap.43", //$NON-NLS-1$
+ "org.jboss.ide.eclipse.as.eap.50", //$NON-NLS-1$
+ };
+
+ public static final String JBOSS_AS_NAME[] = {
+ Messages.JBossRuntimeStartup_JBoss_Application_Server_3_2,
+ Messages.JBossRuntimeStartup_JBoss_Application_Server_4_0,
+ Messages.JBossRuntimeStartup_JBoss_Application_Server_4_2,
+ Messages.JBossRuntimeStartup_JBoss_Application_Server_5_0,
+ Messages.JBossRuntimeStartup_JBoss_Application_Server_5_1,
+ Messages.JBossRuntimeStartup_JBoss_Application_Server_6_0,
+ Messages.JBossRuntimeStartup_JBoss_EAP_Server_4_3,
+ Messages.JBossRuntimeStartup_JBoss_EAP_Server_5_0
+ };
+
+ public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
+
+ public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default"; //$NON-NLS-1$
+
+ //public static final String FIRST_START_PREFERENCE_NAME = "FIRST_START";
+
+ public static final String HSQL_DRIVER_DEFINITION_ID
+ = "DriverDefn.Hypersonic DB"; //$NON-NLS-1$
+
+ public static final String HSQL_DRIVER_NAME = "Hypersonic DB"; //$NON-NLS-1$
+
+ public static final String HSQL_DRIVER_TEMPLATE_ID
+ = "org.eclipse.datatools.enablement.hsqldb.1_8.driver"; //$NON-NLS-1$
+
+ public static final String DTP_DB_URL_PROPERTY_ID
+ = "org.eclipse.datatools.connectivity.db.URL"; //$NON-NLS-1$
+
+ public static final String HSQL_PROFILE_ID = "org.eclipse.datatools.enablement.hsqldb.connectionProfile";
+
+ public static final String JBPM = "JBPM";
+
+}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -25,7 +25,7 @@
import org.jboss.ide.eclipse.as.core.server.bean.ServerBean;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
-public class JBossRuntimeLocator {
+public class JBossRuntimeLocator implements IJBossRuntimePluginConstants {
public static final String JBPM3 = "jBPM3";
@@ -63,7 +63,7 @@
} else {
String seamVersion = getSeamVersionFromManifest(root.getAbsolutePath());
if (seamVersion != null) {
- serverDefinitions.add(new ServerDefinition(root.getName(), seamVersion, JBossRuntimeStartup.SEAM, root.getAbsoluteFile()));
+ serverDefinitions.add(new ServerDefinition(root.getName(), seamVersion, SEAM, root.getAbsoluteFile()));
} else {
String[] files = root.list(new FilenameFilter() {
@@ -79,7 +79,7 @@
String version = getImplementationVersion(root,files[0]);
if (version != null) {
version = version.substring(0,3);
- serverDefinitions.add(new ServerDefinition(root.getName(), version, JBossRuntimeStartup.DROOLS, root.getAbsoluteFile()));
+ serverDefinitions.add(new ServerDefinition(root.getName(), version, DROOLS, root.getAbsoluteFile()));
droolsFound = true;
}
}
@@ -93,7 +93,7 @@
} else if (isJbpm4(root.getAbsolutePath())) {
version = JBPM4;
}
- serverDefinitions.add(new ServerDefinition(root.getName(), version, JBossRuntimeStartup.JBPM, root.getAbsoluteFile()));
+ serverDefinitions.add(new ServerDefinition(root.getName(), version, JBPM, root.getAbsoluteFile()));
jbpmFound = true;
}
}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.runtime;
import java.io.BufferedInputStream;
@@ -7,206 +17,67 @@
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
-import org.drools.eclipse.util.DroolsRuntime;
-import org.drools.eclipse.util.DroolsRuntimeManager;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.ConnectionProfileException;
-import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.drivers.DriverInstance;
-import org.eclipse.datatools.connectivity.drivers.DriverManager;
-import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
-import org.eclipse.datatools.connectivity.drivers.IPropertySet;
-import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
-import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
-import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
-import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
-import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
-import org.jboss.tools.jbpm.preferences.JbpmInstallation;
-import org.jboss.tools.jbpm.preferences.PreferencesManager;
-import org.jboss.tools.seam.core.SeamUtil;
-import org.jboss.tools.seam.core.project.facet.SeamRuntime;
-import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
-import org.jboss.tools.seam.core.project.facet.SeamVersion;
+import org.jboss.tools.runtime.handlers.DroolsHandler;
+import org.jboss.tools.runtime.handlers.JBossASHandler;
+import org.jboss.tools.runtime.handlers.JbpmHandler;
+import org.jboss.tools.runtime.handlers.SeamHandler;
import org.osgi.framework.Bundle;
import org.osgi.service.prefs.BackingStoreException;
-public class JBossRuntimeStartup implements IStartup {
+public class JBossRuntimeStartup implements IStartup, IJBossRuntimePluginConstants {
- /**
- *
- */
- private static final String DEFAULT_DS = "DefaultDS";
+ public static interface IJBossRuntimePersistanceHandler {
+ public void initializeRuntimes(List<ServerDefinition> serverDefinitions);
+ public void importRuntimes();
+ public void exportRuntimes();
+ }
- private static final String RUNTIME = Messages.JBossRuntimeStartup_Runtime;
-
- private static final String EAP = "EAP"; //$NON-NLS-1$
-
- private static final String SOA_P = "SOA-P"; //$NON-NLS-1$
-
- private static final String SOA_P_STD = "SOA-P-STD"; //$NON-NLS-1$
-
- private static final String EPP = "EPP"; //$NON-NLS-1$
-
- private static final String EWP = "EWP"; //$NON-NLS-1$
-
- public static final String SEAM = "SEAM"; // NON-NLS-1$
-
- public static final String DROOLS = "DROOLS"; // NON-NLS-1$
-
- private static final String AS = "AS"; //$NON-NLS-1$
-
- public static final String JBOSS_EAP_HOME = "../../../../jboss-eap/jboss-as"; // JBoss AS home directory (relative to plugin)- <RHDS_HOME>/jbossas. //$NON-NLS-1$
-
- public static final String JBOSS_EAP_HOME_CONFIGURATION = "../../jboss-eap/jboss-as"; // JBoss AS home directory (relative to plugin)- <RHDS_HOME>/jbossas. //$NON-NLS-1$
-
- public static final String SERVERS_FILE_NAME = "application_platforms.properties"; //$NON-NLS-1$
-
- public static final String SERVERS_FILE = "../../../../studio/" + SERVERS_FILE_NAME; //$NON-NLS-1$
-
- public static final String SERVERS_FILE_CONFIGURATION = "../../studio/" + SERVERS_FILE_NAME; //$NON-NLS-1$
-
- public static String RUNTIME_CONFIG_FORMAT_VERSION = "1.0"; //$NON-NLS-1$
-
- public static final String SEAM_1_2_HOME = "../../../../jboss-eap/seam"; //$NON-NLS-1$
- public static final String SEAM_1_2_HOME_CONFIGURATION = "../../jboss-eap/seam"; //$NON-NLS-1$
- public static final String SEAM_1_2_HOME_CP = "../../../../jboss-eap/seam1"; //$NON-NLS-1$
- public static final String SEAM_1_2_HOME_CONFIGURATION_CP = "../../jboss-eap/seam1"; //$NON-NLS-1$
-
- public static final String SEAM_2_0_HOME = "../../../../jboss-eap/seamfp"; //$NON-NLS-1$
- public static final String SEAM_2_0_HOME_CONFIGURATION = "../../jboss-eap/seamfp"; //$NON-NLS-1$
- public static final String SEAM_2_0_HOME_CP = "../../../../jboss-eap/seam2"; //$NON-NLS-1$
- public static final String SEAM_2_0_HOME_CONFIGURATION_CP = "../../jboss-eap/seam2"; //$NON-NLS-1$
-
- public static final String[] SEAM_HOME_FOLDER_OPTIONS = {"seam","seam1","seam2","seamfp"};
-
- // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
- public static final String JBOSS_AS_RUNTIME_TYPE_ID[] = {
- "org.jboss.ide.eclipse.as.runtime.32", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.40", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.42", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.50", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.51", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.60", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.eap.43", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.eap.50" //$NON-NLS-1$
+ public static IJBossRuntimePersistanceHandler[] getPersistanceHandlers() {
+ return new IJBossRuntimePersistanceHandler[] {
+ new JbpmHandler(),
+ new DroolsHandler(),
+ new JBossASHandler(),
+ new SeamHandler()
};
+ }
- public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar"; //$NON-NLS-1$
-
- public static final String HSQLDB_DRIVER_3X_4X_LOCATION = "/server/default/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
-
- public static final String HSQLDB_DRIVER_5X_LOCATION = "/common/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
-
- // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
- public static final String JBOSS_AS_HSQL_DRIVER_LOCATION[] = {
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION,
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION
- };
-
- public static final String JBOSS_AS_TYPE_ID[] = {
- "org.jboss.ide.eclipse.as.32", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.40", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.42", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.50", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.51", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.60", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.eap.43", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.eap.50", //$NON-NLS-1$
- };
-
- public static final String JBOSS_AS_NAME[] = {
- Messages.JBossRuntimeStartup_JBoss_Application_Server_3_2,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_4_0,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_4_2,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_5_0,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_5_1,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_6_0,
- Messages.JBossRuntimeStartup_JBoss_EAP_Server_4_3,
- Messages.JBossRuntimeStartup_JBoss_EAP_Server_5_0
- };
-
- public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
-
- public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default"; //$NON-NLS-1$
-
- //public static final String FIRST_START_PREFERENCE_NAME = "FIRST_START";
-
- public static final String HSQL_DRIVER_DEFINITION_ID
- = "DriverDefn.Hypersonic DB"; //$NON-NLS-1$
-
- public static final String HSQL_DRIVER_NAME = "Hypersonic DB"; //$NON-NLS-1$
-
- public static final String HSQL_DRIVER_TEMPLATE_ID
- = "org.eclipse.datatools.enablement.hsqldb.1_8.driver"; //$NON-NLS-1$
-
- public static final String DTP_DB_URL_PROPERTY_ID
- = "org.eclipse.datatools.connectivity.db.URL"; //$NON-NLS-1$
-
- private static final String HSQL_PROFILE_ID = "org.eclipse.datatools.enablement.hsqldb.connectionProfile";
-
- public static final String JBPM = "JBPM";
-
private List<ServerDefinition> serverDefinitions = new ArrayList<ServerDefinition>();
-
private IEclipsePreferences preferences;
public void earlyStartup() {
- if (!isJBDS()) {
- return;
+ if (isJBDS() && willBeInitialized()) {
+ parseServerFile();
+ initializeRuntimes(serverDefinitions);
+ saveWorkspacePreferences();
}
- if (!willBeInitialized()) {
- return;
+ }
+
+ public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
+ IJBossRuntimePersistanceHandler[] handlers = getPersistanceHandlers();
+ for( int i = 0; i < handlers.length; i++ ) {
+ handlers[i].initializeRuntimes(serverDefinitions);
}
- parseServerFile();
- initializeRuntimes(serverDefinitions);
- saveWorkspacePreferences();
+ refreshCommonNavigator();
}
-
+
private void saveWorkspacePreferences() {
Activator.getDefault().getPreferenceStore().setValue(Activator.FIRST_START, false);
String workspaces = getWorkspaces();
@@ -284,30 +155,7 @@
return jbdsProduct != null;
}
- public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
- initializeJbpmRuntime(serverDefinitions);
- initializeDroolsRuntime(serverDefinitions);
- try {
- String pluginLocation = FileLocator.resolve(Activator.getDefault().getBundle().getEntry("/")).getPath(); //$NON-NLS-1$
- File jbossASDir = new File(pluginLocation, JBOSS_EAP_HOME);
- if (!jbossASDir.isDirectory()) {
- Location configLocation = Platform.getConfigurationLocation();
- URL configURL = configLocation.getURL();
- String configuration = FileLocator.resolve(configURL).getPath();
- jbossASDir = new File(configuration, JBOSS_EAP_HOME_CONFIGURATION).getCanonicalFile();
- } else {
- jbossASDir = jbossASDir.getCanonicalFile();
- }
- if (jbossASDir.isDirectory()) {
- int index = getJBossASVersion(jbossASDir);
- createJBossServer(jbossASDir,index, "jboss-eap", "jboss-eap " + RUNTIME); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } catch (IOException e) {
- log(e,Messages.JBossRuntimeStartup_Cannot_create_new_JBoss_Server);
- }
- createJBossServer(serverDefinitions);
-
- initializeSeam(serverDefinitions);
+ private void refreshCommonNavigator() {
// https://jira.jboss.org/jira/browse/JBDS-1091
Display.getDefault().asyncExec(new Runnable() {
@@ -320,244 +168,9 @@
}
});
}
-
- public void initializeSeam(List<ServerDefinition> serverDefinitions) {
-
- Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
-
- // to fix https://jira.jboss.org/jira/browse/JBDS-682
- // seam runtime initialization goes throug added servers first and
- // then process seam runtimes from bundled servers
- for(ServerDefinition serverDefinition:serverDefinitions) {
- String type = serverDefinition.getType();
- if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type) ) {
- for (String folder : SEAM_HOME_FOLDER_OPTIONS) {
- File seamFile = new File(serverDefinition.getLocation(),folder); //$NON-NLS-1$
- addSeam(map, serverDefinition, seamFile);
- }
- }
- if (SEAM.equals(type)) {
- addSeam(map, serverDefinition, serverDefinition.getLocation());
- }
- }
-
- // Initialize Seam Runtime from JBoss EAP
- String seamGenBuildPath = getSeamGenBuildPath(SEAM_1_2_HOME, SEAM_1_2_HOME_CONFIGURATION);
- SeamVersion seamVersion = getSeamVersion(seamGenBuildPath);
- addSeam1(map, seamGenBuildPath, seamVersion);
-
- // fix for https://jira.jboss.org/jira/browse/JBDS-1215 The installer could not find EAP 4.3 Seam runtimes in recent CP
- seamGenBuildPath = getSeamGenBuildPath(SEAM_1_2_HOME_CP, SEAM_1_2_HOME_CONFIGURATION_CP);
- seamVersion = getSeamVersion(seamGenBuildPath);
- addSeam1(map, seamGenBuildPath, seamVersion);
-
- // Initialize Seam 2.0 Runtime from JBoss EAP
- seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME, SEAM_2_0_HOME_CONFIGURATION);
- seamVersion = getSeamVersion(seamGenBuildPath);
- addSeam2(map, seamGenBuildPath, seamVersion);
-
- // fix for https://jira.jboss.org/jira/browse/JBDS-1215 The installer could not find EAP 4.3 Seam runtimes in recent CPs
- seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME_CP, SEAM_2_0_HOME_CONFIGURATION_CP);
- seamVersion = getSeamVersion(seamGenBuildPath);
- addSeam2(map, seamGenBuildPath, seamVersion);
- }
-
- private void addSeam1(Map<String, SeamRuntime> map,
- String seamGenBuildPath, SeamVersion seamVersion) {
- if (seamVersion != null) {
- StringBuffer name = new StringBuffer("Seam ").append(seamVersion); //$NON-NLS-1$
- if(seamVersion.compareTo(SeamVersion.SEAM_1_2)==0) {
- name.append(".EAP_4.3"); //$NON-NLS-1$
- } else {
- name.append(".EAP5"); //$NON-NLS-1$
- }
- addSeam(map, seamGenBuildPath,seamVersion,name.toString());
- }
- }
-
- private void addSeam2(Map<String, SeamRuntime> map,
- String seamGenBuildPath, SeamVersion seamVersion) {
- if (seamVersion != null) {
- String name = "Seam " + seamVersion + ".FP"; //$NON-NLS-1$ //$NON-NLS-2$
- addSeam(map, seamGenBuildPath, seamVersion,name);
- }
- }
-
- private void addSeam(Map<String, SeamRuntime> map,
- ServerDefinition serverDefinition, File seamFile) {
- if (seamFile.exists() && seamFile.canRead() && seamFile.isDirectory()) {
- SeamVersion seamVersion = getSeamVersion(seamFile.getAbsolutePath());
- if (seamVersion != null) {
- String name = "Seam " + serverDefinition.getName() + " " + seamVersion; //$NON-NLS-1$ //$NON-NLS-2$
- addSeam(map, seamFile.getAbsolutePath(), seamVersion, name);
- }
- }
- }
-
- private SeamVersion getSeamVersion(String seamGenBuildPath) {
- if (seamGenBuildPath == null || seamGenBuildPath.trim().length() <= 0) {
- return null;
- }
- String fullVersion = SeamUtil.getSeamVersionFromManifest(seamGenBuildPath);
- if (fullVersion == null) {
- return null;
- }
- String version = fullVersion.substring(0,3);
- SeamVersion seamVersion = null;
- if (version != null) {
- seamVersion = SeamVersion.findByString(version);
- }
- return seamVersion;
- }
-
- private void addSeam(Map<String, SeamRuntime> map, String seamPath,SeamVersion seamVersion, String name) {
- if (!seamExists(seamPath)) {
- File seamFolder = new File(seamPath);
- if(seamFolder.exists() && seamFolder.isDirectory()) {
- SeamRuntime rt = new SeamRuntime();
- rt.setHomeDir(seamPath);
- rt.setName(name);
- rt.setDefault(true);
- rt.setVersion(seamVersion);
- SeamRuntimeManager.getInstance().addRuntime(rt);
- }
- }
- }
-
- /**
- * @param seamPath
- * @return
- */
- private boolean seamExists(String seamPath) {
- SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance().getRuntimes();
- for (SeamRuntime sr:seamRuntimes) {
- if (seamPath != null && seamPath.equals(sr.getHomeDir())) {
- return true;
- }
- }
- return false;
- }
-
- private String getSeamGenBuildPath(String seamHomePath,
- String seamHomePathConfiguration) {
- try {
- Location configLocation = Platform.getConfigurationLocation();
- URL configURL = configLocation.getURL();
- String configuration = FileLocator.resolve(configURL).getPath();
- File seamGenDir = new File(configuration, seamHomePathConfiguration);
- if (!seamGenDir.isDirectory()) {
- String pluginLocation = null;
- pluginLocation = FileLocator
- .resolve(
- Activator.getDefault().getBundle()
- .getEntry("/")).getFile(); //$NON-NLS-1$
- seamGenDir = new File(pluginLocation, seamHomePath);
- }
- Path p = new Path(seamGenDir.getPath());
- p.makeAbsolute();
- if (p.toFile().exists()) {
- return p.toOSString();
- }
- } catch (IOException e) {
- log(e);
- }
- return ""; //$NON-NLS-1$
- }
- public void createJBossServer(List<ServerDefinition> serverDefinitions) {
- for (ServerDefinition serverDefinition:serverDefinitions) {
- String type = serverDefinition.getType();
- if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || SOA_P_STD.equals(type) || EWP.equals(type)) {
- File asLocation = new File(serverDefinition.getLocation(), "jboss-as");
- if(SOA_P_STD.equals(type)) {
- asLocation = new File(serverDefinition.getLocation(),"jboss-esb"); //$NON-NLS-1$
- } else if(EWP.equals(type)){
- asLocation = new File(serverDefinition.getLocation(),"jboss-as-web"); //$NON-NLS-1$
- }
- if (asLocation.isDirectory()) {
- String name = serverDefinition.getName();
- String runtimeName = name + " " + RUNTIME; //$NON-NLS-1$
- int index = getJBossASVersion(asLocation);
- createJBossServer(asLocation,index,name, runtimeName);
- }
- } else if (AS.equals(type)){
- String version = serverDefinition.getVersion();
- int index = 2;
- if ("3.2".equals(version)) { //$NON-NLS-1$
- index = 0;
- } else if ("4.0".equals(version)) { //$NON-NLS-1$
- index = 1;
- } else if ("4.2".equals(version)) { //$NON-NLS-1$
- index = 2;
- } else if ("5.0".equals(version)) { //$NON-NLS-1$
- index = 3;
- } else if ("5.1".equals(version)) { //$NON-NLS-1$
- index = 4;
- } else if ("6.0".equals(version)) { //$NON-NLS-1$
- index = 5;
- }
- createJBossServer(serverDefinition.getLocation(),index,serverDefinition.getName(),serverDefinition.getName() + " " + RUNTIME); //$NON-NLS-1$
- }
- }
- }
- private int getJBossASVersion(File asLocation) {
- int index = -1;
- String fullVersion = new ServerBeanLoader().getFullServerVersion(new File(asLocation, JBossServerType.AS.getSystemJarPath()));
- if(fullVersion != null ) {
- String version = fullVersion.substring(0, 3);
- if ("4.3".equals(version)) { //$NON-NLS-1$
- index = 6;
- } else if ("5.0".equals(version)) { //$NON-NLS-1$
- index = 7;
- } else if ("5.1".equals(version)) { //$NON-NLS-1$
- // FIXME - this needs to be changed when adding a new runtime type for JBoss EAP 5.1
- index = 7;
- }
- }
- return index;
- }
- private void createJBossServer(File asLocation, int index, String name, String runtimeName) {
- if (!asLocation.isDirectory() || index==-1) {
- return;
- }
- IPath jbossAsLocationPath = new Path(asLocation.getAbsolutePath());
-
- IServer[] servers = ServerCore.getServers();
- for (int i = 0; i < servers.length; i++) {
- IRuntime runtime = servers[i].getRuntime();
- if(runtime != null && runtime.getLocation().equals(jbossAsLocationPath)) {
- return;
- }
- }
-
- IRuntime runtime = null;
- IRuntime[] runtimes = ServerCore.getRuntimes();
- for (int i = 0; i < runtimes.length; i++) {
- if (runtimes[0].getLocation().equals(jbossAsLocationPath)) {
- runtime = runtimes[0].createWorkingCopy();
- break;
- }
- }
-
- IProgressMonitor progressMonitor = new NullProgressMonitor();
- try {
- if (runtime == null) {
- runtime = createRuntime(runtimeName, asLocation.getAbsolutePath(), progressMonitor, index);
- }
- if (runtime != null) {
- createServer(progressMonitor, runtime, index, name);
- }
-
- createDriver(asLocation.getAbsolutePath(), index);
- } catch (CoreException e) {
- log(e,Messages.JBossRuntimeStartup_Cannot_create_new_JBoss_Server);
- } catch (ConnectionProfileException e) {
- log(e,Messages.JBossRuntimeStartup_Cannott_create_new_DTP_Connection_Profile);
- }
- }
-
private void parseServerFile() {
try {
@@ -608,260 +221,9 @@
}
}
} catch (FileNotFoundException e) {
- log(e);
+ Activator.log(e);
} catch (IOException e) {
- log(e);
+ Activator.log(e);
}
- }
-
- private static void log(Throwable e) {
- IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e
- .getLocalizedMessage(), e);
- Activator.getDefault().getLog().log(status);
- }
-
- private static void log(Throwable e, String message) {
- IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, e);
- Activator.getDefault().getLog().log(status);
- }
-
- /**
- * Creates new JBoss AS Runtime, Server and hsqldb driver
- * @param jbossASLocation location of JBoss Server
- * @param progressMonitor to report progress
- * @return server working copy
- * @throws CoreException
- * @throws ConnectionProfileException
- */
-// public static IServerWorkingCopy initJBossAS(String jbossASLocation, IProgressMonitor progressMonitor) throws CoreException, ConnectionProfileException {
-// IRuntime runtime = createRuntime(null, jbossASLocation, progressMonitor, 2);
-// IServerWorkingCopy server = null;
-// if (runtime != null) {
-// server = createServer(progressMonitor, runtime, 2, null);
-// }
-// createDriver(jbossASLocation);
-// return server;
-// }
-
- /**
- * Creates new JBoss AS Runtime
- * @param jbossASLocation location of JBoss AS
- * @param progressMonitor
- * @return runtime working copy
- * @throws CoreException
- */
- private static IRuntime createRuntime(String runtimeName, String jbossASLocation, IProgressMonitor progressMonitor, int index) throws CoreException {
- IRuntimeWorkingCopy runtime = null;
- String type = null;
- String version = null;
- String runtimeId = null;
- IPath jbossAsLocationPath = new Path(jbossASLocation);
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, JBOSS_AS_RUNTIME_TYPE_ID[index]);
- if (runtimeTypes.length > 0) {
- runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
- runtime.setLocation(jbossAsLocationPath);
- if(runtimeName!=null) {
- runtime.setName(runtimeName);
- }
-// to fix https://jira.jboss.org/jira/browse/JBDS-852 VM attributes initialization below was commented
-// IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
- // IJBossServerRuntime.PROPERTY_VM_ID
-// ((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_ID", defaultVM.getId()); //$NON-NLS-1$
- // IJBossServerRuntime.PROPERTY_VM_TYPE_ID
-// ((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_TYPE_ID", defaultVM.getVMInstallType().getId()); //$NON-NLS-1$
- // IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME
- ((RuntimeWorkingCopy) runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName", JBOSS_AS_DEFAULT_CONFIGURATION_NAME); //$NON-NLS-1$
-
- return runtime.save(false, progressMonitor);
- }
- return runtime;
- }
-
- /**
- * Creates new JBoss Server
- * @param progressMonitor
- * @param runtime parent JBoss AS Runtime
- * @return server working copy
- * @throws CoreException
- */
- private static IServerWorkingCopy createServer(IProgressMonitor progressMonitor, IRuntime runtime, int index, String name) throws CoreException {
- if (name == null) {
- name = JBOSS_AS_NAME[index];
- }
- IServer[] servers = ServerCore.getServers();
- for (IServer server:servers) {
- if (name.equals(server.getName()) ) {
- return null;
- }
- }
- IServerType serverType = ServerCore.findServerType(JBOSS_AS_TYPE_ID[index]);
- IServerWorkingCopy server = serverType.createServer(null, null, runtime, progressMonitor);
-
- server.setHost(JBOSS_AS_HOST);
- server.setName(name);
-
- // JBossServer.DEPLOY_DIRECTORY
- String deployVal = runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString(); //$NON-NLS-1$ //$NON-NLS-2$
- ((ServerWorkingCopy) server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory", deployVal); //$NON-NLS-1$
-
- // IDeployableServer.TEMP_DEPLOY_DIRECTORY
- String deployTmpFolderVal = runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ((ServerWorkingCopy) server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory", deployTmpFolderVal); //$NON-NLS-1$
-
- // If we'd need to set up a username / pw for JMX, do it here.
-// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_USERNAME, authUser);
-// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_PASSWORD, authPass);
-
- server.save(false, progressMonitor);
- return server;
- }
-
- /**
- * Creates HSQL DB Driver
- * @param jbossASLocation location of JBoss AS
- * @param index
- * @throws ConnectionProfileException
- * @return driver instance
- */
- private static void createDriver(String jbossASLocation, int index) throws ConnectionProfileException {
- if(ProfileManager.getInstance().getProfileByName(DEFAULT_DS) != null) {
- // Don't create the driver a few times
- return;
- }
- String driverPath;
- try {
- driverPath = new File(jbossASLocation + JBOSS_AS_HSQL_DRIVER_LOCATION[index]).getCanonicalPath(); //$NON-NLS-1$
- } catch (IOException e) {
- Activator.getDefault().getLog().log(new Status(IStatus.ERROR,
- Activator.PLUGIN_ID, Messages.JBossRuntimeStartup_Cannott_create_new_HSQL_DB_Driver, e));
- return;
- }
-
- DriverInstance driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- if (driver == null) {
- TemplateDescriptor descr = TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
- IPropertySet instance = new PropertySetImpl(HSQL_DRIVER_NAME, HSQL_DRIVER_DEFINITION_ID);
- instance.setName(HSQL_DRIVER_NAME);
- instance.setID(HSQL_DRIVER_DEFINITION_ID);
- Properties props = new Properties();
-
- IConfigurationElement[] template = descr.getProperties();
- for (int i = 0; i < template.length; i++) {
- IConfigurationElement prop = template[i];
- String id = prop.getAttribute("id"); //$NON-NLS-1$
-
- String value = prop.getAttribute("value"); //$NON-NLS-1$
- props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
- }
- props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:."); //$NON-NLS-1$
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
-
- instance.setBaseProperties(props);
- DriverManager.getInstance().removeDriverInstance(instance.getID());
- System.gc();
- DriverManager.getInstance().addDriverInstance(instance);
- }
-
- driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- if (driver != null && ProfileManager.getInstance().getProfileByName(DEFAULT_DS) == null) { //$NON-NLS-1$
- // create profile
- Properties props = new Properties();
- props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, HSQL_DRIVER_DEFINITION_ID);
- props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID, ""); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, "Default"); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, ""); //$NON-NLS-1$
- props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false"); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
-
- ProfileManager.getInstance().createProfile(DEFAULT_DS, Messages.JBossRuntimeStartup_The_JBoss_AS_Hypersonic_embedded_database, HSQL_PROFILE_ID, props, "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- }
-
- public void initializeDroolsRuntime(List<ServerDefinition> serverDefinitions) {
- List<DroolsRuntime> droolsRuntimes = new ArrayList<DroolsRuntime>();
- for (ServerDefinition serverDefinition : serverDefinitions) {
- String type = serverDefinition.getType();
- if (!droolsExists(serverDefinition)) {
- if (SOA_P.equals(type) || DROOLS.equals(type)) {
- File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
- if (droolsRoot.isDirectory()) {
- DroolsRuntime runtime = new DroolsRuntime();
- if (SOA_P.equals(type)) {
- runtime.setName("Drools - " + serverDefinition.getName()); //$NON-NLS-1$
- } else {
- runtime.setName("Drools " + serverDefinition.getVersion()+ " - " + serverDefinition.getName()); //$NON-NLS-1$
- }
- runtime.setPath(droolsRoot.getAbsolutePath());
- DroolsRuntimeManager.recognizeJars(runtime);
- runtime.setDefault(true);
- droolsRuntimes.add(runtime);
- }
- }
- }
- }
- if (droolsRuntimes.size() > 0) {
- DroolsRuntime[] dra = droolsRuntimes.toArray(new DroolsRuntime[0]);
- DroolsRuntimeManager.setDroolsRuntimes(dra);
- }
-
- }
-
- /**
- * @param serverDefinition
- * @return
- */
- private boolean droolsExists(ServerDefinition serverDefinition) {
- DroolsRuntime[] droolsRuntimes = DroolsRuntimeManager.getDroolsRuntimes();
- for (DroolsRuntime dr:droolsRuntimes) {
- String location = dr.getPath();
- if (location != null && location.equals(serverDefinition.getLocation().getAbsolutePath())) {
- return true;
- }
- }
- return false;
- }
-
- public void initializeJbpmRuntime(List<ServerDefinition> serverDefinitions) {
- for (ServerDefinition serverDefinition : serverDefinitions) {
- if (!jbpmExists(serverDefinition)) {
- String type = serverDefinition.getType();
- if (SOA_P.equals(type)) {
- File jbpmRoot = new File(serverDefinition.getLocation(),"jbpm-jpdl"); //$NON-NLS-1$
- if (jbpmRoot.isDirectory()) {
- String version = JBossRuntimeLocator.JBPM3;
- if (JBossRuntimeLocator.isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
- version = JBossRuntimeLocator.JBPM4;
- }
- PreferencesManager.getInstance().initializeDefaultJbpmInstallation(serverDefinition.getName(), jbpmRoot.getAbsolutePath(), version);
- }
- } else if (JBPM.equals(type)) {
- PreferencesManager.getInstance().addJbpmInstallation(serverDefinition.getName(), serverDefinition.getLocation().getAbsolutePath(), serverDefinition.getVersion());
- }
- }
- }
-
- }
-
- /**
- * @param serverDefinition
- * @return
- */
- private boolean jbpmExists(ServerDefinition serverDefinition) {
- Map<String, JbpmInstallation> jbpmMap = PreferencesManager.getInstance().getJbpmInstallationMap();
- Collection<JbpmInstallation> jbpmInstalations = jbpmMap.values();
- for (JbpmInstallation jbpm:jbpmInstalations) {
- String location = jbpm.location;
- if (location != null && location.equals(serverDefinition.getLocation().getAbsolutePath())) {
- return true;
- }
- }
- return false;
- }
-
+ }
}
\ No newline at end of file
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Messages.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Messages.java 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/Messages.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.runtime;
import org.eclipse.osgi.util.NLS;
Added: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.runtime.handlers;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.util.DroolsRuntime;
+import org.drools.eclipse.util.DroolsRuntimeManager;
+import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
+import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
+import org.jboss.tools.runtime.ServerDefinition;
+
+public class DroolsHandler implements IJBossRuntimePersistanceHandler,IJBossRuntimePluginConstants {
+
+ public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
+ List<DroolsRuntime> droolsRuntimes = new ArrayList<DroolsRuntime>();
+ for (ServerDefinition serverDefinition : serverDefinitions) {
+ String type = serverDefinition.getType();
+ if (!droolsExists(serverDefinition)) {
+ if (SOA_P.equals(type) || DROOLS.equals(type)) {
+ File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
+ if (droolsRoot.isDirectory()) {
+ DroolsRuntime runtime = new DroolsRuntime();
+ if (SOA_P.equals(type)) {
+ runtime.setName("Drools - " + serverDefinition.getName()); //$NON-NLS-1$
+ } else {
+ runtime.setName("Drools " + serverDefinition.getVersion()+ " - " + serverDefinition.getName()); //$NON-NLS-1$
+ }
+ runtime.setPath(droolsRoot.getAbsolutePath());
+ DroolsRuntimeManager.recognizeJars(runtime);
+ runtime.setDefault(true);
+ droolsRuntimes.add(runtime);
+ }
+ }
+ }
+ }
+ if (droolsRuntimes.size() > 0) {
+ DroolsRuntime[] dra = droolsRuntimes.toArray(new DroolsRuntime[0]);
+ DroolsRuntimeManager.setDroolsRuntimes(dra);
+ }
+
+ }
+
+ /**
+ * @param serverDefinition
+ * @return
+ */
+ private static boolean droolsExists(ServerDefinition serverDefinition) {
+ DroolsRuntime[] droolsRuntimes = DroolsRuntimeManager.getDroolsRuntimes();
+ for (DroolsRuntime dr:droolsRuntimes) {
+ String location = dr.getPath();
+ if (location != null && location.equals(serverDefinition.getLocation().getAbsolutePath())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void importRuntimes() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void exportRuntimes() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -0,0 +1,404 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.runtime.handlers;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.DriverInstance;
+import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
+import org.eclipse.datatools.connectivity.drivers.IPropertySet;
+import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
+import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.IMemento;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.eclipse.wst.server.core.internal.XMLMemento;
+import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
+import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
+import org.jboss.tools.runtime.Activator;
+import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
+import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
+import org.jboss.tools.runtime.Messages;
+import org.jboss.tools.runtime.ServerDefinition;
+
+public class JBossASHandler implements IJBossRuntimePersistanceHandler, IJBossRuntimePluginConstants {
+
+ public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
+ createInitialJBossServer();
+ createJBossServerFromDefinitions(serverDefinitions);
+ }
+
+ public static void createInitialJBossServer(){
+ try {
+ String pluginLocation = FileLocator.resolve(Activator.getDefault().getBundle().getEntry("/")).getPath(); //$NON-NLS-1$
+ File jbossASDir = new File(pluginLocation, JBOSS_EAP_HOME);
+ if (!jbossASDir.isDirectory()) {
+ Location configLocation = Platform.getConfigurationLocation();
+ URL configURL = configLocation.getURL();
+ String configuration = FileLocator.resolve(configURL).getPath();
+ jbossASDir = new File(configuration, JBOSS_EAP_HOME_CONFIGURATION).getCanonicalFile();
+ } else {
+ jbossASDir = jbossASDir.getCanonicalFile();
+ }
+ if (jbossASDir.isDirectory()) {
+ int index = getJBossASVersion(jbossASDir);
+ createJBossServer(jbossASDir,index, "jboss-eap", "jboss-eap " + RUNTIME); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (IOException e) {
+ Activator.log(e,Messages.JBossRuntimeStartup_Cannot_create_new_JBoss_Server);
+ }
+ }
+ public static void createJBossServerFromDefinitions(List<ServerDefinition> serverDefinitions) {
+ for (ServerDefinition serverDefinition:serverDefinitions) {
+ String type = serverDefinition.getType();
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || SOA_P_STD.equals(type) || EWP.equals(type)) {
+ File asLocation = new File(serverDefinition.getLocation(), "jboss-as");
+ if(SOA_P_STD.equals(type)) {
+ asLocation = new File(serverDefinition.getLocation(),"jboss-esb"); //$NON-NLS-1$
+ } else if(EWP.equals(type)){
+ asLocation = new File(serverDefinition.getLocation(),"jboss-as-web"); //$NON-NLS-1$
+ }
+ if (asLocation.isDirectory()) {
+ String name = serverDefinition.getName();
+ String runtimeName = name + " " + RUNTIME; //$NON-NLS-1$
+ int index = getJBossASVersion(asLocation);
+ createJBossServer(asLocation,index,name, runtimeName);
+ }
+ } else if (AS.equals(type)){
+ String version = serverDefinition.getVersion();
+ int index = 2;
+ if ("3.2".equals(version)) { //$NON-NLS-1$
+ index = 0;
+ } else if ("4.0".equals(version)) { //$NON-NLS-1$
+ index = 1;
+ } else if ("4.2".equals(version)) { //$NON-NLS-1$
+ index = 2;
+ } else if ("5.0".equals(version)) { //$NON-NLS-1$
+ index = 3;
+ } else if ("5.1".equals(version)) { //$NON-NLS-1$
+ index = 4;
+ } else if ("6.0".equals(version)) { //$NON-NLS-1$
+ index = 5;
+ }
+ createJBossServer(serverDefinition.getLocation(),index,serverDefinition.getName(),serverDefinition.getName() + " " + RUNTIME); //$NON-NLS-1$
+ }
+ }
+ }
+
+ private static int getJBossASVersion(File asLocation) {
+ int index = -1;
+ String fullVersion = new ServerBeanLoader().getFullServerVersion(new File(asLocation, JBossServerType.AS.getSystemJarPath()));
+ if(fullVersion != null ) {
+ String version = fullVersion.substring(0, 3);
+ if ("4.3".equals(version)) { //$NON-NLS-1$
+ index = 6;
+ } else if ("5.0".equals(version)) { //$NON-NLS-1$
+ index = 7;
+ } else if ("5.1".equals(version)) { //$NON-NLS-1$
+ // FIXME - this needs to be changed when adding a new runtime type for JBoss EAP 5.1
+ index = 7;
+ }
+ }
+ return index;
+ }
+
+ private static void createJBossServer(File asLocation, int index, String name, String runtimeName) {
+ if (!asLocation.isDirectory() || index==-1) {
+ return;
+ }
+ IPath jbossAsLocationPath = new Path(asLocation.getAbsolutePath());
+
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ IRuntime runtime = servers[i].getRuntime();
+ if(runtime != null && runtime.getLocation().equals(jbossAsLocationPath)) {
+ return;
+ }
+ }
+
+ IRuntime runtime = null;
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ if (runtimes[0].getLocation().equals(jbossAsLocationPath)) {
+ runtime = runtimes[0].createWorkingCopy();
+ break;
+ }
+ }
+
+ IProgressMonitor progressMonitor = new NullProgressMonitor();
+ try {
+ if (runtime == null) {
+ runtime = createRuntime(runtimeName, asLocation.getAbsolutePath(), progressMonitor, index);
+ }
+ if (runtime != null) {
+ createServer(progressMonitor, runtime, index, name);
+ }
+
+ createDriver(asLocation.getAbsolutePath(), index);
+ } catch (CoreException e) {
+ Activator.log(e,Messages.JBossRuntimeStartup_Cannot_create_new_JBoss_Server);
+ } catch (ConnectionProfileException e) {
+ Activator.log(e,Messages.JBossRuntimeStartup_Cannott_create_new_DTP_Connection_Profile);
+ }
+ }
+ /**
+ * Creates new JBoss AS Runtime, Server and hsqldb driver
+ * @param jbossASLocation location of JBoss Server
+ * @param progressMonitor to report progress
+ * @return server working copy
+ * @throws CoreException
+ * @throws ConnectionProfileException
+ */
+// public static IServerWorkingCopy initJBossAS(String jbossASLocation, IProgressMonitor progressMonitor) throws CoreException, ConnectionProfileException {
+// IRuntime runtime = createRuntime(null, jbossASLocation, progressMonitor, 2);
+// IServerWorkingCopy server = null;
+// if (runtime != null) {
+// server = createServer(progressMonitor, runtime, 2, null);
+// }
+// createDriver(jbossASLocation);
+// return server;
+// }
+
+ /**
+ * Creates new JBoss AS Runtime
+ * @param jbossASLocation location of JBoss AS
+ * @param progressMonitor
+ * @return runtime working copy
+ * @throws CoreException
+ */
+ private static IRuntime createRuntime(String runtimeName, String jbossASLocation, IProgressMonitor progressMonitor, int index) throws CoreException {
+ IRuntimeWorkingCopy runtime = null;
+ String type = null;
+ String version = null;
+ String runtimeId = null;
+ IPath jbossAsLocationPath = new Path(jbossASLocation);
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, JBOSS_AS_RUNTIME_TYPE_ID[index]);
+ if (runtimeTypes.length > 0) {
+ runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
+ runtime.setLocation(jbossAsLocationPath);
+ if(runtimeName!=null) {
+ runtime.setName(runtimeName);
+ }
+// to fix https://jira.jboss.org/jira/browse/JBDS-852 VM attributes initialization below was commented
+// IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
+ // IJBossServerRuntime.PROPERTY_VM_ID
+// ((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_ID", defaultVM.getId()); //$NON-NLS-1$
+ // IJBossServerRuntime.PROPERTY_VM_TYPE_ID
+// ((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_TYPE_ID", defaultVM.getVMInstallType().getId()); //$NON-NLS-1$
+ // IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME
+ ((RuntimeWorkingCopy) runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName", JBOSS_AS_DEFAULT_CONFIGURATION_NAME); //$NON-NLS-1$
+
+ return runtime.save(false, progressMonitor);
+ }
+ return runtime;
+ }
+
+ /**
+ * Creates new JBoss Server
+ * @param progressMonitor
+ * @param runtime parent JBoss AS Runtime
+ * @return server working copy
+ * @throws CoreException
+ */
+ private static IServerWorkingCopy createServer(IProgressMonitor progressMonitor, IRuntime runtime, int index, String name) throws CoreException {
+ if (name == null) {
+ name = JBOSS_AS_NAME[index];
+ }
+ IServer[] servers = ServerCore.getServers();
+ for (IServer server:servers) {
+ if (name.equals(server.getName()) ) {
+ return null;
+ }
+ }
+ IServerType serverType = ServerCore.findServerType(JBOSS_AS_TYPE_ID[index]);
+ IServerWorkingCopy server = serverType.createServer(null, null, runtime, progressMonitor);
+
+ server.setHost(JBOSS_AS_HOST);
+ server.setName(name);
+
+ // JBossServer.DEPLOY_DIRECTORY
+ String deployVal = runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString(); //$NON-NLS-1$ //$NON-NLS-2$
+ ((ServerWorkingCopy) server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory", deployVal); //$NON-NLS-1$
+
+ // IDeployableServer.TEMP_DEPLOY_DIRECTORY
+ String deployTmpFolderVal = runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ((ServerWorkingCopy) server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory", deployTmpFolderVal); //$NON-NLS-1$
+
+ // If we'd need to set up a username / pw for JMX, do it here.
+// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_USERNAME, authUser);
+// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_PASSWORD, authPass);
+
+ server.save(false, progressMonitor);
+ return server;
+ }
+
+ /**
+ * Creates HSQL DB Driver
+ * @param jbossASLocation location of JBoss AS
+ * @param index
+ * @throws ConnectionProfileException
+ * @return driver instance
+ */
+ private static void createDriver(String jbossASLocation, int index) throws ConnectionProfileException {
+ if(ProfileManager.getInstance().getProfileByName(DEFAULT_DS) != null) {
+ // Don't create the driver a few times
+ return;
+ }
+ String driverPath;
+ try {
+ driverPath = new File(jbossASLocation + JBOSS_AS_HSQL_DRIVER_LOCATION[index]).getCanonicalPath(); //$NON-NLS-1$
+ } catch (IOException e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, Messages.JBossRuntimeStartup_Cannott_create_new_HSQL_DB_Driver, e));
+ return;
+ }
+
+ DriverInstance driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if (driver == null) {
+ TemplateDescriptor descr = TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
+ IPropertySet instance = new PropertySetImpl(HSQL_DRIVER_NAME, HSQL_DRIVER_DEFINITION_ID);
+ instance.setName(HSQL_DRIVER_NAME);
+ instance.setID(HSQL_DRIVER_DEFINITION_ID);
+ Properties props = new Properties();
+
+ IConfigurationElement[] template = descr.getProperties();
+ for (int i = 0; i < template.length; i++) {
+ IConfigurationElement prop = template[i];
+ String id = prop.getAttribute("id"); //$NON-NLS-1$
+
+ String value = prop.getAttribute("value"); //$NON-NLS-1$
+ props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
+ }
+ props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:."); //$NON-NLS-1$
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
+
+ instance.setBaseProperties(props);
+ DriverManager.getInstance().removeDriverInstance(instance.getID());
+ System.gc();
+ DriverManager.getInstance().addDriverInstance(instance);
+ }
+
+ driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if (driver != null && ProfileManager.getInstance().getProfileByName(DEFAULT_DS) == null) { //$NON-NLS-1$
+ // create profile
+ Properties props = new Properties();
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, HSQL_DRIVER_DEFINITION_ID);
+ props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID, ""); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, "Default"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, ""); //$NON-NLS-1$
+ props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
+
+ ProfileManager.getInstance().createProfile(DEFAULT_DS, Messages.JBossRuntimeStartup_The_JBoss_AS_Hypersonic_embedded_database, HSQL_PROFILE_ID, props, "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ }
+
+ public void importRuntimes() {
+ String servers = Activator.getDefault().getPreferenceStore().getString(Activator.SERVERS);
+ if (servers != null && servers.trim().length() > 0) {
+ loadServerInstalations(servers);
+ }
+ }
+ /**
+ * @param servers
+ */
+ private void loadServerInstalations(String servers) {
+ InputStream in = null;
+ try {
+ in = new ByteArrayInputStream(servers.getBytes("UTF-8"));
+ IMemento memento = XMLMemento.loadMemento(in);
+
+ IMemento[] children = memento.getChildren("server");
+ int size = children.length;
+
+ for (int i = 0; i < size; i++) {
+ ServerEx server = new ServerEx(null);
+ server.loadFromMemento(children[i], null);
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.save(false, null);
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ }
+ }
+
+ private static final String SERVER_DATA_FILE = "servers.xml";
+ public void exportRuntimes() {
+ String filename = ServerPlugin.getInstance().getStateLocation().append(SERVER_DATA_FILE).toOSString();
+ if ( !(new File(filename).exists()) ) {
+ Activator.getDefault().getPreferenceStore().setValue(Activator.SERVERS, "");
+ return;
+ }
+ try {
+ XMLMemento memento = (XMLMemento) XMLMemento.loadMemento(filename);
+ String xmlString = memento.saveToString();
+ Activator.getDefault().getPreferenceStore().setValue(Activator.SERVERS, xmlString);
+ Activator.getDefault().savePluginPreferences();
+ } catch (Exception e) {
+ Activator.log (e);
+ }
+ }
+ private static class ServerEx extends Server {
+
+ /**
+ * @param file
+ */
+ public ServerEx(IFile file) {
+ super(file);
+ }
+
+ @Override
+ public void loadFromMemento(IMemento memento, IProgressMonitor monitor) {
+ super.loadFromMemento(memento, monitor);
+ }
+
+ }
+}
Added: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -0,0 +1,125 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.handlers;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.server.core.internal.IMemento;
+import org.eclipse.wst.server.core.internal.XMLMemento;
+import org.jboss.tools.jbpm.preferences.JbpmInstallation;
+import org.jboss.tools.jbpm.preferences.PreferencesManager;
+import org.jboss.tools.runtime.Activator;
+import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
+import org.jboss.tools.runtime.JBossRuntimeLocator;
+import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
+import org.jboss.tools.runtime.ServerDefinition;
+
+public class JbpmHandler implements IJBossRuntimePersistanceHandler,IJBossRuntimePluginConstants {
+ public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
+ for (ServerDefinition serverDefinition : serverDefinitions) {
+ if (!jbpmExists(serverDefinition)) {
+ String type = serverDefinition.getType();
+ if (SOA_P.equals(type)) {
+ File jbpmRoot = new File(serverDefinition.getLocation(),"jbpm-jpdl"); //$NON-NLS-1$
+ if (jbpmRoot.isDirectory()) {
+ String version = JBossRuntimeLocator.JBPM3;
+ if (JBossRuntimeLocator.isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
+ version = JBossRuntimeLocator.JBPM4;
+ }
+ PreferencesManager.getInstance().initializeDefaultJbpmInstallation(serverDefinition.getName(), jbpmRoot.getAbsolutePath(), version);
+ }
+ } else if (JBPM.equals(type)) {
+ PreferencesManager.getInstance().addJbpmInstallation(serverDefinition.getName(), serverDefinition.getLocation().getAbsolutePath(), serverDefinition.getVersion());
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @param serverDefinition
+ * @return
+ */
+ public static boolean jbpmExists(ServerDefinition serverDefinition) {
+ Map<String, JbpmInstallation> jbpmMap = PreferencesManager.getInstance().getJbpmInstallationMap();
+ Collection<JbpmInstallation> jbpmInstalations = jbpmMap.values();
+ for (JbpmInstallation jbpm:jbpmInstalations) {
+ String location = jbpm.location;
+ if (location != null && location.equals(serverDefinition.getLocation().getAbsolutePath())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param jbpms
+ */
+ public static void loadJBPMInstalations(String jbpms) {
+ InputStream in = null;
+ try {
+ in = new ByteArrayInputStream(jbpms.getBytes("UTF-8"));
+ IMemento memento = XMLMemento.loadMemento(in);
+ IMemento[] children = memento.getChildren("installation");
+ for (int i = 0; i < children.length; i++) {
+ JbpmInstallation installation = new JbpmInstallation();
+ installation.name = children[i].getString("name");
+ installation.location = children[i].getString("location");
+ installation.version = children[i].getString("version");
+ PreferencesManager.getInstance().getJbpmInstallationMap()
+ .put(installation.name, installation);
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ public static void exportJbpms() {
+ File file = org.jboss.tools.jbpm.Activator.getDefault().getStateLocation().append("jbpm-installations.xml").toFile();
+ if (!file.exists()) {
+ Activator.getDefault().getPreferenceStore().setValue(Activator.JBPMS, "");
+ return;
+ }
+ try {
+ XMLMemento memento = (XMLMemento) XMLMemento.loadMemento(file.getAbsolutePath());
+ String xmlString = memento.saveToString();
+ Activator.getDefault().getPreferenceStore().setValue(Activator.JBPMS, xmlString);
+ Activator.getDefault().savePluginPreferences();
+ } catch (Exception e) {
+ Activator.log (e);
+ }
+ }
+
+ public void importRuntimes() {
+ String jbpms = Activator.getDefault().getPreferenceStore().getString(Activator.JBPMS);
+ if (jbpms != null && jbpms.trim().length() > 0) {
+ JbpmHandler.loadJBPMInstalations(jbpms);
+ }
+ }
+
+ public void exportRuntimes() {
+ JbpmHandler.exportJbpms();
+ }
+
+}
Added: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -0,0 +1,187 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.handlers;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.jboss.tools.runtime.Activator;
+import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
+import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
+import org.jboss.tools.runtime.ServerDefinition;
+import org.jboss.tools.seam.core.SeamUtil;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
+
+public class SeamHandler implements IJBossRuntimePersistanceHandler, IJBossRuntimePluginConstants {
+ public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
+
+ Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
+
+ // to fix https://jira.jboss.org/jira/browse/JBDS-682
+ // seam runtime initialization goes throug added servers first and
+ // then process seam runtimes from bundled servers
+ for(ServerDefinition serverDefinition:serverDefinitions) {
+ String type = serverDefinition.getType();
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type) ) {
+ for (String folder : SEAM_HOME_FOLDER_OPTIONS) {
+ File seamFile = new File(serverDefinition.getLocation(),folder); //$NON-NLS-1$
+ addSeam(map, serverDefinition, seamFile);
+ }
+ }
+ if (SEAM.equals(type)) {
+ addSeam(map, serverDefinition, serverDefinition.getLocation());
+ }
+ }
+
+ // Initialize Seam Runtime from JBoss EAP
+ String seamGenBuildPath = getSeamGenBuildPath(SEAM_1_2_HOME, SEAM_1_2_HOME_CONFIGURATION);
+ SeamVersion seamVersion = getSeamVersion(seamGenBuildPath);
+ addSeam1(map, seamGenBuildPath, seamVersion);
+
+ // fix for https://jira.jboss.org/jira/browse/JBDS-1215 The installer could not find EAP 4.3 Seam runtimes in recent CP
+ seamGenBuildPath = getSeamGenBuildPath(SEAM_1_2_HOME_CP, SEAM_1_2_HOME_CONFIGURATION_CP);
+ seamVersion = getSeamVersion(seamGenBuildPath);
+ addSeam1(map, seamGenBuildPath, seamVersion);
+
+ // Initialize Seam 2.0 Runtime from JBoss EAP
+ seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME, SEAM_2_0_HOME_CONFIGURATION);
+ seamVersion = getSeamVersion(seamGenBuildPath);
+ addSeam2(map, seamGenBuildPath, seamVersion);
+
+ // fix for https://jira.jboss.org/jira/browse/JBDS-1215 The installer could not find EAP 4.3 Seam runtimes in recent CPs
+ seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME_CP, SEAM_2_0_HOME_CONFIGURATION_CP);
+ seamVersion = getSeamVersion(seamGenBuildPath);
+ addSeam2(map, seamGenBuildPath, seamVersion);
+ }
+
+ private static void addSeam1(Map<String, SeamRuntime> map,
+ String seamGenBuildPath, SeamVersion seamVersion) {
+ if (seamVersion != null) {
+ StringBuffer name = new StringBuffer("Seam ").append(seamVersion); //$NON-NLS-1$
+ if(seamVersion.compareTo(SeamVersion.SEAM_1_2)==0) {
+ name.append(".EAP_4.3"); //$NON-NLS-1$
+ } else {
+ name.append(".EAP5"); //$NON-NLS-1$
+ }
+ addSeam(map, seamGenBuildPath,seamVersion,name.toString());
+ }
+ }
+
+ private static void addSeam2(Map<String, SeamRuntime> map,
+ String seamGenBuildPath, SeamVersion seamVersion) {
+ if (seamVersion != null) {
+ String name = "Seam " + seamVersion + ".FP"; //$NON-NLS-1$ //$NON-NLS-2$
+ addSeam(map, seamGenBuildPath, seamVersion,name);
+ }
+ }
+
+ private static void addSeam(Map<String, SeamRuntime> map,
+ ServerDefinition serverDefinition, File seamFile) {
+ if (seamFile.exists() && seamFile.canRead() && seamFile.isDirectory()) {
+ SeamVersion seamVersion = getSeamVersion(seamFile.getAbsolutePath());
+ if (seamVersion != null) {
+ String name = "Seam " + serverDefinition.getName() + " " + seamVersion; //$NON-NLS-1$ //$NON-NLS-2$
+ addSeam(map, seamFile.getAbsolutePath(), seamVersion, name);
+ }
+ }
+ }
+
+ private static SeamVersion getSeamVersion(String seamGenBuildPath) {
+ if (seamGenBuildPath == null || seamGenBuildPath.trim().length() <= 0) {
+ return null;
+ }
+ String fullVersion = SeamUtil.getSeamVersionFromManifest(seamGenBuildPath);
+ if (fullVersion == null) {
+ return null;
+ }
+ String version = fullVersion.substring(0,3);
+ SeamVersion seamVersion = null;
+ if (version != null) {
+ seamVersion = SeamVersion.findByString(version);
+ }
+ return seamVersion;
+ }
+
+ private static void addSeam(Map<String, SeamRuntime> map, String seamPath,SeamVersion seamVersion, String name) {
+ if (!seamExists(seamPath)) {
+ File seamFolder = new File(seamPath);
+ if(seamFolder.exists() && seamFolder.isDirectory()) {
+ SeamRuntime rt = new SeamRuntime();
+ rt.setHomeDir(seamPath);
+ rt.setName(name);
+ rt.setDefault(true);
+ rt.setVersion(seamVersion);
+ SeamRuntimeManager.getInstance().addRuntime(rt);
+ }
+ }
+ }
+
+ /**
+ * @param seamPath
+ * @return
+ */
+ private static boolean seamExists(String seamPath) {
+ SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance().getRuntimes();
+ for (SeamRuntime sr:seamRuntimes) {
+ if (seamPath != null && seamPath.equals(sr.getHomeDir())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String getSeamGenBuildPath(String seamHomePath,
+ String seamHomePathConfiguration) {
+ try {
+ Location configLocation = Platform.getConfigurationLocation();
+ URL configURL = configLocation.getURL();
+ String configuration = FileLocator.resolve(configURL).getPath();
+ File seamGenDir = new File(configuration, seamHomePathConfiguration);
+ if (!seamGenDir.isDirectory()) {
+ String pluginLocation = null;
+ pluginLocation = FileLocator
+ .resolve(
+ Activator.getDefault().getBundle()
+ .getEntry("/")).getFile(); //$NON-NLS-1$
+ seamGenDir = new File(pluginLocation, seamHomePath);
+ }
+ Path p = new Path(seamGenDir.getPath());
+ p.makeAbsolute();
+ if (p.toFile().exists()) {
+ return p.toOSString();
+ }
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ public void importRuntimes() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void exportRuntimes() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java 2010-10-20 09:03:25 UTC (rev 25932)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java 2010-10-20 09:13:46 UTC (rev 25933)
@@ -12,7 +12,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
@@ -59,12 +58,12 @@
import org.eclipse.wst.server.core.internal.Server;
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.internal.XMLMemento;
-import org.jboss.tools.jbpm.preferences.JbpmInstallation;
-import org.jboss.tools.jbpm.preferences.PreferencesManager;
import org.jboss.tools.runtime.Activator;
import org.jboss.tools.runtime.JBossRuntimeLocator;
import org.jboss.tools.runtime.JBossRuntimeStartup;
import org.jboss.tools.runtime.ServerDefinition;
+import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
+import org.jboss.tools.runtime.handlers.JbpmHandler;
/**
* @author Snjeza
@@ -73,8 +72,6 @@
public class RuntimePreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
- private static final String SERVER_DATA_FILE = "servers.xml";
-
private static final String LASTPATH = "lastPath";
public static final String SEAM_PREFERENCES_ID = "org.jboss.tools.common.model.ui.seam"; //$NON-NLS-1$
public static final String WTP_PREFERENCES_ID = "org.eclipse.wst.server.ui.runtime.preferencePage"; //$NON-NLS-1$
@@ -154,8 +151,10 @@
}
private void exportRuntimes() {
- exportServers();
- exportJbpms();
+ IJBossRuntimePersistanceHandler[] exportHandlers = JBossRuntimeStartup.getPersistanceHandlers();
+ for( int i = 0; i < exportHandlers.length; i++ ) {
+ exportHandlers[i].exportRuntimes();
+ }
PreferencesExportWizard wizard = new PreferencesExportWizard();
wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
WizardDialog dialog = new WizardDialog(getShell(), wizard);
@@ -163,36 +162,7 @@
dialog.open();
}
- private void exportJbpms() {
- File file = org.jboss.tools.jbpm.Activator.getDefault().getStateLocation().append("jbpm-installations.xml").toFile();
- if (!file.exists()) {
- Activator.getDefault().getPreferenceStore().setValue(Activator.JBPMS, "");
- return;
- }
- try {
- XMLMemento memento = (XMLMemento) XMLMemento.loadMemento(file.getAbsolutePath());
- String xmlString = memento.saveToString();
- Activator.getDefault().getPreferenceStore().setValue(Activator.JBPMS, xmlString);
- Activator.getDefault().savePluginPreferences();
- } catch (Exception e) {
- Activator.log (e);
- }
- }
-
private void exportServers() {
- String filename = ServerPlugin.getInstance().getStateLocation().append(SERVER_DATA_FILE).toOSString();
- if ( !(new File(filename).exists()) ) {
- Activator.getDefault().getPreferenceStore().setValue(Activator.SERVERS, "");
- return;
- }
- try {
- XMLMemento memento = (XMLMemento) XMLMemento.loadMemento(filename);
- String xmlString = memento.saveToString();
- Activator.getDefault().getPreferenceStore().setValue(Activator.SERVERS, xmlString);
- Activator.getDefault().savePluginPreferences();
- } catch (Exception e) {
- Activator.log (e);
- }
}
private void importRuntimes() {
@@ -202,69 +172,13 @@
dialog.create();
int ok = dialog.open();
if (ok == Window.OK) {
- String jbpms = Activator.getDefault().getPreferenceStore().getString(Activator.JBPMS);
- if (jbpms != null && jbpms.trim().length() > 0) {
- loadJBPMInstalations(jbpms);
+ IJBossRuntimePersistanceHandler[] importHandlers = JBossRuntimeStartup.getPersistanceHandlers();
+ for( int i = 0; i < importHandlers.length; i++ ) {
+ importHandlers[i].importRuntimes();
}
- String servers = Activator.getDefault().getPreferenceStore().getString(Activator.SERVERS);
- if (servers != null && servers.trim().length() > 0) {
- loadServerInstalations(servers);
- }
}
}
- /**
- * @param servers
- */
- private void loadServerInstalations(String servers) {
- InputStream in = null;
- try {
- in = new ByteArrayInputStream(servers.getBytes("UTF-8"));
- IMemento memento = XMLMemento.loadMemento(in);
-
- IMemento[] children = memento.getChildren("server");
- int size = children.length;
-
- for (int i = 0; i < size; i++) {
- ServerEx server = new ServerEx(null);
- server.loadFromMemento(children[i], null);
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.save(false, null);
- }
- } catch (Exception e) {
- Activator.log(e);
- }
- }
-
- /**
- * @param jbpms
- */
- private void loadJBPMInstalations(String jbpms) {
- InputStream in = null;
- try {
- in = new ByteArrayInputStream(jbpms.getBytes("UTF-8"));
- IMemento memento = XMLMemento.loadMemento(in);
- IMemento[] children = memento.getChildren("installation");
- for (int i = 0; i < children.length; i++) {
- JbpmInstallation installation = new JbpmInstallation();
- installation.name = children[i].getString("name");
- installation.location = children[i].getString("location");
- installation.version = children[i].getString("version");
- PreferencesManager.getInstance().getJbpmInstallationMap()
- .put(installation.name, installation);
- }
- } catch (Exception e) {
- Activator.log(e);
- } finally {
- try {
- if (in != null) {
- in.close();
- }
- } catch (IOException e) {
- }
- }
- }
-
private Button createButton(Composite parent, String labelText, String buttonText) {
GridLayout layout;
Composite composite = new Composite(parent,SWT.NONE);
@@ -385,20 +299,4 @@
((GridData)gd).horizontalAlignment = GridData.FILL;
}
}
-
- private static class ServerEx extends Server {
-
- /**
- * @param file
- */
- public ServerEx(IFile file) {
- super(file);
- }
-
- @Override
- public void loadFromMemento(IMemento memento, IProgressMonitor monitor) {
- super.loadFromMemento(memento, monitor);
- }
-
- }
}
14 years, 2 months
JBoss Tools SVN: r25932 - in trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext: config and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: jpeterka
Date: 2010-10-20 05:03:25 -0400 (Wed, 20 Oct 2010)
New Revision: 25932
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
Log:
jBPM Requirement support for jBPM SWTBot Tests Added
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -162,14 +162,17 @@
perspectiveLabel = IDELabel.SelectPerspectiveDialog.JPA;
break;
case DEBUG:
- perspectiveLabel = IDELabel.SelectPerspectiveDialog.DEBUG;
- break;
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.DEBUG;
+ break;
case GUVNOR_REPOSITORY_EXPLORING:
- perspectiveLabel = IDELabel.SelectPerspectiveDialog.GUVNOR_REPOSITORY_EXPLORING;
- break;
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.GUVNOR_REPOSITORY_EXPLORING;
+ break;
case DROOLS:
- perspectiveLabel = IDELabel.SelectPerspectiveDialog.DROOLS;
- break;
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.DROOLS;
+ break;
+ case JBPM3:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.JBPM3;
+ break;
default:
fail("Unknown perspective to open");
}
@@ -503,6 +506,17 @@
open.finish(wiz, IDELabel.Button.OK);
}
}
+
+ public void addJBPMRuntime(String name, String version, String runtimeHome) {
+ // TODO - needs to be impl.
+ log.info("WARN - Adding JBPM Runtime, needs to be impl.");
+ }
+
+ public void removeJBPMRuntime(String name) {
+ // TODO - needs to be impl
+ log.info("WARN - Removing JBPM Runtime, needs to be impl.");
+ }
+
public void addESBRuntime(String name, String version, String runtimeHome ) {
SWTBot wiz = open.preferenceOpen(ActionItem.Preference.JBossToolsJBossESBRuntimes.LABEL);
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -40,9 +40,14 @@
*/
ESB esb() default @ESB( required = false);
/**
+ * optionally require JBPM runtime
+ * @return
+ */
+ JBPM jbpm() default @JBPM ( required = false );
+ /**
* name of perspective to run within
* @return
- */
+ */
String perspective() default "";
/**
* my default workspace is cleaned before test (attempt to close all shells and editors, closes 'Welcome' view),
@@ -146,6 +151,28 @@
String operator() default "=";
}
+
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface JBPM {
+ /**
+ * true if JBPM is required (default)
+ * @return
+ */
+ boolean required() default true;
+ /**
+ * version of require runtime (use * for all)
+ * @return
+ */
+ String version() default "*";
+ /**
+ * defines operator on runtime version, possible values (=,<,>=<=,>=,!=) default =
+ * @return
+ */
+ String operator() default "=";
+ }
+
+
public enum ServerState {
/**
* server is present, no matter if runs or not
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -17,6 +17,7 @@
private Server server = new Server();
private Seam seam = new Seam();
private ESB esb = new ESB();
+ private JBPM jbpm = new JBPM();
private boolean viewsPrepared = false;
@@ -64,6 +65,13 @@
return esb;
}
+ /**
+ * gets configured jbpm
+ */
+ public JBPM getJBPM() {
+ return jbpm;
+ }
+
public class Server {
/**
* is server runtime & server added?
@@ -125,4 +133,19 @@
*/
public String name = null;
}
+
+ public class JBPM {
+ /**
+ * version of ESB runtime
+ */
+ public String version = null;
+ /**
+ * is configured?
+ */
+ public boolean isConfigured = false;
+ /**
+ * name of added runtime
+ */
+ public String name = null;
+ }
}
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -0,0 +1,27 @@
+package org.jboss.tools.ui.bot.ext.config;
+
+public class JBPMBean {
+ public String version;
+ public String jbpmHome;
+
+ public static JBPMBean fromString(String propValue) throws Exception{
+ try {
+ if (propValue==null) {
+ return null;
+ }
+ String[] jbpmParams = propValue.split(",");
+ JBPMBean bean = new JBPMBean();
+ bean.jbpmHome=jbpmParams[1];
+ bean.version=jbpmParams[0];
+ return bean;
+ }
+ catch (Exception ex) {
+ throw new Exception("Cannot parse jBPM property line",ex);
+ }
+ }
+ @Override
+ public String toString() {
+ return String.format("jBPM runtime version=%s, home=%s",
+ this.version, this.jbpmHome);
+ }
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -28,6 +28,7 @@
private SeamBean seam;
private ESBBean esb;
private JavaBean java;
+ private JBPMBean jbpm;
public TestConfiguration(String propName, String propFile) throws Exception {
this.propName = propName;
@@ -55,6 +56,8 @@
printConfig(Keys.SEAM, seam);
esb = ESBBean.fromString(getProperty(Keys.ESB));
printConfig(Keys.ESB, esb);
+ jbpm = JBPMBean.fromString(getProperty(Keys.JBPM));
+ printConfig(Keys.JBPM, jbpm);
checkConfig();
}
@@ -132,4 +135,8 @@
public String getPropName() {
return propName;
}
+
+ public JBPMBean getJBPM() {
+ return jbpm;
+ }
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -11,6 +11,7 @@
import org.apache.log4j.Logger;
import org.jboss.tools.ui.bot.ext.config.Annotations.ESB;
+import org.jboss.tools.ui.bot.ext.config.Annotations.JBPM;
import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
@@ -26,6 +27,7 @@
public static final String SEAM = "SEAM";
public static final String JAVA = "JAVA";
public static final String ESB = "ESB";
+ public static final String JBPM = "JBPM";
}
public class Values {
@@ -81,6 +83,7 @@
ex.printStackTrace();
}
// load default config by default
+ /*
try {
log.info(" * Loading default configuration first");
currentConfig = new TestConfiguration("default", "");
@@ -92,6 +95,7 @@
finally {
log.info(" * Defaults loaded");
}
+ */
}
/**
@@ -175,6 +179,16 @@
}
return RequirementBase.createAddESB();
}
+
+ private static RequirementBase getJBPMRequirement(JBPM j) {
+ if (!j.required() || currentConfig.getJBPM() == null ) {
+ return null;
+ }
+ if (!matches(currentConfig.getJBPM().version, j.operator(), j.version())) {
+ return null;
+ }
+ return RequirementBase.createAddJBPM();
+ }
/**
* returns list of requirements if given class (Test) can run, all this is
@@ -213,6 +227,14 @@
}
reqs.add(req);
}
+ if (requies.jbpm().required()) {
+ RequirementBase req = getJBPMRequirement(requies.jbpm());
+ if (req == null) {
+ return null;
+ }
+ reqs.add(req);
+ }
+
if (!"".equals(requies.perspective())) {
reqs.add(RequirementBase.createSwitchPerspective(requies
.perspective()));
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -0,0 +1,23 @@
+package org.jboss.tools.ui.bot.ext.config.requirement;
+
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
+
+public class AddJBPM extends RequirementBase {
+
+ @Override
+ public boolean checkFulfilled() {
+ return SWTTestExt.configuredState.getJBPM().isConfigured;
+ }
+
+ @Override
+ public void handle() {
+ String jbpmName = "JBPM-"+TestConfigurator.currentConfig.getJBPM().version;
+ SWTTestExt.eclipse.addJBPMRuntime(jbpmName, TestConfigurator.currentConfig.getJBPM().version, TestConfigurator.currentConfig.getJBPM().jbpmHome);
+ SWTTestExt.configuredState.getJBPM().isConfigured=true;
+ SWTTestExt.configuredState.getJBPM().name=jbpmName;
+ SWTTestExt.configuredState.getJBPM().version=TestConfigurator.currentConfig.getJBPM().version;
+
+ }
+
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -119,6 +119,11 @@
RequirementBase req = new AddESB();
return req;
}
+
+ public static RequirementBase createAddJBPM() {
+ RequirementBase req = new AddJBPM();
+ return req;
+ }
public static AddJava createAddJava() {
AddJava req = new AddJava();
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -22,7 +22,7 @@
public enum EntityType {
HIBERNATE_MAPPING_FILE, JAVA_PROJECT, JAVA_CLASS, HIBERNATE_REVERSE_FILE, HIBERNATE_CONSOLE,
HIBERNATE_CONFIGURATION_FILE, STRUTS_PROJECT, JPA_PROJECT, DROOLS_PROJECT, DROOLS_RULE,
- GUIDED_DROOLS_RULE,DSL_DROOLS_FILE,RESOURCES_FROM_GUVNOR,SMOOKS_CONFIG;
+ GUIDED_DROOLS_RULE,DSL_DROOLS_FILE,RESOURCES_FROM_GUVNOR,SMOOKS_CONFIG, JBPM3_PROJECT;
public List<String> getGroupsLabels() {
List<String> groupLabel = new LinkedList<String>();
@@ -42,6 +42,7 @@
case DSL_DROOLS_FILE: groupLabel.add(IDELabel.EntityGroup.DROOLS);break;
case RESOURCES_FROM_GUVNOR: groupLabel.add(IDELabel.EntityGroup.GUVNOR);break;
case SMOOKS_CONFIG: groupLabel.add(IDELabel.EntityGroup.SMOOKS);break;
+ case JBPM3_PROJECT: groupLabel.add(IDELabel.EntityGroup.JBPM);break;
default: fail("Unknown Entity Type");
}
@@ -70,6 +71,7 @@
case DSL_DROOLS_FILE: entityLabel = IDELabel.EntityLabel.DSL_DROOLS_FILE; break;
case RESOURCES_FROM_GUVNOR: entityLabel = IDELabel.EntityLabel.RESOURCES_FROM_GUVNOR; break;
case SMOOKS_CONFIG: entityLabel = IDELabel.EntityLabel.SMOOKS_CONF_FILE; break;
+ case JBPM3_PROJECT: entityLabel = IDELabel.EntityLabel.JBPM3_PROJECT; break;
default: fail("Unknown Entity Type");
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -160,6 +160,7 @@
public static final String DROOLS = "Drools";
public static final String GUVNOR = "Guvnor";
public static final String SMOOKS = "Smooks";
+ public static final String JBPM = "JBoss jBPM";
}
public class EntityLabel {
@@ -178,6 +179,7 @@
public static final String DSL_DROOLS_FILE = "Domain Specific Language";
public static final String SMOOKS_CONF_FILE = "Smooks Configuration File";
public static final String RESOURCES_FROM_GUVNOR = "Resources from Guvnor";
+ public static final String JBPM3_PROJECT = "jBPM 3 Project";
}
public class JavaProjectWizard {
@@ -231,6 +233,7 @@
public static final String DEBUG = "Debug";
public static final String GUVNOR_REPOSITORY_EXPLORING = "Guvnor Repository Exploring";
public static final String DROOLS = "Drools";
+ public static final String JBPM3 = "jBPM jPDL 3";
}
/**
* Hibernate Console Wizard (ConsoleConfigurationCreationWizard) Labels (
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java 2010-10-20 08:59:34 UTC (rev 25931)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java 2010-10-20 09:03:25 UTC (rev 25932)
@@ -17,6 +17,6 @@
*/
public enum PerspectiveType {
SEAM, JAVA, WEB_DEVELOPMENT, HIBERNATE, DB_DEVELOPMENT, JPA, DEBUG, GUVNOR_REPOSITORY_EXPLORING,
- DROOLS;
+ DROOLS, JBPM3;
}
14 years, 2 months