[jbosstools-commits] JBoss Tools SVN: r42486 - in trunk/as: plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server and 4 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Jul 10 02:59:47 EDT 2012
Author: rob.stryker at jboss.com
Date: 2012-07-10 02:59:43 -0400 (Tue, 10 Jul 2012)
New Revision: 42486
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
Log:
JBIDE-12101 to trunk
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -134,6 +134,11 @@
return PublishUtil.getDeployPath(publishMethod, moduleTree, server);
}
+ protected IPath getTempDeployPath(IModule[] moduleTree, IDeployableServer server) {
+ return PublishUtil.getTempDeployPath(publishMethod, moduleTree, server);
+ }
+
+
/**
* Gets the actual deploy path for this module's parent
* Given modules *MUST* be of length 2 or more
@@ -167,10 +172,15 @@
protected void finishPublish(int publishType, IModule[] moduleTree, IDeployableServer server, IProgressMonitor monitor){
}
+
protected IPublishCopyCallbackHandler getCallbackHandler(IPath path) {
return publishMethod.getCallbackHandler(path, server.getServer());
}
-
+
+ protected IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath, IPath tempDeployPath) {
+ return publishMethod.getCallbackHandler(deployPath, tempDeployPath, server.getServer());
+ }
+
/**
* For certain module trees, some publishers may want to force a child to be zipped.
* For example, JST Publisher may want to force utility project children to be zipped.
@@ -191,7 +201,11 @@
Trace.trace(Trace.STRING_FINER, "Begin Handling a full publish for module " + module.getName()); //$NON-NLS-1$
IPath deployPath = getDeployPath(moduleTree, server);
- IPublishCopyCallbackHandler callback = getCallbackHandler(getRootPath(deployPath).append(deployPath));
+ IPath dPathSafe = getRootPath(deployPath).append(deployPath);
+ IPath tempDeployPath = getTempDeployPath(moduleTree, server);
+ IPath dTempPathSafe = getRootPath(tempDeployPath).append(tempDeployPath);
+
+ IPublishCopyCallbackHandler callback = getCallbackHandler(dPathSafe, dTempPathSafe);
IModuleResource[] members = PublishUtil.getResources(module, getSubMon(monitor, 200));
if( monitor.isCanceled())
@@ -399,11 +413,16 @@
monitor.beginTask("Copying Child Module: " + moduleTree[moduleTree.length-1].getName(), 100); //$NON-NLS-1$
try {
IPath destinationPath = getDeployPath(moduleTree, server);
+ IPath tempDeployPath = getTempDeployPath(moduleTree, server);
IPath destinationFolder = destinationPath.removeLastSegments(1);
+ IPath tempDeployFolder = tempDeployPath.removeLastSegments(1);
+ IPath safeDest = getRootPath(destinationFolder).append(destinationFolder);
+ IPath safeTempDest = getRootPath(tempDeployFolder).append(tempDeployFolder);
+
IModuleResource[] members = PublishUtil.getResources(moduleTree);
File source = PublishUtil.getFile(members[0]);
if( source != null ) {
- IPublishCopyCallbackHandler handler = getCallbackHandler(getRootPath(destinationFolder).append(destinationFolder));
+ IPublishCopyCallbackHandler handler = getCallbackHandler(safeDest, safeTempDest);
IPath localFilePath = new Path(source.getAbsolutePath());
ModuleFile mf = new ModuleFile(localFilePath.toFile(), localFilePath.lastSegment(), localFilePath);
handler.copyFile(mf, new Path(destinationPath.lastSegment()), new NullProgressMonitor());
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -33,13 +33,25 @@
public IPublishCopyCallbackHandler getCallbackHandler(IPath path, IServer server) {
IDeployableServer ds = ServerConverter.getDeployableServer(server);
String tempDeployPath = ds.getTempDeployFolder();
- LocalCopyCallback handler = new LocalCopyCallback(server,
- path, new Path(tempDeployPath));
+ return getCallbackHandler(path, new Path(tempDeployPath), server);
+ }
+
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath,
+ IPath tmpFolder, IServer server) {
+ LocalCopyCallback handler = new LocalCopyCallback(
+ server, deployPath, tmpFolder);
return handler;
}
+
public String getPublishDefaultRootFolder(IServer server) {
IDeployableServer s = ServerConverter.getDeployableServer(server);
return s.getDeployFolder();
}
+
+ public String getPublishDefaultRootTempFolder(IServer server) {
+ IDeployableServer s = ServerConverter.getDeployableServer(server);
+ return s.getTempDeployFolder();
+ }
+
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -65,6 +65,8 @@
* All preferences are stored in the "local" setting as it was decided
* having to replicate deploy paths for each publish method was not good
*
+ * This API should be renamed, as it actually gets a value stored at a property key
+ *
* @param moduleTree
* @param server
* @param defaultFolder
@@ -77,6 +79,7 @@
server, defaultFolder, moduleProperty);
}
+ /* This api should be renamed */
public static String getDeployRootFolder(IModule[] moduleTree, String publishMethod,
IDeployableServer server, String defaultFolder, String moduleProperty) {
String folder = defaultFolder;
@@ -208,6 +211,14 @@
return PublishUtil.getDeployPath(moduleTree, folder, server);
}
+ public static IPath getTempDeployPath(IJBossServerPublishMethod method, IModule[] moduleTree, IDeployableServer server) {
+ String defaultFolder = method.getPublishDefaultRootTempFolder(server.getServer());
+ String folder = PublishUtil.getDeployRootFolder(
+ moduleTree, server, defaultFolder,
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC);
+ return PublishUtil.getDeployPath(moduleTree, folder, server);
+ }
+
public static String getSuffix(String type) {
// TODO
// VirtualReferenceUtilities.INSTANCE. has utility methods to help!!
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -34,7 +34,30 @@
*/
public int publishModule(DeployableServerBehavior behaviour, int kind, int deltaKind, IModule[] module, IProgressMonitor monitor) throws CoreException;
- // Methods moved from publishers into the publish method
- public IPublishCopyCallbackHandler getCallbackHandler(IPath path, IServer server);
+ /**
+ * Create a callback handler with the given deploy path and server.
+ * Use a default temporary folder as provided by the server's settings
+ */
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath, IServer server);
+
+ /**
+ * Create a callback handler with the given deploy path and server.
+ * Use a default temporary folder as provided by the server's settings
+ */
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath, IPath tmpFolder, IServer server);
+
+
+ /**
+ * Get the default root deploy folder for this server
+ * @param server
+ * @return
+ */
public String getPublishDefaultRootFolder(IServer server);
+
+ /**
+ * Get the default root TEMP deploy folder for this server
+ * @param server
+ * @return
+ */
+ public String getPublishDefaultRootTempFolder(IServer server);
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -26,6 +26,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerAttributes;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.internal.Server;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
@@ -64,6 +65,7 @@
return server.getAttribute(IDeployableServer.SERVER_MODE, defaultType);
}
+ @Deprecated
public static DeploymentPreferences loadPreferencesFromFile(IServer server) {
File f = getFile(server);
if( f.exists()) {
@@ -86,6 +88,7 @@
return new DeploymentPreferences(bis);
}
+ @Deprecated
public static void savePreferences(IServer server, DeploymentPreferences prefs) throws IOException {
File f = getFile(server);
prefs.getMemento().saveToFile(f.getAbsolutePath());
@@ -262,15 +265,19 @@
}
public static void savePreferencesToServerWorkingCopy(ServerAttributeHelper helper, DeploymentPreferences prefs) {
+ savePreferencesToServerWorkingCopy(helper.getWorkingCopy(), prefs);
+ }
+
+ public static void savePreferencesToServerWorkingCopy(IServerWorkingCopy wc, DeploymentPreferences prefs) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DeploymentPreferenceLoader.savePreferences(bos, prefs);
String asXML = new String(bos.toByteArray());
- helper.setAttribute(DeploymentPreferenceLoader.DEPLOYMENT_PREFERENCES_KEY, asXML);
+ wc.setAttribute(DeploymentPreferenceLoader.DEPLOYMENT_PREFERENCES_KEY, asXML);
} catch(IOException ioe) {
// Should never happen since this is a simple byte array output stream
JBossServerCorePlugin.log(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Could not save module deployment preferences to server " + helper.getServer().getName(), ioe)); //$NON-NLS-1$
+ "Could not save module deployment preferences to server " + wc.getOriginal().getName(), ioe)); //$NON-NLS-1$
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -244,6 +244,10 @@
public String getPublishDefaultRootFolder(IServer server) {
return getRemoteRootFolder().toString();
}
+ public String getPublishDefaultRootTempFolder(IServer server) {
+ // unsupported
+ return getPublishDefaultRootFolder(server);
+ }
private void launchCommandNoResult(DelegatingServerBehavior behaviour, int delay, String command) {
Trace.trace(Trace.STRING_FINER, "Launching remote command: " + command);
@@ -255,4 +259,11 @@
ServerLogger.getDefault().log(behaviour.getServer(), ce.getStatus());
}
}
+
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath,
+ IPath tmpFolder, IServer server) {
+ // Currently RSE support does not copy files to a temporary folder and then renameTo.
+ // In fact, RSE support does not use any temporary folder at all.
+ return getCallbackHandler(deployPath, server);
+ }
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -39,6 +39,7 @@
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeployBinaryChildModuleTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentTester;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentWarUpdateXML;
+import org.jboss.ide.eclipse.as.test.publishing.v2.JSTModuleDeployFoldersTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.Mock2FilterTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.MockJSTPublisherTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.MockJSTPublisherTestDynUtil;
@@ -86,6 +87,7 @@
suite.addTestSuite(TestEar5WithJBossRuntime.class);
suite.addTestSuite(JSTDeploymentTester.class);
suite.addTestSuite(JSTDeployBinaryChildModuleTest.class);
+ suite.addTestSuite(JSTModuleDeployFoldersTest.class);
suite.addTestSuite(SingleFileDeploymentTester.class);
suite.addTestSuite(JBossServerAPITest.class);
suite.addTestSuite(Mock2FilterTest.class);
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2012-07-10 06:07:49 UTC (rev 42485)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2012-07-10 06:59:43 UTC (rev 42486)
@@ -28,27 +28,58 @@
public static final String PUBLISH_METHOD_ID = "mock";
public static final String MOCK_ROOT = "mockRoot";
+ public static final String MOCK_TEMP_ROOT = "mockTempRoot";
public static ArrayList<IPath> changed = new ArrayList<IPath>();
public static ArrayList<IPath> removed = new ArrayList<IPath>();
+ public static ArrayList<IPath> tempFiles = new ArrayList<IPath>();
public static ArrayList<IModuleFile> copiedFiles = new ArrayList<IModuleFile>();
+
+ protected static String expectedRoot = MOCK_ROOT;
+ protected static String expectedTempRoot = MOCK_TEMP_ROOT;
+
public IPublishCopyCallbackHandler getCallbackHandler(IPath path,
IServer server) {
- return new MockCopyCallbackHandler(path);
+ return new MockCopyCallbackHandler(path, null);
}
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath,
+ IPath tmpFolder, IServer server) {
+ return new MockCopyCallbackHandler(deployPath, tmpFolder);
+ }
+
+
public String getPublishDefaultRootFolder(IServer server) {
return "/" + MOCK_ROOT;
}
+ public String getPublishDefaultRootTempFolder(IServer server) {
+ return "/" + MOCK_TEMP_ROOT;
+ }
+
+
+
+
public String getPublishMethodId() {
return PUBLISH_METHOD_ID;
}
public static void reset() {
changed.clear();
removed.clear();
+ tempFiles.clear();
copiedFiles.clear();
+ expectedRoot = MOCK_ROOT;
+ expectedTempRoot = MOCK_TEMP_ROOT;
}
+
+ public static void setExpectedRoot(String s) {
+ expectedRoot = s;
+ }
+
+ public static void setExpectedTempRoot(String s) {
+ expectedTempRoot = s;
+ }
+
public static IPath[] getRemoved() {
return (IPath[]) removed.toArray(new IPath[removed.size()]);
}
@@ -59,16 +90,24 @@
public static IPath[] getChanged() {
return (IPath[]) changed.toArray(new IPath[changed.size()]);
}
+ public static IPath[] getTempPaths() {
+ return (IPath[]) tempFiles.toArray(new IPath[tempFiles.size()]);
+ }
public class MockCopyCallbackHandler implements IPublishCopyCallbackHandler {
- private IPath root;
- public MockCopyCallbackHandler(IPath root) {
- if( !(new Path(MOCK_ROOT).isPrefixOf(root))) {
+ private IPath root, tempRoot;
+ public MockCopyCallbackHandler(IPath root, IPath tempRoot) {
+ if( !(new Path(expectedRoot).isPrefixOf(root))) {
System.out.println("Expected " + new Path(MOCK_ROOT) + " but got: " + root.toString());
throw new RuntimeException("Unacceptable use of callback handler");
}
+ if( tempRoot != null && !(new Path(expectedTempRoot).isPrefixOf(tempRoot))) {
+ System.out.println("Expected " + new Path(MOCK_TEMP_ROOT) + " but got: " + root.toString());
+ throw new RuntimeException("Unacceptable use of callback handler");
+ }
this.root = root;
+ this.tempRoot = tempRoot;
}
public IStatus[] deleteResource(IPath path, IProgressMonitor monitor)
@@ -102,6 +141,8 @@
IPath path2 = root.append(path);
if( !changed.contains(path2.makeRelative()))
changed.add(path2.makeRelative());
+ IPath tmpFile = (tempRoot == null ? root : tempRoot).append(path);
+ tempFiles.add(tmpFile);
copiedFiles.add(mf);
return new IStatus[]{};
}
More information about the jbosstools-commits
mailing list