Author: rob.stryker(a)jboss.com
Date: 2010-07-20 06:00:57 -0400 (Tue, 20 Jul 2010)
New Revision: 23583
Added:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/rse/
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/rse/RSEZippedJSTPublisher.java
Log:
RSE - not sure why this wasn't added
Added:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/rse/RSEZippedJSTPublisher.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/rse/RSEZippedJSTPublisher.java
(rev 0)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/rse/RSEZippedJSTPublisher.java 2010-07-20
10:00:57 UTC (rev 23583)
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ * TODO: Logging and Progress Monitors
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.webtools.modules.rse;
+
+import java.io.File;
+import java.util.ArrayList;
+
+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.Status;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+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.model.IModuleResourceDelta;
+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.IJBossServerConstants;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.LocalCopyCallback;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.rse.core.AbstractJSTPublisher;
+import org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod;
+
+public class RSEZippedJSTPublisher extends AbstractJSTPublisher {
+
+ private RSEPublishMethod method;
+
+ @Override
+ protected String getTargetedPublishMethodId() {
+ return RSEPublishMethod.RSE_ID;
+ }
+
+ @Override
+ protected boolean zipSettingsMatch() {
+ // TODO handle this
+ return true;
+ }
+
+ @Override
+ public IStatus publishModule(IJBossServerPublishMethod method,
+ IServer server, IModule[] module, int publishType,
+ IModuleResourceDelta[] delta, IProgressMonitor monitor)
+ throws CoreException {
+ this.method = (RSEPublishMethod)method;
+ return super.publishModule(method, server, module, publishType, delta, monitor);
+ }
+
+ @Override
+ protected IPath getDeployPath(IModule[] moduleTree, IDeployableServer server) {
+ String folder = PublishUtil.getDeployRootFolder(
+ moduleTree, server,
+ method.getRemoteRootFolder().toString(),
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
+ return PublishUtil.getDeployPath(moduleTree, folder);
+ }
+
+ @Override
+ protected IPublishCopyCallbackHandler getCallbackHandler(IPath path, IServer server,
+ IJBossServerPublishMethod method) {
+ IPath tempRoot = JBossServerCorePlugin.getServerStateLocation(server)
+ .append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute();
+ IPath remoteRoot = JBossServerCorePlugin.getServerStateLocation(server)
+ .append(IJBossServerConstants.TEMP_REMOTE_DEPLOY).makeAbsolute();
+ return new LocalCopyCallback(server, remoteRoot, tempRoot);
+ }
+
+ protected class RSERemotePublishHandler implements IPublishCopyCallbackHandler {
+ public IPath root;
+ private ArrayList<IPath> createdFolders = new ArrayList<IPath>();
+ public RSERemotePublishHandler(IPath path) {
+ this.root = path;
+ }
+ public IStatus[] copyFile(IModuleFile mf, IPath path,
+ IProgressMonitor monitor) throws CoreException {
+ File file = PublishUtil.getFile(mf);
+ IPath remotePath = root.append(path);
+ try {
+ method.getFileService().upload(file, remotePath.removeLastSegments(1).toString(),
+ remotePath.lastSegment(), true, null, null, monitor);
+ } catch( SystemMessageException sme ) {
+ System.err.println("failed to copy to " + remotePath.toString());
//$NON-NLS-1$
+ }
+ return null;
+ }
+
+ public IStatus[] deleteResource(IPath path, IProgressMonitor monitor)
+ throws CoreException {
+ IPath remotePath = root.append(path);
+ try {
+ method.getFileService().delete(remotePath.removeLastSegments(1).toString(),
remotePath.lastSegment(), monitor);
+ } catch( SystemMessageException sme ) {
+ System.err.println("failed to delete " + remotePath.toString());
//$NON-NLS-1$
+ }
+ return null;
+ }
+
+ public IStatus[] makeDirectoryIfRequired(IPath dir,
+ IProgressMonitor monitor) throws CoreException {
+ if( dir.segmentCount() > 0 )
+ makeDirectoryIfRequired(dir.removeLastSegments(1), monitor);
+ IPath toMake = root.append(dir);
+ if( createdFolders.contains(toMake))
+ return new IStatus[]{Status.OK_STATUS};
+ try {
+ method.getFileService().createFolder(toMake.removeLastSegments(1).toString(),
toMake.lastSegment(), monitor);
+ } catch( SystemMessageException sme ) {
+ System.err.println("failed to make folder " + toMake.toString());
//$NON-NLS-1$
+ }
+ createdFolders.add(toMake);
+ return null;
+ }
+ }
+
+ @Override
+ protected void finishPublish(int publishType, IModule[] moduleTree,
+ IDeployableServer server, IProgressMonitor monitor) {
+ // do nothing
+ }
+}