JBoss Tools SVN: r30591 - workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-15 12:05:01 -0400 (Fri, 15 Apr 2011)
New Revision: 30591
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/jboss-management-service.xml
Log:
implementing service
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/jboss-management-service.xml
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/jboss-management-service.xml (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/jboss-management-service.xml 2011-04-15 16:05:01 UTC (rev 30591)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.jboss.ide.eclipse.as7.deployment">
+ <implementation class="org.jboss.ide.eclipse.as7.internal.deployment.JBossManagementService"/>
+ <service>
+ <provide interface="org.jboss.ide.eclipse.as7.deployment.IJBossManagementService"/>
+ </service>
+</scr:component>
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/jboss-management-service.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 7 months
JBoss Tools SVN: r30590 - in workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7: internal/deployment and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-15 12:03:03 -0400 (Fri, 15 Apr 2011)
New Revision: 30590
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java
Log:
implementing service
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java 2011-04-15 15:57:31 UTC (rev 30589)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java 2011-04-15 16:03:03 UTC (rev 30590)
@@ -23,9 +23,10 @@
* @param monitor The progress monitor
*
* @return Not sure what to return yet
+ * @throws Exception
*/
- public Object asyncDeploy(String host, int port,
- String deploymentName, File file, IProgressMonitor monitor);
+ public Object deployAsync(String host, int port,
+ String deploymentName, File file, IProgressMonitor monitor) throws Exception;
/**
* Synchronously deploy a file to a server
@@ -37,9 +38,10 @@
* @param monitor The progress monitor
*
* @return Not sure what to return yet
+ * @throws Exception
*/
- public Object syncDeploy(String host, int port,
- String deploymentName, File file, IProgressMonitor monitor);
+ public Object deploySync(String host, int port,
+ String deploymentName, File file, IProgressMonitor monitor) throws Exception;
/**
@@ -52,9 +54,10 @@
* @param monitor The progress monitor
*
* @return Not sure what to return yet
+ * @throws Exception
*/
- public Object asyncUndeploy(String host, int port,
- String deploymentName, boolean removeFile, IProgressMonitor monitor);
+ public Object undeployAsync(String host, int port,
+ String deploymentName, boolean removeFile, IProgressMonitor monitor) throws Exception;
/**
@@ -67,9 +70,10 @@
* @param monitor The progress monitor
*
* @return Not sure what to return yet
+ * @throws Exception
*/
public Object syncUndeploy(String host, int port,
- String deploymentName, boolean removeFile, IProgressMonitor monitor);
+ String deploymentName, boolean removeFile, IProgressMonitor monitor) throws Exception;
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java 2011-04-15 15:57:31 UTC (rev 30589)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java 2011-04-15 16:03:03 UTC (rev 30590)
@@ -1,35 +1,35 @@
package org.jboss.ide.eclipse.as7.internal.deployment;
import java.io.File;
-import java.util.concurrent.Future;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
+import org.jboss.ide.eclipse.as7.internal.deployment.TypedDeployer.DeploymentResult;
public class JBossDeploymentManager implements IJBossDeploymentManager {
- public Future asyncDeploy(String host, int port, String deploymentName,
- File file, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
+ public DeploymentResult deployAsync(String host, int port, String deploymentName,
+ File file, IProgressMonitor monitor) throws Exception {
+ TypedDeployer deployer = new TypedDeployer(host, port);
+ return deployer.deploy(deploymentName, file);
}
- public Object syncDeploy(String host, int port, String deploymentName,
- File file, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
+ public DeploymentResult deploySync(String host, int port, String deploymentName,
+ File file, IProgressMonitor monitor) throws Exception {
+ TypedDeployer deployer = new TypedDeployer(host, port);
+ return deployer.deploySync(deploymentName, file, monitor);
}
- public Future asyncUndeploy(String host, int port, String deploymentName,
- boolean removeFile, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
+ public DeploymentResult undeployAsync(String host, int port, String deploymentName,
+ boolean removeFile, IProgressMonitor monitor) throws Exception {
+ TypedDeployer deployer = new TypedDeployer(host, port);
+ return deployer.undeploy(deploymentName, monitor);
}
- public Object syncUndeploy(String host, int port, String deploymentName,
- boolean removeFile, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
+ public DeploymentResult syncUndeploy(String host, int port, String deploymentName,
+ boolean removeFile, IProgressMonitor monitor) throws Exception {
+ TypedDeployer deployer = new TypedDeployer(host, port);
+ return deployer.undeploySync(deploymentName, monitor);
}
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java 2011-04-15 15:57:31 UTC (rev 30589)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java 2011-04-15 16:03:03 UTC (rev 30590)
@@ -53,17 +53,19 @@
this.manager = ServerDeploymentManager.Factory.create(client);
}
- public void undeploySync(String name, IProgressMonitor monitor) throws DeployerException {
- DeploymentResult result = undeploy(name);
+ public DeploymentResult undeploySync(String name, IProgressMonitor monitor) throws DeployerException {
+ DeploymentResult result = undeploy(name, monitor);
result.getStatus();
+ return result;
}
- public void syncDeploy(String name, File file, IProgressMonitor monitor) throws DeployerException {
+ public DeploymentResult deploySync(String name, File file, IProgressMonitor monitor) throws DeployerException {
DeploymentResult result = deploy(name, file);
result.getStatus();
+ return result;
}
- public DeploymentResult undeploy(String name) throws DeployerException {
+ public DeploymentResult undeploy(String name, IProgressMonitor monitor) throws DeployerException {
try {
DeploymentPlanBuilder builder = manager.newDeploymentPlan();
builder = builder.undeploy(name).andRemoveUndeployed();
13 years, 7 months
JBoss Tools SVN: r30589 - in trunk/modeshape: plugins/org.jboss.tools.modeshape.rest/META-INF and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2011-04-15 11:57:31 -0400 (Fri, 15 Apr 2011)
New Revision: 30589
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
Removed:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PreferenceInitializer.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java
Log:
JBIDE-7857 ModeShape preferences should match the "Team"->"Ignored Resources." Deleted the file name and folder name preferences. Added an "ignored resources" preference. Changed to preference page to match the "Team" preference page and behavior.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF 2011-04-15 15:57:31 UTC (rev 30589)
@@ -20,6 +20,7 @@
.
Export-Package: javax.jcr.nodetype,
org.jboss.tools.modeshape.rest,
+ org.jboss.tools.modeshape.rest.preferences,
org.modeshape.common.i18n,
org.modeshape.web.jcr.rest.client,
org.modeshape.web.jcr.rest.client.domain
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties 2011-04-15 15:57:31 UTC (rev 30589)
@@ -14,7 +14,7 @@
contextMenu.label = ModeShape
decorator.description = Decorates objects in the ModeShape View
decorator.label = ModeShape View Decorator
-fileFiltersPreferencePage = File Filters
+ignoredResourcesPreferencePage = Ignored Resources
modeShapeCategory = ModeShape
preferenceInitializer = Preference Initializer for default values
publishCommand.name = Publish
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml 2011-04-15 15:57:31 UTC (rev 30589)
@@ -209,14 +209,14 @@
</page>
</extension>
-<!-- File Filters Preference Page -->
+<!-- Ignored Resources Preference Page -->
<extension
point="org.eclipse.ui.preferencePages">
<page
- name="%fileFiltersPreferencePage"
+ name="%ignoredResourcesPreferencePage"
category="modeShapePreferencePage"
- class="org.jboss.tools.modeshape.rest.preferences.FileFiltersPreferencePage"
- id="modeShapeFileFiltersPreferencePage">
+ class="org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesPreferencePage"
+ id="modeShapeIgnoredResourcesPreferencePage">
</page>
<!-- Preference Initializer -->
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -90,27 +90,27 @@
* The message console help context.
*/
String MESSAGE_CONSOLE_HELP_CONTEXT = HELP_CONTEXT_PREFIX + "messageConsoleHelpContext"; //$NON-NLS-1$
-
+
/**
* The preference pages help context.
*/
String PREFERENCE_PAGE_HELP_CONTEXT = HELP_CONTEXT_PREFIX + "preferencesHelpContext"; //$NON-NLS-1$
-
+
/**
* The publish and unpublish dialog help context.
*/
String PUBLISH_DIALOG_HELP_CONTEXT = HELP_CONTEXT_PREFIX + "publishDialogHelpContext"; //$NON-NLS-1$
-
+
/**
* The server wizard and dialog page help context.
*/
String SERVER_DIALOG_HELP_CONTEXT = HELP_CONTEXT_PREFIX + "serverDialogHelpContext"; //$NON-NLS-1$
-
+
/**
* The server view help context.
*/
String SERVER_VIEW_HELP_CONTEXT = HELP_CONTEXT_PREFIX + "serverViewHelpContext"; //$NON-NLS-1$
-
+
}
/**
@@ -122,22 +122,18 @@
* A preference that indicates if the ModeShape server should use resource versioning. If versioning is not used, only one
* copy of the resource will be persisted.
*/
- String ENABLE_RESOURCE_VERSIONING = "modeShape.preference.filteredFileExtensions"; //$NON-NLS-1$
+ String ENABLE_RESOURCE_VERSIONING = "modeShape.preference.enableResourceVersioning"; //$NON-NLS-1$
/**
- * A preference for a list of file extensions that will not be part of publishing operations.
+ * A preference for a list of ignored resource patterns. Files or folders whose name matches on of the patterns will not be
+ * part of publishing operations.
*/
- String FILTERED_FILE_EXTENSIONS_PREFERENCE = "modeShape.preference.filteredFileExtensions"; //$NON-NLS-1$
+ String IGNORED_RESOURCES_PREFERENCE = "modeShape.preference.ignoredResources"; //$NON-NLS-1$
/**
- * A preference for a list of folder names whose contents will not be part of publishing operations.
+ * The ignored resources preference page ID.
*/
- String FILTERED_FOLDER_NAMES_PREFERENCE = "modeShape.preference.filteredFolderNames"; //$NON-NLS-1$
-
- /**
- * The file and folder preference page ID.
- */
- String FILTERS_PREFERENCE_PAGE_ID = "modeShapeFileFiltersPreferencePage"; //$NON-NLS-1$
+ String IGNORED_RESOURCES_PREFERENCE_PAGE_ID = "modeShapeIgnoredResourcesPreferencePage"; //$NON-NLS-1$
/**
* The main ModeShape preference page ID.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -38,19 +38,15 @@
public static I18n errorRestoringServerRegistry;
public static I18n errorSavingServerRegistry;
- public static I18n fileFiltersPreferencePageDescription;
- public static I18n fileFiltersPreferencePageFilteredFileExtensionsLabel;
- public static I18n fileFiltersPreferencePageFilteredFolderNamesLabel;
- public static I18n fileFiltersPreferencePageMessage;
- public static I18n fileFiltersPreferencePageTitle;
+ public static I18n ignoredResourcesPreferencePageDescription;
+ public static I18n ignoredResourcesPreferencePageLabel;
+ public static I18n ignoredResourcesPreferencePageMessage;
+ public static I18n ignoredResourcesPreferencePageTitle;
public static I18n missingImage;
- public static I18n newFilteredFileExtensionDialogLabel;
- public static I18n newFilteredFileExtensionDialogTitle;
-
- public static I18n newFilteredFolderNameDialogLabel;
- public static I18n newFilteredFolderNameDialogTitle;
+ public static I18n newIgnoredResourceDialogLabel;
+ public static I18n newIgnoredResourceDialogTitle;
public static I18n newItemDialogValueExists;
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2011-04-15 15:57:31 UTC (rev 30589)
@@ -30,19 +30,15 @@
errorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
errorSavingServerRegistry = Error trying to save the server registry to "{0}"
-fileFiltersPreferencePageDescription = Add or remove file extensions and folder names. Files with a matching file extension or files that are contained in a folder with a matching name will NOT be published to or unpublished from repositories.
-fileFiltersPreferencePageFilteredFileExtensionsLabel = Filtered File Extensions:
-fileFiltersPreferencePageFilteredFolderNamesLabel = Filtered Folder Names:
-fileFiltersPreferencePageMessage = File Filters
-fileFiltersPreferencePageTitle = File Filters
+ignoredResourcesPreferencePageDescription = Use this page to specify a list of file and folder name patterns to exclude from publishing operations. \n\nIgnore Patterns:
+ignoredResourcesPreferencePageLabel = Ignore Patterns:
+ignoredResourcesPreferencePageMessage = Ignored Resources
+ignoredResourcesPreferencePageTitle = Ignored Resources
missingImage = The following image cannot be found "{0}"
-newFilteredFileExtensionDialogLabel = File extension:
-newFilteredFileExtensionDialogTitle = New Filtered File Extension
-
-newFilteredFolderNameDialogLabel = Folder name:
-newFilteredFolderNameDialogTitle = New Filtered Folder Name
+newIgnoredResourceDialogLabel = Enter a file name or folder name (* = any string, ? = and character):
+newIgnoredResourceDialogTitle = New Ignore Pattern
newItemDialogValueExists = Value already exists
@@ -109,8 +105,8 @@
publishPageNoAvailableRepositoriesStatusMsg = There are no repositories available on that server, or a \nconnection to the server cannot be made.
publishPageNoAvailableServersStatusMsg = A server must be created first
publishPageNoAvailableWorkspacesStatusMsg = There are no JCR workspaces available on that server and repository, or a \nconnection to the server cannot be made.
-publishPageNoResourcesToPublishStatusMsg = There are no files that can be published (may be due to your file filter preferences).
-publishPageNoResourcesToUnpublishStatusMsg = There are no files that can be unpublished
+publishPageNoResourcesToPublishStatusMsg = There are no files that can be published (may be due to your ignored resources preference).
+publishPageNoResourcesToUnpublishStatusMsg = There are no files that can be unpublished (may be due to your ignored resources preference).
publishPageOpenPreferencePageLink = ( change default in your <a>preferences</a> )
publishPagePublishOkStatusMsg = Choose the location of the JCR repository where your local files \nand folders will be published, and then click "Finish."
publishPagePublishResourcesLabel = These files were selected and will be published:
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -12,11 +12,9 @@
package org.jboss.tools.modeshape.rest;
import static org.jboss.tools.modeshape.rest.IUiConstants.PLUGIN_ID;
+
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
@@ -27,28 +25,7 @@
public final class Utils {
- // ===========================================================================================================================
- // Class Methods
- // ===========================================================================================================================
-
/**
- * @param tokens the tokens being combined into one value (never <code>null</code>)
- * @param delimiter the character inserted to separate each token
- * @return the tokens separated by the delimiter
- */
- public static String combineTokens( String[] tokens,
- char delimiter ) {
- CheckArg.isNotNull(tokens, "tokens");
- StringBuilder value = new StringBuilder();
-
- for (String token : tokens) {
- value.append(token).append(delimiter);
- }
-
- return value.toString();
- }
-
- /**
* Converts the non-Eclipse status severity to an Eclipse severity level. An {@link Status.Severity#UNKNOWN unknown status} is
* converted to {@link IStatus#CANCEL cancel}.
*
@@ -84,7 +61,7 @@
* @return the Eclipse status object (never <code>null</code>)
*/
public static IStatus convert( Status status ) {
- CheckArg.isNotNull(status, "status");
+ CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
return new org.eclipse.core.runtime.Status(convertSeverity(status.getSeverity()), PLUGIN_ID, status.getMessage(),
status.getException());
}
@@ -96,7 +73,7 @@
* @return the image or <code>null</code> if no associated image for the status severity
*/
public static Image getImage( Status status ) {
- CheckArg.isNotNull(status, "status");
+ CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
String imageId = null;
if (status.isError()) {
@@ -115,38 +92,13 @@
}
/**
- * @param string the string whose tokens are being requested (may be <code>null</code>)
- * @param delimiters the delimiters that separate the tokens (never <code>null</code>)
- * @param removeDuplicates a flag indicating if duplicate tokens should be removed
- * @return the tokens (never <code>null</code>)
- */
- public static String[] getTokens( String string,
- String delimiters,
- boolean removeDuplicates ) {
- CheckArg.isNotNull(delimiters, "delimiters");
-
- if (string == null) {
- return new String[0];
- }
-
- Collection<String> tokens = removeDuplicates ? new TreeSet<String>() : new ArrayList<String>();
- StringTokenizer st = new StringTokenizer(string, delimiters);
-
- while (st.hasMoreTokens()) {
- tokens.add(st.nextToken());
- }
-
- return tokens.toArray(new String[tokens.size()]);
- }
-
- /**
* The image can be used to decorate an existing image.
*
* @param status the status whose image overlay is being requested (never <code>null</code>)
* @return the image descriptor or <code>null</code> if none found for the status severity
*/
public static ImageDescriptor getOverlayImage( Status status ) {
- CheckArg.isNotNull(status, "status");
+ CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
String imageId = null;
if (status.isError()) {
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,16 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+/**
+ * The ModeShape REST Client Eclipse jobs package defines the Eclipse jobs that are needed to publish, unpublish, and manage
+ * the server registry.
+ */
+package org.jboss.tools.modeshape.rest.jobs;
\ No newline at end of file
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -1,180 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import static org.jboss.tools.modeshape.rest.IUiConstants.ModeShape_IMAGE_16x;
-import static org.jboss.tools.modeshape.rest.IUiConstants.HelpContexts.PREFERENCE_PAGE_HELP_CONTEXT;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageDescription;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageMessage;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageTitle;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.IWorkbenchHelpSystem;
-import org.jboss.tools.modeshape.rest.Activator;
-
-/**
- * The <code>FileFiltersPreferencePage</code> is the UI for managing all file extension and folder name filter preferences.
- */
-public final class FileFiltersPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- /**
- * The editor used to manage the list of filtered file extensions.
- */
- private FilteredFileExtensionEditor extensionsEditor;
-
- /**
- * The editor used to manage the list of filtered folder names.
- */
- private FilteredFoldersEditor foldersEditor;
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createContents( Composite parent ) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new GridLayout(2, false));
- panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // create the filtered extensions editor
- this.extensionsEditor = new FilteredFileExtensionEditor(panel);
- this.extensionsEditor.setPreferenceStore(getPreferenceStore());
- this.extensionsEditor.getListControl(panel).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // populate the extensions editor
- this.extensionsEditor.load();
-
- // create the filtered folders editor
- this.foldersEditor = new FilteredFoldersEditor(panel);
- this.foldersEditor.setPreferenceStore(getPreferenceStore());
- this.foldersEditor.getListControl(panel).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // populate the folders editor
- this.foldersEditor.load();
-
- // register with the help system
- IWorkbenchHelpSystem helpSystem = Activator.getDefault().getWorkbench().getHelpSystem();
- helpSystem.setHelp(panel, PREFERENCE_PAGE_HELP_CONTEXT);
-
- return panel;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getDescription()
- */
- @Override
- public String getDescription() {
- return fileFiltersPreferencePageDescription.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getImage()
- */
- @Override
- public Image getImage() {
- return Activator.getDefault().getImage(ModeShape_IMAGE_16x);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getMessage()
- */
- @Override
- public String getMessage() {
- return fileFiltersPreferencePageMessage.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
- */
- @Override
- public IPreferenceStore getPreferenceStore() {
- return PrefUtils.getPreferenceStore();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getTitle()
- */
- @Override
- public String getTitle() {
- return fileFiltersPreferencePageTitle.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- @Override
- public void init( IWorkbench workbench ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- @Override
- protected void performDefaults() {
- this.extensionsEditor.loadDefault();
- this.foldersEditor.loadDefault();
- super.performDefaults();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#performOk()
- */
- @Override
- public boolean performOk() {
- this.extensionsEditor.store();
- this.foldersEditor.store();
- return super.performOk();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
- */
- @Override
- public void setVisible( boolean visible ) {
- super.setVisible(visible);
-
- if (visible) {
- this.extensionsEditor.setFocus();
- }
- }
-
-}
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -1,97 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FILE_EXTENSIONS_PREFERENCE;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageFilteredFileExtensionsLabel;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFileExtensionDialogLabel;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFileExtensionDialogTitle;
-
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.modeshape.rest.Utils;
-
-/**
- * The <code>FilteredFileExtensionEditor</code> is an editor for managing a set of filtered file extensions.
- */
-public final class FilteredFileExtensionEditor extends SortedListEditor implements VerifyListener {
-
- /**
- * The filter that removes resources, with specific file extensions, from publishing operations (never <code>null</code>).
- */
- private final PublishingFileFilter filter;
-
- /**
- * @param parent the parent control
- */
- public FilteredFileExtensionEditor( Composite parent ) {
- super(FILTERED_FILE_EXTENSIONS_PREFERENCE, fileFiltersPreferencePageFilteredFileExtensionsLabel.text(), parent);
- this.filter = new PublishingFileFilter();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
- */
- @Override
- protected String createList( String[] items ) {
- return Utils.combineTokens(items, this.filter.getFileExtensionDelimiter());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogLabel()
- */
- @Override
- protected String getNewItemDialogLabel() {
- return newFilteredFileExtensionDialogLabel.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogTitle()
- */
- @Override
- protected String getNewItemDialogTitle() {
- return newFilteredFileExtensionDialogTitle.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
- */
- @Override
- protected String[] parseString( String stringList ) {
- return Utils.getTokens(stringList, Character.toString(this.filter.getFileExtensionDelimiter()), true);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
- */
- @Override
- public void verifyText( VerifyEvent event ) {
- for (char c : this.filter.getFileExtensionInvalidCharacters().toCharArray()) {
- if (c == event.character) {
- event.doit = false;
- break;
- }
- }
- }
-
-}
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -1,97 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FOLDER_NAMES_PREFERENCE;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageFilteredFolderNamesLabel;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFolderNameDialogLabel;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFolderNameDialogTitle;
-
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.modeshape.rest.Utils;
-
-/**
- * The <code>FilteredFoldersEditor</code> is an editor for managing a set of folder names.
- */
-public final class FilteredFoldersEditor extends SortedListEditor implements VerifyListener {
-
- /**
- * The filter that removes resources, contained in specific folders, from publishing operations (never <code>null</code>).
- */
- private final PublishingFileFilter filter;
-
- /**
- * @param parent the parent control
- */
- public FilteredFoldersEditor( Composite parent ) {
- super(FILTERED_FOLDER_NAMES_PREFERENCE, fileFiltersPreferencePageFilteredFolderNamesLabel.text(), parent);
- this.filter = new PublishingFileFilter();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
- */
- @Override
- protected String createList( String[] items ) {
- return Utils.combineTokens(items, this.filter.getFolderNameDelimiter());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogLabel()
- */
- @Override
- protected String getNewItemDialogLabel() {
- return newFilteredFolderNameDialogLabel.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogTitle()
- */
- @Override
- protected String getNewItemDialogTitle() {
- return newFilteredFolderNameDialogTitle.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
- */
- @Override
- protected String[] parseString( String stringList ) {
- return Utils.getTokens(stringList, Character.toString(this.filter.getFolderNameDelimiter()), true);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
- */
- @Override
- public void verifyText( VerifyEvent event ) {
- for (char c : this.filter.getFolderNameInvalidCharacters().toCharArray()) {
- if (c == event.character) {
- event.doit = false;
- break;
- }
- }
- }
-
-}
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,539 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.IGNORED_RESOURCES_PREFERENCE;
+import static org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageLabel;
+import static org.jboss.tools.modeshape.rest.RestClientI18n.newIgnoredResourceDialogLabel;
+import static org.jboss.tools.modeshape.rest.RestClientI18n.newIgnoredResourceDialogTitle;
+
+import java.util.Collection;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.jboss.tools.modeshape.rest.Activator;
+import org.jboss.tools.modeshape.rest.RestClientI18n;
+
+/**
+ * The <code>IgnoredResourcesEditor</code> is an editor for managing a set of ignored resources.
+ */
+public final class IgnoredResourcesEditor extends FieldEditor {
+
+ private Button btnAdd;
+
+ private Button btnRemove;
+
+ /**
+ * The data model (never <code>null</code>).
+ */
+ private IgnoredResourcesModel model;
+
+ private TableViewer viewer;
+
+ /**
+ * @param parent the parent control
+ */
+ public IgnoredResourcesEditor( Composite parent ) {
+ super(IGNORED_RESOURCES_PREFERENCE, ignoredResourcesPreferencePageLabel.text(), parent);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
+ */
+ @Override
+ protected void adjustForNumColumns( int numColumns ) {
+ Control control = getLabelControl();
+ ((GridData)control.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)this.viewer.getControl().getLayoutData()).horizontalSpan = numColumns - 1;
+ }
+
+ /**
+ * Creates a push button.
+ *
+ * @param parent the parent control
+ * @param key the resource name used to supply the button's label text
+ * @return the button (never <code>null</code>)
+ */
+ private Button createPushButton( Composite parent,
+ String key ) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(JFaceResources.getString(key));
+ button.setFont(parent.getFont());
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
+ data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ button.setLayoutData(data);
+ return button;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
+ */
+ @Override
+ protected void doFillIntoGrid( Composite parent,
+ int numColumns ) {
+ // create table
+ this.viewer = new TableViewer(parent, (SWT.CHECK | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER));
+
+ this.viewer.setContentProvider(new IStructuredContentProvider() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ return getPatterns().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( Viewer viewer,
+ Object oldInput,
+ Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ // sort the table rows by resource name pattern
+ this.viewer.setComparator(new ViewerComparator() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public int compare( Viewer viewer,
+ Object e1,
+ Object e2 ) {
+ ResourcePattern pattern1 = (ResourcePattern)e1;
+ ResourcePattern pattern2 = (ResourcePattern)e2;
+
+ return pattern1.getPattern().compareTo(pattern2.getPattern());
+ }
+ });
+
+ this.viewer.setLabelProvider(new LabelProvider() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( Object element ) {
+ return ((ResourcePattern)element).getPattern();
+ }
+ });
+
+ Table table = this.viewer.getTable();
+ table.setLayout(new TableLayout());
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ table.addListener(SWT.Selection, new Listener() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent( Event event ) {
+ if (event.detail == SWT.CHECK) {
+ handlePatternChecked((TableItem)event.item);
+ } else {
+ handlePatternSelected();
+ }
+ }
+ });
+
+ // create buttons
+ Composite pnlButtons = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ pnlButtons.setLayout(layout);
+ pnlButtons.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ this.btnAdd = createPushButton(pnlButtons, "ListEditor.add");//$NON-NLS-1$
+ this.btnAdd.addSelectionListener(new SelectionAdapter() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleAddPressed();
+ }
+ });
+
+ this.btnRemove = createPushButton(pnlButtons, "ListEditor.remove");//$NON-NLS-1$
+ this.btnRemove.setEnabled(false);
+ this.btnRemove.addSelectionListener(new SelectionAdapter() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleRemovePressed();
+ }
+ });
+
+ this.model = new IgnoredResourcesModel(); // model must be created before setInput is called
+ this.viewer.setInput(this); // doesn't matter what you pass in
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doLoad()
+ */
+ @Override
+ protected void doLoad() {
+ // load model from current preference value and refresh UI
+ String prefValue = getPreferenceStore().getString(getPreferenceName());
+ this.model.load(prefValue);
+ refreshUi();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
+ */
+ @Override
+ protected void doLoadDefault() {
+ // load model from default preference value and refresh UI
+ String prefValue = getPreferenceStore().getDefaultString(getPreferenceName());
+ this.model.load(prefValue);
+ refreshUi();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doStore()
+ */
+ @Override
+ protected void doStore() {
+ getPreferenceStore().setValue(getPreferenceName(), this.model.createList());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 2;
+ }
+
+ Collection<ResourcePattern> getPatterns() {
+ return this.model.getPatterns();
+ }
+
+ /**
+ * Handler for when add button is pressed.
+ */
+ void handleAddPressed() {
+ // display dialog to get new pattern from user
+ NewPatternDialog dialog = new NewPatternDialog(this.btnAdd.getShell(), getPatterns());
+
+ if (dialog.open() == Window.OK) {
+ // update model and UI
+ this.model.addPattern(new ResourcePattern(dialog.getNewPattern(), true));
+ refreshUi();
+ }
+ }
+
+ /**
+ * @param item the item whose checked state has been changed (may not be <code>null</code>)
+ */
+ void handlePatternChecked( TableItem item ) {
+ ResourcePattern pattern = (ResourcePattern)item.getData();
+ pattern.setEnabled(item.getChecked());
+ }
+
+ /**
+ * Handler for when pattern is selected.
+ */
+ void handlePatternSelected() {
+ IStructuredSelection selection = (IStructuredSelection)this.viewer.getSelection();
+ boolean enable = !selection.isEmpty();
+
+ if (this.btnRemove.getEnabled() != enable) {
+ this.btnRemove.setEnabled(enable);
+ }
+ }
+
+ /**
+ * Handler for when the remove button is pressed.
+ */
+ void handleRemovePressed() {
+ assert (!this.viewer.getSelection().isEmpty());
+ Object pattern = ((IStructuredSelection)this.viewer.getSelection()).getFirstElement();
+ this.model.removePattern((ResourcePattern)pattern);
+ refreshUi();
+ }
+
+ /**
+ * Updates the check state of each table item to reflect the appropriate value in the model.
+ */
+ private void initializeCheckBoxStates() {
+ for (TableItem item : this.viewer.getTable().getItems()) {
+ ResourcePattern pattern = (ResourcePattern)item.getData();
+
+ if (pattern.isEnabled()) {
+ item.setChecked(true);
+ }
+ }
+ }
+
+ /**
+ * Refreshes the viewer.
+ */
+ private void refreshUi() {
+ this.viewer.refresh();
+ initializeCheckBoxStates();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ this.viewer.getControl().setFocus();
+ }
+
+ /**
+ * A <code>NewPatternDialog</code> allows the user to enter a pattern.
+ */
+ class NewPatternDialog extends Dialog implements ModifyListener {
+
+ /**
+ * The existing ignored resource patterns.
+ */
+ private final Collection<ResourcePattern> existingPatterns;
+
+ /**
+ * A message for the user.
+ */
+ private CLabel lblMessage;
+
+ /**
+ * The contents of the new pattern text field.
+ */
+ private String newPattern;
+
+ /**
+ * @param parentShell the parent shell (can be <code>null</code>)
+ * @param existingPatterns the existing patterns (can be <code>null</code> or empty)
+ */
+ public NewPatternDialog( Shell parentShell,
+ Collection<ResourcePattern> existingPatterns ) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.existingPatterns = existingPatterns;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell( Shell newShell ) {
+ newShell.setText(newIgnoredResourceDialogTitle.text());
+ super.configureShell(newShell);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int, java.lang.String, boolean)
+ */
+ @Override
+ protected Button createButton( Composite parent,
+ int id,
+ String label,
+ boolean defaultButton ) {
+ Button button = super.createButton(parent, id, label, defaultButton);
+
+ // disable OK button initially
+ if (id == OK) {
+ button.setEnabled(false);
+ }
+
+ return button;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea( Composite parent ) {
+ Composite panel = (Composite)super.createDialogArea(parent);
+ Composite pnlEditor = new Composite(panel, SWT.NONE);
+ pnlEditor.setLayout(new GridLayout());
+ pnlEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label label = new Label(pnlEditor, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, false, false));
+ label.setText(newIgnoredResourceDialogLabel.text());
+
+ Text textField = new Text(pnlEditor, SWT.BORDER);
+ textField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+ textField.addModifyListener(this);
+ textField.addVerifyListener(new VerifyListener() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
+ */
+ @Override
+ public void verifyText( VerifyEvent e ) {
+ // don't allow slashes as input
+ if (e.text.contains("\\") || e.text.contains("/")) { //$NON-NLS-1$ //$NON-NLS-2$
+ e.doit = false;
+ }
+ }
+ });
+
+ // add image and message labels
+ this.lblMessage = new CLabel(pnlEditor, SWT.NONE);
+ this.lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+ ((GridData)this.lblMessage.getLayoutData()).horizontalSpan = 2;
+
+ return panel;
+ }
+
+ /**
+ * @return the new pattern name or <code>null</code> if the dialog was canceled
+ */
+ public String getNewPattern() {
+ if (getReturnCode() == OK) {
+ return this.newPattern;
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ */
+ @Override
+ protected void initializeBounds() {
+ super.initializeBounds();
+
+ // resize shell to be twice the width needed for the title (without this the title maybe cropped)
+ int width = (4 * convertWidthInCharsToPixels(newIgnoredResourceDialogTitle.text().length()));
+ Rectangle rectangle = getShell().getBounds();
+ getShell().setBounds(rectangle.x, rectangle.y, width, rectangle.height);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( ModifyEvent event ) {
+ // clear message
+ this.lblMessage.setImage(null);
+ this.lblMessage.setText(""); //$NON-NLS-1$
+
+ // enable/disable OK button
+ this.newPattern = ((Text)event.widget).getText();
+
+ // make sure at least one character entered
+ boolean enable = (this.newPattern.length() != 0);
+
+ // make sure value is not a disallowed value
+ if (enable && (this.existingPatterns != null)) {
+ for (ResourcePattern pattern : this.existingPatterns) {
+ if (this.newPattern.equals(pattern.getPattern())) {
+ enable = false;
+ this.lblMessage.setImage(Activator.getDefault().getSharedImage(ISharedImages.IMG_OBJS_INFO_TSK));
+ this.lblMessage.setText(RestClientI18n.newItemDialogValueExists.text());
+ break;
+ }
+ }
+ }
+
+ // set enabled state if different than current state
+ if (getButton(OK).getEnabled() != enable) {
+ getButton(OK).setEnabled(enable);
+ }
+ }
+
+ }
+
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.modeshape.common.util.CheckArg;
+
+/**
+ * The <code>IgnoredResourcesModel</code> class is used to keep track of ignored resources patterns used for resources publishing
+ * operations.
+ */
+public final class IgnoredResourcesModel {
+
+ /**
+ * Delimiter used when creating a single string representative of all patterns. Also used when parsing.
+ *
+ * @see #createList()
+ * @see #load(String)
+ */
+ private final static char DELIMITER = '\n';
+
+ /**
+ * Combines the ignored resource patterns into a single string. This method is the converse of <code>load</code>.
+ *
+ * @param patterns the patterns that will be combined into a string representation (never <code>null</code>)
+ * @return the string representation of the specified patterns (never <code>null</code> but can be empty)
+ */
+ public static String createList( ResourcePattern... patterns ) {
+ StringBuilder value = new StringBuilder();
+
+ for (ResourcePattern pattern : patterns) {
+ value.append(pattern.getPattern()).append(DELIMITER).append(pattern.isEnabled()).append(DELIMITER);
+ }
+
+ return value.toString();
+ }
+
+ /**
+ * @param stringList a string representation of zero or more patterns (may be <code>null</code> or empty)
+ * @return the patterns parsed from the string (never <code>null</code> but can be empty)
+ */
+ public ResourcePattern[] parseList( String stringList ) {
+ if ((stringList != null) && !stringList.equals("")) { //$NON-NLS-1$
+ StringTokenizer st = new StringTokenizer(stringList, Character.toString(DELIMITER));
+ ResourcePattern[] patterns = new ResourcePattern[(st.countTokens() > 0) ? (st.countTokens() / 2) : 0];
+ int i = 0;
+
+ while (st.hasMoreTokens()) {
+ String pattern = st.nextToken();
+ boolean enabled = Boolean.parseBoolean(st.nextToken());
+ patterns[i++] = new ResourcePattern(pattern, enabled);
+ }
+
+ return patterns;
+ }
+
+ return new ResourcePattern[0];
+ }
+
+ /**
+ * The patterns included in this model (never <code>null</code>).
+ */
+ private final Set<ResourcePattern> patterns = new HashSet<ResourcePattern>();
+
+ /**
+ * Adds the specified pattern if one with that same pattern does not already exist.
+ *
+ * @param pattern the pattern being added (may not be <code>null</code>)
+ */
+ public void addPattern( ResourcePattern pattern ) {
+ CheckArg.isNotNull(pattern, "pattern"); //$NON-NLS-1$
+ this.patterns.add(pattern);
+ }
+
+ /**
+ * Combines the ignored resource patterns into a single string. This method is the converse of <code>load</code>.
+ *
+ * @return the combined string (never <code>null</code> but can be empty)
+ * @see #load(String)
+ */
+ public String createList() {
+ return createList(this.patterns.toArray(new ResourcePattern[this.patterns.size()]));
+ }
+
+ /**
+ * @return an unmodifiable collection of patterns contained in this model (never <code>null</code>)
+ */
+ public Collection<ResourcePattern> getPatterns() {
+ return Collections.unmodifiableCollection(this.patterns);
+ }
+
+ /**
+ * Clears the current patterns and loads new patterns by parsing the specified string.
+ *
+ * @param stringList a string representation of zero or more patterns (may be <code>null</code> or empty)
+ */
+ public void load( String stringList ) {
+ this.patterns.clear();
+
+ // parse list into new patterns
+ ResourcePattern[] temp = parseList(stringList);
+
+ if (temp.length != 0) {
+ this.patterns.addAll(Arrays.asList(temp));
+ }
+ }
+
+ /**
+ * @param pattern the pattern being removed if it exists in the model (may not be <code>null</code>)
+ */
+ public void removePattern( ResourcePattern pattern ) {
+ CheckArg.isNotNull(pattern, "pattern"); //$NON-NLS-1$
+ this.patterns.remove(pattern);
+ }
+
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,164 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.jboss.tools.modeshape.rest.IUiConstants.ModeShape_IMAGE_16x;
+import static org.jboss.tools.modeshape.rest.IUiConstants.HelpContexts.PREFERENCE_PAGE_HELP_CONTEXT;
+import static org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageDescription;
+import static org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageMessage;
+import static org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageTitle;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.jboss.tools.modeshape.rest.Activator;
+
+/**
+ * The <code>IgnoredResourcesPreferencePage</code> is the UI for managing all ignored file extension and folder names.
+ */
+public final class IgnoredResourcesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ /**
+ * The editor used to manage the list of ignored file extensions and folder names.
+ */
+ private IgnoredResourcesEditor ignoredResourcesEditor;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents( Composite parent ) {
+ Composite panel = new Composite(parent, SWT.NONE);
+ panel.setLayout(new GridLayout(2, false));
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ // create the filtered extensions editor
+ this.ignoredResourcesEditor = new IgnoredResourcesEditor(panel);
+ this.ignoredResourcesEditor.setPreferenceStore(getPreferenceStore());
+
+ // populate the extensions editor
+ this.ignoredResourcesEditor.load();
+
+ // register with the help system
+ IWorkbenchHelpSystem helpSystem = Activator.getDefault().getWorkbench().getHelpSystem();
+ helpSystem.setHelp(panel, PREFERENCE_PAGE_HELP_CONTEXT);
+
+ return panel;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return ignoredResourcesPreferencePageDescription.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return Activator.getDefault().getImage(ModeShape_IMAGE_16x);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return ignoredResourcesPreferencePageMessage.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getTitle()
+ */
+ @Override
+ public String getTitle() {
+ return ignoredResourcesPreferencePageTitle.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ @Override
+ public void init( IWorkbench workbench ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ @Override
+ protected void performDefaults() {
+ this.ignoredResourcesEditor.loadDefault();
+ super.performDefaults();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ this.ignoredResourcesEditor.store();
+ return super.performOk();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+ */
+ @Override
+ public void setVisible( boolean visible ) {
+ super.setVisible(visible);
+
+ if (visible) {
+ this.ignoredResourcesEditor.setFocus();
+ }
+ }
+
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -109,7 +109,7 @@
*/
@Override
public IPreferenceStore getPreferenceStore() {
- return PrefUtils.getPreferenceStore();
+ return Activator.getDefault().getPreferenceStore();
}
/**
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -1,64 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.jboss.tools.modeshape.rest.Activator;
-import org.jboss.tools.modeshape.rest.Utils;
-import org.modeshape.common.util.CheckArg;
-
-/**
- * The <code>PrefUtils</code> class provides common utilities relating to preferences. This class assumes the Eclipse runtime
- * platform is running.
- */
-public final class PrefUtils {
-
- /**
- * @param propertyId the property name whose list values are being requested (never <code>null</code>)
- * @param delimiter the character separating the items in the property value
- * @param removeDuplicates a flag indicating if duplicate items should be removed
- * @return the property value items (never <code>null</code>)
- */
- public static String[] getListPropertyValue( String propertyId,
- char delimiter,
- boolean removeDuplicates ) {
- CheckArg.isNotNull(propertyId, "propertyId"); //$NON-NLS-1$
- return Utils.getTokens(getPreferenceStore().getString(propertyId), Character.toString(delimiter), removeDuplicates);
- }
-
- /**
- * @return the plugin preference store
- */
- public static IPreferenceStore getPreferenceStore() {
- return Activator.getDefault().getPreferenceStore();
- }
-
- /**
- * @param propertyId the property name being set (never <code>null</code>)
- * @param items the items used to create the property value (never <code>null</code>)
- * @param delimiter the character to use to separate the items
- */
- public static void setListPropertyValue( String propertyId,
- String[] items,
- char delimiter ) {
- CheckArg.isNotNull(propertyId, "propertyId"); //$NON-NLS-1$
- CheckArg.isNotNull(items, "items"); //$NON-NLS-1$
- getPreferenceStore().setValue(propertyId, Utils.combineTokens(items, delimiter));
- }
-
- /**
- * Don't allow construction.
- */
- private PrefUtils() {
- // nothing to do
- }
-}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PreferenceInitializer.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PreferenceInitializer.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PreferenceInitializer.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -44,7 +44,7 @@
*/
@Override
public void initializeDefaultPreferences() {
- IEclipsePreferences defaultValues = new DefaultScope().getNode(PLUGIN_ID);
+ IEclipsePreferences defaultValues = DefaultScope.INSTANCE.getNode(PLUGIN_ID);
if (defaultValues == null) {
// would only happen if PLUGIN_ID is wrong
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -11,171 +11,58 @@
*/
package org.jboss.tools.modeshape.rest.preferences;
-import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FILE_EXTENSIONS_PREFERENCE;
-import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FOLDER_NAMES_PREFERENCE;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.preferenceNotFound;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.jboss.tools.modeshape.rest.Activator;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.web.jcr.rest.client.Status;
-import org.modeshape.web.jcr.rest.client.Status.Severity;
/**
- * The <code>PublishingFileFilter</code> is a file filter that uses the preferences when filtering files.
+ * The <code>PublishingFileFilter</code> is a resource name filter.
*/
public final class PublishingFileFilter {
/**
- * The preference name for the delimiter that separates filtered file extensions when the preference value is stored.
+ * @param text the text being tested against the pattern (may not be <code>null</code> or empty)
+ * @param pattern the pattern used (may not be <code>null</code> or empty)
+ * @return <code>true</code> if the text is matched by the pattern
*/
- private static final String FILE_EXT_DELIMITER_PREF_NAME = "fileExtension.delimiter"; //$NON-NLS-1$
+ public static boolean matches( String text,
+ String pattern ) {
+ final String regex = pattern.replace("?", ".?").replace("*", ".*?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return text.matches(regex);
+ }
/**
- * The preference name for characters that are <strong>NOT</strong> allowed to appear in a file extension.
+ * The data model (never <code>null</code>).
*/
- private static final String FILE_EXT_INVALID_CHARS_PREF_NAME = "fileExtension.invalidChars"; //$NON-NLS-1$
+ private final IgnoredResourcesModel model;
/**
- * The preference name for the delimiter that separates filtered folder names when the preference value is stored.
+ * @param model the data model (may not be <code>null</code>)
*/
- private static final String FOLDER_NAME_DELIMITER_PREF_NAME = "folderName.delimiter"; //$NON-NLS-1$
+ public PublishingFileFilter( IgnoredResourcesModel model ) {
+ CheckArg.isNotNull(model, "model"); //$NON-NLS-1$
+ this.model = model;
+ }
/**
- * The preference name for characters that are <strong>NOT</strong> allowed to appear in a folder name.
- */
- private static final String FOLDER_NAME_INVALID_CHARS_PREF_NAME = "folderName.invalidChars"; //$NON-NLS-1$
-
- /**
- * @param resource the resource being tested (never <code>null</code>)
+ * @param resource the resource being tested (may not be <code>null</code>)
* @return <code>true</code> if the resource should be included (i.e., it is not filtered out)
*/
public boolean accept( IResource resource ) {
CheckArg.isNotNull(resource, "resource"); //$NON-NLS-1$
+ final String name = resource.getName();
- if ((resource instanceof IFolder) || (resource instanceof IProject)) {
- String name = resource.getName();
-
- // see if folder name has been filtered
- for (String filteredName : getFilteredFolderNames()) {
- if (filteredName.equals(name)) {
- return false;
- }
+ for (ResourcePattern pattern : model.getPatterns()) {
+ if (pattern.isEnabled() && matches(name, pattern.getPattern())) {
+ return false;
}
-
- // check parent
- if (resource.getParent() != null) {
- return accept(resource.getParent());
- }
- } else if (resource instanceof IFile) {
- // see if file extension has been filtered
- for (String extension : getFilteredFileExtensions()) {
- if (resource.getFullPath().toString().endsWith('.' + extension)) {
- return false;
- }
- }
-
- // check parent
- if (resource.getParent() != null) {
- return accept(resource.getParent());
- }
}
-
- return true;
- }
-
- /**
- * The delimiter that separates filtered file extensions when the preference value is stored.
- *
- * @return the file extension separator character
- */
- public char getFileExtensionDelimiter() {
- String value = PrefUtils.getPreferenceStore().getDefaultString(FILE_EXT_DELIMITER_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value.charAt(0);
+
+ if (resource.getParent() == null) {
+ return true;
}
- // no value found so log and give a default value
- value = ","; //$NON-NLS-1$
- Activator.getDefault().log(new Status(Severity.ERROR, preferenceNotFound.text(FILE_EXT_DELIMITER_PREF_NAME, value), null));
- return value.charAt(0);
+ // check parents
+ return accept(resource.getParent());
}
- /**
- * The characters that are <strong>NOT</strong> allowed to appear in a file extension.
- *
- * @return the invalid file extension characters (never <code>null</code> or empty)
- */
- public String getFileExtensionInvalidCharacters() {
- String value = PrefUtils.getPreferenceStore().getDefaultString(FILE_EXT_INVALID_CHARS_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value;
- }
-
- // no value found so log and give a default value
- value = "*?<>|/\\:;."; //$NON-NLS-1$
- Activator.getDefault().log(new Status(Severity.ERROR,
- preferenceNotFound.text(FILE_EXT_INVALID_CHARS_PREF_NAME, value),
- null));
- return value;
- }
-
- /**
- * @return the file extensions being filtered out of publishing operations (never <code>null</code> but can be empty)
- */
- public String[] getFilteredFileExtensions() {
- return PrefUtils.getListPropertyValue(FILTERED_FILE_EXTENSIONS_PREFERENCE, getFileExtensionDelimiter(), true);
- }
-
- /**
- * @return the folder names being filtered out of publishing operations (never <code>null</code> but can be empty)
- */
- public String[] getFilteredFolderNames() {
- return PrefUtils.getListPropertyValue(FILTERED_FOLDER_NAMES_PREFERENCE, getFolderNameDelimiter(), true);
- }
-
- /**
- * The delimiter that separates filtered folder names when the preference value is stored.
- *
- * @return the folder name separator character
- */
- public char getFolderNameDelimiter() {
- String value = PrefUtils.getPreferenceStore().getDefaultString(FOLDER_NAME_DELIMITER_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value.charAt(0);
- }
-
- // no value found so log and give a default value
- value = ","; //$NON-NLS-1$
- Activator.getDefault()
- .log(new Status(Severity.ERROR, preferenceNotFound.text(FOLDER_NAME_DELIMITER_PREF_NAME, value), null));
- return value.charAt(0);
- }
-
- /**
- * The characters that are <strong>NOT</strong> allowed to appear in a folder name (never <code>null</code> but can be empty).
- *
- * @return the invalid folder name characters (never <code>null</code> or empty)
- */
- public String getFolderNameInvalidCharacters() {
- String value = PrefUtils.getPreferenceStore().getDefaultString(FOLDER_NAME_INVALID_CHARS_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value;
- }
-
- // no value found so log and give a default value
- value = "*?<>|/\\:;"; //$NON-NLS-1$
- Activator.getDefault().log(new Status(Severity.ERROR,
- preferenceNotFound.text(FOLDER_NAME_INVALID_CHARS_PREF_NAME, value),
- null));
- return value;
- }
-
}
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import org.modeshape.common.util.CheckArg;
+
+/**
+ * A <code>ResourcePattern</code> is a resource name pattern that is used to determine if a resource shoiuld be include in
+ * publishing operations. Wildcards (*, ?) are allowed.
+ */
+public final class ResourcePattern {
+
+ /**
+ * The name pattern (may not be <code>null</code>).
+ */
+ private final String pattern;
+
+ /**
+ * Indicates if the patter is enabled. Default is {@value} .
+ */
+ private boolean enabled;
+
+ /**
+ * @param pattern the resource name pattern (may not be <code>null</code> or empty)
+ * @param enabled <code>true</code> if the pattern should be enabled
+ */
+ public ResourcePattern( String pattern,
+ boolean enabled ) {
+ CheckArg.isNotEmpty(pattern, "pattern"); //$NON-NLS-1$
+ this.pattern = pattern;
+ this.enabled = enabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || !getClass().equals(obj.getClass())) {
+ return false;
+ }
+
+ return this.pattern.equals(((ResourcePattern)obj).pattern);
+ }
+
+ /**
+ * @return the resource name pattern (never <code>null</code>)
+ */
+ public String getPattern() {
+ return this.pattern;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return this.pattern.hashCode();
+ }
+
+ /**
+ * @return <code>true</code> if pattern is enabled
+ */
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ /**
+ * @param enabled <code>true</code> if pattern should be enabled
+ */
+ public void setEnabled( boolean enabled ) {
+ this.enabled = enabled;
+ }
+
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -1,371 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
- *
- * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.ListEditor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.ISharedImages;
-import org.jboss.tools.modeshape.rest.Activator;
-import org.jboss.tools.modeshape.rest.RestClientI18n;
-import org.modeshape.common.util.CheckArg;
-
-/**
- * A preference list string value editor that sorts its entries each time a value is added.
- */
-public abstract class SortedListEditor extends ListEditor {
-
- /**
- * Indicates if duplicate values are allowed.
- */
- private boolean allowDuplicates;
-
- /**
- * The listener verifying input characters.
- */
- private VerifyListener verifyListener;
-
- /**
- * Duplicate items are not allowed.
- *
- * @param name the name of the preference this field editor works on
- * @param labelText the label text of the field editor
- * @param parent the parent of the field editor's control
- */
- public SortedListEditor( String name,
- String labelText,
- Composite parent ) {
- super(name, labelText, parent);
- }
-
- private void disableUpDownButtons() {
- // disable up button
- Button button = getUpButton();
-
- if (button.getEnabled()) {
- button.setEnabled(false);
- }
-
- // disable down button
- button = getDownButton();
-
- if (button.getEnabled()) {
- button.setEnabled(false);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#getButtonBoxControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public Composite getButtonBoxControl( Composite parent ) {
- Composite buttonBox = super.getButtonBoxControl(parent);
- getUpButton().setVisible(false);
- getDownButton().setVisible(false);
- disableUpDownButtons();
- return buttonBox;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#getNewInputObject()
- */
- @Override
- protected final String getNewInputObject() {
- NewItemDialog dialog = new NewItemDialog(getShell(), getNewItemDialogTitle(), getNewItemDialogLabel(), this.verifyListener);
- if (!this.allowDuplicates) {
- dialog.setDisallowedValues(getList().getItems());
- }
-
- if (dialog.open() == Window.OK) {
- String newItem = dialog.getNewItem();
-
- // add new item, sort, and update list
- if (newItem != null) {
- getList().add(newItem);
- String[] items = getList().getItems();
- Arrays.sort(items);
- getList().setItems(items);
- }
- }
-
- // always return null because we have already updated the list
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#selectionChanged()
- */
- @Override
- protected void selectionChanged() {
- super.selectionChanged();
- disableUpDownButtons();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#setEnabled(boolean, org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void setEnabled( boolean enabled,
- Composite parent ) {
- super.setEnabled(enabled, parent);
- disableUpDownButtons();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#setFocus()
- */
- @Override
- public void setFocus() {
- if ((getList() == null) || getList().getItemCount() == 0) {
- getAddButton().setFocus();
- } else {
- super.setFocus();
- }
- }
-
- /**
- * @return the localized dialog title used when a new item is added (may not be <code>null</code>)
- */
- protected abstract String getNewItemDialogTitle();
-
- /**
- * @return the localized label on the new item dialog that identifies the type of the new item (may not be <code>null</code>)
- */
- protected abstract String getNewItemDialogLabel();
-
- /**
- * @param verifyListener a listener that verifies input from the user of a new item entry (can be <code>null</code>)
- */
- protected void setVerifyListener( VerifyListener verifyListener ) {
- this.verifyListener = verifyListener;
- }
-
- /**
- * A <code>NewItemDialog</code> allows the user to enter a text value. Caller can optionally furnish a list of disallowed
- * values.
- */
- class NewItemDialog extends Dialog implements ModifyListener {
-
- /**
- * The label describing the new item.
- */
- private final String label;
-
- /**
- * A list of disallowed values. If <code>null</code> any non-empty value is allowed.
- */
- private String[] disallowedValues;
-
- /**
- * A message for the user.
- */
- private CLabel lblMessage;
-
- /**
- * The contents of the new item text field.
- */
- private String newItem;
-
- /**
- * The dialog title.
- */
- private final String title;
-
- /**
- * The listener verifying input characters.
- */
- private final VerifyListener verifyListener;
-
- /**
- * @param parentShell the parent shell (may be <code>null</code>)
- * @param title the localized dialog title (never <code>null</code>)
- * @param label the localized label (never <code>null</code>)
- * @param verifyListener a listener that validates input characters (may be <code>null</code>)
- */
- public NewItemDialog( Shell parentShell,
- String title,
- String label,
- VerifyListener verifyListener ) {
- super(parentShell);
-
- CheckArg.isNotNull(title, "title"); //$NON-NLS-1$
- CheckArg.isNotNull(label, "label"); //$NON-NLS-1$
-
- this.title = title;
- this.label = label;
- this.verifyListener = verifyListener;
-
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell( Shell newShell ) {
- newShell.setText(this.title);
- super.configureShell(newShell);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int, java.lang.String, boolean)
- */
- @Override
- protected Button createButton( Composite parent,
- int id,
- String label,
- boolean defaultButton ) {
- Button button = super.createButton(parent, id, label, defaultButton);
-
- // disable OK button initially
- if (id == OK) {
- button.setEnabled(false);
- }
-
- return button;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea( Composite parent ) {
- Composite panel = (Composite)super.createDialogArea(parent);
- Composite pnlEditor = new Composite(panel, SWT.NONE);
- pnlEditor.setLayout(new GridLayout(2, false));
- pnlEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Label label = new Label(pnlEditor, SWT.NONE);
- label.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, false, false));
- label.setText(this.label);
-
- Text textField = new Text(pnlEditor, SWT.BORDER);
- textField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- textField.addModifyListener(this);
-
- // add listener if necessary
- if (this.verifyListener != null) {
- textField.addVerifyListener(this.verifyListener);
- }
-
- // add image and message labels
- this.lblMessage = new CLabel(pnlEditor, SWT.NONE);
- this.lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- ((GridData)this.lblMessage.getLayoutData()).horizontalSpan = 2;
-
- return panel;
- }
-
- /**
- * @return the new item or <code>null</code> if the dialog was canceled
- */
- public String getNewItem() {
- if (getReturnCode() == OK) {
- return this.newItem;
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
- */
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
-
- // resize shell to be twice the width needed for the title (without this the title maybe cropped)
- int width = (2 * convertWidthInCharsToPixels(this.title.length()));
- Rectangle rectangle = getShell().getBounds();
- getShell().setBounds(rectangle.x, rectangle.y, width, rectangle.height);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- @Override
- public void modifyText( ModifyEvent event ) {
- // clear message
- this.lblMessage.setImage(null);
- this.lblMessage.setText(""); //$NON-NLS-1$
-
- // enable/disable OK button
- this.newItem = ((Text)event.widget).getText();
-
- // make sure at least one character entered
- boolean enable = (this.newItem.length() != 0);
-
- // make sure value is not a disallowed value
- if (enable && (this.disallowedValues != null)) {
- for (String disallowedValue : this.disallowedValues) {
- if (this.newItem.equals(disallowedValue)) {
- enable = false;
- this.lblMessage.setImage(Activator.getDefault().getSharedImage(ISharedImages.IMG_OBJS_INFO_TSK));
- this.lblMessage.setText(RestClientI18n.newItemDialogValueExists.text());
- break;
- }
- }
- }
-
- // set enabled state if different than current state
- if (getButton(OK).getEnabled() != enable) {
- getButton(OK).setEnabled(enable);
- }
- }
-
- /**
- * A list of values that are not allowed as an input.
- *
- * @param disallowedValues the list of values which are not allowed (can be <code>null</code> or empty)
- */
- public void setDisallowedValues( String[] disallowedValues ) {
- if ((disallowedValues == null) || (disallowedValues.length == 0)) {
- this.disallowedValues = null;
- } else {
- this.disallowedValues = disallowedValues;
- }
- }
-
- }
-}
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,15 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+/**
+ * The ModeShape REST Client Eclipse preferences package is responsible for managing preferences.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
\ No newline at end of file
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties 2011-04-15 15:57:31 UTC (rev 30589)
@@ -10,14 +10,10 @@
# individual contributors.
#
-# This properties file is read in by PreferenceInitializer and contains preference default values. The delimiter values are used
-# when the preference values are stored and the valid character values are used by the field editors when they validate user input.
+# This properties file is read in by PreferenceInitializer and contains preference default values.
-fileExtension.delimiter = ,
-fileExtension.invalidChars = *?<>|/\:;.
-
-folderName.delimiter = ,
-folderName.invalidChars = *?<>|/\:;
-
# indicates if ModeShape server should version resources
-enableVersioning = false
\ No newline at end of file
+modeShape.preference.enableResourceVersioning = true
+
+# default ignored resources patterns
+modeShape.preference.ignoredResources = .svn\ntrue\n.project\ntrue\n
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -13,6 +13,7 @@
import static org.jboss.tools.modeshape.rest.IUiConstants.HelpContexts.PUBLISH_DIALOG_HELP_CONTEXT;
import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.ENABLE_RESOURCE_VERSIONING;
+import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.IGNORED_RESOURCES_PREFERENCE;
import static org.jboss.tools.modeshape.rest.IUiConstants.Preferences.MAIN_PREFERENCE_PAGE_ID;
import java.util.ArrayList;
@@ -56,6 +57,7 @@
import org.jboss.tools.modeshape.rest.WorkspaceArea;
import org.jboss.tools.modeshape.rest.actions.NewServerAction;
import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
+import org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesModel;
import org.jboss.tools.modeshape.rest.preferences.PublishingFileFilter;
import org.modeshape.common.util.CheckArg;
import org.modeshape.web.jcr.rest.client.Status;
@@ -101,12 +103,11 @@
PublishingFileFilter filter ) throws CoreException {
List<IFile> result = new ArrayList<IFile>();
- if (((container instanceof IProject) && !((IProject) container).isOpen())
- || ((filter != null) && !filter.accept(container))) {
- return result;
- }
+ if (((container instanceof IProject) && !((IProject)container).isOpen()) || ((filter != null) && !filter.accept(container))) {
+ return result;
+ }
- // process container members
+ // process container members
for (IResource member : container.members()) {
if (recurse && (member instanceof IContainer)) {
// don't select closed projects
@@ -376,8 +377,10 @@
this.type = type;
this.resources = resources;
- // filter should not be cached as preferences may change
- this.filter = (filterFiles ? new PublishingFileFilter() : null);
+ // load filter with current preference value
+ IgnoredResourcesModel model = new IgnoredResourcesModel();
+ model.load(Activator.getDefault().getPreferenceStore().getString(IGNORED_RESOURCES_PREFERENCE));
+ this.filter = (filterFiles ? new PublishingFileFilter(model) : null);
}
private void constructLocationPanel( Composite parent ) {
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class IgnoredResourcesModelTest {
+
+ private final static int NUM_PATTERNS = 10;
+
+ private final static ResourcePattern[] ENABLED_PATTERNS = new ResourcePattern[NUM_PATTERNS];
+
+ private final static ResourcePattern[] DISABLED_PATTERNS = new ResourcePattern[NUM_PATTERNS];
+
+ static {
+ for (int i = 0; i < NUM_PATTERNS; ++i) {
+ ENABLED_PATTERNS[i] = new ResourcePattern(i + "*.class", true); //$NON-NLS-1$
+ DISABLED_PATTERNS[i] = new ResourcePattern(i + "*.class", false); //$NON-NLS-1$
+ }
+ }
+
+ private IgnoredResourcesModel model;
+
+ @Before
+ public void beforeEach() {
+ this.model = new IgnoredResourcesModel();
+ }
+
+ @Test
+ public void shouldClearPatternsWhenLoading() {
+ this.model.load(IgnoredResourcesModel.createList(DISABLED_PATTERNS));
+ this.model.load(IgnoredResourcesModel.createList(ENABLED_PATTERNS));
+ assertThat(this.model.getPatterns().size(), is(NUM_PATTERNS));
+ }
+
+ @Test
+ public void shouldHaveNoPatternsAfterConstruction() {
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldLoadEmptyString() {
+ this.model.load(""); //$NON-NLS-1$
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldLoadNullString() {
+ this.model.load(null);
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldNotLoadSamePatternTwice() {
+ this.model.load(IgnoredResourcesModel.createList(DISABLED_PATTERNS[0]));
+ this.model.load(IgnoredResourcesModel.createList(DISABLED_PATTERNS[0]));
+ assertThat(this.model.getPatterns().size(), is(1));
+
+ this.model.load(IgnoredResourcesModel.createList(ENABLED_PATTERNS[0]));
+ assertThat(this.model.getPatterns().size(), is(1));
+ }
+
+ @Test
+ public void shouldAddNewPattern() {
+ final ResourcePattern rp = DISABLED_PATTERNS[0];
+ this.model.addPattern(rp);
+ assertThat(this.model.getPatterns().size(), is(1));
+ assertThat(this.model.getPatterns().iterator().next(), sameInstance(rp));
+ }
+
+ @Test
+ public void shouldRemovePattern() {
+ final ResourcePattern rp = DISABLED_PATTERNS[0];
+ this.model.addPattern(rp);
+ this.model.removePattern(rp);
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldAllowRemoveOfPatternNotInModel() {
+ this.model.removePattern(DISABLED_PATTERNS[0]);
+ }
+
+}
Property changes on: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class PublishingFileFilterTest {
+
+ private static final String PARTS_PROJECT = "PartsProject"; //$NON-NLS-1$
+
+ @Test
+ public void shouldMatchPartsProject() {
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "PartsProject"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Parts*"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "*Parts*"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "?arts*"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Part?*"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Part?*t"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "*Project"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "P*r*s*r*j*c*"), is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "?a?t?P?o?e?t"), is(true)); //$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldNotMatchPartsProject() {
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, " PartsProject"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "PartsProject "), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "PartsProject2"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "artsProject2"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Parts?"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "*artsP*2"), is(false)); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class ResourcePatternTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldNotAllowNullPattern() {
+ new ResourcePattern(null, true);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldNotAllowEmptyPattern() {
+ new ResourcePattern("", true); //$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldBeEqualWhenPatternsAreEqual() {
+ final String pattern = "mypattern"; //$NON-NLS-1$
+ ResourcePattern rp1 = new ResourcePattern(pattern, true);
+ ResourcePattern rp2 = new ResourcePattern(pattern, false);
+ assertThat(rp1.equals(rp2), is(true));
+ }
+
+ @Test
+ public void shouldNotBeEqualWhenComparingWithNull() {
+ ResourcePattern rp = new ResourcePattern("mypattern", true); //$NON-NLS-1$
+ assertThat(rp.equals(null), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualWhenPatternsAreNotEqual() {
+ ResourcePattern rp1 = new ResourcePattern("mypattern", true); //$NON-NLS-1$
+ ResourcePattern rp2 = new ResourcePattern(rp1.getPattern() + "abc", rp1.isEnabled()); //$NON-NLS-1$
+ assertThat(rp1.equals(rp2), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualWhenComparingWithDifferentClass() {
+ final String pattern = "mypattern"; //$NON-NLS-1$
+ ResourcePattern rp = new ResourcePattern(pattern, true);
+ assertThat(rp.equals(pattern), is(false));
+ }
+
+ @Test
+ public void shouldSetPatternCorrectly() {
+ final String pattern = "mypattern"; //$NON-NLS-1$
+ ResourcePattern rp = new ResourcePattern(pattern, true);
+ assertThat(rp.getPattern(), is(pattern));
+ }
+
+ @Test
+ public void shouldSetEnabledStateCorrectlyAtConstruction() {
+ boolean enabled = true;
+ ResourcePattern rp = new ResourcePattern("mypattern", enabled); //$NON-NLS-1$
+ assertThat(rp.isEnabled(), is(enabled));
+
+ enabled = !enabled;
+ rp = new ResourcePattern("mypattern", enabled); //$NON-NLS-1$
+ assertThat(rp.isEnabled(), is(enabled));
+ }
+
+ @Test
+ public void shouldSetEnabledStateCorrectly() {
+ boolean enabled = true;
+ ResourcePattern rp = new ResourcePattern("mypattern", enabled); //$NON-NLS-1$
+ rp.setEnabled(!enabled);
+ assertThat(rp.isEnabled(), is(!enabled));
+
+ rp = new ResourcePattern("mypattern", !enabled); //$NON-NLS-1$
+ rp.setEnabled(enabled);
+ assertThat(rp.isEnabled(), is(enabled));
+ }
+
+}
Property changes on: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java 2011-04-15 15:47:09 UTC (rev 30588)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java 2011-04-15 15:57:31 UTC (rev 30589)
@@ -3,11 +3,15 @@
import org.jboss.tools.modeshape.rest.PersistedServerTest;
import org.jboss.tools.modeshape.rest.ServerManagerTest;
import org.jboss.tools.modeshape.rest.ServerRegistryEventTest;
+import org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesModelTest;
+import org.jboss.tools.modeshape.rest.preferences.PublishingFileFilterTest;
+import org.jboss.tools.modeshape.rest.preferences.ResourcePatternTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
-@RunWith( Suite.class )
-(a)Suite.SuiteClasses( {PersistedServerTest.class, ServerManagerTest.class, ServerRegistryEventTest.class} )
+(a)RunWith(Suite.class)
+(a)Suite.SuiteClasses({ IgnoredResourcesModelTest.class, PersistedServerTest.class, PublishingFileFilterTest.class,
+ ResourcePatternTest.class, ServerManagerTest.class, ServerRegistryEventTest.class })
public class AllTests {
// nothing to do
}
13 years, 7 months
JBoss Tools SVN: r30587 - trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2011-04-15 11:35:03 -0400 (Fri, 15 Apr 2011)
New Revision: 30587
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java
Log:
JBIDE-8733 Problems With EclipseLogger When Running JUnit Tests. Logger now checking to see if platform is running before calling a method that requires a running Eclipse.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java 2011-04-15 15:32:27 UTC (rev 30586)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java 2011-04-15 15:35:03 UTC (rev 30587)
@@ -26,15 +26,26 @@
*/
public final class EclipseLogger implements Logger {
- private static boolean DEBUG_MODE = Platform.inDebugMode()
- && Boolean.parseBoolean(Platform.getDebugOption(IUiConstants.PLUGIN_ID + "/debug")); //$NON-NLS-1$
+ private static boolean initialized = false;
- private static ILog LOGGER = Platform.getLog(Platform.getBundle(IUiConstants.PLUGIN_ID));
+ private static boolean DEBUG_MODE = Platform.isRunning();
+ private static ILog LOGGER; // will be null when platform is not running
+
private String name;
EclipseLogger( String name ) {
this.name = name;
+
+ if (!initialized) {
+ initialized = true;
+
+ if (Platform.isRunning()) {
+ DEBUG_MODE = Platform.inDebugMode()
+ && Boolean.parseBoolean(Platform.getDebugOption(IUiConstants.PLUGIN_ID + "/debug")); //$NON-NLS-1$
+ LOGGER = Platform.getLog(Platform.getBundle(IUiConstants.PLUGIN_ID));
+ }
+ }
}
/**
@@ -194,7 +205,7 @@
@Override
public void error( String message,
Throwable e ) {
- if (isErrorEnabled()) {
+ if (isErrorEnabled() && (LOGGER != null)) {
LOGGER.log(new Status(IStatus.ERROR, IUiConstants.PLUGIN_ID, message, e));
}
}
@@ -321,7 +332,7 @@
@Override
public void info( String message,
Throwable e ) {
- if (isInfoEnabled()) {
+ if (isInfoEnabled() && (LOGGER != null)) {
LOGGER.log(new Status(IStatus.INFO, IUiConstants.PLUGIN_ID, message, e));
}
}
@@ -655,7 +666,7 @@
@Override
public void warn( String message,
Throwable e ) {
- if (isWarnEnabled()) {
+ if (isWarnEnabled() && (LOGGER != null)) {
LOGGER.log(new Status(IStatus.WARNING, IUiConstants.PLUGIN_ID, message, e));
}
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java 2011-04-15 15:32:27 UTC (rev 30586)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java 2011-04-15 15:35:03 UTC (rev 30587)
@@ -13,33 +13,22 @@
import java.util.HashMap;
import java.util.Map;
+
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
public final class EclipseLoggerFactory implements ILoggerFactory {
- // ===========================================================================================================================
- // Class Fields
- // ===========================================================================================================================
-
/**
* The shared instance of the factory.
*/
static final EclipseLoggerFactory INSTANCE = new EclipseLoggerFactory();
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
/**
* Map of loggers keyed by logger name.
*/
private Map<String, Logger> loggerMap;
- // ===========================================================================================================================
- // Constructors
- // ===========================================================================================================================
-
/**
* Constructs the factory.
*/
@@ -47,10 +36,6 @@
this.loggerMap = new HashMap<String, Logger>();
}
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
/**
* {@inheritDoc}
*
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java 2011-04-15 15:35:03 UTC (rev 30587)
@@ -0,0 +1,15 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+/**
+ * The ModeShape REST Client Eclipse log package maps SLF4J logging from the ModeShape library to the Ecipse log.
+ */
+package org.jboss.tools.modeshape.rest.log;
\ No newline at end of file
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 7 months
JBoss Tools SVN: r30586 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-15 11:32:27 -0400 (Fri, 15 Apr 2011)
New Revision: 30586
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java
Log:
replaced future with DeploymentResult
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-15 10:01:21 UTC (rev 30585)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-15 15:32:27 UTC (rev 30586)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="jboss-threads-2.0.0.CR8.jar" sourcepath="/home/adietish/jboss-workspaces/jboss-tools/jbosstools-src/jboss-threads-2.0.0.CR8-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/home/rob/.m2/repository/org/jboss/as/jboss-as-controller-client/7.0.0.Beta3-SNAPSHOT/jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT-sources.jar"/>
+ <classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/jboss-as-controller-client"/>
<classpathentry exported="true" kind="lib" path="jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/jboss-as-protocol"/>
<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Beta5.jar" sourcepath="/home/adietish/jboss-workspaces/jboss-tools/jbosstools-src/jboss-dmr-1.0.0.Beta5-sources.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-logging-3.0.0.Beta3.jar"/>
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java 2011-04-15 10:01:21 UTC (rev 30585)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java 2011-04-15 15:32:27 UTC (rev 30586)
@@ -22,14 +22,21 @@
package org.jboss.ide.eclipse.as7.internal.deployment;
import java.io.File;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
-import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
import org.jboss.as.protocol.StreamUtils;
/**
@@ -38,83 +45,68 @@
*/
public class TypedDeployer {
- public static void undeploySync(String name, String host, int port, IProgressMonitor monitor) throws DeployerException {
- Future f = undeploy(name, host, port);
- syncWait(f, monitor);
- }
-
- public static void syncDeploy(String name, File file, String host, int port, IProgressMonitor monitor) throws DeployerException {
- Future f = deploy(name, file, host, port);
- syncWait(f, monitor);
+ private ModelControllerClient client;
+ private ServerDeploymentManager manager;
+
+ public TypedDeployer(String host, int port) throws UnknownHostException {
+ this.client = ModelControllerClient.Factory.create(host, port);
+ this.manager = ServerDeploymentManager.Factory.create(client);
}
-
- private static void syncWait(Future f, IProgressMonitor monitor) {
- while(!f.isDone()) {
- if( monitor.isCanceled()) {
- f.cancel(true);
- return;
- }
- try {
- Thread.sleep(150);
- } catch(InterruptedException ie) {
- }
- }
+
+ public void undeploySync(String name, IProgressMonitor monitor) throws DeployerException {
+ DeploymentResult result = undeploy(name);
+ result.getStatus();
}
-
- public static Future undeploy(String name, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
+
+ public void syncDeploy(String name, File file, IProgressMonitor monitor) throws DeployerException {
+ DeploymentResult result = deploy(name, file);
+ result.getStatus();
+ }
+
+ public DeploymentResult undeploy(String name) throws DeployerException {
try {
- client = ModelControllerClient.Factory.create(host, port);
- ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
- InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
-
- DeploymentPlan plan = builder.undeploy(name).andRemoveUndeployed().build();
- return manager.execute(plan);
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ builder = builder.undeploy(name).andRemoveUndeployed();
+ return new DeploymentResult(builder.getLastAction(), manager.execute(builder.build()));
} catch (Exception e) {
throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
}
}
- public static Future deploy(File file, String host, int port) throws DeployerException {
- return deploy(file.getName(), file, host, port);
+ public DeploymentResult deploy(File file) throws DeployerException {
+ return deploy(file.getName(), file);
}
- public static Future deploy(String name, File file, String host, int port) throws DeployerException {
- return internalDeploy(name, file, host, port, false);
+ public DeploymentResult deploy(String name, File file) throws DeployerException {
+ try {
+ return execute(manager.newDeploymentPlan().add(name, file).andDeploy());
+ } catch (IOException e) {
+ throw new DeployerException(e);
+ }
}
- public static Future replace(File file, String host, int port) throws DeployerException {
- return replace(file.getName(), file, host, port);
+ public DeploymentResult replace(File file) throws DeployerException {
+ return replace(file.getName(), file);
}
- public static Future replace(String name, File file, String host, int port) throws DeployerException {
- return internalDeploy(name, file, host, port, true);
+ public DeploymentResult replace(String name, File file) throws DeployerException {
+ try {
+ return execute(manager.newDeploymentPlan().replace(name, file));
+ } catch (IOException e) {
+ throw new DeployerException(e);
+ }
}
- public static Future internalDeploy(String name, File file, String host, int port, boolean replace) throws DeployerException {
- ModelControllerClient client = null;
+ private DeploymentResult execute(DeploymentPlanBuilder builder) throws DeployerException {
try {
- client = ModelControllerClient.Factory.create(host, port);
- ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
- InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
-
- DeploymentPlan plan = null;
- if( replace )
- plan = builder.replace(name, file).build();
- else
- plan = builder.add(name, file).deploy(name).build();
-
- return manager.execute(plan);
+ DeploymentAction action = builder.getLastAction();
+ Future<ServerDeploymentPlanResult> planResult = manager.execute(builder.build());
+ return new DeploymentResult(action, planResult);
} catch (Exception e) {
throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
}
}
-
-
+
//
// public static boolean isDeployed(String name, String host, int port)
// throws CancellationException, IOException {
@@ -141,8 +133,67 @@
// }
// }
- private TypedDeployer() {
- // inhibit instantiation
+ public void dispose() {
+ StreamUtils.safeClose(client);
}
+ public static class DeploymentResult {
+
+ private Future<ServerDeploymentPlanResult> planResult;
+ private DeploymentAction action;
+
+ public DeploymentResult(DeploymentAction action, Future<ServerDeploymentPlanResult> planResult) {
+ Assert.isNotNull(action);
+ this.action = action;
+ Assert.isNotNull(planResult);
+ this.planResult = planResult;
+ }
+
+ public IStatus getStatus() throws DeployerException {
+ try {
+ ServerDeploymentActionResult actionResult = planResult.get().getDeploymentActionResult(action.getId());
+ return createStatus(action.getDeploymentUnitUniqueName(), action.getType().name(), actionResult);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ private IStatus createStatus(String deploymentName, String actionName, ServerDeploymentActionResult actionResult) {
+ if (actionResult == null) {
+ return null;
+ }
+
+ IStatus status = null;
+ switch (actionResult.getResult()) {
+ case NOT_EXECUTED:
+ status = createStatus(IStatus.ERROR, "The operation {0} was not executed on unit {1}",
+ actionName, deploymentName);
+ break;
+ case EXECUTED:
+ status = Status.OK_STATUS;
+ break;
+ case FAILED:
+ status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}",
+ actionName, deploymentName);
+ break;
+ case ROLLED_BACK:
+ status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back",
+ actionName, deploymentName);
+ break;
+ case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
+ status = createStatus(
+ IStatus.WARNING,
+ "The operation {0} was not executed on unit {1}. The server configuration was changed though and the server needs to be restarted",
+ actionName, deploymentName);
+ break;
+ }
+ return status;
+ }
+
+ private IStatus createStatus(int severity, String messagePattern, Object... messageArguments) {
+ return new Status(severity, Activator.getContext().getBundle().getSymbolicName(), MessageFormat.format(
+ messagePattern, messageArguments));
+ }
+ }
+
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-15 10:01:21 UTC (rev 30585)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-15 15:32:27 UTC (rev 30586)
@@ -24,9 +24,14 @@
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.net.UnknownHostException;
+import java.util.concurrent.ExecutionException;
import org.jboss.ide.eclipse.as7.internal.deployment.DeployerException;
import org.jboss.ide.eclipse.as7.internal.deployment.TypedDeployer;
+import org.jboss.ide.eclipse.as7.internal.deployment.TypedDeployer.DeploymentResult;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -35,12 +40,24 @@
*/
public class TypedDeployerIntegrationTest {
+ private TypedDeployer deployer;
+
+ @Before
+ public void setUp() throws UnknownHostException {
+ this.deployer = new TypedDeployer(DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
+ }
+
+ @After
+ public void tearDown() {
+ deployer.dispose();
+ }
+
@Test
public void canDeploy() throws Exception {
File warFile = DeployerTestUtils.getWarFile(DeployerTestUtils.MINIMALISTIC_WAR);
try {
- TypedDeployer.deploy(warFile, DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
-
+ waitUntilFinished(deployer.deploy(warFile));
+
String response = DeployerTestUtils.getWebappResponse(
"minimalistic", DeployerTestUtils.HOST, DeployerTestUtils.WEB_PORT);
assertTrue(response.indexOf("minimalistic") >= 0);
@@ -54,26 +71,26 @@
public void cannotDeployWarTwice() throws Exception {
File warFile = DeployerTestUtils.getWarFile(DeployerTestUtils.MINIMALISTIC_WAR);
try {
- TypedDeployer.deploy(warFile, DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
- TypedDeployer.deploy(warFile, DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
+ waitUntilFinished(deployer.deploy(warFile));
+ waitUntilFinished(deployer.deploy(warFile));
} finally {
quietlyUndeploy(warFile);
}
}
@Test(expected = DeployerException.class)
- public void cannotUndeployNondeployed() throws DeployerException {
- TypedDeployer.undeploy("inexistant", DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
+ public void cannotUndeployNondeployed() throws DeployerException, InterruptedException, ExecutionException {
+ waitUntilFinished(deployer.undeploy("inexistant"));
}
@Test
- public void canReplaceyWar() throws Exception {
+ public void canReplaceWar() throws Exception {
File warFile = DeployerTestUtils.getWarFile(DeployerTestUtils.MINIMALISTIC_WAR);
File warFile2 = DeployerTestUtils.getWarFile(DeployerTestUtils.GWT_HELLOWORLD_WAR);
String name = warFile.getName();
try {
- TypedDeployer.deploy(name, warFile, DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
- TypedDeployer.replace(name, warFile2, DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
+ waitUntilFinished(deployer.deploy(name, warFile));
+ waitUntilFinished(deployer.replace(name, warFile2));
String response = DeployerTestUtils.getWebappResponse(
"minimalistic", DeployerTestUtils.HOST, DeployerTestUtils.WEB_PORT);
assertTrue(response.indexOf("GWT") >= 0);
@@ -126,12 +143,17 @@
// return writer.toString();
// }
//
+
private void quietlyUndeploy(File file) {
try {
- TypedDeployer.undeploy(file.getName(), DeployerTestUtils.HOST, DeployerTestUtils.MGMT_PORT);
+ waitUntilFinished(deployer.undeploy(file.getName()));
} catch (Exception e) {
e.printStackTrace();
// ignore
}
}
+
+ private void waitUntilFinished(DeploymentResult result) throws DeployerException {
+ result.getStatus(); // wait for operation to finish
+ }
}
13 years, 7 months
JBoss Tools SVN: r30585 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7 and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-15 06:01:21 -0400 (Fri, 15 Apr 2011)
New Revision: 30585
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Activator.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Deployable.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeployerException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DetypedDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossManagementService.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JbossManagementUtil.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/CommandFormatException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/CommandLineException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/DefaultOperationRequestAddress.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/DefaultOperationRequestBuilder.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationFormatException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationRequestAddress.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationRequestBuilder.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/ValidatingOperationCallbackHandler.java
Log:
corrected internal package name
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF 2011-04-15 10:01:21 UTC (rev 30585)
@@ -3,7 +3,7 @@
Bundle-Name: Deployment
Bundle-SymbolicName: org.jboss.ide.eclipse.as7.deployment
Bundle-Version: 0.0.1.qualifier
-Bundle-Activator: org.jboss.ide.eclipse.as7.deployment.internal.Activator
+Bundle-Activator: org.jboss.ide.eclipse.as7.internal.deployment.Activator
Require-Bundle: org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
@@ -24,7 +24,7 @@
org.jboss.as.protocol.mgmt,
org.jboss.dmr,
org.jboss.ide.eclipse.as7.deployment,
- org.jboss.ide.eclipse.as7.deployment.internal,
+ org.jboss.ide.eclipse.as7.internal.deployment,
org.jboss.logging,
org.jboss.marshalling,
org.jboss.marshalling.cloner,
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,30 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- private static BundleContext context;
-
- public static BundleContext getContext() {
- return context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext bundleContext) throws Exception {
- Activator.context = null;
- }
-
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,94 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
-
-public class Deployable {
-
- private String name;
- private File file;
- private Future<ServerDeploymentPlanResult> resultFuture;
- private long timeout;
- private DeploymentAction action;
-
- protected Deployable(String name, File file, long timeout) {
- this.name = name;
- this.file = file;
- this.timeout = timeout;
- }
-
- protected void setDeploymentAction(DeploymentAction action) {
- this.action = action;
- }
-
- protected void setResultFuture(Future<ServerDeploymentPlanResult> resultFuture) {
- this.resultFuture = resultFuture;
- }
-
- public File getFile() {
- return file;
- }
-
- public String getName() {
- return name;
- }
-
- public IStatus getStatus() throws DeployerException {
- if (resultFuture == null
- || action == null) {
- return null;
- }
- try {
- ServerDeploymentPlanResult result = resultFuture.get(timeout, TimeUnit.MILLISECONDS);
- ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(action.getId());
- return createStatus(action, actionResult);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- private IStatus createStatus(DeploymentAction action, ServerDeploymentActionResult actionResult) {
- if (actionResult == null) {
- return null;
- }
-
- IStatus status = null;
- switch (actionResult.getResult()) {
- case NOT_EXECUTED:
- status = createStatus(IStatus.ERROR, "The operation {0} was not executed on unit {1}", action
- .getType().name(), getName());
- break;
- case EXECUTED:
- status = Status.OK_STATUS;
- break;
- case FAILED:
- status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}", action.getType()
- .name(), getName());
- break;
- case ROLLED_BACK:
- status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back", action
- .getType().name(), getName());
- break;
- case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
- status = createStatus(
- IStatus.WARNING,
- "The operation {0} was not executed on unit {1}. The server configuration was changed though and the server needs to be restarted",
- action.getType().name(), getName());
- break;
- }
- return status;
- }
-
- private IStatus createStatus(int severity, String messagePattern, Object... messageArguments) {
- return new Status(severity, Activator.getContext().getBundle().getSymbolicName(), MessageFormat.format(
- messagePattern, messageArguments));
- }
-}
\ No newline at end of file
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * 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:
- * Red Hat Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-/**
- * @author André Dietisheim
- */
-public class DeployerException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DeployerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DeployerException(Throwable cause) {
- super(cause);
- }
-
- public DeployerException(String message) {
- super(message);
- }
-
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import static org.jboss.as.protocol.StreamUtils.safeClose;
-
-import java.io.File;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-
-/**
- * Used to deploy/undeploy deployments to a running <b>standalone</b>
- * application server
- *
- * @author <a href="adietish(a)redhat.com">André Dietisheim</a>
- */
-public class DeploymentManager {
-
- public static final long DEFAULT_TIMEOUT = 15000;
-
- private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
- private final ModelControllerClient client;
- private final ServerDeploymentManager manager;
- private long timeout = DEFAULT_TIMEOUT;
-
- public DeploymentManager(String host, int port) throws UnknownHostException {
- client = ModelControllerClient.Factory.create(host, port);
- manager = ServerDeploymentManager.Factory.create(client);
- }
-
- public synchronized DeploymentManager deploy(File file) {
- deployments.add(new DeployOperation(file));
- return this;
- }
-
- public synchronized DeploymentManager deploy(String name, File file) {
- deployments.add(new DeployOperation(name, file));
- return this;
- }
-
- public synchronized DeploymentManager undeploy(String name) {
- deployments.add(new UndeployOperation(name));
- return this;
- }
-
- public synchronized DeploymentManager undeploy(File file) {
- deployments.add(new UndeployOperation(file));
- return this;
- }
-
- public synchronized void execute() throws DeployerException {
- try {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- for (IDeploymentPlanBuilderOperation deployment : deployments) {
- builder = deployment.addTo(builder);
- }
- manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- public void setTimeout(long timeout) {
- this.timeout = timeout;
- }
-
- public void dispose() {
- safeClose(client);
- }
-
- private static class DeployOperation extends FileOperation {
-
- private DeployOperation(File file) {
- super(file);
- }
-
- private DeployOperation(String name, File file) {
- super(name, file);
- }
-
- public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
- String name = getName();
- return builder.add(name, getFile()).deploy(name);
- }
- }
-
- private static class UndeployOperation extends FileOperation {
-
- private UndeployOperation(File file) {
- super(file);
- }
-
- private UndeployOperation(String name) {
- super(name, null);
- }
-
- public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
- String name = getName();
- return builder.undeploy(name).undeploy(name);
- }
- }
-
- private abstract static class FileOperation extends NamedOperation {
-
- private File file;
-
- private FileOperation(File file) {
- this(null, file);
- }
-
- private FileOperation(String name, File file) {
- super(name);
- this.file = file;
- }
-
- protected File getFile() {
- return file;
- }
-
- protected String getName() {
- if (name != null) {
- return name;
- } else {
- return file.getName();
- }
- }
-
- }
-
- private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
-
- protected String name;
-
- private NamedOperation(String name) {
- this.name = name;
- }
- }
-
- private interface IDeploymentPlanBuilderOperation {
-
- public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
-
- }
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,143 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.List;
-import java.util.concurrent.CancellationException;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.Operation;
-import org.jboss.as.controller.client.OperationBuilder;
-import org.jboss.as.protocol.StreamUtils;
-import org.jboss.dmr.ModelNode;
-
-/**
- * @author André Dietisheim
- */
-public class DetypedDeployer {
-
- public static void undeploy(String name, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
- // undeploy
- ModelNode request = new ModelNode();
- request.get("operation").set("undeploy");
- request.get("address").add("deployment", name);
- ModelNode result = client.execute(request);
- throwOnFailure(result);
-
- // remove
- request = new ModelNode();
- request.get("operation").set("remove");
- request.get("address").add("deployment", name);
- result = client.execute(request);
- } catch (Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- public static void deploy(File file, String host, int port) throws DeployerException {
- deploy(file.getName(), file, host, port);
- }
-
- public static void deploy(String name, File file, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
-
- ModelNode request = new ModelNode();
- request.get("operation").set("add");
- request.get("address").add("deployment", name);
- request.get("enabled").set(true);
-
- OperationBuilder builder = OperationBuilder.Factory.create(request);
- builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
- Operation operation = builder.build();
- request.get("input-stream-index").set(0);
-
- ModelNode result = client.execute(operation);
- System.out.println(result);
-
- throwOnFailure(result);
- } catch (Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- public static void replace(String name, File file, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
-
- ModelNode request = new ModelNode();
- request.get("operation").set("full-replace-deployment");
- request.get("name").set(name);
-
- OperationBuilder builder = OperationBuilder.Factory.create(request);
- builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
- Operation operation = builder.build();
- request.get("input-stream-index").set(0);
-
- ModelNode result = client.execute(operation);
-
- throwOnFailure(result);
- } catch (Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
- try {
- return JbossManagementUtil.isDeployed(name, client);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- public static List<String> getDeployments(String host, int port) throws UnknownHostException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
- return JbossManagementUtil.getDeployments(client);
- }
-
- private static void throwOnFailure(ModelNode result) throws DeployerException {
- if (!JbossManagementUtil.isSuccess(result)) {
- throw new DeployerException(JbossManagementUtil.getFailureDescription(result));
- }
- }
-
- private DetypedDeployer() {
- // inhibit instantiation
- }
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,35 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import java.io.File;
-import java.util.concurrent.Future;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
-
-public class JBossDeploymentManager implements IJBossDeploymentManager {
-
- public Future asyncDeploy(String host, int port, String deploymentName,
- File file, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object syncDeploy(String host, int port, String deploymentName,
- File file, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Future asyncUndeploy(String host, int port, String deploymentName,
- boolean removeFile, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object syncUndeploy(String host, int port, String deploymentName,
- boolean removeFile, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,25 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
-import org.jboss.ide.eclipse.as7.deployment.IJBossManagementInterface;
-import org.jboss.ide.eclipse.as7.deployment.IJBossManagementService;
-
-public class JBossManagementService implements IJBossManagementService {
-
- private IJBossDeploymentManager deploymentManager = null;
- private IJBossManagementInterface manager = null;
-
- @Override
- public IJBossDeploymentManager getDeploymentManager() {
- if( deploymentManager == null )
- deploymentManager = new JBossDeploymentManager();
- return deploymentManager;
- }
-
- @Override
- public IJBossManagementInterface getManagementInterface() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.Property;
-import org.jboss.ide.eclipse.as7.deployment.internal.operations.DefaultOperationRequestBuilder;
-import org.jboss.ide.eclipse.as7.deployment.internal.operations.OperationFormatException;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class JbossManagementUtil {
-
- public static boolean isSuccess(ModelNode operationResult) {
- if(operationResult != null) {
- ModelNode outcome = operationResult.get("outcome");
- return outcome != null && outcome.asString().equals("success");
- }
- return false;
- }
-
- public static String getFailureDescription(ModelNode operationResult) {
- if(operationResult == null) {
- return null;
- }
-
- ModelNode descr = operationResult.get("failure-description");
- if(descr == null) {
- return null;
- }
-
- return descr.asString();
- }
-
- public static List<String> getList(ModelNode operationResult) {
- if(!operationResult.hasDefined("result"))
- return Collections.emptyList();
-
- List<ModelNode> nodeList = operationResult.get("result").asList();
- if(nodeList.isEmpty())
- return Collections.emptyList();
-
- List<String> list = new ArrayList<String>(nodeList.size());
- for(ModelNode node : nodeList) {
- list.add(node.asString());
- }
- return list;
- }
-
- public static byte[] getHash(ModelNode operationResult) {
- if(!operationResult.hasDefined("result"))
- return null;
- return operationResult.get("result").asBytes();
- }
-
- public static List<String> getRequestPropertyNames(ModelNode operationResult) {
- if(!operationResult.hasDefined("result"))
- return Collections.emptyList();
-
- ModelNode result = operationResult.get("result");
- if(!result.hasDefined("request-properties"))
- return Collections.emptyList();
-
- List<Property> nodeList = result.get("request-properties").asPropertyList();
- if(nodeList.isEmpty())
- return Collections.emptyList();
-
- List<String> list = new ArrayList<String>(nodeList.size());
- for(Property node : nodeList) {
- list.add(node.getName());
- }
- return list;
- }
-
- public static boolean isDeployed(String name, ModelControllerClient client) {
- return getDeployments(client).contains(name);
- }
-
- public static List<String> getDeployments(ModelControllerClient client) {
-
- DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
- final ModelNode request;
- try {
- builder.operationName("read-children-names");
- builder.addProperty("child-type", "deployment");
- request = builder.buildRequest();
- } catch (OperationFormatException e) {
- throw new IllegalStateException("Failed to build operation", e);
- }
-
- try {
- ModelNode outcome = client.execute(request);
- if (isSuccess(outcome)) {
- return getList(outcome);
- }
- } catch (Exception e) {
- }
-
- return Collections.emptyList();
- }
-
- public static List<String> getJmsResources(ModelControllerClient client, String type) {
-
- DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
- final ModelNode request;
- try {
- builder.addNode("subsystem", "jms");
- builder.operationName("read-children-names");
- builder.addProperty("child-type", type);
- request = builder.buildRequest();
- } catch (OperationFormatException e) {
- throw new IllegalStateException("Failed to build operation", e);
- }
-
- try {
- ModelNode outcome = client.execute(request);
- if (isSuccess(outcome)) {
- return getList(outcome);
- }
- } catch (Exception e) {
- }
-
- return Collections.emptyList();
- }
-
- public static boolean isTopic(ModelControllerClient client, String name) {
- List<String> topics = getJmsResources(client, "topic");
- return topics.contains(name);
- }
-
- public static boolean isQueue(ModelControllerClient client, String name) {
- List<String> queues = getJmsResources(client, "queue");
- return queues.contains(name);
- }
-
- public static boolean isConnectionFactory(ModelControllerClient client, String name) {
- List<String> cf = getJmsResources(client, "connection-factory");
- return cf.contains(name);
- }
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -1,148 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as7.deployment.internal;
-
-import java.io.File;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
-import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-import org.jboss.as.protocol.StreamUtils;
-
-/**
- *
- * @author André Dietisheim
- */
-public class TypedDeployer {
-
- public static void undeploySync(String name, String host, int port, IProgressMonitor monitor) throws DeployerException {
- Future f = undeploy(name, host, port);
- syncWait(f, monitor);
- }
-
- public static void syncDeploy(String name, File file, String host, int port, IProgressMonitor monitor) throws DeployerException {
- Future f = deploy(name, file, host, port);
- syncWait(f, monitor);
- }
-
- private static void syncWait(Future f, IProgressMonitor monitor) {
- while(!f.isDone()) {
- if( monitor.isCanceled()) {
- f.cancel(true);
- return;
- }
- try {
- Thread.sleep(150);
- } catch(InterruptedException ie) {
- }
- }
- }
-
- public static Future undeploy(String name, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
- ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
- InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
-
- DeploymentPlan plan = builder.undeploy(name).andRemoveUndeployed().build();
- return manager.execute(plan);
- } catch (Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- public static Future deploy(File file, String host, int port) throws DeployerException {
- return deploy(file.getName(), file, host, port);
- }
-
- public static Future deploy(String name, File file, String host, int port) throws DeployerException {
- return internalDeploy(name, file, host, port, false);
- }
-
- public static Future replace(File file, String host, int port) throws DeployerException {
- return replace(file.getName(), file, host, port);
- }
-
- public static Future replace(String name, File file, String host, int port) throws DeployerException {
- return internalDeploy(name, file, host, port, true);
- }
-
- public static Future internalDeploy(String name, File file, String host, int port, boolean replace) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
- ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
- InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
-
- DeploymentPlan plan = null;
- if( replace )
- plan = builder.replace(name, file).build();
- else
- plan = builder.add(name, file).deploy(name).build();
-
- return manager.execute(plan);
- } catch (Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
-
- //
- // public static boolean isDeployed(String name, String host, int port)
- // throws CancellationException, IOException {
- // ModelControllerClient client = ModelControllerClient.Factory.create(host,
- // port);
- // try {
- // return Util.isDeployed(name, client);
- // } finally {
- // StreamUtils.safeClose(client);
- // }
- // }
- //
- // public static List<String> getDeployments(String host, int port) throws
- // UnknownHostException {
- // ModelControllerClient client = ModelControllerClient.Factory.create(host,
- // port);
- // return Util.getDeployments(client);
- // }
- //
- // private static void throwOnFailure(ModelNode result) throws
- // DeployerException {
- // if (!Util.isSuccess(result)) {
- // throw new DeployerException(Util.getFailureDescription(result));
- // }
- // }
-
- private TypedDeployer() {
- // inhibit instantiation
- }
-
-}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Activator.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Activator.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Activator.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,30 @@
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ public static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Activator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Deployable.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Deployable.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Deployable.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,94 @@
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
+
+public class Deployable {
+
+ private String name;
+ private File file;
+ private Future<ServerDeploymentPlanResult> resultFuture;
+ private long timeout;
+ private DeploymentAction action;
+
+ protected Deployable(String name, File file, long timeout) {
+ this.name = name;
+ this.file = file;
+ this.timeout = timeout;
+ }
+
+ protected void setDeploymentAction(DeploymentAction action) {
+ this.action = action;
+ }
+
+ protected void setResultFuture(Future<ServerDeploymentPlanResult> resultFuture) {
+ this.resultFuture = resultFuture;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public IStatus getStatus() throws DeployerException {
+ if (resultFuture == null
+ || action == null) {
+ return null;
+ }
+ try {
+ ServerDeploymentPlanResult result = resultFuture.get(timeout, TimeUnit.MILLISECONDS);
+ ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(action.getId());
+ return createStatus(action, actionResult);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ private IStatus createStatus(DeploymentAction action, ServerDeploymentActionResult actionResult) {
+ if (actionResult == null) {
+ return null;
+ }
+
+ IStatus status = null;
+ switch (actionResult.getResult()) {
+ case NOT_EXECUTED:
+ status = createStatus(IStatus.ERROR, "The operation {0} was not executed on unit {1}", action
+ .getType().name(), getName());
+ break;
+ case EXECUTED:
+ status = Status.OK_STATUS;
+ break;
+ case FAILED:
+ status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}", action.getType()
+ .name(), getName());
+ break;
+ case ROLLED_BACK:
+ status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back", action
+ .getType().name(), getName());
+ break;
+ case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
+ status = createStatus(
+ IStatus.WARNING,
+ "The operation {0} was not executed on unit {1}. The server configuration was changed though and the server needs to be restarted",
+ action.getType().name(), getName());
+ break;
+ }
+ return status;
+ }
+
+ private IStatus createStatus(int severity, String messagePattern, Object... messageArguments) {
+ return new Status(severity, Activator.getContext().getBundle().getSymbolicName(), MessageFormat.format(
+ messagePattern, messageArguments));
+ }
+}
\ No newline at end of file
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/Deployable.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeployerException.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeployerException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeployerException.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * 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:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+/**
+ * @author André Dietisheim
+ */
+public class DeployerException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public DeployerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DeployerException(Throwable cause) {
+ super(cause);
+ }
+
+ public DeployerException(String message) {
+ super(message);
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeployerException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeploymentManager.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeploymentManager.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeploymentManager.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import static org.jboss.as.protocol.StreamUtils.safeClose;
+
+import java.io.File;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+
+/**
+ * Used to deploy/undeploy deployments to a running <b>standalone</b>
+ * application server
+ *
+ * @author <a href="adietish(a)redhat.com">André Dietisheim</a>
+ */
+public class DeploymentManager {
+
+ public static final long DEFAULT_TIMEOUT = 15000;
+
+ private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
+ private final ModelControllerClient client;
+ private final ServerDeploymentManager manager;
+ private long timeout = DEFAULT_TIMEOUT;
+
+ public DeploymentManager(String host, int port) throws UnknownHostException {
+ client = ModelControllerClient.Factory.create(host, port);
+ manager = ServerDeploymentManager.Factory.create(client);
+ }
+
+ public synchronized DeploymentManager deploy(File file) {
+ deployments.add(new DeployOperation(file));
+ return this;
+ }
+
+ public synchronized DeploymentManager deploy(String name, File file) {
+ deployments.add(new DeployOperation(name, file));
+ return this;
+ }
+
+ public synchronized DeploymentManager undeploy(String name) {
+ deployments.add(new UndeployOperation(name));
+ return this;
+ }
+
+ public synchronized DeploymentManager undeploy(File file) {
+ deployments.add(new UndeployOperation(file));
+ return this;
+ }
+
+ public synchronized void execute() throws DeployerException {
+ try {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ for (IDeploymentPlanBuilderOperation deployment : deployments) {
+ builder = deployment.addTo(builder);
+ }
+ manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public void dispose() {
+ safeClose(client);
+ }
+
+ private static class DeployOperation extends FileOperation {
+
+ private DeployOperation(File file) {
+ super(file);
+ }
+
+ private DeployOperation(String name, File file) {
+ super(name, file);
+ }
+
+ public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
+ String name = getName();
+ return builder.add(name, getFile()).deploy(name);
+ }
+ }
+
+ private static class UndeployOperation extends FileOperation {
+
+ private UndeployOperation(File file) {
+ super(file);
+ }
+
+ private UndeployOperation(String name) {
+ super(name, null);
+ }
+
+ public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
+ String name = getName();
+ return builder.undeploy(name).undeploy(name);
+ }
+ }
+
+ private abstract static class FileOperation extends NamedOperation {
+
+ private File file;
+
+ private FileOperation(File file) {
+ this(null, file);
+ }
+
+ private FileOperation(String name, File file) {
+ super(name);
+ this.file = file;
+ }
+
+ protected File getFile() {
+ return file;
+ }
+
+ protected String getName() {
+ if (name != null) {
+ return name;
+ } else {
+ return file.getName();
+ }
+ }
+
+ }
+
+ private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
+
+ protected String name;
+
+ private NamedOperation(String name) {
+ this.name = name;
+ }
+ }
+
+ private interface IDeploymentPlanBuilderOperation {
+
+ public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
+
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DeploymentManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DetypedDeployer.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DetypedDeployer.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/DetypedDeployer.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.concurrent.CancellationException;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.Operation;
+import org.jboss.as.controller.client.OperationBuilder;
+import org.jboss.as.protocol.StreamUtils;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * @author André Dietisheim
+ */
+public class DetypedDeployer {
+
+ public static void undeploy(String name, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ // undeploy
+ ModelNode request = new ModelNode();
+ request.get("operation").set("undeploy");
+ request.get("address").add("deployment", name);
+ ModelNode result = client.execute(request);
+ throwOnFailure(result);
+
+ // remove
+ request = new ModelNode();
+ request.get("operation").set("remove");
+ request.get("address").add("deployment", name);
+ result = client.execute(request);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static void deploy(File file, String host, int port) throws DeployerException {
+ deploy(file.getName(), file, host, port);
+ }
+
+ public static void deploy(String name, File file, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+
+ ModelNode request = new ModelNode();
+ request.get("operation").set("add");
+ request.get("address").add("deployment", name);
+ request.get("enabled").set(true);
+
+ OperationBuilder builder = OperationBuilder.Factory.create(request);
+ builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ Operation operation = builder.build();
+ request.get("input-stream-index").set(0);
+
+ ModelNode result = client.execute(operation);
+ System.out.println(result);
+
+ throwOnFailure(result);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static void replace(String name, File file, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+
+ ModelNode request = new ModelNode();
+ request.get("operation").set("full-replace-deployment");
+ request.get("name").set(name);
+
+ OperationBuilder builder = OperationBuilder.Factory.create(request);
+ builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ Operation operation = builder.build();
+ request.get("input-stream-index").set(0);
+
+ ModelNode result = client.execute(operation);
+
+ throwOnFailure(result);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ try {
+ return JbossManagementUtil.isDeployed(name, client);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static List<String> getDeployments(String host, int port) throws UnknownHostException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ return JbossManagementUtil.getDeployments(client);
+ }
+
+ private static void throwOnFailure(ModelNode result) throws DeployerException {
+ if (!JbossManagementUtil.isSuccess(result)) {
+ throw new DeployerException(JbossManagementUtil.getFailureDescription(result));
+ }
+ }
+
+ private DetypedDeployer() {
+ // inhibit instantiation
+ }
+}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossDeploymentManager.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,35 @@
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import java.io.File;
+import java.util.concurrent.Future;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
+
+public class JBossDeploymentManager implements IJBossDeploymentManager {
+
+ public Future asyncDeploy(String host, int port, String deploymentName,
+ File file, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object syncDeploy(String host, int port, String deploymentName,
+ File file, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Future asyncUndeploy(String host, int port, String deploymentName,
+ boolean removeFile, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object syncUndeploy(String host, int port, String deploymentName,
+ boolean removeFile, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossManagementService.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossManagementService.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JBossManagementService.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,25 @@
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
+import org.jboss.ide.eclipse.as7.deployment.IJBossManagementInterface;
+import org.jboss.ide.eclipse.as7.deployment.IJBossManagementService;
+
+public class JBossManagementService implements IJBossManagementService {
+
+ private IJBossDeploymentManager deploymentManager = null;
+ private IJBossManagementInterface manager = null;
+
+ @Override
+ public IJBossDeploymentManager getDeploymentManager() {
+ if( deploymentManager == null )
+ deploymentManager = new JBossDeploymentManager();
+ return deploymentManager;
+ }
+
+ @Override
+ public IJBossManagementInterface getManagementInterface() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JbossManagementUtil.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JbossManagementUtil.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/JbossManagementUtil.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.Property;
+import org.jboss.ide.eclipse.as7.internal.deployment.operations.DefaultOperationRequestBuilder;
+import org.jboss.ide.eclipse.as7.internal.deployment.operations.OperationFormatException;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class JbossManagementUtil {
+
+ public static boolean isSuccess(ModelNode operationResult) {
+ if(operationResult != null) {
+ ModelNode outcome = operationResult.get("outcome");
+ return outcome != null && outcome.asString().equals("success");
+ }
+ return false;
+ }
+
+ public static String getFailureDescription(ModelNode operationResult) {
+ if(operationResult == null) {
+ return null;
+ }
+
+ ModelNode descr = operationResult.get("failure-description");
+ if(descr == null) {
+ return null;
+ }
+
+ return descr.asString();
+ }
+
+ public static List<String> getList(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ List<ModelNode> nodeList = operationResult.get("result").asList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(ModelNode node : nodeList) {
+ list.add(node.asString());
+ }
+ return list;
+ }
+
+ public static byte[] getHash(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return null;
+ return operationResult.get("result").asBytes();
+ }
+
+ public static List<String> getRequestPropertyNames(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ ModelNode result = operationResult.get("result");
+ if(!result.hasDefined("request-properties"))
+ return Collections.emptyList();
+
+ List<Property> nodeList = result.get("request-properties").asPropertyList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(Property node : nodeList) {
+ list.add(node.getName());
+ }
+ return list;
+ }
+
+ public static boolean isDeployed(String name, ModelControllerClient client) {
+ return getDeployments(client).contains(name);
+ }
+
+ public static List<String> getDeployments(ModelControllerClient client) {
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ final ModelNode request;
+ try {
+ builder.operationName("read-children-names");
+ builder.addProperty("child-type", "deployment");
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
+ }
+
+ try {
+ ModelNode outcome = client.execute(request);
+ if (isSuccess(outcome)) {
+ return getList(outcome);
+ }
+ } catch (Exception e) {
+ }
+
+ return Collections.emptyList();
+ }
+
+ public static List<String> getJmsResources(ModelControllerClient client, String type) {
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ final ModelNode request;
+ try {
+ builder.addNode("subsystem", "jms");
+ builder.operationName("read-children-names");
+ builder.addProperty("child-type", type);
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
+ }
+
+ try {
+ ModelNode outcome = client.execute(request);
+ if (isSuccess(outcome)) {
+ return getList(outcome);
+ }
+ } catch (Exception e) {
+ }
+
+ return Collections.emptyList();
+ }
+
+ public static boolean isTopic(ModelControllerClient client, String name) {
+ List<String> topics = getJmsResources(client, "topic");
+ return topics.contains(name);
+ }
+
+ public static boolean isQueue(ModelControllerClient client, String name) {
+ List<String> queues = getJmsResources(client, "queue");
+ return queues.contains(name);
+ }
+
+ public static boolean isConnectionFactory(ModelControllerClient client, String name) {
+ List<String> cf = getJmsResources(client, "connection-factory");
+ return cf.contains(name);
+ }
+}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java (from rev 30584, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.internal.deployment;
+
+import java.io.File;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
+import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+import org.jboss.as.protocol.StreamUtils;
+
+/**
+ *
+ * @author André Dietisheim
+ */
+public class TypedDeployer {
+
+ public static void undeploySync(String name, String host, int port, IProgressMonitor monitor) throws DeployerException {
+ Future f = undeploy(name, host, port);
+ syncWait(f, monitor);
+ }
+
+ public static void syncDeploy(String name, File file, String host, int port, IProgressMonitor monitor) throws DeployerException {
+ Future f = deploy(name, file, host, port);
+ syncWait(f, monitor);
+ }
+
+ private static void syncWait(Future f, IProgressMonitor monitor) {
+ while(!f.isDone()) {
+ if( monitor.isCanceled()) {
+ f.cancel(true);
+ return;
+ }
+ try {
+ Thread.sleep(150);
+ } catch(InterruptedException ie) {
+ }
+ }
+ }
+
+ public static Future undeploy(String name, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
+ InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
+
+ DeploymentPlan plan = builder.undeploy(name).andRemoveUndeployed().build();
+ return manager.execute(plan);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static Future deploy(File file, String host, int port) throws DeployerException {
+ return deploy(file.getName(), file, host, port);
+ }
+
+ public static Future deploy(String name, File file, String host, int port) throws DeployerException {
+ return internalDeploy(name, file, host, port, false);
+ }
+
+ public static Future replace(File file, String host, int port) throws DeployerException {
+ return replace(file.getName(), file, host, port);
+ }
+
+ public static Future replace(String name, File file, String host, int port) throws DeployerException {
+ return internalDeploy(name, file, host, port, true);
+ }
+
+ public static Future internalDeploy(String name, File file, String host, int port, boolean replace) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
+ InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
+
+ DeploymentPlan plan = null;
+ if( replace )
+ plan = builder.replace(name, file).build();
+ else
+ plan = builder.add(name, file).deploy(name).build();
+
+ return manager.execute(plan);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+
+ //
+ // public static boolean isDeployed(String name, String host, int port)
+ // throws CancellationException, IOException {
+ // ModelControllerClient client = ModelControllerClient.Factory.create(host,
+ // port);
+ // try {
+ // return Util.isDeployed(name, client);
+ // } finally {
+ // StreamUtils.safeClose(client);
+ // }
+ // }
+ //
+ // public static List<String> getDeployments(String host, int port) throws
+ // UnknownHostException {
+ // ModelControllerClient client = ModelControllerClient.Factory.create(host,
+ // port);
+ // return Util.getDeployments(client);
+ // }
+ //
+ // private static void throwOnFailure(ModelNode result) throws
+ // DeployerException {
+ // if (!Util.isSuccess(result)) {
+ // throw new DeployerException(Util.getFailureDescription(result));
+ // }
+ // }
+
+ private TypedDeployer() {
+ // inhibit instantiation
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/TypedDeployer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/CommandFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandFormatException.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/CommandFormatException.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
/**
* @author Alexey Loubyansky
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/CommandLineException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandLineException.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/CommandLineException.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
/**
* @author Alexey Loubyansky
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/DefaultOperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestAddress.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/DefaultOperationRequestAddress.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
import java.util.ArrayList;
import java.util.Iterator;
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/DefaultOperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestBuilder.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/DefaultOperationRequestBuilder.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
import java.io.IOException;
import java.util.Iterator;
@@ -28,7 +28,7 @@
import javax.security.auth.callback.UnsupportedCallbackException;
import org.jboss.dmr.ModelNode;
-import org.jboss.ide.eclipse.as7.deployment.internal.operations.OperationRequestAddress.Node;
+import org.jboss.ide.eclipse.as7.internal.deployment.operations.OperationRequestAddress.Node;
/**
*
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationFormatException.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationFormatException.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
/**
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestAddress.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationRequestAddress.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestBuilder.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/OperationRequestBuilder.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
import org.jboss.dmr.ModelNode;
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/ValidatingOperationCallbackHandler.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/ValidatingOperationCallbackHandler.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/internal/deployment/operations/ValidatingOperationCallbackHandler.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+package org.jboss.ide.eclipse.as7.internal.deployment.operations;
import java.util.regex.Pattern;
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -35,8 +35,8 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
-import org.jboss.ide.eclipse.as7.deployment.internal.DeploymentManager;
+import org.jboss.ide.eclipse.as7.internal.deployment.DeployerException;
+import org.jboss.ide.eclipse.as7.internal.deployment.DeploymentManager;
import org.junit.Test;
import org.osgi.framework.Bundle;
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -31,7 +31,7 @@
import org.jboss.ide.eclipse.as7.deployment.detyped.DeployerException;
import org.jboss.ide.eclipse.as7.deployment.detyped.DetypedDeployer;
-import org.jboss.ide.eclipse.as7.deployment.internal.TypedDeployer;
+import org.jboss.ide.eclipse.as7.internal.deployment.TypedDeployer;
import org.junit.Test;
/**
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-15 03:25:25 UTC (rev 30584)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-15 10:01:21 UTC (rev 30585)
@@ -25,8 +25,8 @@
import java.io.File;
-import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
-import org.jboss.ide.eclipse.as7.deployment.internal.TypedDeployer;
+import org.jboss.ide.eclipse.as7.internal.deployment.DeployerException;
+import org.jboss.ide.eclipse.as7.internal.deployment.TypedDeployer;
import org.junit.Test;
/**
13 years, 7 months
JBoss Tools SVN: r30584 - in workspace/adietish/org.jboss.ide.eclipse.as7.deployment: src/org/jboss/ide/eclipse/as7/deployment/internal and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-04-14 23:25:25 -0400 (Thu, 14 Apr 2011)
New Revision: 30584
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandFormatException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandLineException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestAddress.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestBuilder.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationFormatException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestAddress.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestBuilder.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/ValidatingOperationCallbackHandler.java
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
Log:
settling on API / still evolving
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-14 22:31:32 UTC (rev 30583)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-15 03:25:25 UTC (rev 30584)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="jboss-threads-2.0.0.CR8.jar" sourcepath="/home/adietish/jboss-workspaces/jboss-tools/jbosstools-src/jboss-threads-2.0.0.CR8-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/jboss-as-controller-client"/>
+ <classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/home/rob/.m2/repository/org/jboss/as/jboss-as-controller-client/7.0.0.Beta3-SNAPSHOT/jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/jboss-as-protocol"/>
<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Beta5.jar" sourcepath="/home/adietish/jboss-workspaces/jboss-tools/jbosstools-src/jboss-dmr-1.0.0.Beta5-sources.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-logging-3.0.0.Beta3.jar"/>
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DetypedDeployer.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.concurrent.CancellationException;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.Operation;
+import org.jboss.as.controller.client.OperationBuilder;
+import org.jboss.as.protocol.StreamUtils;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * @author André Dietisheim
+ */
+public class DetypedDeployer {
+
+ public static void undeploy(String name, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ // undeploy
+ ModelNode request = new ModelNode();
+ request.get("operation").set("undeploy");
+ request.get("address").add("deployment", name);
+ ModelNode result = client.execute(request);
+ throwOnFailure(result);
+
+ // remove
+ request = new ModelNode();
+ request.get("operation").set("remove");
+ request.get("address").add("deployment", name);
+ result = client.execute(request);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static void deploy(File file, String host, int port) throws DeployerException {
+ deploy(file.getName(), file, host, port);
+ }
+
+ public static void deploy(String name, File file, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+
+ ModelNode request = new ModelNode();
+ request.get("operation").set("add");
+ request.get("address").add("deployment", name);
+ request.get("enabled").set(true);
+
+ OperationBuilder builder = OperationBuilder.Factory.create(request);
+ builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ Operation operation = builder.build();
+ request.get("input-stream-index").set(0);
+
+ ModelNode result = client.execute(operation);
+ System.out.println(result);
+
+ throwOnFailure(result);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static void replace(String name, File file, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+
+ ModelNode request = new ModelNode();
+ request.get("operation").set("full-replace-deployment");
+ request.get("name").set(name);
+
+ OperationBuilder builder = OperationBuilder.Factory.create(request);
+ builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ Operation operation = builder.build();
+ request.get("input-stream-index").set(0);
+
+ ModelNode result = client.execute(operation);
+
+ throwOnFailure(result);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ try {
+ return JbossManagementUtil.isDeployed(name, client);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static List<String> getDeployments(String host, int port) throws UnknownHostException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ return JbossManagementUtil.getDeployments(client);
+ }
+
+ private static void throwOnFailure(ModelNode result) throws DeployerException {
+ if (!JbossManagementUtil.isSuccess(result)) {
+ throw new DeployerException(JbossManagementUtil.getFailureDescription(result));
+ }
+ }
+
+ private DetypedDeployer() {
+ // inhibit instantiation
+ }
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossDeploymentManager.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,35 @@
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+import java.io.File;
+import java.util.concurrent.Future;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
+
+public class JBossDeploymentManager implements IJBossDeploymentManager {
+
+ public Future asyncDeploy(String host, int port, String deploymentName,
+ File file, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object syncDeploy(String host, int port, String deploymentName,
+ File file, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Future asyncUndeploy(String host, int port, String deploymentName,
+ boolean removeFile, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object syncUndeploy(String host, int port, String deploymentName,
+ boolean removeFile, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JBossManagementService.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,25 @@
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+import org.jboss.ide.eclipse.as7.deployment.IJBossDeploymentManager;
+import org.jboss.ide.eclipse.as7.deployment.IJBossManagementInterface;
+import org.jboss.ide.eclipse.as7.deployment.IJBossManagementService;
+
+public class JBossManagementService implements IJBossManagementService {
+
+ private IJBossDeploymentManager deploymentManager = null;
+ private IJBossManagementInterface manager = null;
+
+ @Override
+ public IJBossDeploymentManager getDeploymentManager() {
+ if( deploymentManager == null )
+ deploymentManager = new JBossDeploymentManager();
+ return deploymentManager;
+ }
+
+ @Override
+ public IJBossManagementInterface getManagementInterface() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/JbossManagementUtil.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.Property;
+import org.jboss.ide.eclipse.as7.deployment.internal.operations.DefaultOperationRequestBuilder;
+import org.jboss.ide.eclipse.as7.deployment.internal.operations.OperationFormatException;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class JbossManagementUtil {
+
+ public static boolean isSuccess(ModelNode operationResult) {
+ if(operationResult != null) {
+ ModelNode outcome = operationResult.get("outcome");
+ return outcome != null && outcome.asString().equals("success");
+ }
+ return false;
+ }
+
+ public static String getFailureDescription(ModelNode operationResult) {
+ if(operationResult == null) {
+ return null;
+ }
+
+ ModelNode descr = operationResult.get("failure-description");
+ if(descr == null) {
+ return null;
+ }
+
+ return descr.asString();
+ }
+
+ public static List<String> getList(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ List<ModelNode> nodeList = operationResult.get("result").asList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(ModelNode node : nodeList) {
+ list.add(node.asString());
+ }
+ return list;
+ }
+
+ public static byte[] getHash(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return null;
+ return operationResult.get("result").asBytes();
+ }
+
+ public static List<String> getRequestPropertyNames(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ ModelNode result = operationResult.get("result");
+ if(!result.hasDefined("request-properties"))
+ return Collections.emptyList();
+
+ List<Property> nodeList = result.get("request-properties").asPropertyList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(Property node : nodeList) {
+ list.add(node.getName());
+ }
+ return list;
+ }
+
+ public static boolean isDeployed(String name, ModelControllerClient client) {
+ return getDeployments(client).contains(name);
+ }
+
+ public static List<String> getDeployments(ModelControllerClient client) {
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ final ModelNode request;
+ try {
+ builder.operationName("read-children-names");
+ builder.addProperty("child-type", "deployment");
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
+ }
+
+ try {
+ ModelNode outcome = client.execute(request);
+ if (isSuccess(outcome)) {
+ return getList(outcome);
+ }
+ } catch (Exception e) {
+ }
+
+ return Collections.emptyList();
+ }
+
+ public static List<String> getJmsResources(ModelControllerClient client, String type) {
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ final ModelNode request;
+ try {
+ builder.addNode("subsystem", "jms");
+ builder.operationName("read-children-names");
+ builder.addProperty("child-type", type);
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
+ }
+
+ try {
+ ModelNode outcome = client.execute(request);
+ if (isSuccess(outcome)) {
+ return getList(outcome);
+ }
+ } catch (Exception e) {
+ }
+
+ return Collections.emptyList();
+ }
+
+ public static boolean isTopic(ModelControllerClient client, String name) {
+ List<String> topics = getJmsResources(client, "topic");
+ return topics.contains(name);
+ }
+
+ public static boolean isQueue(ModelControllerClient client, String name) {
+ List<String> queues = getJmsResources(client, "queue");
+ return queues.contains(name);
+ }
+
+ public static boolean isConnectionFactory(ModelControllerClient client, String name) {
+ List<String> cf = getJmsResources(client, "connection-factory");
+ return cf.contains(name);
+ }
+}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-14 22:31:32 UTC (rev 30583)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -22,8 +22,10 @@
package org.jboss.ide.eclipse.as7.deployment.internal;
import java.io.File;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
@@ -31,13 +33,35 @@
import org.jboss.as.protocol.StreamUtils;
/**
+ *
* @author André Dietisheim
*/
public class TypedDeployer {
- private static final long TIMEOUT = 15 * 1000;
-
- public static void undeploy(String name, String host, int port) throws DeployerException {
+ public static void undeploySync(String name, String host, int port, IProgressMonitor monitor) throws DeployerException {
+ Future f = undeploy(name, host, port);
+ syncWait(f, monitor);
+ }
+
+ public static void syncDeploy(String name, File file, String host, int port, IProgressMonitor monitor) throws DeployerException {
+ Future f = deploy(name, file, host, port);
+ syncWait(f, monitor);
+ }
+
+ private static void syncWait(Future f, IProgressMonitor monitor) {
+ while(!f.isDone()) {
+ if( monitor.isCanceled()) {
+ f.cancel(true);
+ return;
+ }
+ try {
+ Thread.sleep(150);
+ } catch(InterruptedException ie) {
+ }
+ }
+ }
+
+ public static Future undeploy(String name, String host, int port) throws DeployerException {
ModelControllerClient client = null;
try {
client = ModelControllerClient.Factory.create(host, port);
@@ -45,7 +69,7 @@
InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
DeploymentPlan plan = builder.undeploy(name).andRemoveUndeployed().build();
- manager.execute(plan).get(TIMEOUT, TimeUnit.MILLISECONDS);
+ return manager.execute(plan);
} catch (Exception e) {
throw new DeployerException(e);
} finally {
@@ -53,46 +77,44 @@
}
}
- public static void deploy(File file, String host, int port) throws DeployerException {
- deploy(file.getName(), file, host, port);
+ public static Future deploy(File file, String host, int port) throws DeployerException {
+ return deploy(file.getName(), file, host, port);
}
- public static void deploy(String name, File file, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
- ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
- InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ public static Future deploy(String name, File file, String host, int port) throws DeployerException {
+ return internalDeploy(name, file, host, port, false);
+ }
- DeploymentPlan plan = builder.add(name, file).deploy(name).build();
- manager.execute(plan).get(TIMEOUT, TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
+ public static Future replace(File file, String host, int port) throws DeployerException {
+ return replace(file.getName(), file, host, port);
}
- public static void replace(File file, String host, int port) throws DeployerException {
- replace(file.getName(), file, host, port);
+ public static Future replace(String name, File file, String host, int port) throws DeployerException {
+ return internalDeploy(name, file, host, port, true);
}
- public static void replace(String name, File file, String host, int port) throws DeployerException {
+ public static Future internalDeploy(String name, File file, String host, int port, boolean replace) throws DeployerException {
ModelControllerClient client = null;
try {
client = ModelControllerClient.Factory.create(host, port);
ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
- DeploymentPlan plan = builder.replace(name, file).build();
- manager.execute(plan).get(TIMEOUT, TimeUnit.MILLISECONDS);
+ DeploymentPlan plan = null;
+ if( replace )
+ plan = builder.replace(name, file).build();
+ else
+ plan = builder.add(name, file).deploy(name).build();
+
+ return manager.execute(plan);
} catch (Exception e) {
throw new DeployerException(e);
} finally {
StreamUtils.safeClose(client);
}
}
-
+
+
//
// public static boolean isDeployed(String name, String host, int port)
// throws CancellationException, IOException {
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandFormatException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandFormatException.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+/**
+ * @author Alexey Loubyansky
+ *
+ */
+public class CommandFormatException extends CommandLineException {
+
+ private static final long serialVersionUID = -5802389813870206943L;
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public CommandFormatException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public CommandFormatException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public CommandFormatException(Throwable cause) {
+ super(cause);
+ }
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandLineException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandLineException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/CommandLineException.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+/**
+ * @author Alexey Loubyansky
+ *
+ */
+public class CommandLineException extends Exception {
+
+ private static final long serialVersionUID = 423938082439473323L;
+
+ public CommandLineException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CommandLineException(String message) {
+ super(message);
+ }
+
+ public CommandLineException(Throwable cause) {
+ super(cause);
+ }
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestAddress.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestAddress.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,258 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This implementation is not thread-safe.
+ *
+ * @author Alexey Loubyansky
+ */
+public class DefaultOperationRequestAddress implements OperationRequestAddress {
+
+ private final List<NodeImpl> nodes = new ArrayList<NodeImpl>();
+
+ public DefaultOperationRequestAddress() {
+ }
+
+ /**
+ * Creates a prefix and initializes it to the value of the argument.
+ * @param initial the initial value
+ */
+ public DefaultOperationRequestAddress(OperationRequestAddress initial) {
+ if(!initial.isEmpty()) {
+ for(Node node : initial) {
+ toNode(node.getType(), node.getName());
+ }
+ }
+ }
+
+ @Override
+ public void toNodeType(String nodeType) {
+
+ nodes.add(new NodeImpl(nodeType, null));
+ }
+
+ @Override
+ public void toNode(String nodeName) {
+
+ if(nodes.isEmpty())
+ throw new IllegalStateException("The prefix should end with the node type before going to a specific node name.");
+
+ nodes.get(nodes.size() - 1).name = nodeName;
+ }
+
+ @Override
+ public void toNode(String nodeType, String nodeName) {
+
+ if(endsOnType()) {
+ throw new IllegalStateException("The prefix ends on a type. A node name must be specified before this method can be invoked.");
+ }
+ nodes.add(new NodeImpl(nodeType, nodeName));
+ }
+
+ @Override
+ public String toNodeType() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ String name = nodes.get(nodes.size() - 1).name;
+ nodes.get(nodes.size() - 1).name = null;
+ return name;
+ }
+
+ @Override
+ public Node toParentNode() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ return nodes.remove(nodes.size() - 1);
+ }
+
+ @Override
+ public void reset() {
+ nodes.clear();
+ }
+
+ @Override
+ public boolean endsOnType() {
+ if(nodes.isEmpty()) {
+ return false;
+ }
+
+ NodeImpl node = nodes.get(nodes.size() - 1);
+ return node.name == null;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return nodes.isEmpty();
+ }
+
+ @Override
+ public Iterator<Node> iterator() {
+
+ final Node[] array = nodes.toArray(new Node[nodes.size()]);
+ return new Iterator<Node>() {
+
+ int i = 0;
+
+ @Override
+ public boolean hasNext() {
+ return i < array.length;
+ }
+
+ @Override
+ public Node next() {
+ return array[i++];
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+
+ @Override
+ public String getNodeType() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ return nodes.get(nodes.size() - 1).type;
+ }
+
+ @Override
+ public String getNodeName() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ return nodes.get(nodes.size() - 1).name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof OperationRequestAddress))
+ return false;
+
+ OperationRequestAddress other = (OperationRequestAddress) obj;
+
+ if(isEmpty() != other.isEmpty())
+ return false;
+
+ Iterator<Node> thisIterator = iterator();
+ Iterator<Node> otherIterator = other.iterator();
+ boolean result = true;
+ while(result) {
+ if(!thisIterator.next().equals(otherIterator.next())) {
+ result = false;
+ } else {
+ if (!thisIterator.hasNext()) {
+ if (otherIterator.hasNext()) {
+ result = false;
+ }
+ break;
+ }
+ if (!otherIterator.hasNext()) {
+ if (thisIterator.hasNext()) {
+ result = false;
+ }
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ private static final class NodeImpl implements Node {
+
+ String type;
+ String name;
+
+ NodeImpl(String type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+
+ if(!(obj instanceof Node))
+ return false;
+
+ Node other = (Node) obj;
+ if (name == null) {
+ if (other.getName() != null)
+ return false;
+ } else if (!name.equals(other.getName()))
+ return false;
+ if (type == null) {
+ if (other.getType() != null)
+ return false;
+ } else if (!type.equals(other.getType()))
+ return false;
+ return true;
+ }
+ }
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestBuilder.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/DefaultOperationRequestBuilder.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as7.deployment.internal.operations.OperationRequestAddress.Node;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class DefaultOperationRequestBuilder extends ValidatingOperationCallbackHandler implements OperationRequestBuilder {
+
+ private ModelNode request = new ModelNode();
+ private OperationRequestAddress prefix;
+
+ public DefaultOperationRequestBuilder() {
+ this.prefix = new DefaultOperationRequestAddress();
+ }
+
+ public DefaultOperationRequestBuilder(OperationRequestAddress prefix) {
+ if(prefix == null) {
+ throw new IllegalArgumentException("Prefix can't be null");
+ }
+ this.prefix = new DefaultOperationRequestAddress(prefix);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#rootNode()
+ */
+ public void rootNode() {
+ prefix.reset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#parentNode()
+ */
+ public void parentNode() {
+ prefix.toParentNode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeType()
+ */
+ public void nodeType() {
+ prefix.toNodeType();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeTypeNameSeparator(int)
+ */
+ public void nodeTypeNameSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeSeparator(int)
+ */
+ public void nodeSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#addressOperationSeparator(int)
+ */
+ public void addressOperationSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#operationName(java.lang.String)
+ */
+ @Override
+ public void validatedOperationName(String operationName) {
+ this.setOperationName(operationName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyListStart(int)
+ */
+ public void propertyListStart(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyNameValueSeparator(int)
+ */
+ public void propertyNameValueSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertySeparator(int)
+ */
+ public void propertySeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyListEnd(int)
+ */
+ public void propertyListEnd(int index) {
+ }
+
+ @Override
+ protected void validatedNodeType(String nodeType)
+ throws OperationFormatException {
+ this.addNodeType(nodeType);
+ }
+
+ @Override
+ protected void validatedNodeName(String nodeName)
+ throws OperationFormatException {
+ this.addNodeName(nodeName);
+ }
+
+ @Override
+ protected void validatedPropertyName(String propertyName)
+ throws OperationFormatException {
+ throw new OperationFormatException("Property '" + propertyName + "' is missing the value.");
+ }
+
+ @Override
+ protected void validatedProperty(String name, String value,
+ int nameValueSeparatorIndex) throws OperationFormatException {
+ this.addProperty(name, value);
+ }
+
+ public void nodeTypeOrName(String typeOrName)
+ throws OperationFormatException {
+
+ if(prefix.endsOnType()) {
+ this.addNodeName(typeOrName);
+ } else {
+ this.addNodeType(typeOrName);
+ }
+ }
+
+ /**
+ * Makes sure that the operation name and the address have been set and returns a ModelNode
+ * representing the operation request.
+ */
+ public ModelNode buildRequest() throws OperationFormatException {
+
+ ModelNode address = request.get("address");
+ if(prefix.isEmpty()) {
+ address.setEmptyList();
+ } else {
+ Iterator<Node> iterator = prefix.iterator();
+ while (iterator.hasNext()) {
+ OperationRequestAddress.Node node = iterator.next();
+ if (node.getName() != null) {
+ address.add(node.getType(), node.getName());
+ } else if (iterator.hasNext()) {
+ throw new OperationFormatException(
+ "The node name is not specified for type '"
+ + node.getType() + "'");
+ }
+ }
+ }
+
+ if(!request.hasDefined("operation")) {
+ throw new OperationFormatException("The operation name is missing or the format of the operation request is wrong.");
+ }
+
+ return request;
+ }
+
+ @Override
+ public void setOperationName(String name) {
+ request.get("operation").set(name);
+ }
+
+ @Override
+ public void addNode(String type, String name) {
+ prefix.toNode(type, name);
+ }
+
+ @Override
+ public void addNodeType(String type) {
+ prefix.toNodeType(type);
+ }
+
+ @Override
+ public void addNodeName(String name) {
+ prefix.toNode(name);
+ }
+
+ @Override
+ public void addProperty(String name, String value) {
+
+ if(name == null || name.trim().isEmpty())
+ throw new IllegalArgumentException("The argument name is not specified: '" + name + "'");
+ if(value == null || value.trim().isEmpty())
+ throw new IllegalArgumentException("The argument value is not specified: '" + value + "'");
+ ModelNode toSet = null;
+ try {
+ toSet = ModelNode.fromString(value);
+ } catch (Exception e) {
+ // just use the string
+ toSet = new ModelNode().set(value);
+ }
+ request.get(name).set(toSet);
+ }
+
+ public ModelNode getModelNode() {
+ return request;
+ }
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ // TODO Auto-generated method stub
+
+ }
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationFormatException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationFormatException.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class OperationFormatException extends CommandFormatException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3481664048439674648L;
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public OperationFormatException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public OperationFormatException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public OperationFormatException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestAddress.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestAddress.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+
+
+/**
+ * An instance of this interface represents a prefix for the operation request address part.
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestAddress extends Iterable<OperationRequestAddress.Node> {
+
+ /**
+ * Appends the node type to the prefix.
+ * Note, the current prefix must end on the node name before this method
+ * is invoked.
+ *
+ * @param nodeType the node type to append to the prefix.
+ */
+ void toNodeType(String nodeType);
+
+ /**
+ * Appends the node name to the prefix.
+ * Note, the current prefix must end on the node type before this method
+ * is invoked.
+ *
+ * @param nodeName the node name to append to the prefix.
+ */
+ void toNode(String nodeName);
+
+ /**
+ * Appends the node to the prefix.
+ * Note, the current prefix must end on the node (i.e. node name) before
+ * this method is invoked.
+ *
+ * @param nodeType the node type of the node to append to the prefix
+ * @param nodeName the node name of the node to append to the prefix
+ */
+ void toNode(String nodeType, String nodeName);
+
+ /**
+ * Sets the current prefix to the node type of the current node,
+ * i.e. the node name is removed from the end of the prefix.
+ * @return the node name the prefix ended on
+ */
+ String toNodeType();
+
+ /**
+ * Removes the last node in the prefix, i.e. moves the value a node up.
+ * @return the node the prefix ended on
+ */
+ Node toParentNode();
+
+ /**
+ * Resets the prefix, i.e. this will make the prefix empty.
+ */
+ void reset();
+
+ /**
+ * Checks whether the prefix ends on a node type or a node name.
+ * @return true if the prefix ends on a node type, otherwise false.
+ */
+ boolean endsOnType();
+
+ /**
+ * Checks whether the prefix is empty.
+ * @return true if the prefix is empty, otherwise false.
+ */
+ boolean isEmpty();
+
+ /**
+ * Returns the node type of the last node.
+ * @return the node type of the last node or null if the prefix is empty.
+ */
+ String getNodeType();
+
+ /**
+ * Returns the node name of the last node.
+ * @return the node name of the last node or null if the prefix ends
+ * on a type or is empty.
+ */
+ String getNodeName();
+
+ interface Node {
+
+ String getType();
+
+ String getName();
+ }
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestBuilder.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/OperationRequestBuilder.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+import org.jboss.dmr.ModelNode;
+
+/**
+ * TODO this is not used for now...
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestBuilder {
+
+ /**
+ * Sets the name operation to be invoked.
+ *
+ * @param name the name of the operation to invoke.
+ */
+ void setOperationName(String name);
+
+ /**
+ * The address is specified as a path to the target node. Each element of the path is a node
+ * and is identified by its type and name.
+ *
+ * @param type the type of the node
+ * @param name the name of the node
+ */
+ void addNode(String type, String name);
+
+ /**
+ * This method is supposed to be invoked from applying the prefix with ends on a node type.
+ * @param type the type of the node.
+ */
+ void addNodeType(String type);
+
+ /**
+ * This method assumes there is a non-empty prefix which ends on a node type.
+ * Otherwise, this method will result in an exception.
+ * @param name the name of the node for the type specified by the prefix.
+ */
+ void addNodeName(String name);
+
+ /**
+ * Adds an argument.
+ *
+ * @param name the name of the argument
+ * @param value the value of the argument
+ */
+ void addProperty(String name, String value);
+
+ /**
+ * Builds the operation request based on the collected operation name, address and arguments.
+ *
+ * @return an instance of ModelNode representing the operation request
+ * @throws OperationFormatException
+ */
+ ModelNode buildRequest() throws OperationFormatException;
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/ValidatingOperationCallbackHandler.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/ValidatingOperationCallbackHandler.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/operations/ValidatingOperationCallbackHandler.java 2011-04-15 03:25:25 UTC (rev 30584)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.internal.operations;
+
+import java.util.regex.Pattern;
+
+import javax.security.auth.callback.CallbackHandler;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public abstract class ValidatingOperationCallbackHandler implements CallbackHandler {
+
+ private static final Pattern ALPHANUMERICS_PATTERN = Pattern.compile("[_a-zA-Z](?:[-_a-zA-Z0-9]*[_a-zA-Z0-9])?");
+ private static final Pattern NODE_NAME_PATTERN = Pattern.compile("\\*|[^*\\p{Space}\\p{Cntrl}]+");
+
+
+ protected String operationStr;
+
+ public void start(String operationString) {
+ this.operationStr = operationString;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeType(java.lang.String)
+ */
+ public void nodeType(String nodeType) throws OperationFormatException {
+
+ assertValidType(nodeType);
+ validatedNodeType(nodeType);
+ }
+
+ protected abstract void validatedNodeType(String nodeType) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeName(java.lang.String)
+ */
+ public void nodeName(String nodeName) throws OperationFormatException {
+
+ assertValidNodeName(nodeName);
+ validatedNodeName(nodeName);
+ }
+
+ protected abstract void validatedNodeName(String nodeName) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#operationName(java.lang.String)
+ */
+ public void operationName(String operationName)
+ throws OperationFormatException {
+
+ if (operationName == null || !ALPHANUMERICS_PATTERN.matcher(operationName).matches()) {
+ throw new OperationFormatException("'" + operationName + "' is not a valid operation name.");
+ }
+
+ validatedOperationName(operationName);
+ }
+
+ protected abstract void validatedOperationName(String operationName) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyName(java.lang.String)
+ */
+ public void propertyName(String propertyName)
+ throws OperationFormatException {
+
+ assertValidParameterName(propertyName);
+ validatedPropertyName(propertyName);
+ }
+
+ protected abstract void validatedPropertyName(String propertyName) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#property(java.lang.String, java.lang.String, int)
+ */
+ public void property(String name, String value, int nameValueSeparatorIndex)
+ throws OperationFormatException {
+
+ assertValidParameterName(name);
+
+ if (value.isEmpty()) {
+ throw new OperationFormatException("Parameter '" + value + "' is missing value.");
+ }
+
+ validatedProperty(name, value, nameValueSeparatorIndex);
+ }
+
+ protected abstract void validatedProperty(String name, String value, int nameValueSeparatorIndex) throws OperationFormatException;
+
+ protected void assertValidType(String nodeType)
+ throws OperationFormatException {
+ if (nodeType == null || !ALPHANUMERICS_PATTERN.matcher(nodeType).matches()) {
+ throw new OperationFormatException("'" + nodeType + "' is not a valid node type name.");
+ }
+ }
+
+ protected void assertValidNodeName(String nodeName)
+ throws OperationFormatException {
+ if (nodeName == null || !NODE_NAME_PATTERN.matcher(nodeName).matches()) {
+ throw new OperationFormatException("'" + nodeName + "' is not a valid node name.");
+ }
+ }
+
+ protected void assertValidParameterName(String name)
+ throws OperationFormatException {
+ if (name == null || !ALPHANUMERICS_PATTERN.matcher(name).matches()) {
+ throw new OperationFormatException("'" + name + "' is not a valid parameter name.");
+ }
+ }
+
+}
13 years, 7 months
Newsletter Fri, 15 Apr 2011 04:39:06 +0300
by jbosstools-commits@lists.jboss.org
Halo!!
Do you want a prosperous future, increase in earning power, and the praise of all?
Special offer:
We can assist with Diplomas from prestigious universities based on your present knowledge and professional experience.
Get a Degree in 4 weeks with our program!
~Our program will help EVERYONE with professional experience
get a 100% verified Degree:
~Doctorate
~Bachelors
~Masters
- Just think about it...
- Realize YOUR Dreams!
- Live a wonderful life by earning or upgrading your degree.
This is a splendid chance to make a right move and receive your due
benefits... if you are qualified but are lacking that piece of paper. Get one from us in a fraction of the time.
Call 7 days a week! to start improving your life!
~CONTACT US~
1-305-460-2287
You must leave us a voice message with your name and phone number with country code if outside USA and we will call you back as soon as possible.
It's your decision...
Make the right decision.
Best regards.
Do Not Reply to this Email.
We do not reply to text inquiries, and our server will reject all response traffic.
We apologize for any inconvenience this may have caused you.
13 years, 7 months
JBoss Tools SVN: r30583 - trunk/seam/docs/reference/en-US.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-04-14 18:31:32 -0400 (Thu, 14 Apr 2011)
New Revision: 30583
Modified:
trunk/seam/docs/reference/en-US/crud_database_application.xml
Log:
fixed TOOLSDOC-162
Modified: trunk/seam/docs/reference/en-US/crud_database_application.xml
===================================================================
--- trunk/seam/docs/reference/en-US/crud_database_application.xml 2011-04-14 21:47:40 UTC (rev 30582)
+++ trunk/seam/docs/reference/en-US/crud_database_application.xml 2011-04-14 22:31:32 UTC (rev 30583)
@@ -22,7 +22,7 @@
</para>
<para>
- In the next section we will create <xref linkend="intro"/> Web application, connect it to the <ulink url="http://www.hsqldb.org/">HSQL</ulink> database and add <property>CRUD</property> support.
+ In the next section we will create a Seam Web application, connect it to the <ulink url="http://www.hsqldb.org/">HSQL</ulink> database and add <property>CRUD</property> support.
</para>
</section>
13 years, 7 months