Author: adietish
Date: 2011-05-31 05:16:12 -0400 (Tue, 31 May 2011)
New Revision: 31668
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
Log:
[JBIDE-9023] extracted AS7 marker util methods to their own file (no deprecation - avoids
even more mess - since this is a new API)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2011-05-31
05:28:33 UTC (rev 31667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2011-05-31
09:16:12 UTC (rev 31668)
@@ -32,6 +32,7 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7JSTPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7Server;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.DeploymentMarkerUtils;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -84,6 +85,7 @@
String name = sourcePath.lastSegment();
IStatus result = null;
+ removeDeployFailedMarker(monitor);
// Am I a removal? If yes, remove me, and return
if( publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
@@ -118,19 +120,31 @@
AbstractServerToolsPublisher.getSubMon(monitor, 150)
);
if( JBoss7Server.supportsJBoss7MarkerDeployment(server))
- JBoss7JSTPublisher.addDoDeployMarkerFile(method,
ServerConverter.getDeployableServer(server), module, monitor);
+ DeploymentMarkerUtils.addDoDeployMarker(method,
ServerConverter.getDeployableServer(server), module, monitor);
} catch(CoreException ce) {
return ce.getStatus();
}
return Status.OK_STATUS;
}
+ private IStatus removeDeployFailedMarker(IProgressMonitor monitor) {
+ try {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ if (JBoss7Server.supportsJBoss7MarkerDeployment(server)) {
+ return DeploymentMarkerUtils.removeDeployFailedMarkerIfExists(method, ds, module,
monitor);
+ }
+ } catch(CoreException ce) {
+ return ce.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+
private IStatus removeRemoteDeployment( IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) throws CoreException {
IDeployableServer ds = ServerConverter.getDeployableServer(server);
try {
if( JBoss7Server.supportsJBoss7MarkerDeployment(server))
- return JBoss7JSTPublisher.removeDeployedMarkerFile(method, ds, module, monitor);
+ return DeploymentMarkerUtils.removeDeployedMarkerIfExists(method, ds, module,
monitor);
return removeRemoteDeploymentFolder(sourcePath, destFolder, name, monitor);
} catch(CoreException ce) {
return ce.getStatus();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2011-05-31
05:28:33 UTC (rev 31667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2011-05-31
09:16:12 UTC (rev 31668)
@@ -30,6 +30,7 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7JSTPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7Server;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.DeploymentMarkerUtils;
import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -81,7 +82,7 @@
IDeployableServer ds = ServerConverter.getDeployableServer(server);
String deployRoot = getDeployRoot(module, ds);
if( publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
- JBoss7JSTPublisher.removeDeployedMarkerFile(method, ds, module, monitor);
+ DeploymentMarkerUtils.removeDeployedMarkerIfExists(method, ds, module, monitor);
} else {
LocalZippedPublisherUtil util = new LocalZippedPublisherUtil();
IStatus s = util.publishModule(server, deployRoot, module, publishType, delta,
monitor);
@@ -95,7 +96,7 @@
callback.copyFile(mf, new Path(depPath.lastSegment()), monitor);
// Add marker
- JBoss7JSTPublisher.addDoDeployMarkerFile(method, ds, module, new
NullProgressMonitor());
+ DeploymentMarkerUtils.addDoDeployMarker(method, ds, module, new
NullProgressMonitor());
}
monitor.done();
return s;
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java 2011-05-31
09:16:12 UTC (rev 31668)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.v7;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.util.ModuleFile;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
+
+/**
+ *
+ * @author André Dietisheim
+ *
+ */
+public class DeploymentMarkerUtils {
+
+ public static final String DEPLOYED = ".deployed"; //$NON-NLS-1$
+ public static final String FAILED_DEPLOY = ".failed";//$NON-NLS-1$
+ public static final String DO_DEPLOY = ".dodeploy";//$NON-NLS-1$
+ public static final String DEPLOYING = ".isdeploying";//$NON-NLS-1$
+ public static final String UNDEPLOYING = ".isundeploying";//$NON-NLS-1$
+ public static final String UNDEPLOYED = ".undeployed";//$NON-NLS-1$
+ public static final String SKIP_DEPLOY = ".skipdeploy";//$NON-NLS-1$
+ public static final String PENDING = ".pending";//$NON-NLS-1$
+
+ public static IStatus addDoDeployMarker(IJBossServerPublishMethod
method,IDeployableServer server,
+ IModule[] moduleTree, IProgressMonitor monitor ) throws CoreException {
+ IPath depPath = PublishUtil.getDeployPath(method, moduleTree, server);
+ return addDeployMarker(method, server.getServer(), depPath, monitor);
+ }
+
+ public static IStatus addDeployMarker(IJBossServerPublishMethod method,IServer server,
+ IPath depPath, IProgressMonitor monitor ) throws CoreException {
+ IPath folder = depPath.removeLastSegments(1);
+ IPublishCopyCallbackHandler callback = method.getCallbackHandler(folder, server);
+ callback.copyFile(createBlankModule(), new Path(depPath.lastSegment() + DO_DEPLOY),
monitor);
+ return Status.OK_STATUS;
+ }
+
+ private static IModuleFile createBlankModule() {
+ return new ModuleFile(getBlankFile(), "", new Path("/"));
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private static File getBlankFile() {
+ IPath p =
JBossServerCorePlugin.getDefault().getStateLocation().append("BLANK_FILE");
//$NON-NLS-1$
+ if( !p.toFile().exists()) {
+ try {
+ OutputStream out = new FileOutputStream(p.toFile());
+ if (out != null) {
+ out.close();
+ }
+ } catch(IOException ioe) {}
+ }
+ return p.toFile();
+ }
+
+ public static IStatus removeDeployFailedMarker(
+ IServer server, IPath depPath,
+ IJBossServerPublishMethod method,
+ IProgressMonitor monitor) throws CoreException {
+ return removeFile(FAILED_DEPLOY, server, depPath, method, monitor);
+ }
+
+ private static IStatus removeFile(String suffix,IServer server, IPath
depPath,IJBossServerPublishMethod method,
+ IProgressMonitor monitor) throws CoreException {
+ IPath folder = depPath.removeLastSegments(1);
+ IPublishCopyCallbackHandler callback = method.getCallbackHandler(folder, server);
+ IPath file = new Path(depPath.lastSegment()+suffix);
+ callback.deleteResource(file, monitor);
+ return Status.OK_STATUS;
+ }
+
+ public static IStatus removeDeployedMarkerIfExists(IJBossServerPublishMethod method,
IDeployableServer jbServer, IModule[] module, IProgressMonitor monitor)
+ throws CoreException {
+ return removeDeployedMarkerIfExists(
+ jbServer.getServer(), PublishUtil.getDeployPath(method, module, jbServer), method,
monitor);
+ }
+
+ public static IStatus removeDeployFailedMarkerIfExists(IJBossServerPublishMethod method,
IDeployableServer jbServer, IModule[] module,
+ IProgressMonitor monitor) throws CoreException {
+ IPath depPath = PublishUtil.getDeployPath(method, module, jbServer);
+ return removeDeployedMarkerIfExists(jbServer.getServer(), depPath, method, monitor);
+ }
+
+ public static IStatus removeDeployedMarkerIfExists(IServer server, IPath depPath,
IJBossServerPublishMethod method, IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ return removeFile(DEPLOYED, server, depPath, method, monitor);
+ } catch(Exception e) {
+ return Status.OK_STATUS;
+ }
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java 2011-05-31
05:28:33 UTC (rev 31667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java 2011-05-31
09:16:12 UTC (rev 31668)
@@ -38,29 +38,24 @@
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
public class JBoss7JSTPublisher extends AbstractServerToolsPublisher {
+
// Same as super class but just a *bit* different
public boolean accepts(String method, IServer server, IModule[] module) {
return super.accepts(method, server, module);
// && JBoss7Server.supportsJBoss7MarkerDeployment(server);
}
- public static final String DEPLOYED = ".deployed"; //$NON-NLS-1$
- public static final String FAILED_DEPLOY = ".failed";//$NON-NLS-1$
- public static final String DO_DEPLOY = ".dodeploy";//$NON-NLS-1$
- public static final String DEPLOYING = ".isdeploying";//$NON-NLS-1$
- public static final String UNDEPLOYING = ".isundeploying";//$NON-NLS-1$
- public static final String UNDEPLOYED = ".undeployed";//$NON-NLS-1$
- public static final String SKIP_DEPLOY = ".skipdeploy";//$NON-NLS-1$
- public static final String PENDING = ".pending";//$NON-NLS-1$
-
public IStatus publishModuleToAS7(
IJBossServerPublishMethod method,
IServer server, IModule[] module,
int publishType, IModuleResourceDelta[] delta,
IProgressMonitor monitor) throws CoreException {
IDeployableServer ds = ServerConverter.getDeployableServer(server);
+
+ DeploymentMarkerUtils.removeDeployFailedMarker(server,
PublishUtil.getDeployPath(method, module, ds), method, monitor);
+
if( publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
- JBoss7JSTPublisher.removeDeployedMarkerFile(method, ds, module, monitor);
+ DeploymentMarkerUtils.removeDeployedMarkerIfExists(method, ds, module, monitor);
} else {
IStatus s = super.publishModule(method, server, module, publishType, delta, monitor);
if( module.length == 1 &&
@@ -120,54 +115,4 @@
// if( !list.contains(p))
// list.add(p);
// }
-
- public static IStatus addDoDeployMarkerFile(IJBossServerPublishMethod
method,IDeployableServer server,
- IModule[] moduleTree, IProgressMonitor monitor ) throws CoreException {
- IPath depPath = PublishUtil.getDeployPath(method, moduleTree, server);
- return addDoDeployMarkerFile(method, server.getServer(), depPath, monitor);
- }
-
- public static IStatus addDoDeployMarkerFile(IJBossServerPublishMethod method,IServer
server,
- IPath depPath, IProgressMonitor monitor ) throws CoreException {
- IPath folder = depPath.removeLastSegments(1);
- IPublishCopyCallbackHandler callback = method.getCallbackHandler(folder, server);
- callback.copyFile(createBlankModuleFile(), new Path(depPath.lastSegment() + DO_DEPLOY),
monitor);
- return Status.OK_STATUS;
- }
-
-
- public static IStatus removeDeployedMarkerFile(
- IJBossServerPublishMethod method,
- IDeployableServer jbServer, IModule[] module,
- IProgressMonitor monitor) throws CoreException {
- IPath depPath = PublishUtil.getDeployPath(method, module, jbServer);
- return removeDeployedMarkerFile(jbServer.getServer(), depPath, method, monitor);
- }
- public static IStatus removeDeployedMarkerFile(
- IServer server, IPath depPath,
- IJBossServerPublishMethod method,
- IProgressMonitor monitor) throws CoreException {
- IPath folder = depPath.removeLastSegments(1);
- IPublishCopyCallbackHandler callback = method.getCallbackHandler(folder, server);
- IPath deployed = new Path(depPath.lastSegment()+DEPLOYED);
- callback.deleteResource(deployed, monitor);
- return Status.OK_STATUS;
- }
-
-
- public static IModuleFile createBlankModuleFile() {
- return new ModuleFile(getBlankFile(), "", new Path("/"));
//$NON-NLS-1$ //$NON-NLS-2$
- }
- protected static File getBlankFile() {
- IPath p =
JBossServerCorePlugin.getDefault().getStateLocation().append("BLANK_FILE");
//$NON-NLS-1$
- if( !p.toFile().exists()) {
- try {
- OutputStream out = new FileOutputStream(p.toFile());
- if (out != null) {
- out.close();
- }
- } catch(IOException ioe) {}
- }
- return p.toFile();
- }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-05-31
05:28:33 UTC (rev 31667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-05-31
09:16:12 UTC (rev 31668)
@@ -130,7 +130,7 @@
Iterator<IPath> i = l.iterator();
IPath p;
while (i.hasNext()) {
- JBoss7JSTPublisher.addDoDeployMarkerFile(method, getServer(), i.next(), new
SubProgressMonitor(monitor,
+ DeploymentMarkerUtils.addDeployMarker(method, getServer(), i.next(), new
SubProgressMonitor(monitor,
1));
}
super.publishFinish(new SubProgressMonitor(monitor, 1));