| /******************************************************************************* |
| * Copyright (c) 2005 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.jst.server.tomcat.core.internal; |
| |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.core.runtime.IAdaptable; |
| import org.eclipse.core.runtime.IPath; |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.jst.server.core.PublishUtil; |
| import org.eclipse.wst.server.core.IModule; |
| import org.eclipse.wst.server.core.IServer; |
| import org.eclipse.wst.server.core.model.IModuleResource; |
| import org.eclipse.wst.server.core.model.IModuleResourceDelta; |
| import org.eclipse.wst.server.core.model.PublishOperation; |
| import org.eclipse.wst.server.core.util.ProjectModule; |
| |
| public class PublishOperation2 extends PublishOperation { |
| protected TomcatServerBehaviour server; |
| protected IModule module; |
| protected int kind; |
| protected int deltaKind; |
| |
| public PublishOperation2(TomcatServerBehaviour server, int kind, IModule module, int deltaKind) { |
| super("Publish to server", "Publish Web module to Tomcat server"); |
| this.server = server; |
| this.module = module; |
| this.kind = kind; |
| this.deltaKind = deltaKind; |
| } |
| |
| public int getOrder() { |
| return 0; |
| } |
| |
| public int getKind() { |
| return REQUIRED; |
| } |
| |
| public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException { |
| IPath path = server.getTempDirectory().append("webapps"); |
| path = path.append(module.getName()); |
| |
| if (kind == IServer.PUBLISH_CLEAN) { // clean and republish from scratch |
| PublishUtil.deleteDirectory(path.toFile(), monitor); |
| } |
| |
| if (kind == IServer.PUBLISH_CLEAN || kind == IServer.PUBLISH_FULL) { |
| ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, monitor); |
| IModuleResource[] mr = pm.members(); |
| PublishUtil.copy(mr, path); |
| return; |
| } |
| |
| IModuleResourceDelta[] delta = server.getPublishedResourceDelta(new IModule[] { module }); |
| |
| int size = delta.length; |
| for (int i = 0; i < size; i++) { |
| PublishUtil.handleDelta(kind, path, delta[i]); |
| } |
| } |
| } |