summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-05-10 09:16:49 (EDT)
committerStephan Born2012-05-16 05:10:50 (EDT)
commitb67f4c3b420dbc1b387824ea3bd5ae03ccdde87b (patch)
tree6c699a0eb000ca3b65227632c4fcb603e8331471
parentc179d1def2c217bd6fc5dc5826e785fb3c78b0ff (diff)
downloadorg.eclipse.stardust.ide.wst-b67f4c3b420dbc1b387824ea3bd5ae03ccdde87b.zip
org.eclipse.stardust.ide.wst-b67f4c3b420dbc1b387824ea3bd5ae03ccdde87b.tar.gz
org.eclipse.stardust.ide.wst-b67f4c3b420dbc1b387824ea3bd5ae03ccdde87b.tar.bz2
Removed clas which has been comitted accidentally.
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide.wst@56215 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--org.eclipse.stardust.ide.wst.server.tomcat/IppConfigPublisher.java454
1 files changed, 0 insertions, 454 deletions
diff --git a/org.eclipse.stardust.ide.wst.server.tomcat/IppConfigPublisher.java b/org.eclipse.stardust.ide.wst.server.tomcat/IppConfigPublisher.java
deleted file mode 100644
index aeb440b..0000000
--- a/org.eclipse.stardust.ide.wst.server.tomcat/IppConfigPublisher.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 SunGard CSA LLC 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:
- * SunGard CSA LLC - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package ag.carnot.bpm.wst.server.tomcat;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import nu.xom.Document;
-
-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.eclipse.core.resources.ResourcesPlugin;
-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.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerPort;
-import org.eclipse.wst.server.core.TaskModel;
-import org.eclipse.wst.server.core.model.PublisherDelegate;
-
-import com.infinity.bpm.ide.wst.portals.IPPPortalBundleActivator;
-
-import ag.carnot.base.CompareHelper;
-import ag.carnot.bpm.wst.common.utils.FacetSetupUtils;
-import ag.carnot.bpm.wst.common.utils.ProjectSetupUtils;
-import ag.carnot.bpm.wst.utils.TomcatContextUtils;
-import ag.carnot.eclipse.utils.BundleUtils;
-import ag.carnot.utils.io.CloseableUtil;
-import ag.carnot.ws.axis.utils.StringUtils;
-
-/**
- * Checks if the the configuration for this project has changed
- * (new license path or new server port) ,applies the changes if necessary
- * and publishes the changes to the server
- *
- * @author Holger
- * @version $Revision: $
- */
-@SuppressWarnings("restriction")
-public class IppConfigPublisher extends PublisherDelegate
-{
- private final String WEB_MODULE_CRITERIA = "jst.web"; //$NON-NLS-1$
-
- private final String DEPLOY_FOLDER = "WEB-INF/classes"; //$NON-NLS-1$
-
- private boolean moduleModified = false;
-
- @SuppressWarnings({"rawtypes"})
- @Override
- public IStatus execute(int kind, IProgressMonitor monitor, IAdaptable info)
- throws CoreException
- {
- TaskModel tm = getTaskModel();
- IServer server = (IServer) tm.getObject(TaskModel.TASK_SERVER);
- List modules = (List) tm.getObject(TaskModel.TASK_MODULES);
- IModule webModule = findWebModule(modules);
-
- if (webModule != null)
- {
- IProject project = webModule.getProject();
- if (isIppProject(project))
- {
- if (!isLicenseSetInUi())
- {
- new UIJob(Tomcat_Messages.TXT_INFINITY_DEPLOYMENT)
- {
- public IStatus runInUIThread(IProgressMonitor monitor)
- {
- MessageDialog
- .openWarning(
- null,
- Tomcat_Messages.MSG_DIA_INFINITY_DEPLOYMENT,
- Tomcat_Messages.MSG_DIA_YOUR_ECLIPSE_WORKSPACE_WAS_NOT_CORRECTLY_CONFIGURED);
- return Status.OK_STATUS;
- }
- }.schedule();
- return Status.OK_STATUS;
- }
- else
- {
- IWebModule webModuleAdapter = (IWebModule) webModule
- .getAdapter(IWebModule.class);
- TomcatServerBehaviour tomcatServer = (TomcatServerBehaviour) server
- .loadAdapter(TomcatServerBehaviour.class, null);
- IPath deployProjectPath = tomcatServer.getModuleDeployDirectory(webModule);
- File deployFolder = new File(deployProjectPath.toOSString(), DEPLOY_FOLDER);
-
- applyChanges(monitor, server, webModuleAdapter, project, deployFolder);
- }
- }
-
- }
-
- return Status.OK_STATUS;
- }
-
- private void copyModifiedFiles(List<File> filesCopy, File deployFolder)
- throws IOException
- {
- for (File fileToCopy : filesCopy)
- {
- if(fileToCopy.exists() && deployFolder.exists())
- {
- File targetFile = new File(deployFolder, fileToCopy.getName());
- if (targetFile.exists())
- {
- targetFile.delete();
-
- }
- targetFile.createNewFile();
- copy(fileToCopy, targetFile);
- }
- }
- }
-
- //TODO: use file utility class
- private void copy(File source, File target) throws IOException
- {
- if (source.exists())
- {
- if (!target.exists())
- {
- target.createNewFile();
- }
-
- FileInputStream in = null;
- FileOutputStream out = null;
- try
- {
- in = new FileInputStream(source);
- out = new FileOutputStream(target);
- byte[] buffer = new byte[4096];
- int bytesRead;
-
- while ((bytesRead = in.read(buffer)) != -1)
- {
- out.write(buffer, 0, bytesRead);
- }
- out.flush();
- }
- finally
- {
- CloseableUtil.closeQuietly(in);
- CloseableUtil.closeQuietly(out);
- }
- }
- }
-
- private boolean isIppProject(IProject prj)
- {
- if (prj != null)
- {
- // ipp project - check for modified resources
- IResource resConfig = prj.findMember(ProjectSetupUtils.IPP_RESOURCE_FOLDER);
- if ((null != resConfig) && resConfig.exists() && (resConfig instanceof IFolder))
- {
- return true;
- }
- }
- return false;
- }
-
- private void applyChanges(IProgressMonitor monitor, IServer server,
- IWebModule webModule, IProject prj, File deployFolder) throws CoreException
- {
- List<File> modifiedFiles = new ArrayList<File>();
- IPath wsRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation();
-
- // check for modified resources
- IResource resConfig = prj.findMember(ProjectSetupUtils.IPP_RESOURCE_FOLDER);
- if ((null != resConfig) && resConfig.exists() && (resConfig instanceof IFolder))
- {
- File changedResource = null;
- IFolder configFolder = (IFolder) resConfig;
- changedResource = updateRemotingFile(server, webModule, configFolder, wsRoot);
- if (changedResource != null)
- {
- modifiedFiles.add(changedResource);
- }
-
- changedResource = updateLicenseFile(configFolder, wsRoot);
- if (changedResource != null)
- {
- modifiedFiles.add(changedResource);
- }
-
- updateContextFile(prj, wsRoot);
-
- // files have been modified
- if (!modifiedFiles.isEmpty())
- {
- moduleModified = true;
- try
- {
- copyModifiedFiles(modifiedFiles, deployFolder);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
-
- new RefreshJob(configFolder).schedule();
- }
- }
- }
-
- private File updateRemotingFile(IServer server, IWebModule webModule,
- IFolder configFolder, IPath wsRoot)
- {
- File modifiedResource = null;
-
- int httpPort = -1;
- ServerPort[] ports = server.getServerPorts(null);
- for (int i = 0; i < ports.length; i++)
- {
- if ("HTTP".equals(ports[i].getProtocol())) //$NON-NLS-1$
- {
- httpPort = ports[i].getPort();
- break;
- }
- }
- String baseUrl = "http://localhost"; //$NON-NLS-1$
- if (-1 != httpPort)
- {
- baseUrl += ":" + httpPort; //$NON-NLS-1$
- }
-
- IResource properties = configFolder.findMember("carnot-spring-client.properties"); //$NON-NLS-1$
- if (properties.exists() && (properties instanceof IFile))
- {
- File fRemotingProps = wsRoot.append(properties.getFullPath()).toFile();
- try
- {
- FileInputStream propsIn = new FileInputStream(fRemotingProps);
- Properties props = new Properties();
- props.load(propsIn);
- propsIn.close();
-
- String remotingUrl = baseUrl + "/" + webModule.getContextRoot() + "/remoting"; //$NON-NLS-1$ //$NON-NLS-2$
- if (!CompareHelper.areEqual(remotingUrl,
- props.get("Carnot.Spring.RemotingUrl"))) //$NON-NLS-1$
- {
- props.put("Carnot.Spring.RemotingUrl", remotingUrl); //$NON-NLS-1$
- FileOutputStream fosProps = new FileOutputStream(fRemotingProps);
- try
- {
- props.store(fosProps, "Infinity Spring Remoting"); //$NON-NLS-1$
- }
- finally
- {
- CloseableUtil.closeQuietly(fosProps);
- }
-
- modifiedResource = fRemotingProps;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- return modifiedResource;
- }
-
- private File updateLicenseFile(IFolder configFolder, IPath wsRoot)
- {
- File modifiedResource = null;
-
- IResource properties = configFolder.findMember("carnot.properties"); //$NON-NLS-1$
- if (properties.exists() && (properties instanceof IFile))
- {
- String uiLicensePath = ProjectSetupUtils.getLicensePath();
- Properties props = new Properties();
- File carnotPropsFile = wsRoot.append(properties.getFullPath()).toFile();
-
- try
- {
- FileInputStream propsIn = new FileInputStream(carnotPropsFile);
- props.load(propsIn);
- propsIn.close();
-
- String propLicensePath = (String) props.get("License.LicenseFilePath"); //$NON-NLS-1$
- // if license path is default or different in the ui - update the properties
- // file
- if (CompareHelper.areEqual(ProjectSetupUtils.LICENSE_PATH_TOKEN,
- propLicensePath)
- || !CompareHelper.areEqual(uiLicensePath, propLicensePath))
- {
- Map<String, String> antProps = new HashMap<String, String>();
- antProps.put("licensePath", uiLicensePath); //$NON-NLS-1$
- antProps.put("configDir", wsRoot.append(configFolder.getFullPath()) //$NON-NLS-1$
- .toOSString());
- antProps.put("carnotPropFile", wsRoot.append(properties.getFullPath()) //$NON-NLS-1$
- .toOSString());
-
- IPath srcFolder = BundleUtils.getBundleLocation(IPPPortalBundleActivator
- .getInstance().getBundle());
- FacetSetupUtils.executeAntTarget(null,
- srcFolder.append("tools/templates.xml"), "replaceLicensePath", //$NON-NLS-1$ //$NON-NLS-2$
- antProps);
-
- modifiedResource = new File(properties.getRawLocation().toOSString());
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- return modifiedResource;
- }
-
- private void updateContextFile(IProject prj, IPath wsRoot)
- {
- IResource resMetaInf = prj.findMember("carnot-processportal/META-INF"); //$NON-NLS-1$
- if ((null != resMetaInf) && resMetaInf.exists() && (resMetaInf instanceof IFolder))
- {
- IFolder metaInfFolder = (IFolder) resMetaInf;
-
- IResource configXml = metaInfFolder.findMember("context.xml"); //$NON-NLS-1$
- if (configXml.exists() && (configXml instanceof IFile))
- {
- File fContextXml = wsRoot.append(configXml.getFullPath()).toFile();
- try
- {
- Document dContextXml = TomcatContextUtils.loadTomcatContext(fContextXml);
- if (null != dContextXml)
- {
- boolean contextIsDirty = TomcatContextUtils.updateAuditTrailResLink(
- dContextXml, "jdbc/AuditTrail.DataSource", //$NON-NLS-1$
- "AuditTrail.DataSource"); //$NON-NLS-1$
- if (contextIsDirty)
- {
- TomcatContextUtils.saveTomcatContext(fContextXml, dContextXml);
- configXml.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- }
-
- @Override
- public boolean isModifyModules()
- {
- return moduleModified;
- }
-
- private boolean isLicenseSetInUi()
- {
- boolean licenseSet = false;
- String licensePath = ProjectSetupUtils.getLicensePath();
- if (!StringUtils.isEmpty(licensePath)
- && !CompareHelper.areEqual(licensePath, ProjectSetupUtils.LICENSE_PATH_TOKEN))
- {
- licenseSet = true;
- }
- return licenseSet;
- }
-
- @SuppressWarnings("rawtypes")
- private IModule findWebModule( List modules)
- {
- for (int i = 0; i < modules.size(); ++i)
- {
- IModule[] nestedModules = (IModule[]) modules.get(i);
- for (int j = 0; j < nestedModules.length; j++)
- {
- IModule module = nestedModules[j];
- if (isWebModule(module))
- {
- return module;
- }
- }
- }
-
- return null;
- }
-
- private boolean isWebModule(IModule module)
- {
- boolean isWebModule = false;
- String typeId = module.getModuleType().getId();
-
- if (typeId.indexOf(WEB_MODULE_CRITERIA) != -1)
- {
- isWebModule = true;
- }
-
- return isWebModule;
- }
-
- private class RefreshJob extends Job
- {
- private IFolder configFolder;
-
- RefreshJob(IFolder configFolder)
- {
- super(Tomcat_Messages.TXT_REFRESHING_RESOURCE_FOLDER);
- this.configFolder = configFolder;
- }
-
- public boolean belongsTo(Object family)
- {
- return family == ResourcesPlugin.FAMILY_MANUAL_REFRESH;
- }
-
- protected IStatus run(IProgressMonitor pm)
- {
- try
- {
- configFolder.refreshLocal(IResource.DEPTH_INFINITE, pm);
- }
- catch (CoreException e)
- {
- return e.getStatus();
- }
- return Status.OK_STATUS;
- }
- }
-}