diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/j2eeplugin/org')
50 files changed, 0 insertions, 7030 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/DelegateConfigurationElement.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/DelegateConfigurationElement.java deleted file mode 100644 index f19bcd66e..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/DelegateConfigurationElement.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Created on Dec 14, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.InvalidRegistryObjectException; - -/** - * An object which represents the user-defined contents of an extension in a plug-in manifest. - */ -public class DelegateConfigurationElement implements IConfigurationElement { - - private final IConfigurationElement delegateElement; - private static final String DELEGATE_NAME = "delegateConfigurationElement"; //$NON-NLS-1$ - private static final String DELEGATE_NAMESPACE = "delegateConfigurationElementNamespace"; //$NON-NLS-1$ - private static final String DELEGATE_NULL_STRING = "delegateConfigurationElement: NULL"; //$NON-NLS-1$ - - public DelegateConfigurationElement(IConfigurationElement aDelegate) { - delegateElement = aDelegate; - } - - /** - * @param propertyName - * @return - * @throws org.eclipse.core.runtime.CoreException - */ - public Object createExecutableExtension(String propertyName) throws CoreException { - if (delegateElement == null) - return null; - return delegateElement.createExecutableExtension(propertyName); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (delegateElement == null) - return false; - return delegateElement.equals(obj); - } - - /** - * @param name - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getAttribute(String name) throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getAttribute(name); - } - - /** - * @param name - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getAttributeAsIs(String name) throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getAttributeAsIs(name); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String[] getAttributeNames() throws InvalidRegistryObjectException { - if (delegateElement == null) - return new String[0]; - return delegateElement.getAttributeNames(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException { - if (delegateElement == null) - return new IConfigurationElement[0]; - return delegateElement.getChildren(); - } - - /** - * @param name - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException { - if (delegateElement == null) - return new IConfigurationElement[0]; - return delegateElement.getChildren(name); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public IExtension getDeclaringExtension() throws InvalidRegistryObjectException { - if (delegateElement == null) - throw new InvalidRegistryObjectException(); - return delegateElement.getDeclaringExtension(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getName() throws InvalidRegistryObjectException { - if (delegateElement == null) - return DELEGATE_NAME; - return delegateElement.getName(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getNamespace() throws InvalidRegistryObjectException { - if (delegateElement == null) - return DELEGATE_NAMESPACE; - return delegateElement.getNamespace(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public Object getParent() throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getParent(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getValue() throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getValue(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getValueAsIs() throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getValueAsIs(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - if (delegateElement == null) - return -1; - return delegateElement.hashCode(); - } - - /** - * @return - */ - public boolean isValid() { - - if (delegateElement == null) - return false; - return delegateElement.isValid(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - public String toString() { - if (delegateElement == null) - return DELEGATE_NULL_STRING; - return delegateElement.toString(); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/IBackendManager.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/IBackendManager.java deleted file mode 100644 index a96222439..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/IBackendManager.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal; - - -import java.util.List; - -import org.eclipse.jst.j2ee.internal.project.J2EENature; - - -/** - * @author cbridgha - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - */ -public interface IBackendManager { - public List getAllBackendIDs(); - - public void setNature(J2EENature nature); - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEEditModel.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEEditModel.java deleted file mode 100644 index a87f60482..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEEditModel.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal; - - -import org.eclipse.jst.common.jdt.internal.integration.WorkingCopyManager; -import org.eclipse.jst.common.jdt.internal.integration.WorkingCopyManagerFactory; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.jst.j2ee.webservice.wsclient.WebServicesResource; -import org.eclipse.wst.common.frameworks.internal.activities.WTPActivityBridge; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelEvent; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelListener; - - -/** - * This class is used by clients (mainly editors) when there is an intent to modify a resource - * within the Workbench. All clients with a specific key (this specifies a grouping of common - * resources), will get the same instance of the J2EEEditModel. Clients will obtain resources - * through this edit model. A client can add themselves as a listener (@see J2EEEditModelListener). - * This will allow clients to fire property change notifications when a J2EEEditModelEvent is - * detected. This helps to synchronize editors within the Workbench. There is no need for editors to - * add themselves as CommandStack listeners because this edit model will catch CommandStack changes - * and forward them to all listeners as J2EEEditModelEvents. - * - * A J2EEEditModel is obtained from the J2EENature (@see getEditModel(Object)). - * - * TIPS ON USING THIS EDIT MODEL: - * - * To determine if a client needs to save (e.g., <code>isSaveNeeded()</code>), one should call - * <code>isDirty()</code>. - * - * To determine if a client needs to save when closing (e.g., <code>isSaveOnCloseNeeded()</code>), - * one should call <code>needsToSave()</code>. - * - * When the main client (editor) performs a save (e.g., <code>doSave()</code>), they should call - * <code>save()</code>. - * - * If a wizard or another client needs to save the resources but they are not the primary editor, - * <code>saveIfNecessary()</code> should be called. This will save the resources only if there are - * no other references to this edit model. - * - * When disposing the client, <code>releaseAccess</code> should be called. - * - * @deprecated - * Use - * <p> - * ArtifactEdit - * </p> - */ -public class J2EEEditModel extends EditModel { - - private WorkingCopyManager workingCopyManager = null; - - /** - * J2EEEditModel constructor comment. - */ - public J2EEEditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly) { - super(editModelID, context, readOnly); - } - - /** - * J2EEEditModel constructor comment. - */ - public J2EEEditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly, boolean accessUnkownResourcesAsReadOnly) { - super(editModelID, context, readOnly); - } - - /** - * This will be the type of the deployment descriptor docuemnt. Subclasses should override if - * they have a deployment descriptor. - * - * @see XMLResource#APP_CLIENT_TYPE - * @see XMLResource#APPLICATION_TYPE - * @see XMLResource#EJB_TYPE - * @see XMLResource#WEB_APP_TYPE - * @see XMLResource#RAR_TYPE - */ - public int getDeploymentDescriptorType() { - if (getJ2EENature() != null) - return getJ2EENature().getDeploymentDescriptorType(); - return -1; - } - - /** - * Subclasses should override to return the proper deployment descriptor resource. - */ - public XMLResource getDeploymentDescriptorResource() { - return null; - } - - public J2EENature getJ2EENature() { - return J2EENature.getRegisteredRuntime(getProject()); - } - - - public WebServicesResource get13WebServicesClientResource() { - return null; - } - - - private ActivityEditModelListener activityEditModelListener = null; - - private class ActivityEditModelListener implements EditModelListener { - public void editModelChanged(EditModelEvent anEvent) { - if (anEvent.getEventCode() == EditModelEvent.DIRTY) { - try { - WTPActivityBridge.getInstance().enableActivity(getDevelopmentAcivityID(), true); - } finally { - removeListener(this); - activityEditModelListener = null; - } - } - } - } - - public void notifyActivityChanges(boolean b) { - if (null != activityEditModelListener || null == getDevelopmentAcivityID()) { - return; - } - activityEditModelListener = new ActivityEditModelListener(); - getListeners().add(activityEditModelListener); - } - - public String getDevelopmentAcivityID() { - return null; - } - - /** - * Returns the working copy remembered for the compilation unit. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if there is no - * remembered working copy for this compilation unit - */ - public org.eclipse.jdt.core.ICompilationUnit getWorkingCopy(org.eclipse.jdt.core.ICompilationUnit cu, boolean forNewCU) throws org.eclipse.core.runtime.CoreException { - if (isReadOnly()) - return null; - return getWorkingCopyManager().getWorkingCopy(cu, forNewCU); - } - - public WorkingCopyManager getWorkingCopyManager() { - if (workingCopyManager == null) - workingCopyManager = WorkingCopyManagerFactory.newRegisteredInstance(); - return workingCopyManager; - } - - /** - * Reset the working copy manager because the ejb-jar.xml was removed without disposing. - */ - protected void resetWorkingCopyManager() { - if (workingCopyManager != null) { - workingCopyManager.dispose(); - workingCopyManager = null; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEModulePostImportHandler.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEModulePostImportHandler.java deleted file mode 100644 index d99420ee2..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEModulePostImportHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Jun 9, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.core.resources.IProject; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface J2EEModulePostImportHandler { - - public void moduleImported(IProject moduleProject); - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEModulePostImportHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEModulePostImportHelper.java deleted file mode 100644 index c14eafb9e..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/J2EEModulePostImportHelper.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Jun 9, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPluginResourceHandler; - - -/** - * @author jsholl - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class J2EEModulePostImportHelper { - - private static final String WEB = J2EEPluginResourceHandler.getString("J2EEModulePostImportHelper.0"); //$NON-NLS-1$ - private static final String EJB = J2EEPluginResourceHandler.getString("J2EEModulePostImportHelper.1"); //$NON-NLS-1$ - private static final String APP_CLIENT = J2EEPluginResourceHandler.getString("J2EEModulePostImportHelper.2"); //$NON-NLS-1$ - private static final String CONNECTOR = J2EEPluginResourceHandler.getString("J2EEModulePostImportHelper.3"); //$NON-NLS-1$ - - private static IConfigurationElement[] webExtensions = null; - private static IConfigurationElement[] ejbExtensions = null; - private static IConfigurationElement[] appClientExtensions = null; - private static IConfigurationElement[] connectorExtensions = null; - - private static boolean firstTimeLoading = true; - - public static void notifyWebExtensions(IProject project) { - if (webExtensions == null) { - loadConfiguration(WEB); - } - notifyExtensions(webExtensions, project); - } - - public static void notifyEjbExtensions(IProject project) { - if (ejbExtensions == null) { - loadConfiguration(EJB); - } - notifyExtensions(ejbExtensions, project); - } - - public static void notifyAppClientExtensions(IProject project) { - if (appClientExtensions == null) { - loadConfiguration(APP_CLIENT); - } - notifyExtensions(appClientExtensions, project); - } - - public static void notifyConnectorExtensions(IProject project) { - if (connectorExtensions == null) { - loadConfiguration(CONNECTOR); - } - notifyExtensions(connectorExtensions, project); - } - - private static void notifyExtensions(IConfigurationElement[] postImportElement, IProject project) { - for (int i = 0; i < postImportElement.length; i++) { - try { - J2EEModulePostImportHandler postCreate = (J2EEModulePostImportHandler) postImportElement[i].createExecutableExtension("className"); //$NON-NLS-1$ - postCreate.moduleImported(project); - } catch (CoreException e) { - e.printStackTrace(); - } - } - } - - private static void loadConfiguration(final String loadingModuleType) { - boolean shouldLogErrors = firstTimeLoading; - firstTimeLoading = false; - - J2EEPlugin plugin = J2EEPlugin.getPlugin(); - IExtension[] importExtensions = plugin.getDescriptor().getExtensionPoint("J2EEModulePostImport").getExtensions(); //$NON-NLS-1$ - - ArrayList interestedExtensions = new ArrayList(); - for (int i = 0; i < importExtensions.length; i++) { - IExtension extension = importExtensions[i]; - IConfigurationElement[] configElements = extension.getConfigurationElements(); - boolean isExtensionInterested = false; - IConfigurationElement postImportElement = null; - int moduleCount = 0; - for (int j = 0; j < configElements.length; j++) { - try { - IConfigurationElement element = configElements[j]; - if (element.getName().equalsIgnoreCase("postImport")) { //$NON-NLS-1$ - postImportElement = element; - } else if (element.getName().equalsIgnoreCase(("module"))) { //$NON-NLS-1$ - moduleCount++; - if (!isExtensionInterested) { - String moduleType = element.getAttribute("type"); //$NON-NLS-1$ - if (WEB == loadingModuleType && WEB.equalsIgnoreCase(moduleType)) { - isExtensionInterested = true; - } else if (EJB == loadingModuleType && EJB.equalsIgnoreCase(moduleType)) { - isExtensionInterested = true; - } else if (APP_CLIENT == loadingModuleType && APP_CLIENT.equalsIgnoreCase(moduleType)) { - isExtensionInterested = true; - } else if (CONNECTOR == loadingModuleType && CONNECTOR.equalsIgnoreCase(moduleType)) { - isExtensionInterested = true; - } - } - } - } catch (Exception e) { - if (shouldLogErrors) { - e.printStackTrace(); - } - } - } - - //if no module types are defined the default is to listen to all of them. - if (!isExtensionInterested && 0 == moduleCount) { - isExtensionInterested = true; - } - - if (isExtensionInterested) { - try { - //try instantiating the class before adding it to the list. - postImportElement.createExecutableExtension("className"); //$NON-NLS-1$ - interestedExtensions.add(postImportElement); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - IConfigurationElement[] configElements = new IConfigurationElement[interestedExtensions.size()]; - for (int i = 0; i < configElements.length; i++) { - configElements[i] = (IConfigurationElement) interestedExtensions.get(i); - } - if (WEB == loadingModuleType) { - webExtensions = configElements; - } else if (EJB == loadingModuleType) { - ejbExtensions = configElements; - } else if (APP_CLIENT == loadingModuleType) { - appClientExtensions = configElements; - } else if (CONNECTOR == loadingModuleType) { - connectorExtensions = configElements; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/ResourceTypeReaderHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/ResourceTypeReaderHelper.java deleted file mode 100644 index c4768a072..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/ResourceTypeReaderHelper.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on 10-Oct-03 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal; - -import java.util.ArrayList; -import java.util.Arrays; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; - -/** - * @author sapnam - * - * This helper class was created for ResourceRefTypeReader and ResourceEnvRefTypeReader to read all - * valid types from extensions of each and to return a array of String to populate the Ref 'Type' - * fields. - */ -public class ResourceTypeReaderHelper { - private static String extensionPoint; - private static String typeAttributeName; - private static final String USAGE_TYPE = "type"; //$NON-NLS-1$ - private static final String USAGE_ATTRIBUTE_NAME = "usage"; //$NON-NLS-1$ - private static final String USAGE_COMMON = "Common"; //$NON-NLS-1$ - private static final String USAGE_EJB = "EJB Jar"; //$NON-NLS-1$ - private static final String SERVER_TARGET_IDS_ATTRIBUTE_NAME = "target-server-ids"; //$NON-NLS-1$ - private static final String SERVER_TARGET_IDS_SEPARATOR = ","; //$NON-NLS-1$ - private boolean isEJBJar; - - public static final int RESOURCE_REF = 0; - public static final int RESOURCE_ENV_REF = 1; - - private static final String[] EXTENSION_POINTS = {"org.eclipse.jst.j2ee.resourceRefType", "org.eclipse.jst.j2ee.resourceEnvRefType"};//$NON-NLS-1$ //$NON-NLS-2$ - - public static String[] getAllReferences(int refType, String serverTargetID, boolean isEJBJar, String[] baseItems) { - String extensionPointLocal = EXTENSION_POINTS[refType]; - ResourceTypeReaderHelper reader = new ResourceTypeReaderHelper(extensionPointLocal, USAGE_TYPE, isEJBJar); - String[] extendedItems = null == serverTargetID ? reader.getResTypes() : reader.getResTypes(serverTargetID); - String[] allItems = null; - if (null == extendedItems || 0 == extendedItems.length) { - allItems = baseItems; - } else { - allItems = new String[baseItems.length + extendedItems.length]; - System.arraycopy(baseItems, 0, allItems, 0, baseItems.length); - System.arraycopy(extendedItems, 0, allItems, baseItems.length, extendedItems.length); - } - Arrays.sort(allItems); - return allItems; - } - - - private ResourceTypeReaderHelper(String extPoint, String typeAttName, boolean ejbJar) { - extensionPoint = extPoint; - typeAttributeName = typeAttName; - isEJBJar = ejbJar; - } - - private IExtensionPoint getExtensionPoint() { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint exPoint = registry.getExtensionPoint(extensionPoint); //$NON-NLS-1$ - return exPoint; - } - - private ArrayList processExtensions() { - IExtension[] allExtensions = getExtensionPoint().getExtensions(); - ArrayList tempTypes = new ArrayList(); - for (int x = 0; x < allExtensions.length; ++x) { - IExtension config = allExtensions[x]; - IConfigurationElement[] cElems = config.getConfigurationElements(); - for (int i = 0; i < cElems.length; i++) { - if (getValidTypes(cElems[i]) != null) { - tempTypes.add(getValidTypes(cElems[i])); - } - } - } - return tempTypes; - } - - - /** - * @return an array of string containing valid Resource Ref or Resource Env Ref types. - */ - public String[] getResTypes() { - ArrayList types = processExtensions(); - String[] allTypes = new String[types.size()]; - for (int z = 0; z < types.size(); z++) { - allTypes[z] = (String) types.get(z); - } - return allTypes; - } - - private ArrayList processExtensions(String targetServer) { - IExtension[] allExtensions = getExtensionPoint().getExtensions(); - ArrayList tempTypes = new ArrayList(); - for (int x = 0; x < allExtensions.length; ++x) { - IExtension config = allExtensions[x]; - IConfigurationElement[] cElems = config.getConfigurationElements(); - for (int i = 0; i < cElems.length; i++) { - if (getValidTypes(cElems[i], targetServer) != null) { - tempTypes.add(getValidTypes(cElems[i], targetServer)); - } - } - } - return tempTypes; - } - - /** - * @param element - * A configuration element. - * @return A valid Type - */ - private Object getValidTypes(IConfigurationElement element, String targetServer) { - String elementServerIDs = element.getAttribute(SERVER_TARGET_IDS_ATTRIBUTE_NAME); - if (null == elementServerIDs || isValidTargeted(elementServerIDs, targetServer)) { - String usage = element.getAttribute(USAGE_ATTRIBUTE_NAME); - if (usage.equals(USAGE_COMMON)) { - return element.getAttribute(typeAttributeName); - } else if (isEJBJar && usage.equals(USAGE_EJB)) { - return element.getAttribute(typeAttributeName); - } - } - return null; - } - - /** - * @param element - * A configuration element. - * @return A valid Type - */ - private Object getValidTypes(IConfigurationElement element) { - return getValidTypes(element, null); - } - - /** - * @return an array of string containing valid Resource Ref or Resource Env Ref types. - */ - public String[] getResTypes(String targetServer) { - ArrayList types = processExtensions(targetServer); - String[] allTypes = new String[types.size()]; - for (int z = 0; z < types.size(); z++) { - allTypes[z] = (String) types.get(z); - } - return allTypes; - } - - private boolean isValidTargeted(String attribute, String targetServerId) { - if (attribute == null || targetServerId == null) - return false; - if (attribute.trim().equalsIgnoreCase(targetServerId.trim())) - return true; - if (attribute.indexOf(targetServerId.trim() + SERVER_TARGET_IDS_SEPARATOR) >= 0) - return true; - if (attribute.trim().length() > (targetServerId.trim().length() + 1) && attribute.substring(attribute.trim().length() - targetServerId.length()).equalsIgnoreCase(targetServerId.trim())) - return true; - return false; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java deleted file mode 100644 index 5af2533f7..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Mar 30, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.deploy; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.internal.emf.utilities.ICommand; -import org.eclipse.wst.server.core.IRuntime; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class DeployerRegistry { - /** - * - */ - private static DeployerRegistry INSTANCE; - private HashMap deployModuleExtensions = new HashMap(); - - public DeployerRegistry() { - super(); - } - - /** - * @param deployer - * @param serverTarget - * @param natureID - */ - public void register(ICommand deployer, List serverTargets, List natures) { - - HashMap targetDeployers; - for (Iterator iter = natures.iterator(); iter.hasNext();) { - String natureID = (String) iter.next(); - for (Iterator iterator = serverTargets.iterator(); iterator.hasNext();) { - String runtimeID = (String) iterator.next(); - targetDeployers = getDeployModuleExtensions(natureID); - getTargetDeployers(targetDeployers, runtimeID).add(deployer); - } - } - - - - } - - private List getDeployers(String natureID, String serverTarget) { - HashMap targetDeployers = getDeployModuleExtensions(natureID); - return getTargetDeployers(targetDeployers, serverTarget); - } - - public static DeployerRegistry instance() { - if (INSTANCE == null) { - INSTANCE = new DeployerRegistry(); - readRegistry(); - } - return INSTANCE; - } - - /** - * - */ - private static void readRegistry() { - DeployerRegistryReader reader = new DeployerRegistryReader(); - reader.readRegistry(); - } - - /** - * @return - */ - public static List getSelectedModules(Object[] mySelections) { - List modules = new ArrayList(); - for (int i = 0; i < mySelections.length; i++) { - Object object = mySelections[i]; - if (object instanceof EObject) { - object = ProjectUtilities.getProject(object); - } - if (object instanceof IProject) { - J2EENature nature = J2EENature.getRegisteredRuntime((IProject) object); - if (nature == null) - continue; - if (modules.contains(nature.getDeploymentDescriptorRoot())) - continue; - // Order Ears first... - if (nature.getNatureID().equals(IEARNatureConstants.NATURE_ID)) - modules.add(0, nature.getDeploymentDescriptorRoot()); - else - modules.add(nature.getDeploymentDescriptorRoot()); - } - } - return modules; - } - - /** - * @param targetDeployers - * @param serverTarget - */ - private List getTargetDeployers(HashMap targetDeployers, String serverTarget) { - if (targetDeployers.get(serverTarget) == null) - targetDeployers.put(serverTarget, new ArrayList()); - return (List) targetDeployers.get(serverTarget); - - } - - /** - * @param natureID - * @return - */ - private HashMap getDeployModuleExtensions(String natureID) { - - if (getDeployModuleExtensions().get(natureID) == null) - getDeployModuleExtensions().put(natureID, new HashMap()); - return (HashMap) getDeployModuleExtensions().get(natureID); - } - - /** - * @return Returns the deployExtensions. - */ - public HashMap getDeployModuleExtensions() { - return deployModuleExtensions; - } - - /** - * @param deployExtensions - * The deployExtensions to set. - */ - public void setDeployModuleExtensions(HashMap deployExtensions) { - this.deployModuleExtensions = deployExtensions; - } - - /** - * @param module - * @param runtime - * @return - */ - public List getDeployModuleExtensions(EObject module, IRuntime runtime) { - - IProject proj = ProjectUtilities.getProject(module); - String natureID = J2EENature.getRegisteredRuntime(proj).getNatureID(); - String runtimeID = runtime.getRuntimeType().getId(); - return getDeployers(natureID, runtimeID); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java deleted file mode 100644 index df22e23cb..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Mar 29, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.deploy; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jem.util.RegistryReader; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.wst.common.internal.emf.utilities.ICommand; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class DeployerRegistryReader extends RegistryReader { - /** - * @param registry - * @param plugin - * @param extensionPoint - */ - static final String J2EE_DEPLOYER_EXTENSION_POINT = "DeployerExtension"; //$NON-NLS-1$ - static final String TARGET_SERVER_RUNTIME_ID = "runtime_server_id"; //$NON-NLS-1$ - static final String RUNTIME = "runtime"; //$NON-NLS-1$ - static final String DEPLOYER = "deployer"; //$NON-NLS-1$ - static final String DEPLOYER_CLASS = "deployer_class"; //$NON-NLS-1$ - static final String MODULE_TYPE_NATURE_ID = "module_nature_id"; //$NON-NLS-1$ - static final String NATURE = "nature"; //$NON-NLS-1$ - - public DeployerRegistryReader() { - super(J2EEPlugin.PLUGIN_ID, J2EE_DEPLOYER_EXTENSION_POINT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement) - */ - public boolean readElement(IConfigurationElement element) { - if (!element.getName().equals(DEPLOYER)) - return false; - List runtimeList = new ArrayList(); - List natureList = new ArrayList(); - IConfigurationElement[] runtimes = element.getChildren(RUNTIME); - for (int i = 0; i < runtimes.length; i++) { - IConfigurationElement runtime = runtimes[i]; - String serverTarget = runtime.getAttribute(TARGET_SERVER_RUNTIME_ID); - runtimeList.add(serverTarget); - } - IConfigurationElement[] natures = element.getChildren(NATURE); - for (int i = 0; i < natures.length; i++) { - IConfigurationElement nature = natures[i]; - String natureID = nature.getAttribute(MODULE_TYPE_NATURE_ID); - natureList.add(natureID); - } - - ICommand deployer = null; - try { - Object ext = element.createExecutableExtension(DEPLOYER_CLASS); - if (ext instanceof ICommand) - deployer = (ICommand) ext; - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (deployer != null) { - DeployerRegistry.instance().register(deployer, runtimeList, natureList); - return true; - } - return false; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/FatalDeployerException.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/FatalDeployerException.java deleted file mode 100644 index 2ff200cce..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/FatalDeployerException.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Mar 30, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.deploy; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class FatalDeployerException extends Exception { - /** - * - */ - public FatalDeployerException() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @param message - */ - public FatalDeployerException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * @param message - * @param cause - */ - public FatalDeployerException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param cause - */ - public FatalDeployerException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployHelper.java deleted file mode 100644 index 8bb4afe21..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployHelper.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Aug 4, 2004 - */ -package org.eclipse.jst.j2ee.internal.deploy; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.ApplicationResource; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.IApplicationClientNatureConstants; -import org.eclipse.jst.j2ee.client.ApplicationClient; -import org.eclipse.jst.j2ee.client.ApplicationClientResource; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EJBResource; -import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants; -import org.eclipse.jst.j2ee.internal.project.IConnectorNatureConstants; -import org.eclipse.jst.j2ee.internal.project.IEJBNatureConstants; -import org.eclipse.jst.j2ee.internal.project.IWebNatureConstants; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.jst.j2ee.jca.Connector; -import org.eclipse.jst.j2ee.jca.ConnectorResource; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WebAppResource; -import org.eclipse.wst.common.internal.emf.utilities.ICommandContext; - - -/** - * @author cbridgha - * - * - */ -public class J2EEDeployHelper { - - /** - * @param resource - * @param context - * @return - */ - public static EJBJar getEJBJar(IResource resource, ICommandContext context) { - - if ((resource instanceof IProject) && (J2EENature.hasRuntime((IProject) resource, IEJBNatureConstants.NATURE_ID))) { - String jarURI = J2EENature.getRuntime((IProject) resource, IEJBNatureConstants.NATURE_ID).getDeploymentDescriptorURI(); - return ((EJBResource) context.getResourceSet().getResource(URI.createURI(jarURI), false)).getEJBJar(); - } - return null; - } - - /** - * @param resource - * @param context - * @return - */ - public static Application getApplication(IResource resource, ICommandContext context) { - if ((resource instanceof IProject) && (J2EENature.hasRuntime((IProject) resource, IEARNatureConstants.NATURE_ID))) { - String earURI = J2EENature.getRuntime((IProject) resource, IEARNatureConstants.NATURE_ID).getDeploymentDescriptorURI(); - return ((ApplicationResource) context.getResourceSet().getResource(URI.createURI(earURI), false)).getApplication(); - } - return null; - } - - /** - * @param resource - * @param context - * @return - */ - public static ApplicationClient getAppClient(IResource resource, ICommandContext context) { - if ((resource instanceof IProject) && (J2EENature.hasRuntime((IProject) resource, IApplicationClientNatureConstants.NATURE_ID))) { - String appClientURI = J2EENature.getRuntime((IProject) resource, IApplicationClientNatureConstants.NATURE_ID).getDeploymentDescriptorURI(); - return ((ApplicationClientResource) context.getResourceSet().getResource(URI.createURI(appClientURI), false)).getApplicationClient(); - } - return null; - } - - /** - * @param resource - * @param context - * @return - */ - public static WebApp getWebApp(IResource resource, ICommandContext context) { - - if ((resource instanceof IProject) && (J2EENature.hasRuntime((IProject) resource, IWebNatureConstants.J2EE_NATURE_ID))) { - String warURI = J2EENature.getRuntime((IProject) resource, IWebNatureConstants.J2EE_NATURE_ID).getDeploymentDescriptorURI(); - return ((WebAppResource) context.getResourceSet().getResource(URI.createURI(warURI), false)).getWebApp(); - } - return null; - } - - /** - * @param resource - * @param context - * @return - */ - public static Connector getConnector(IResource resource, ICommandContext context) { - if ((resource instanceof IProject) && (J2EENature.hasRuntime((IProject) resource, IConnectorNatureConstants.NATURE_ID))) { - String connURI = J2EENature.getRuntime((IProject) resource, IConnectorNatureConstants.NATURE_ID).getDeploymentDescriptorURI(); - return ((ConnectorResource) context.getResourceSet().getResource(URI.createURI(connURI), false)).getConnector(); - } - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployOperation.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployOperation.java deleted file mode 100644 index b837f8179..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployOperation.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Apr 1, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.deploy; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPluginResourceHandler; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; -import org.eclipse.wst.common.internal.emf.utilities.CommandContext; -import org.eclipse.wst.common.internal.emf.utilities.ICommand; -import org.eclipse.wst.common.internal.emf.utilities.ICommandContext; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEDeployOperation extends WTPOperation { - - private Object[] selection; - private List multiStatus = new ArrayList(); - - /** - * - */ - public J2EEDeployOperation(Object[] deployableObjects) { - super(); - selection = deployableObjects; - // TODO Auto-generated constructor stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - - DeployerRegistry reg = DeployerRegistry.instance(); - - List modules = DeployerRegistry.getSelectedModules(selection); - monitor.beginTask(J2EEPluginResourceHandler.getString("J2EEDeployOperation_UI_0"), modules.size()); //$NON-NLS-1$ - for (int i = 0; i < modules.size(); i++) { - - EObject module = (EObject) modules.get(i); - IProject proj = ProjectUtilities.getProject(module); - IRuntime runtime = ServerCore.getProjectProperties(proj).getRuntimeTarget(); - if (runtime == null) - continue; - List visitors = reg.getDeployModuleExtensions(module, runtime); - deploy(visitors, module, monitor); - monitor.worked(1); - } - - } - - /** - * @param visitors - * @param module - */ - private void deploy(List visitors, EObject module, IProgressMonitor monitor) { - - IProject proj = ProjectUtilities.getProject(module); - IStatus main = addMainStatus(proj); - for (int i = 0; i < visitors.size(); i++) { - if (!(visitors.get(i) instanceof ICommand)) - continue; - ICommand dep = (ICommand) visitors.get(i); - ICommandContext ctx = new CommandContext(monitor, null, module.eResource().getResourceSet()); - dep.init(selection); - - monitor.setTaskName(J2EEPluginResourceHandler.getString("J2EEDeployOperation_1_UI_", new Object[]{proj.getName(), dep.getClass().getName()})); //$NON-NLS-1$ - try { - dep.execute(proj, null, ctx); - addOKStatus(dep.getClass().getName(), main); - } catch (CoreException ex) { - Logger.getLogger().logError(ex); - monitor.setCanceled(true); - Throwable statusException = (ex.getStatus().getException() != null) ? ex.getStatus().getException() : ex; - addErrorStatus(ex.getStatus(), dep.getClass().getName(), statusException, main); - continue; - } - } - - } - - /** - * @param proj - * @param name - */ - private void addOKStatus(String DeployerName, IStatus main) { - - IStatus statusLocal = new Status(IStatus.OK, " ", IStatus.OK, (J2EEPluginResourceHandler.getString("J2EEDeployOperation_2_UI_", new Object[]{DeployerName})), null); //$NON-NLS-1$ //$NON-NLS-2$ - addStatus(statusLocal); - - } - - /** - * @param exceptionStatus - * @param proj - * @param name - */ - private void addErrorStatus(IStatus exceptionStatus, String DeployerName, Throwable ex, IStatus main) { - - if (exceptionStatus instanceof MultiStatus) { - IStatus[] stati = ((MultiStatus) exceptionStatus).getChildren(); - for (int i = 0; 1 < stati.length; i++) { - addErrorStatus(stati[i], DeployerName, stati[i].getException(), main); - } - } - String errorNotes = (ex != null && ex.getMessage() != null) ? ex.getMessage() : main.getMessage(); - - String message = J2EEPluginResourceHandler.getString("J2EEDeployOperation_3_UI_", new Object[]{DeployerName, errorNotes}); //$NON-NLS-1$ - IStatus statusLocal = new Status(IStatus.ERROR, J2EEPlugin.getPlugin().getPluginID(), IStatus.ERROR, message, ex); //$NON-NLS-1$ - - addStatus(statusLocal); - - - - } - - private IStatus addMainStatus(IProject proj) { - - IStatus aStatus = new MultiStatus(J2EEPlugin.getPlugin().getPluginID(), IStatus.OK, J2EEPluginResourceHandler.getString("J2EEDeployOperation_4_UI_", new Object[]{proj.getName()}), null); //$NON-NLS-1$ - - getMultiStatus().add(aStatus); - return aStatus; - } - - /** - * @return Returns the multiStatus. - */ - public List getMultiStatus() { - return multiStatus; - } - - /** - * @param multiStatus - * The multiStatus to set. - */ - public void setMultiStatus(List multiStatus) { - this.multiStatus = multiStatus; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployer.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployer.java deleted file mode 100644 index b6ad428d8..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/J2EEDeployer.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.deploy; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.client.ApplicationClient; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.jca.Connector; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/* - * Deployer interface for the J2EEDeploymentFramework - */ -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - * @deprecated - Change to use the org.eclipse.wst.common.emf.utilities.ICommand interface - */ -public interface J2EEDeployer { - /* - * This will contain the multi-selection of objects to deploy. This selection could be used to - * filter elements within a Module. Any other setup code should be done here... - */ - void init(Object[] selection); - - /* - * This will visit each extension's deploy operation on the deployable object. A Multi-Status - * should be returned - */ - IStatus visit(EJBJar deployable) throws FatalDeployerException; - - IStatus visit(ApplicationClient deployable) throws FatalDeployerException; - - IStatus visit(Application deployable) throws FatalDeployerException; - - IStatus visit(WebApp deployable) throws FatalDeployerException; - - IStatus visit(Connector deployable) throws FatalDeployerException; - - /* - * Any cleanup should be done here... - */ - void finish(); - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java deleted file mode 100644 index b4b87dc71..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployable.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.internal.project.J2EEModuleNature; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.jst.server.core.IApplicationClientModule; - -public class ApplicationClientDeployable extends J2EEDeployable implements IApplicationClientModule {/* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /** - * Constructor for ApplicationClientDeployable. - * - * @param aNature - * @param aFactoryId - */ - public ApplicationClientDeployable(J2EENature aNature, String aFactoryId) { - super(aNature, aFactoryId); - } - - /** - * @see com.ibm.etools.server.core.util.DeployableProject#getRootFolder() - */ - public IPath getRootFolder() { - J2EEModuleNature aNature = (J2EEModuleNature) getNature(); - if (aNature == null) - return super.getRootFolder(); - else if (aNature.isBinaryProject()) - return null; - else - return aNature.getModuleServerRoot().getProjectRelativePath(); - } - - public String getType() { - return "j2ee.appclient"; //$NON-NLS-1$ - } - - public String getVersion() { - return getNature().getJ2EEVersionText(); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java deleted file mode 100644 index 14cf77863..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/ApplicationClientDeployableFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.IApplicationClientNatureConstants; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.server.core.IModule; - -/** - * @version 1.0 - * @author - */ -public class ApplicationClientDeployableFactory extends J2EEDeployableFactory { - private static final String ID = "com.ibm.wtp.server.j2ee.appclient"; //$NON-NLS-1$ - - /** - * Constructor for ApplicationClientDeployableFactory. - */ - public ApplicationClientDeployableFactory() { - super(); - } - - /* - * @see DeployableProjectFactoryDelegate#getFactoryID() - */ - public String getFactoryId() { - return ID; - } - - /* - * @see J2EEDeployableFactory#getNatureID() - */ - public String getNatureID() { - return IApplicationClientNatureConstants.NATURE_ID; - } - - /* - * @see J2EEDeployableFactory#createDeployable(J2EENature) - */ - - public IModule createModule(J2EENature nature) { - if (nature == null) - return null; - ApplicationClientDeployable moduleDelegate = null; - IModule module = nature.getModule(); - if (module == null) { - try { - moduleDelegate = new ApplicationClientDeployable(nature, ID); - module = createModule(moduleDelegate.getId(), moduleDelegate.getName(), moduleDelegate.getType(), moduleDelegate.getVersion(), moduleDelegate.getProject()); - nature.setModule(module); - moduleDelegate.initialize(module); - } catch (Exception e) { - Logger.getLogger().write(e); - } finally { - moduleDelegates.add(moduleDelegate); - } - } - return module; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFactory#createModules(org.eclipse.wst.common.modulecore.ModuleCoreNature) - */ - protected List createModules(ModuleCoreNature nature) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() - */ - public IModule[] getModules() { - // TODO Auto-generated method stub - return null; - } - - protected boolean isValidModule(IProject project) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFactory#createModuleDelegates(org.eclipse.emf.common.util.EList, org.eclipse.core.resources.IProject) - */ - protected List createModuleDelegates(EList workBenchModules, IProject project) { - // TODO Auto-generated method stub - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java deleted file mode 100644 index e318e567c..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployable.java +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.server.core.IEnterpriseApplication; -import org.eclipse.jst.server.core.IJ2EEModule; -import org.eclipse.jst.server.core.ILooseArchive; -import org.eclipse.jst.server.core.ILooseArchiveSupport; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.server.core.IModule; - - - -public class EnterpriseApplicationDeployable extends J2EEFlexProjDeployable implements IEnterpriseApplication, ILooseArchiveSupport { - - public static final String EAR_MODULE_TYPE = "jst.ear"; //$NON-NLS-1$ - - public EnterpriseApplicationDeployable(IProject project, String aFactoryId, WorkbenchComponent aWorkbenchModule) { - super(project, aFactoryId, aWorkbenchModule); - - - } - - public String getJ2EESpecificationVersion() { - String Version = "1.2"; //$NON-NLS-1$ - - EARArtifactEdit earEdit = null; - try { - ComponentHandle handle = ComponentHandle.create(StructureEdit.getContainingProject(wbModule),wbModule.getName()); - earEdit = EARArtifactEdit.getEARArtifactEditForRead(handle); - if (earEdit != null) { - int nVersion = earEdit.getJ2EEVersion(); - switch (nVersion) { - case 12 : - Version = IModuleConstants.J2EE_VERSION_1_2; - break; - case 13 : - Version = IModuleConstants.J2EE_VERSION_1_3; - break; - case 14 : - Version = IModuleConstants.J2EE_VERSION_1_4; - break; - default : - Version = IModuleConstants.J2EE_VERSION_1_2; - break; - } - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (earEdit != null) - earEdit.dispose(); - } - - return Version; - } - - public IModule[] getModules() { - List modules = new ArrayList(3); - EARArtifactEdit earEdit = null; - try { - ComponentHandle handle = ComponentHandle.create(StructureEdit.getContainingProject(wbModule),wbModule.getName()); - earEdit = EARArtifactEdit.getEARArtifactEditForRead(handle); - if (earEdit != null) { - List components = earEdit.getJ2EEModuleReferences(); - for (Iterator iter = components.iterator(); iter.hasNext();) { - IVirtualReference reference = (IVirtualReference) iter.next(); - IVirtualComponent virtualComp = reference.getReferencedComponent(); - Object module = FlexibleProjectServerUtil.getModuleDelegate(virtualComp); - modules.add(module); - } - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (earEdit != null) - earEdit.dispose(); - } - IModule[] moduleArray = new IModule[modules.size()]; - modules.toArray(moduleArray); - return moduleArray; - - } - - public String getURI(IJ2EEModule module) { - // TODO Auto-generated method stub - return module.getLocation().toString(); - } - - public boolean containsLooseModules() { - // TODO Auto-generated method stub - return false; - } - - public IPath getLocation() { - // TODO Auto-generated method stub - return new Path(wbModule.getHandle().toString()); - } - - public IModule[] getLooseArchives() { - // TODO Auto-generated method stub - return null; - } - - public String getURI(ILooseArchive archive) { - // TODO Auto-generated method stub - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableAdapterUtil.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableAdapterUtil.java deleted file mode 100644 index bd19f6bd5..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableAdapterUtil.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.util.NullModuleArtifact; - - -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; - -/** - * Creates the Object adapter for ear projects. - */ -public class EnterpriseApplicationDeployableAdapterUtil { - - /** - * Constructor for EnterpriseApplicationDeployableObjectAdapter. - */ - public EnterpriseApplicationDeployableAdapterUtil() { - super(); - }// EnterpriseApplicationDeployableObjectAdapter - - /** - * Gets the object for a type of object. - * - * @param Object - * obj - Object to adapt. - */ - public static IModuleArtifact getModuleObject(Object obj) { - if (obj instanceof Application) - return getModuleObject((Application) obj); - if (obj instanceof IProject) - return getModuleObject((IProject) obj); - if (obj instanceof IFile) - return getModuleObject((IFile) obj); - return null; - }// getDeployableObject - - /** - * Gets the deployable object for ear instance. - * - * @param Application - * application - EAR instance. - */ - protected static IModuleArtifact getModuleObject(Application application) { - IModule dep = getModule(application); - return createModuleObject(dep); - }// getDeployableObject - - /** - * Gets the deployable object for project instances. - * - * @param IProject - * project - Project instance. - * @return IModuleObject - */ - protected static IModuleArtifact getModuleObject(IProject project) { - org.eclipse.wst.server.core.IModule dep = getModule(project,null); - return createModuleObject(dep); - }// getModuleObject - - /** - * Gets the deployable object for file instances. - * - * @param IFile - * file - File instance. - * @return IModuleObject - */ - protected static IModuleArtifact getModuleObject(IFile file) { - if (file.getProjectRelativePath().toString().endsWith(ArchiveConstants.APPLICATION_DD_URI)) { - { - IVirtualResource[] resources = ComponentCore.createResources(file); - IVirtualComponent component = null; - if (resources[0] != null || resources.length <= 0) - component = resources[0].getComponent(); - return createModuleObject(getModule(file.getProject(), component)); - } - }// if - return null; - }// getModuleObject - - /** - * Gets the deployable object. - * - * @param EObject - * refObject - The current refObject. - * @return IModule - */ - protected static org.eclipse.wst.server.core.IModule getModule(EObject refObject) { - IProject proj = ProjectUtilities.getProject(refObject); - Resource servResource = refObject.eResource(); - IVirtualResource[] resources = null; - try { - IResource eclipeServResoruce = (IResource) WorkbenchResourceHelper.getFile(servResource); - resources = ComponentCore.createResources(eclipeServResoruce); - } catch (Exception e) { - e.printStackTrace(); - } - IVirtualComponent component = null; - if (resources[0] != null) - component = resources[0].getComponent(); - return getModule(proj,component); - }// getModule - - - - /** - * Gets the ear nature. - * - * @param IProject - * project - The current project. - * @return EARNatureRuntime - */ - protected static EARNatureRuntime getNature(IProject project) { - if (project != null) { - return EARNatureRuntime.getRuntime(project); - }// if - return null; - }// getNature - - - - protected static IModule getModuleProject(IProject project, Iterator iterator) { - IModule deployable = null; - while (iterator.hasNext()) { - Object next = iterator.next(); - if (next instanceof IModule) { - deployable = (IModule) next; - if (deployable.getProject().equals(project)) - return deployable; - } - } - return null; - } - - protected static IModule getModule(IProject project, IVirtualComponent component) { - IModule deployable = null; - Iterator iterator = Arrays.asList(ServerUtil.getModules("j2ee.ear")).iterator(); - String componentName = null; - if (component != null) - componentName = component.getName(); - else - return getModuleProject(project, iterator); - while (iterator.hasNext()) { - Object next = iterator.next(); - if (next instanceof IModule) { - deployable = (IModule) next; - if (deployable.getName().equals(componentName)) { - return deployable; - } - } - } - return null; - } - - /** - * Creates the deployable object. - * - * @param IModuleObject - * deployable - The current module object. - */ - protected static IModuleArtifact createModuleObject(IModule module) { - - if (module != null) { - return new NullModuleArtifact(module); - } - - return null; - }// createDeployableObject - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModuleArtifactAdapter#getId() - */ - public String getId() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModuleArtifactAdapter#getObjectClassName() - */ - public String getObjectClassName() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModuleArtifactAdapter#isPluginActivated() - */ - public boolean isPluginActivated() { - // TODO Auto-generated method stub - return false; - } - -}// EnterpriseApplicationDeployableObjectAdapter diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java deleted file mode 100644 index 33ef27389..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableFactory.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.j2ee.internal.deployables; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IProjectProperties; -import org.eclipse.wst.server.core.ServerCore; - -/** - * @version 1.0 - * @author - */ -public class EnterpriseApplicationDeployableFactory extends J2EEDeployableFactory { - - protected static final String ID = "com.ibm.wtp.server.j2ee.application"; //$NON-NLS-1$ - - protected static final IPath[] PATHS = new IPath[]{new Path("META-INF/application.xml"), //$NON-NLS-1$ - new Path("META-INF/.modulemaps") //$NON-NLS-1$ - }; - - public EnterpriseApplicationDeployableFactory() { - super(); - } - - - - public IModule createModule(J2EENature nature) { - return null; - } - - - protected IPath[] getListenerPaths() { - return PATHS; - } - - - protected List createModuleDelegates(EList workBenchModules, IProject project) { - EnterpriseApplicationDeployable moduleDelegate = null; - IModule module = null; - List moduleList = new ArrayList(workBenchModules.size()); - // J2EENature nature = (J2EENature)project.getNature(getNatureID()); - - for (int i = 0; i < workBenchModules.size(); i++) { - try { - WorkbenchComponent wbModule = (WorkbenchComponent) workBenchModules.get(i); - if (wbModule.getComponentType() == null || wbModule.getComponentType().getComponentTypeId() == null || !wbModule.getComponentType().getComponentTypeId().equals(EnterpriseApplicationDeployable.EAR_MODULE_TYPE)) - continue; - moduleDelegate = new EnterpriseApplicationDeployable(project, ID, wbModule); - //moduleDelegate.getModules(); - module = createModule(wbModule.getName(), wbModule.getName(), moduleDelegate.getType(), moduleDelegate.getVersion(), moduleDelegate.getProject()); - moduleList.add(module); - moduleDelegate.initialize(module); - // adapt(moduleDelegate, (WorkbenchComponent) workBenchModules.get(i)); - } catch (Exception e) { - Logger.getLogger().write(e); - } finally { - if (module != null) { - if (getModuleDelegate(module) == null) - moduleDelegates.add(moduleDelegate); - } - } - } - return moduleList; - } - - public IModule[] getModules() { - cacheModules(false); - ArrayList moduleList = new ArrayList(); - for (Iterator iter = projects.values().iterator(); iter.hasNext();) { - IModule[] element = (IModule[]) iter.next(); - for (int j = 0; j < element.length; j++) { - moduleList.add(element[j]); - } - } - IModule[] modules = new IModule[moduleList.size()]; - moduleList.toArray(modules); - return modules; - - } - - - - protected String getNatureID() { - return IModuleConstants.MODULE_NATURE_ID; - } - - protected boolean isValidModule(IProject project) { - if (isFlexableProject(project)) { - IProjectProperties properties = ServerCore.getProjectProperties(project); - if (properties != null || properties.getRuntimeTarget() == null || properties.getRuntimeTarget().getRuntimeType().getModuleTypes() != null) { - IModuleType[] moduleTypes = properties.getRuntimeTarget().getRuntimeType().getModuleTypes(); - for (int i = 0; i < moduleTypes.length; i++) { - IModuleType moduleType = moduleTypes[i]; - if (moduleType.getId().equals("j2ee.ear")) - return true; - } - - } - - } - return false; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableOLD.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableOLD.java deleted file mode 100644 index c72d93fd6..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseApplicationDeployableOLD.java +++ /dev/null @@ -1,441 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel; -import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.jst.server.core.IEnterpriseApplication; -import org.eclipse.jst.server.core.IJ2EEModule; -import org.eclipse.jst.server.core.ILooseArchive; -import org.eclipse.jst.server.core.ILooseArchiveSupport; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.model.ModuleFactoryDelegate; - - - -public class EnterpriseApplicationDeployableOLD extends J2EEDeployable implements IEnterpriseApplication, ILooseArchiveSupport { - // cached children - protected IJ2EEModule[] containedModules; - - protected ILooseArchive[] containedArchives; - - // cached URIs - deployable to String - protected Map containedModuleURIs = new HashMap(4); - - protected Map containedArchiveURIs = new HashMap(4); - - /** - * Constructor for EnterpriseApplicationDeployable. - * - * @param aNature - * @param aFactoryId - */ - public EnterpriseApplicationDeployableOLD(J2EENature aNature, String aFactoryId) { - super(aNature, aFactoryId); - - update(); - } - - /** - * @see IEnterpriseApplication#containsLooseModules() - */ - public boolean containsLooseModules() { - return true; - } - - /** - * @see IEnterpriseApplication#containsLooseArchives() - */ - public boolean containsLooseArchives() { - return true; - } - - /* - * @see IEnterpriseApplication#getModules() - */ - /*public IModule[] getModules() { - return containedModules; - }*/ - - /* - * @see IEnterpriseApplication#getVendorSupport() - */ - public String[] getVendorSupport() { - return null; - } - - protected EARNatureRuntime getEARNature() { - return (EARNatureRuntime) getNature(); - } - - protected static IModule getModule(J2EENature nature) { - IModule dep = nature.getModule(); - if (dep == null) { - ModuleFactoryDelegate fac = getModuleFactory(nature); - if (fac != null) { - /*if (fac instanceof J2EEDeployableFactory) { - dep = ((J2EEDeployableFactory) fac).getModuleProject(nature.getProject()); - }*/ - } - } - return dep; - } - - protected static ModuleFactoryDelegate getModuleFactory(J2EENature nature) { - /* - * Iterator factories = ServerCore.getModuleFactories().iterator(); while - * (factories.hasNext()) { ModuleFactory deployableFactory = (ModuleFactory) - * factories.next(); if - * (!deployableFactory.getId().equals(EnterpriseApplicationDeployableFactory.ID)) { - * ModuleFactoryDelegate deployableFactoryDelegate = deployableFactory.getDelegate(); if - * (deployableFactoryDelegate instanceof J2EEDeployableFactory) { J2EEDeployableFactory fac = - * (J2EEDeployableFactory) deployableFactory.getDelegate(); if - * (fac.getNatureID().equals(nature.getNatureID())) { return fac; } } } } - */ - return null; - } - - protected static LooseArchiveDeployableFactory getLooseArchiveDeployableFactory() { - /* - * Iterator factories = ServerCore.getModuleFactories().iterator(); while - * (factories.hasNext()) { ModuleFactory deployableFactory = (ModuleFactory) - * factories.next(); if - * (!deployableFactory.getId().equals(EnterpriseApplicationDeployableFactory.ID)) { - * ModuleFactoryDelegate deployableFactoryDelegate = deployableFactory.getDelegate(); if - * (deployableFactoryDelegate instanceof LooseArchiveDeployableFactory) return - * (LooseArchiveDeployableFactory) deployableFactoryDelegate; } } - */ - return null; - } - - /* - * @see IEnterpriseApplication#getURI(IJ2EEModule) - */ - public String getURI(IJ2EEModule module) { - try { - return (String) containedModuleURIs.get(module); - } catch (Exception e) { - // ignore - } - return null; - } - - public String getURI(ILooseArchive archive) { - try { - return (String) containedArchiveURIs.get(archive); - } catch (Exception e) { - // ignore - } - return null; - } - -/* public ILooseArchive[] getLooseArchives() { - return containedArchives; - }*/ - - protected ILooseArchive getArchiveDeployable(IProject aProject, LooseArchiveDeployableFactory fact) { - try { - // return (ILooseArchive) fact.getModuleProject(aProject); - } catch (RuntimeException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - protected void update() { - IJ2EEModule[] oldModules = containedModules; - containedModules = getContainedModules(); - ILooseArchive[] oldArchives = containedArchives; - - ////////////TODO add back looselib support/////////////////////////// - //containedArchives = getContainedArchives(); - containedArchives = new ILooseArchive[0]; - // get add events - List add = new ArrayList(2); - addAddedObjects(add, oldModules, containedModules); - addAddedObjects(add, oldArchives, containedArchives); - - // get remove events - List remove = new ArrayList(2); - addRemovedObjects(remove, oldModules, containedModules); - addRemovedObjects(remove, oldArchives, containedArchives); - - // fire change events - int size = containedModules.length; - List change = new ArrayList(size); - for (int i = 0; i < size; i++) { - String newURI = getContainedURI(containedModules[i]); - String oldURI = getURI(containedModules[i]); - - if (oldURI != null && !oldURI.equals(newURI)) { - change.add(containedModules[i]); - } - containedModuleURIs.put(containedModules[i], newURI); - } - - size = containedArchives.length; - for (int i = 0; i < size; i++) { - String newURI = getContainedURI(containedArchives[i]); - String oldURI = getURI(containedArchives[i]); - - if (oldURI != null && !oldURI.equals(newURI)) { - change.add(containedArchives[i]); - } - containedArchiveURIs.put(containedArchives[i], newURI); - } - - if (!add.isEmpty() || !remove.isEmpty() || !change.isEmpty()) { - IModule[] added = new IModule[add.size()]; - getModulesFromDelegates(add).toArray(added); - IModule[] changed = new IModule[change.size()]; - getModulesFromDelegates(change).toArray(changed); - IModule[] removed = new IModule[remove.size()]; - getModulesFromDelegates(remove).toArray(removed); - ////////////TODO add back looselib support/////////////////////////// - //containedArchives = getContainedArchives(); - // fireModuleChangeEvent(true, added, changed, removed); - } - } - - protected List getModulesFromDelegates(List delegates) { - List result = new ArrayList(); - for (int i = 0; i < delegates.size(); i++) { - Object delegate = delegates.get(i); - if (delegate != null && delegate instanceof J2EEDeployable) - result.add(((J2EEDeployable) delegate).getModule()); - } - return result; - } - - /** - * Return the objects that have been added between array a and array b. Assumes that there are - * no null objects in the array. - */ - protected static void addAddedObjects(List list, Object[] a, Object[] b) { - if (b == null) - return; - else if (a == null) { - int size = b.length; - for (int i = 0; i < size; i++) - list.add(b[i]); - return; - } - int size = b.length; - for (int i = 0; i < size; i++) { - Object obj = b[i]; - boolean found = false; - if (a != null) { - int size2 = a.length; - for (int j = 0; !found && j < size2; j++) { - if (obj.equals(a[j])) - found = true; - } - } - if (!found) - list.add(obj); - } - } - - /** - * Return the objects that have been removed between array a and array b. Assumes that there are - * no null objects in the array. - */ - protected static void addRemovedObjects(List list, Object[] a, Object[] b) { - if (a == null) - return; - else if (b == null) { - int size = a.length; - for (int i = 0; i < size; i++) - list.add(a[i]); - return; - } - int size = a.length; - for (int i = 0; i < size; i++) { - Object obj = a[i]; - boolean found = false; - if (b != null) { - int size2 = b.length; - for (int j = 0; !found && j < size2; j++) { - if (obj.equals(b[j])) - found = true; - } - } - if (!found) - list.add(obj); - } - } - - /** - * - */ - protected IJ2EEModule[] getContainedModules() { - Collection projects = getEARNature().getModuleProjects().values(); - List mods = new ArrayList(projects.size()); - Iterator it = projects.iterator(); - J2EENature nat = null; - while (it.hasNext()) { - nat = (J2EENature) it.next(); - if (nat != null) { - Object module = getModule(nat); - if (module != null && module instanceof IModule) { - Object moduleDelegate = ((IModule) module).getAdapter(ModuleDelegate.class); - if (moduleDelegate != null) - mods.add(moduleDelegate); - } - } - } - IJ2EEModule[] result = new IJ2EEModule[mods.size()]; - mods.toArray(result); - return result; - } - - /** - * - */ - protected ILooseArchive[] getContainedArchives() { - EAREditModel editModel = getEARNature().getEarEditModelForRead(this); - try { - List maps = editModel.getUtilityJARMappings(); - if (maps == null) - return new ILooseArchive[0]; - - LooseArchiveDeployableFactory fact = getLooseArchiveDeployableFactory(); - List arcs = new ArrayList(maps.size()); - for (int i = 0; i < maps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) maps.get(i); - IProject proj = null; - if (map.getProjectName() != null) - proj = J2EEPlugin.getWorkspace().getRoot().getProject(map.getProjectName()); - if (proj != null && proj.exists()) { - ILooseArchive archive = getArchiveDeployable(proj, fact); - if (archive != null) - arcs.add(archive); - } - } - ILooseArchive[] result = new ILooseArchive[arcs.size()]; - arcs.toArray(result); - return result; - } finally { - if (editModel != null) - editModel.releaseAccess(this); - } - } - - /* - * @see IEnterpriseApplication#getURI(IJ2EEModule) - */ - protected String getContainedURI(ILooseArchive deployable) { - if (deployable instanceof LooseArchiveDeployable) { - LooseArchiveDeployable archive = (LooseArchiveDeployable) deployable; - EAREditModel editModel = getEARNature().getEarEditModelForRead(this); - try { - UtilityJARMapping map = editModel.getUtilityJARMapping(archive.getProject()); - if (map != null) - return map.getUri(); - return null; - } finally { - editModel.releaseAccess(this); - } - } - - return null; - } - - protected String getContainedURI(IJ2EEModule deployable) { - if (deployable instanceof J2EEDeployable) { - IProject aProject = ((J2EEDeployable) deployable).getProject(); - if (aProject != null) { - Module m = getEARNature().getModule(aProject); - if (m != null) - return m.getUri(); - } - } - return null; - } - - public String getType() { - return "j2ee.ear"; //$NON-NLS-1$ - } - - public String getVersion() { - return getNature().getJ2EEVersionText(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.server.j2ee.IEnterpriseApplication#getLocation() - */ - public IPath getLocation() { - if (getProject() != null && getProject().isAccessible()) - return getProject().getLocation(); - return null; - } - - /** - * Returns the child modules of this module. - * - * @return org.eclipse.wst.server.core.model.IModule[] - */ - public IModule[] getChildModules() { - List list = new ArrayList(); - - if (containedModules != null) { - int size = containedModules.length; - for (int i = 0; i < size; i++) - list.add(containedModules[i]); - } - if (containedArchives != null) { - int size = containedArchives.length; - for (int i = 0; i < size; i++) - list.add(containedArchives[i]); - } - - IModule[] children = new IModule[list.size()]; - list.toArray(children); - return children; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - public IModule[] getModules() { - // TODO Auto-generated method stub - return null; - } - - public IModule[] getLooseArchives() { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseDeployableArtifactAdapterFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseDeployableArtifactAdapterFactory.java deleted file mode 100644 index 87e364ef3..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseDeployableArtifactAdapterFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Created on Jan 18, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.deployables; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; - -public class EnterpriseDeployableArtifactAdapterFactory extends ModuleArtifactAdapterDelegate implements IAdapterFactory { - - public Object getAdapter(Object adaptableObject, Class adapterType) { - return null; - } - - public Class[] getAdapterList() { - return new Class[] {ILaunchable.class }; - } - - public IModuleArtifact getModuleArtifact(Object obj) { - return EnterpriseApplicationDeployableAdapterUtil.getModuleObject(obj); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseModuleArtifact.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseModuleArtifact.java deleted file mode 100644 index 41d4b7fc3..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/EnterpriseModuleArtifact.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Created on Feb 21, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.deployables; - -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; - -/** - * @author blancett - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class EnterpriseModuleArtifact implements IModuleArtifact { - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModuleArtifact#getModule() - */ - public IModule getModule() { - // TODO Auto-generated method stub - return null; - } - - public Class[] getAdapterList() { - return new Class[] { IModuleArtifact.class, ILaunchable.class }; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/FlexibleProjectServerUtil.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/FlexibleProjectServerUtil.java deleted file mode 100644 index 83cdfddd6..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/FlexibleProjectServerUtil.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.eclipse.jst.j2ee.internal.deployables; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.server.core.IJ2EEModule; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.Module; -import org.eclipse.wst.server.core.internal.ModuleFactory; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.model.ModuleDelegate; - -public class FlexibleProjectServerUtil { - public static final String JST_EJB_ID = "jst.ejb"; - public static final String JST_WEB_ID = "jst.web"; - public static final String JST_EAR_ID = "jst.ear"; - public static final String J2EE_EJB_ID = "j2ee.ejb"; - public static final String J2EE_WEB_ID = "j2ee.web"; - public static final String J2EE_EAR_ID = "j2ee.ear"; - - - public static IJ2EEModule getModuleDelegate(WorkbenchComponent component) { - IModule[] modules = getModules(component); - for (int i = 0; i < modules.length; i++) { - Module module = (Module) modules[i]; - if (module.getName().equals(component.getName())) - return getModuleDelgate(module); - } - - return null; - } - - public static IJ2EEModule getModuleDelegate(IVirtualComponent component) { - IModule[] modules = getModules(component); - for (int i = 0; i < modules.length; i++) { - Module module = (Module) modules[i]; - if (module.getName().equals(component.getName())) - return getModuleDelgate(module); - } - - return null; - } - - public static IJ2EEModule getModuleDelgate(Module module) { - ModuleFactory[] factories = ServerPlugin.getModuleFactories(); - for (int i = 0; i < factories.length; i++) { - if (factories[i].getDelegate() == null) - continue; - ModuleDelegate moduleDel = factories[i].getDelegate().getModuleDelegate(module); - if (moduleDel != null) - return (IJ2EEModule) moduleDel; - } - return null; - } - - public static IModule getModule(WorkbenchComponent component) { - IModule[] modules = getModules(component); - for (int i = 0; i < modules.length; i++) { - Module module = (Module) modules[i]; - if (module.getName().equals(component.getName())) - return module; - } - - return null; - } - - protected static IModule[] getModules(WorkbenchComponent component) { - ComponentType type = component.getComponentType(); - IProject project = StructureEdit.getContainingProject(component); - if (type == null || project == null || type.getComponentTypeId() == null) - return null; - IModule[] modules = ServerUtil.getModules(project); - return modules; - } - - protected static IModule[] getModules(IVirtualComponent component) { - IProject project = component.getProject(); - if (project == null || component.getComponentTypeId() == null) - return null; - IModule[] modules = ServerUtil.getModules(project); - return modules; - } - - - public static String convertJSTVersions(String id) { - - if (id.equals(JST_EJB_ID)) - return J2EE_EJB_ID; - - if (id.equals(JST_WEB_ID)) - return J2EE_WEB_ID; - - if (id.equals(JST_EAR_ID)) - return J2EE_EAR_ID; - - - return ""; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java deleted file mode 100644 index 5acdae2e9..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployable.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jst.j2ee.internal.project.J2EEModuleNature; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.jst.server.core.IJ2EEModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.util.ProjectModule; - -/** - * J2EE deployable superclass. - */ -public abstract class J2EEDeployable extends ProjectModule implements IJ2EEModule { - private String factoryId; - - private J2EENature nature; - - /** - * Constructor for J2EEDeployable. - * - * @param project - */ - public J2EEDeployable(J2EENature aNature, String aFactoryId) { - super(aNature.getProject()); - factoryId = aFactoryId; - setNature(aNature); - } - - public String getJ2EESpecificationVersion() { - return getNature().getJ2EEVersionText(); - } - - /* - * @see IJ2EEModule#getLocation() - */ - public IPath getLocation() { - if (getNature() instanceof J2EEModuleNature) - return ((J2EEModuleNature) getNature()).computeModuleAbsoluteLocation(); - return null; - } - - /* - * @see IModule#getFactoryId() - */ - public String getFactoryId() { - return factoryId; - } - - /** - * Gets the nature. - * - * @return Returns a J2EENature - */ - public J2EENature getNature() { - return nature; - } - - /** - * Sets the nature. - * - * @param nature - * The nature to set - */ - protected void setNature(J2EENature nature) { - this.nature = nature; - nature.setModule(getModule()); - } - - /** - * @see com.ibm.etools.server.j2ee.IJ2EEModule#isBinary() - */ - public boolean isBinary() { - if (nature instanceof J2EEModuleNature) - return nature != null && ((J2EEModuleNature) nature).isBinaryProject(); - return false; - } - - public String getModuleTypeName() { - return getName(); - } - - public String getModuleTypeVersion() { - return getVersion(); - } - - public String getVersion() { - return "1.2"; //$NON-NLS-1$ - } - - public String getType() { - return "j2ee.ear"; //$NON-NLS-1$ - } - - public IModuleType getModuleType() { - return new IModuleType() { - - public String getId() { - return getType(); - } - - public String getName() { - return getModuleTypeName(); - } - - public String getVersion() { - return getModuleTypeVersion(); - } - }; - - } - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableAdapterFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableAdapterFactory.java deleted file mode 100644 index 54a70bb75..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableAdapterFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Created on Feb 21, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.deployables; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.Platform; -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.wst.server.core.IModuleArtifact; - - -public class J2EEDeployableAdapterFactory implements IAdapterFactory { - public Object getAdapter(Object adaptableObject, Class adapterType) { - IModuleArtifact moduleArtifact = null; -/* if (adapterType == IModuleArtifact.class ) { - - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.web.deployables.WebModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.web.deployables.WebModuleArtifact"); - } - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.jst.j2ee.ejb.internal.deployables.IEJBModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.jst.j2ee.ejb.internal.deployables.IEJBModuleArtifact"); - } - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.deployables.EnterpriseModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.deployables.EnterpriseModuleArtifact"); - } - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.wst.web.internal.deployables.IStaticWebModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.wst.web.internal.deployables.IStaticWebModuleArtifact"); - } - }*/ - return moduleArtifact; - } - - public Class[] getAdapterList() { - return new Class[]{IModuleArtifact.class, ILaunchable.class}; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java deleted file mode 100644 index 733ccac96..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.internal.Trace; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate; - -/** - * J2EE deployable factory superclass. - */ -public abstract class J2EEDeployableFactory extends ProjectModuleFactoryDelegate { - - protected HashMap projectModules; - - protected final List moduleDelegates = Collections.synchronizedList(new ArrayList(1)); - - private long cachedStamp = -2; - - protected static boolean isFlexableProject(IProject project) { - return ModuleCoreNature.getModuleCoreNature(project) != null; - } - - public J2EEDeployableFactory() { - super(); - } - - /* - * protected void addModuleProject(IProject project) { if (!isFlexableProject(project)) { - * super.addModuleProject(project); return; } ModuleCoreNature nature = null; try { nature = - * (ModuleCoreNature) project.getNature(IModuleConstants.MODULE_NATURE_ID); } catch - * (CoreException e) { Logger.getLogger().write(e); } List modules = createModules(nature); List - * oldModules = (List) getProjectModules().get(project); if (oldModules != null && - * !oldModules.isEmpty()) addNewModules(modules, oldModules); else - * getProjectModules().put(project, modules); if (added == null) added = new ArrayList(2); - * added.addAll(modules); } - */ - - /* *//** - * @param newModules - */ - /* - * private void addNewModules(List newModules, List oldModules) { for (int i = 0; i < - * newModules.size(); i++) { if (!oldModules.contains(newModules.get(i))) - * oldModules.add(newModules.get(i)); } - * } - */ - - - - protected boolean needsUpdating(IProject project) { - if(!initialized) - return true; - IFile wtpmodules = project.getFile(IModuleConstants.WTPMODULE_FILE_PATH); - if(wtpmodules.getModificationStamp() != cachedStamp) { - cachedStamp = wtpmodules.getModificationStamp(); - return true; - } - return false; - } - - - /** - * Return the workspace root. - * - * @return the workspace root - */ - private static IWorkspaceRoot getWorkspaceRoot() { - return ResourcesPlugin.getWorkspace().getRoot(); - } - - - - protected IModule[] createModules(IProject project) { - - // List modules = createModules(nature); - ModuleCoreNature nature = null; - try { - nature = (ModuleCoreNature) project.getNature(IModuleConstants.MODULE_NATURE_ID); - } catch (CoreException e) { - Logger.getLogger().write(e); - } - List modules = createModules(nature); - if (modules == null) - return new IModule[0]; - IModule[] moduleArray = new IModule[modules.size()]; - modules.toArray(moduleArray); - return moduleArray; - } - - protected List createModules(ModuleCoreNature nature) { - IProject project = nature.getProject(); - List modules = new ArrayList(1); - StructureEdit moduleCore = null; - try { - - moduleCore = StructureEdit.getStructureEditForRead(project); - ProjectComponents projComp = moduleCore.getComponentModelRoot(); - if (projComp == null) - return modules; - EList workBenchModules = projComp.getComponents(); - if (workBenchModules.isEmpty()) - return modules; - modules = createModuleDelegates(workBenchModules, project); - - } catch (Exception e) { - e.printStackTrace(); - } finally { - if(moduleCore != null) - moduleCore.dispose(); - } - return modules; - } - - - protected abstract List createModuleDelegates(EList workBenchModules, IProject project) throws CoreException; - - - protected boolean isValidModule(IProject project) { - try { - return isFlexableProject(project); - } catch (Exception e) { - //Ignore - } - return false; - } - - protected abstract String getNatureID(); - - -/* protected IModule createModule(IProject project) { - try { - J2EENature nature = (J2EENature) project.getNature(getNatureID()); - return createModule(nature); - } catch (Exception e) { - } - return null; - }*/ - - - public ModuleDelegate getModuleDelegate(IModule module) { - if(moduleDelegates.size() == 0) - return null; - ModuleDelegate[] delegates = (ModuleDelegate[]) - moduleDelegates.toArray(new ModuleDelegate[moduleDelegates.size()]); - for (int i=0; i<delegates.length; i++) { - if (module == delegates[i].getModule()) - return delegates[i]; - } - return null; - } - - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java deleted file mode 100644 index 5324923dd..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jst.server.core.IJ2EEModule; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.util.ProjectModule; - -/** - * J2EE deployable superclass. - */ -public abstract class J2EEFlexProjDeployable extends ProjectModule implements IJ2EEModule { - private String factoryId; - protected WorkbenchComponent wbModule = null; - - - /** - * Constructor for J2EEFlexProjDeployable. - * - * @param project - */ - public J2EEFlexProjDeployable(IProject project, String aFactoryId, WorkbenchComponent aWorkbenchModule) { - super(project); - factoryId = aFactoryId; - wbModule = aWorkbenchModule; - } - - public String getJ2EESpecificationVersion() { - return "1.2"; //$NON-NLS-1$ - } - - /* - * @see IJ2EEModule#getLocation() - */ - public IPath getLocation() { - - IPath path = null; - if ( ModuleCoreNature.getModuleCoreNature(project) != null ) { - if( wbModule != null ){ - - IFolder outputContainer = StructureEdit.getOutputContainerRoot(wbModule); - path = outputContainer.getRawLocation(); - } - } - - return path; - - } - - - - /* - * @see IModule#getFactoryId() - */ - public String getFactoryId() { - return factoryId; - } - - - - - - /** - * @see com.ibm.etools.server.j2ee.IJ2EEModule#isBinary() - */ - public boolean isBinary() { - return false; - } - - public String getModuleTypeName() { - return getName(); - } - - public String getModuleTypeVersion() { - return getVersion(); - } - public ComponentHandle getComponentHandle() { - return ComponentHandle.create(StructureEdit.getContainingProject(wbModule),wbModule.getHandle()); - } - - public String getVersion() { - return "1.2"; //$NON-NLS-1$ - } - - public String getType() { - return "j2ee.ear"; //$NON-NLS-1$ - } - - public IModuleType getModuleType() { - return new IModuleType() { - - public String getId() { - return getType(); - } - - public String getName() { - return getModuleTypeName(); - } - - public String getVersion() { - return getModuleTypeVersion(); - } - }; - - } - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JavaComponentBuilderDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JavaComponentBuilderDataModelProvider.java deleted file mode 100644 index 2552d9696..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JavaComponentBuilderDataModelProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004, 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.j2ee.internal.deployables; - -import org.eclipse.wst.common.componentcore.internal.builder.WorkbenchComponentBuilderDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class JavaComponentBuilderDataModelProvider extends WorkbenchComponentBuilderDataModelProvider { - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#getDefaultOperation() - */ - public IDataModelOperation getDefaultOperation() { - return new JavaComponentBuilderOperation(model); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JavaComponentBuilderOperation.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JavaComponentBuilderOperation.java deleted file mode 100644 index cb3571c75..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JavaComponentBuilderOperation.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004, 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.j2ee.internal.deployables; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IMarker; -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.NullProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.ClasspathEntry; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPluginResourceHandler; -import org.eclipse.wst.common.componentcore.datamodel.properties.IWorkbenchComponentBuilderDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.builder.ComponentStructuralBuilder; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class JavaComponentBuilderOperation extends AbstractDataModelOperation implements IWorkbenchComponentBuilderDataModelProperties{ - /** - * @param model - */ - public JavaComponentBuilderOperation(IDataModel model) { - super(model); - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus execute(IProgressMonitor monitor, IAdaptable info) { - try { - WorkbenchComponent workbenchModule = (WorkbenchComponent)model.getProperty(WORKBENCH_COMPONENT); - - IProject project = (IProject)model.getProperty(PROJECT); - IPath projectPath = project.getFullPath(); - IJavaProject javaProj = JavaProjectUtilities.getJavaProject(project); - List javaSourceFolderList = JavaProjectUtilities.getSourceContainers(project); - - - // create output container folder if it does not exist - IFolder outputContainer = (IFolder)model.getProperty(OUTPUT_CONTAINER); - if(!outputContainer.exists()) - createFolder(outputContainer); - - IPath outputContainerPath = outputContainer.getFullPath(); - - // copy resources except the java source folder - List resourceList = workbenchModule.getResources(); - List javaOutputPathList = new ArrayList(); - for (int i = 0; i < resourceList.size(); i++) { - ComponentResource wmr = (ComponentResource)resourceList.get(i); - IResource sourceResource = StructureEdit.getEclipseResource(wmr); - if (sourceResource == null || sourceResource.getName().endsWith(".java") ) - continue; - IPath deployPath = outputContainerPath.append(wmr.getRuntimePath()); - // check if it is a java source folder - if (javaSourceFolderList.contains(sourceResource)) { - // check if there are nested java output paths. if so, abort. - for (int j = 0; j < javaOutputPathList.size(); j++) { - IPath path = (IPath)javaOutputPathList.get(j); - if (!path.equals(deployPath) && (path.isPrefixOf(deployPath) || deployPath.isPrefixOf(path))) { - - IResource wtpmoduleFile = project.findMember(".wtpmodules"); //$NON-NLS-1$ - // add a problem marker - IMarker m = wtpmoduleFile.createMarker(IMarker.PROBLEM); - String msg = J2EEPluginResourceHandler.getString("NESTED_JAVA_OUTPUT_ERROR"); //$NON-NLS-1$ - m.setAttribute(IMarker.MESSAGE, msg); - m.setAttribute(IMarker.SEVERITY,IMarker.SEVERITY_ERROR); - return OK_STATUS; - } - } - // add deployPath to list - javaOutputPathList.add(deployPath); - continue; - } - // create parent folders for deploy folder if not exist - IPath parentPath = deployPath.removeLastSegments(1); - createFolder(parentPath); - ComponentStructuralBuilder.smartCopy(sourceResource, deployPath, new NullProgressMonitor()); - } - - // set Java specific output path, do it after resource copy - IClasspathEntry[] cpe = javaProj.getRawClasspath(); - boolean classpathModified = false; - for (int i = 0; i < resourceList.size(); i++) { - ComponentResource wmr = (ComponentResource)resourceList.get(i); - IResource sourceResource = StructureEdit.getEclipseResource(wmr); - // check if it is a java source folder - if (javaSourceFolderList.contains(sourceResource)) { - // get the classpath entry - int index = -1; - for (int j = 0; j < cpe.length; j++) { - if (cpe[j].getPath().equals(sourceResource.getFullPath())) { - index = j; - break; - } - } - IPath classFilesPath = outputContainerPath.append(wmr.getRuntimePath()); - // check if the classpath is modified. Use relative path to avoid - // the problem that drive letter could be upper or lower case - IPath relativeClassFilesPath = classFilesPath.makeRelative(); - IPath oldClassFilesPath = ((ClasspathEntry)cpe[index]).specificOutputLocation; - IPath oldRelativeClassFilesPath = null; - if (oldClassFilesPath != null) - oldRelativeClassFilesPath = oldClassFilesPath.makeRelative(); - if (!relativeClassFilesPath.equals(oldRelativeClassFilesPath)) { - ((ClasspathEntry)cpe[index]).specificOutputLocation = classFilesPath; - classpathModified = true; - } - createFolder(classFilesPath); - } - } - // update classpath only when it is modified - if (classpathModified) - javaProj.setRawClasspath(cpe, new NullProgressMonitor()); - } catch (JavaModelException e) { - Logger.getLogger().log(e.getMessage()); - } catch (CoreException e) { - Logger.getLogger().log(e.getMessage()); - } - return OK_STATUS; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus redo(IProgressMonitor monitor, IAdaptable info) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus undo(IProgressMonitor monitor, IAdaptable info) { - // TODO Auto-generated method stub - return null; - } - /** - * @param outputContainer - */ - private void createFolder(IFolder outputContainer) { - IContainer parentContainer = outputContainer.getParent(); - if(parentContainer != null && !parentContainer.exists() && parentContainer.getType() == IResource.FOLDER) { - createFolder((IFolder)outputContainer.getParent()); - } - try { - if(!outputContainer.exists()) - outputContainer.create(true, true, null); - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - /** - * Get resource for given absolute path - * - * @exception com.ibm.itp.core.api.resources.CoreException - */ - private IResource getResource(IPath absolutePath) throws CoreException { - IResource resource = null; - if (absolutePath != null && !absolutePath.isEmpty()) - resource = ResourcesPlugin.getWorkspace().getRoot().findMember(absolutePath); - return resource; - } - - - /** - * Create a folder for given absolute path - * - * @exception com.ibm.itp.core.api.resources.CoreException - */ - private IFolder createFolder(IPath absolutePath) throws CoreException { - if (absolutePath == null || absolutePath.isEmpty()) - return null; - IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(absolutePath); - // check if the parent is there - IContainer parent = folder.getParent(); - if (parent != null && !parent.exists() && (parent instanceof IFolder)) - createFolder(parent.getFullPath()); - if (!folder.exists()) - folder.create(true, true, new NullProgressMonitor()); - return folder; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/LooseArchiveDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/LooseArchiveDeployable.java deleted file mode 100644 index 47a4c64a9..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/LooseArchiveDeployable.java +++ /dev/null @@ -1,116 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.server.core.ILooseArchive; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.util.ProjectModule; - - -public class LooseArchiveDeployable extends ProjectModule implements ILooseArchive{ - protected String factoryId; - - /** - * Constructor for LooseArchiveDeployable. - */ - public LooseArchiveDeployable(IProject aProject, String aFactoryId) { - super(aProject); - factoryId = aFactoryId; - } - - /* - * @see ILooseArchive#getLocation() - */ - public IPath getLocation() { - return J2EEProjectUtilities.getRuntimeLocation(project); - } - - /* - * @see com.ibm.etools.server.core.util.DeployableProject#isBinary() - */ - public boolean isBinary() { - return JavaProjectUtilities.isBinaryProject(getProject()); - } - - /* - * @see com.ibm.etools.server.core.util.DeployableProject#getRootFolder() - */ - public IPath getRootFolder() { - if (isBinary()) - return null; - IContainer c = JavaProjectUtilities.getJavaProjectOutputContainer(getProject()); - if (c != null) - return c.getProjectRelativePath(); - return null; - } - - /* - * @see getFactoryId() - */ - public String getFactoryId() { - return factoryId; - } - - public String getType() { - return "j2ee.loosearchive"; //$NON-NLS-1$ - } - - public String getVersion() { - return "1.0"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#getModuleType() - */ - public IModuleType getModuleType() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.IModule#getChildModules(org.eclipse.core.runtime.IProgressMonitor) - */ - public IModule[] getChildModules(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/LooseArchiveDeployableFactory.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/LooseArchiveDeployableFactory.java deleted file mode 100644 index e71e08c12..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/LooseArchiveDeployableFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.deployables; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate; - -public class LooseArchiveDeployableFactory extends ProjectModuleFactoryDelegate { - private static final String ID = "com.ibm.wtp.server.looseArchive"; //$NON-NLS-1$ - - /* - * @see DeployableProjectFactoryDelegate#getFactoryID() - */ - public String getFactoryId() { - return ID; - } - - /** - * Returns true if the project represents a deployable project of this type. - * - * @param project - * org.eclipse.core.resources.IProject - * @return boolean - */ - protected boolean isValidModule(IProject project) { - - return false; - } - - /** - * Creates the deployable project for the given project. - * - * @param project - * org.eclipse.core.resources.IProject - * @return com.ibm.etools.server.core.model.IProjectModule - */ - - - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule) - */ - public ModuleDelegate getModuleDelegate(IModule module) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() - */ - public IModule[] getModules() { - // TODO Auto-generated method stub - return null; - } - - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate#createModules(org.eclipse.core.resources.IProject) - */ - protected IModule[] createModules(IProject project) { - // TODO Auto-generated method stub - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java deleted file mode 100644 index b8f2cedea..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.eclipse.jst.j2ee.internal.plugin; - -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; - -public interface IJ2EEModuleConstants extends IModuleConstants { - - String J2EE_PLUGIN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java deleted file mode 100644 index a0c2f8a3e..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.plugin; - - -public interface IJ2EEPreferences { - - String PREF_J2EEWEBCONTENT = "org.eclipse.jst.j2ee.internal.preference.j2eeWebContentName"; //$NON-NLS-1$ - String PREF_STATICWEBCONTENT = "org.eclipse.jst.j2ee.internal.preference.staticWebContentName"; //$NON-NLS-1$ - String PREF_JAVASOURCE = "org.eclipse.jst.j2ee.internal.preference.javaSourceName"; //$NON-NLS-1$ - String DEFAULT_J2EEWEBCONTENT = "WebContent"; //$NON-NLS-1$ - String DEFAULT_STATICWEBCONTENT = "WebContent"; //$NON-NLS-1$ - String DEFAULT_JAVASOURCE = "JavaSource"; //$NON-NLS-1$ - String SERVER_TARGET_SUPPORT = "org.eclipse.jst.j2ee.internal.preference.servertargetsupport"; //$NON-NLS-1$ - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java deleted file mode 100644 index c7ea0800b..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Dec 4, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.plugin; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.frameworks.internal.enablement.IGroupInitializer; - - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class J2EEGroupInitializer implements IGroupInitializer { - - /** - * - */ - public J2EEGroupInitializer() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.group.IGroupInitializer#isGroupEnabled(org.eclipse.core.resources.IProject) - */ - public boolean isGroupEnabled(IProject project) { - return true; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java deleted file mode 100644 index 1c1572fb8..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java +++ /dev/null @@ -1,563 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.plugin; - - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Vector; - -import org.eclipse.core.internal.boot.PlatformURLConnection; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -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.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.util.ResourceLocator; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.internal.core.JavaModel; -import org.eclipse.jem.util.UIContextDetermination; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; -import org.eclipse.jst.j2ee.application.ApplicationFactory; -import org.eclipse.jst.j2ee.applicationclient.internal.modulecore.util.AppClientEditAdapterFactory; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveInit; -import org.eclipse.jst.j2ee.internal.application.ApplicationPackage; -import org.eclipse.jst.j2ee.internal.application.impl.ApplicationFactoryImpl; -import org.eclipse.jst.j2ee.internal.application.impl.ApplicationResourceFactory; -import org.eclipse.jst.j2ee.internal.client.impl.ApplicationClientResourceFactory; -import org.eclipse.jst.j2ee.internal.common.impl.J2EEResourceFactoryRegistry; -import org.eclipse.jst.j2ee.internal.modulecore.util.EarEditAdapterFactory; -import org.eclipse.jst.j2ee.internal.validation.ResourceUtil; -import org.eclipse.jst.j2ee.internal.webservices.WSDLServiceExtensionRegistry; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.impl.WTPResourceFactoryRegistry; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; -import org.eclipse.wst.common.frameworks.internal.operations.IHeadlessRunnableWithProgress; -import org.eclipse.wst.common.internal.emf.resource.ReferencedXMIFactoryImpl; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.validation.internal.operations.ValidatorManager; -import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -/** - * This is a top-level class of the j2ee plugin. - * - * @see AbstractUIPlugin for additional information on UI plugins - */ - -public class J2EEPlugin extends WTPPlugin implements ResourceLocator { - // Default instance of the receiver - private static J2EEPlugin inst; - public static final String PLUGIN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$ - public static final String UI_PLUGIN_ID = "org.eclipse.jst.j2ee.ui"; //$NON-NLS-1$ - protected final IPath iconsFolder = new Path(Platform.getBundle(PLUGIN_ID).getEntry("icons").getPath()); //$NON-NLS-1$ - // LibDir Change Listener - public static final String LIBDIRCHANGE_BUILDER_ID = "org.eclipse.jst.j2ee.web.LibDirBuilder"; //$NON-NLS-1$ - // LibCopy builder ID - public static final String LIBCOPY_BUILDER_ID = PLUGIN_ID + ".LibCopyBuilder"; //$NON-NLS-1$ - // Validation part of the plugin - public static final String VALIDATION_BUILDER_ID = ValidationPlugin.VALIDATION_BUILDER_ID; // plugin - private static final String KEY_PREFIX = "%"; //$NON-NLS-1$ - private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$ - // id - // of - // the - // validation - // builder//$NON-NLS-1$ - //Global ResourceSet (somewhat global) - private static boolean defaultIsWorkspaceRelativeSchema = false; - - private List fextendedEditModels; - private static IPath location; - - public static IStatus OK_STATUS = new Status(IStatus.OK, PLUGIN_ID, 0, "OK", null); //$NON-NLS-1$ - - public static final String[] ICON_DIRS = new String[]{"icons/full/obj16", //$NON-NLS-1$ - "icons/full/cview16", //$NON-NLS-1$ - "icons/full/ctool16", //$NON-NLS-1$ - "icons/full/clcl16", //$NON-NLS-1$ - "icons/full/ovr16", //$NON-NLS-1$ - "icons/full/extra", //$NON-NLS-1$ - "icons/full/wizban", //$NON-NLS-1$ - "icons", //$NON-NLS-1$ - ""}; //$NON-NLS-1$ - - protected static Boolean EJB_AVAILABLE = null; - private static Boolean HAS_DEV_ROLE; - - private J2EEPreferences preferences = null; - public static J2EEPlugin INSTANCE = inst; - - /** - * Create the J2EE plugin and cache its default instance - */ - public J2EEPlugin() { - super(); - if (inst == null) - inst = this; - try { - resourceBundle = ResourceBundle.getBundle("org.eclipse.jst.j2ee"); //$NON-NLS-1$ - } catch (MissingResourceException x) { - resourceBundle = null; - } - } - - /** - * Insert the method's description here. Creation date: (7/16/2001 7:38:56 PM) - * - * @return boolean - */ - public static boolean defaultIsWorkspaceRelativeSchema() { - return defaultIsWorkspaceRelativeSchema; - } - - /** - * Get the one application factory. - */ - public ApplicationFactory getApplicationFactory() { - return (ApplicationFactory) getApplicationPackage().getEFactoryInstance(); - } - - /** - * Get the one ejb package. - */ - public ApplicationPackage getApplicationPackage() { - return ApplicationFactoryImpl.getPackage(); - } - - /** - * Get the plugin singleton. - */ - static public J2EEPlugin getDefault() { - return inst; - } - - /* - * Javadoc copied from interface. - */ - public URL getBaseURL() { - return getBundle().getEntry("/"); - } - - - public Object[] getJ2EEWebProjectMigrationExtensions() { - - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint pct = registry.getExtensionPoint("J2EEWebProjectMigrationExtension"); //$NON-NLS-1$ - List ret = new Vector(); - if (pct != null) { - IExtension[] extension = pct.getExtensions(); - for (int l = 0; l < extension.length; ++l) { - IExtension config = extension[l]; - - IConfigurationElement[] cElems = config.getConfigurationElements(); - for (int i = 0; i < cElems.length; i++) { - IConfigurationElement d = cElems[i]; - if (d.getName().equals("migration")) { //$NON-NLS-1$ - try { - Object me = d.createExecutableExtension("run"); //$NON-NLS-1$ - - ret.add(me); - } catch (Exception ex) { - // ignore this extension, keep going - } - } - } - } - } - return ret.toArray(); - } - - public EditModel getExtendedEditModel(String editModelKey) { - - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint pct = registry.getExtensionPoint("EditModelExtension"); //$NON-NLS-1$ - - IExtension[] extension = pct.getExtensions(); - for (int l = 0; l < extension.length; ++l) { - IExtension config = extension[l]; - - IConfigurationElement[] cElems = config.getConfigurationElements(); - for (int i = 0; i < cElems.length; i++) { - IConfigurationElement d = cElems[i]; - if (d.getName().equals("editmodel") && editModelKey.equals(d.getAttribute("key"))) //$NON-NLS-1$ //$NON-NLS-2$ - { // editmodel class - try { - return (EditModel) d.createExecutableExtension("run"); //$NON-NLS-1$ - - } catch (Exception ex) { - return null; - } - } - } - } - - return null; - } - - public List getExtendedEditModels() { - - if (fextendedEditModels != null) - return fextendedEditModels; - List editModels = new ArrayList(); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint pct = registry.getExtensionPoint("EditModelExtension"); //$NON-NLS-1$ - - IExtension[] extension = pct.getExtensions(); - for (int l = 0; l < extension.length; ++l) { - IExtension config = extension[l]; - - IConfigurationElement[] cElems = config.getConfigurationElements(); - for (int i = 0; i < cElems.length; i++) { - IConfigurationElement d = cElems[i]; - if (d.getName().equals("editmodel")) //$NON-NLS-1$ - { - // editmodel class - try { - editModels.add(d.createExecutableExtension("run")); //$NON-NLS-1$ - - } catch (Exception ex) { - return null; - } - } - } - } - fextendedEditModels = editModels; - return fextendedEditModels; - } - - /** - * This gets a .gif from the icons folder. - */ - public static URL getImageURL(String key, Bundle bundle) { - String gif = "/" + key + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$ - IPath path = null; - for (int i = 0; i < ICON_DIRS.length; i++) { - path = new Path(ICON_DIRS[i]).append(gif); - if (Platform.find(bundle,path) == null) - continue; - try { - return new URL( bundle.getEntry("/"), path.toString()); - } catch (MalformedURLException exception) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(J2EEPluginResourceHandler.getString("Load_Image_Error_", new Object[]{key})); //$NON-NLS-1$ - exception.printStackTrace(); - continue; - } - } - return null; - } - - /** - * This gets a .gif from the icons folder. - */ - public Object getImage(String key) { - return getImageURL(key,this.getBundle()); - } - - public static IPath getInstallLocation() { - if (location == null) { - URL url = getInstallURL(); - try { - String installLocation = ((PlatformURLConnection) url.openConnection()).getURLAsLocal().getFile(); - location = new Path(installLocation); - } catch (IOException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(J2EEPluginResourceHandler.getString("Install_Location_Error_", new Object[]{url}) + e); //$NON-NLS-1$ - } - } - return location; - } - - public static URL getInstallURL() { - return getDefault().getBundle().getEntry("/"); - } - - protected static JavaModel getJavaModel() { - return JavaProjectUtilities.getJavaModel(); - } - - protected static JavaModel getJavaModel(IProject aProject) { - if (aProject != null) - return JavaProjectUtilities.getJavaModel(); - return null; - } - - public static IJavaProject getJavaProject(IProject project) { - JavaModel model = getJavaModel(project); - if (model != null) - return model.getJavaProject(project); - return null; - } - - /** - * Retrieves a hashtable of a logger's preferences initially from the - * com.ibm.etools.logging.util.loggingDefaults extension point if specified in the - * com.ibm.etools.logging.util plugin.xml file. If specified, the - * com.ibm.etools.logging.util.loggingOptions extension point preferences in the parameter - * plugin's plugin.xml file are returned. - * - * The logger's preferences are stored in the return hashtable using the static instance - * variables in LoggerStateHashKeys as keys. - * - * @param plugin - * the Plugin polled for their logger's preferences in the plugin.xml file - * @return hashtable of a logger's preferences - */ - /* - * public java.util.Hashtable getMsgLoggerConfig(org.eclipse.core.runtime.Plugin plugin) { - * return (new PluginHelperImpl().getMsgLoggerConfig(plugin)); } - */ - /** - * Get the singleton instance. - */ - public static J2EEPlugin getPlugin() { - return inst; - } - - /** - * Return the plugin directory location- the directory that all the plugins are located in (i.e. - * d:\installdir\plugin) - */ - public static IPath getPluginLocation(String pluginId) { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - Bundle bundle = Platform.getBundle(pluginId); - if (bundle != null) { - try { - IPath installPath = new Path(bundle.getEntry("/").toExternalForm()).removeTrailingSeparator(); - String installStr = Platform.asLocalURL(new URL(installPath.toString())).getFile(); - return new Path(installStr); - } catch (IOException e) { - }; - } - return null; - } - - protected void initializeDefaultPluginPreferences() { - getJ2EEPreferences().initializeDefaultPreferences(); - } - - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - /** - * If this is called from an operation, in response to some other exception that was caught, - * then the client code should throw {@link com.ibm.etools.wft.util.WFTWrappedException}; - * otherwise this can still be used to signal some other error condition within the operation, - * or to throw a core exception in a context other than executing an operation - * - * Create a new IStatus of type ERROR using the J2EEPlugin ID. aCode is just an internal code. - */ - public static IStatus newErrorStatus(int aCode, String aMessage, Throwable exception) { - return newStatus(IStatus.ERROR, aCode, aMessage, exception); - } - - /** - * If this is called from an operation, in response to some other exception that was caught, - * then the client code should throw {@link com.ibm.etools.wft.util.WFTWrappedException}; - * otherwise this can still be used to signal some other error condition within the operation, - * or to throw a core exception in a context other than executing an operation - * - * Create a new IStatus of type ERROR, code OPERATION_FAILED, using the J2EEPlugin ID - */ - public static IStatus newErrorStatus(String aMessage, Throwable exception) { - return newErrorStatus(0, aMessage, exception); - } - - /** - * If this is called from an operation, in response to some other exception that was caught, - * then the client code should throw {@link com.ibm.etools.wft.util.WFTWrappedException}; - * otherwise this can still be used to signal some other error condition within the operation. - * - * Create a new IStatus of type ERROR, code OPERATION_FAILED, using the J2EEPlugin ID - */ - public static IStatus newOperationFailedStatus(String aMessage, Throwable exception) { - return newStatus(IStatus.ERROR, IResourceStatus.OPERATION_FAILED, aMessage, exception); - } - - /** - * Create a new IStatus with a severity using the J2EEPlugin ID. aCode is just an internal code. - */ - public static IStatus newStatus(int severity, int aCode, String aMessage, Throwable exception) { - return new Status(severity, PLUGIN_ID, aCode, aMessage, exception); - } - - /* - * Javadoc copied from interface. - */ - public String getString(String key) { - try { - return Platform.getResourceString(getBundle(), key); - } catch (MissingResourceException ex) { - //TODO Don't throw error - just show unresolved key - //Logger.getLogger().logError(ex); - return '!' + key + '!'; - } - } - - /* - * Javadoc copied from interface. - */ - public String getString(String key, Object[] substitutions) { - return MessageFormat.format(getString(key), substitutions); - } - - /** - * Insert the method's description here. Creation date: (7/16/2001 7:38:56 PM) - * - * @param newDefaultIsWorkspaceRelativeSchema - * boolean - */ - public static void setDefaultIsWorkspaceRelativeSchema(boolean newDefaultIsWorkspaceRelativeSchema) { - defaultIsWorkspaceRelativeSchema = newDefaultIsWorkspaceRelativeSchema; - } - - /** - * This method should be used to determine if the EJB UI support is currently packaged in the - * image. - */ - public static boolean isEJBSupportAvailable() { - if (EJB_AVAILABLE == null) { - //TODO We need a better mechanism for the detection of the EJB support. - //IPluginDescriptor desc = - // Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.jst.j2ee.internal.internal.ejb.ui"); - // //$NON-NLS-1$ - // EJB_AVAILABLE = new Boolean(desc != null); - EJB_AVAILABLE = Boolean.TRUE; - } - return EJB_AVAILABLE.booleanValue(); - } - - /** - * This method should be used to determine if the workbench is running in UI or Headless - * - * @deprecated use {@link org.eclipse.wst.common.frameworks.internal.UIContextDetermination} - */ - public static boolean isHeadless() { - return UIContextDetermination.getCurrentContext() == UIContextDetermination.HEADLESS_CONTEXT; - } - - /** - * Sets the logger's preferences based on values in the parameter hashtable. - * - * The logger's preferences are stored in the parameter hashtable using the static instance - * variables in LoggerStateHashKeys as keys. - * - * @param msgLoggerConfig - * hashtable of the logger's preferences - */ - /* - * public void setMsgLoggerConfig(java.util.Hashtable msgLoggerConfig) { MsgLogger ml = - * getLogger(); ml.setMsgLoggerConfig(msgLoggerConfig); - * org.eclipse.wst.common.frameworks.internal.logger.proxy.Logger.getLogger(PLUGIN_ID).setTraceMode( - * ml.getMsgLoggerConfig().get(LoggerStateHashKeys.LEVEL).equals(Level.getLevelName(Level.FINEST))); } - */ - public void stop(BundleContext bundle) throws Exception { - super.stop(bundle); - } - - public void start(BundleContext context) throws Exception { - super.start(context); - //Have to do the next line immediately to fix timing problems with factory registration - ArchiveInit.init(false); - //ModuleMaps are the maps from modules in an ear project to the j2ee projects for the - // modules - org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapInit.init(false); - ensureFactoryRegistration(); - ValidatorManager.setResourceUtilClass(ResourceUtil.class); - IAdapterManager manager = Platform.getAdapterManager(); - manager.registerAdapters(new EarEditAdapterFactory(), ArtifactEditModel.class); - manager.registerAdapters(new AppClientEditAdapterFactory(), ArtifactEditModel.class); - ApplicationResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); - ApplicationClientResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); - WSDLServiceExtensionRegistry.getInstance(); - - } - - /* - * need to make sure the correct factories get loaded when we are in the UI - */ - private void ensureFactoryRegistration() { - //Inside the workbench we do not want the global override defined here. - ensureDefaultReferencedXMIResourceFactoryRegistration(); - } - - /** - * - */ - private void ensureDefaultReferencedXMIResourceFactoryRegistration() { - J2EEResourceFactoryRegistry reg = J2EEResourceFactoryRegistry.INSTANCE; - ReferencedXMIFactoryImpl factory = new ReferencedXMIFactoryImpl(); - reg.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, factory); - // add xmi because other plugins are registering it globally - reg.getExtensionToFactoryMap().put("xmi", factory); //$NON-NLS-1$ - } - - /** - * This is currently just a convenience api for the AAW to turn off unwanted actions. It will - * currently be initialized based on the existence of the AAW plugin. - */ - public static boolean hasDevelopmentRole() { - if (HAS_DEV_ROLE == null) { - Bundle desc = Platform.getBundle("org.eclipse.jst.j2ee.assembly"); //$NON-NLS-1$ - HAS_DEV_ROLE = desc != null ? Boolean.FALSE : Boolean.TRUE; - } - return HAS_DEV_ROLE.booleanValue(); - } - - public static IWorkspaceRunnable getWorkspaceRunnable(final IHeadlessRunnableWithProgress op) { - return new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - try { - op.run(monitor); - } catch (InvocationTargetException e) { - throw new CoreException(newErrorStatus(0, e.getMessage(), e)); - } catch (InterruptedException e) { - throw new CoreException(newErrorStatus(0, e.getMessage(), e)); - } - } - }; - } - - public String getPluginID() { - return PLUGIN_ID; - } - - /** - * @return Returns the preferences. - */ - public J2EEPreferences getJ2EEPreferences() { - if (this.preferences == null) - this.preferences = new J2EEPreferences(this); - return this.preferences; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java deleted file mode 100644 index 54eb06053..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.plugin; - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class J2EEPluginResourceHandler { - - private static ResourceBundle fgResourceBundle; - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle("j2eewtpplugin");//$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and - // getString(String, String) will return the key - // it was called with - } - return null; - } - - public static String getString(String key) { - if (fgResourceBundle == null) { - fgResourceBundle = getResourceBundle(); - } - - if (fgResourceBundle != null) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - } - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - - public static String getString(String key, Object[] args) { - - try { - return MessageFormat.format(getString(key), args); - } catch (IllegalArgumentException e) { - return getString(key); - } - - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java deleted file mode 100644 index 64b87a3c5..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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 - *******************************************************************************/ -/* - * Created on Jan 26, 2004 - * - * To change the template for this generated file go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.plugin; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; - - -/** - * @author mdelder - */ -public class J2EEPreferences { - - public interface Keys { - final static String J2EE_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.j2eeWebContentName"; //$NON-NLS-1$ - final static String STATIC_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.staticWebContentName"; //$NON-NLS-1$ - final static String JAVA_SOURCE = "org.eclipse.jst.j2ee.preference.javaSourceName"; //$NON-NLS-1$ - final static String SERVER_TARGET_SUPPORT = "org.eclipse.jst.j2ee.preference.servertargetsupport"; //$NON-NLS-1$ - final static String CREATE_EJB_CLIENT_JAR = "org.eclipse.jst.j2ee.preference.createClientJar"; //$NON-NLS-1$ - final static String J2EE_VERSION = "org.eclipse.jst.j2ee.ui.preference.j2eeVersion"; //$NON-NLS-1$ - final static String EJB_CLIENT_JAR_CP_COMPATIBILITY = "org.eclipse.jst.j2ee.preference.clientjar.cp.compatibility"; //$NON-NLS-1$ - final static String INCREMENTAL_DEPLOYMENT_SUPPORT = "org.eclipse.jst.j2ee.ui.preference.incrementalDeployment"; //$NON-NLS-1$ - - - } - - public interface Values { - final static String J2EE_VERSION_1_2 = "J2EE_1_2"; //$NON-NLS-1$ - final static String J2EE_VERSION_1_3 = "J2EE_1_3"; //$NON-NLS-1$ - final static String J2EE_VERSION_1_4 = "J2EE_1_4"; //$NON-NLS-1$ - - final static String J2EE_WEB_CONTENT = "WebContent"; //$NON-NLS-1$ - final static String STATIC_WEB_CONTENT = "WebContent"; //$NON-NLS-1$ - final static String JAVA_SOURCE = "JavaSource"; //$NON-NLS-1$ - } - - public interface Defaults { - - final static String J2EE_WEB_CONTENT = Values.J2EE_WEB_CONTENT; - final static String STATIC_WEB_CONTENT = Values.STATIC_WEB_CONTENT; - final static String JAVA_SOURCE = Values.JAVA_SOURCE; - final static String J2EE_VERSION = Values.J2EE_VERSION_1_4; - final static int J2EE_VERSION_ID = J2EEVersionConstants.J2EE_1_4_ID; - final static boolean CREATE_EJB_CLIENT_JAR = false; - final static boolean EJB_CLIENT_JAR_CP_COMPATIBILITY = true; - final static boolean INCREMENTAL_DEPLOYMENT_SUPPORT = false; - } - - private Plugin owner = null; - private Preferences preferences = null; - private boolean persistOnChange = false; - - public J2EEPreferences(Plugin owner) { - this.owner = owner; - } - - protected void initializeDefaultPreferences() { - getPreferences().setDefault(Keys.J2EE_WEB_CONTENT, Defaults.J2EE_WEB_CONTENT); - getPreferences().setDefault(Keys.STATIC_WEB_CONTENT, Defaults.STATIC_WEB_CONTENT); - getPreferences().setDefault(Keys.JAVA_SOURCE, Defaults.JAVA_SOURCE); - - getPreferences().setDefault(Keys.J2EE_VERSION, Defaults.J2EE_VERSION); - getPreferences().setDefault(Keys.CREATE_EJB_CLIENT_JAR, Defaults.CREATE_EJB_CLIENT_JAR); - getPreferences().setDefault(Keys.EJB_CLIENT_JAR_CP_COMPATIBILITY, Defaults.EJB_CLIENT_JAR_CP_COMPATIBILITY); - getPreferences().setDefault(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT, Defaults.INCREMENTAL_DEPLOYMENT_SUPPORT); - - } - - public String getJ2EEWebContentFolderName() { - return getPreferences().getString(Keys.J2EE_WEB_CONTENT); - } - - public String getStaticWebContentFolderName() { - return getPreferences().getString(Keys.STATIC_WEB_CONTENT); - } - - public String getJavaSourceFolderName() { - return getPreferences().getString(Keys.JAVA_SOURCE); - } - - public String getHighestJ2EEVersionSetting() { - return getPreferences().getString(Keys.J2EE_VERSION); - } - - public boolean isServerTargetingEnabled() { - return getPreferences().getBoolean(Keys.SERVER_TARGET_SUPPORT); - } - - /// - public void setJ2EEWebContentFolderName(String value) { - getPreferences().setValue(Keys.J2EE_WEB_CONTENT, value); - firePreferenceChanged(); - } - - public void setStaticWebContentFolderName(String value) { - getPreferences().setValue(Keys.STATIC_WEB_CONTENT, value); - firePreferenceChanged(); - } - - public void setJavaSourceFolderName(String value) { - getPreferences().setValue(Keys.JAVA_SOURCE, value); - firePreferenceChanged(); - } - - public void setHighestJ2EEVersionSetting(String value) { - getPreferences().setValue(Keys.J2EE_VERSION, value); - firePreferenceChanged(); - } - - public void setServerTargetingEnabled(boolean value) { - getPreferences().setValue(Keys.SERVER_TARGET_SUPPORT, value); - firePreferenceChanged(); - } - - public void setIncrementalDeploymentEnabled(boolean value) { - getPreferences().setValue(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT, value); - firePreferenceChanged(); - } - - public boolean isIncrementalDeploymentEnabled() { - return getPreferences().getBoolean(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT); - } - - /** - * @return one of J2EEVersionConstants.J2EE_VERSION_X_X (@see J2EEVersionConstants) - */ - public int getHighestJ2EEVersionID() { - String versionPreference = getHighestJ2EEVersionSetting(); - if (Values.J2EE_VERSION_1_2.equals(versionPreference)) - return J2EEVersionConstants.J2EE_1_2_ID; - else if (Values.J2EE_VERSION_1_3.equals(versionPreference)) - return J2EEVersionConstants.J2EE_1_3_ID; - else - return J2EEVersionConstants.J2EE_1_4_ID; - } - - public void firePreferenceChanged() { - if (isPersistOnChange()) - persist(); - } - - public void persist() { - getOwner().savePluginPreferences(); - } - - /** - * @return Returns the persistOnChange. - */ - public boolean isPersistOnChange() { - return this.persistOnChange; - } - - /** - * @param persistOnChange - * The persistOnChange to set. - */ - public void setPersistOnChange(boolean persistOnChange) { - this.persistOnChange = persistOnChange; - } - - private Preferences getPreferences() { - if (this.preferences == null) - this.preferences = getOwner().getPluginPreferences(); - return this.preferences; - } - - /** - * @return Returns the owner. - */ - private Plugin getOwner() { - return this.owner; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java deleted file mode 100644 index 57ad496dc..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java +++ /dev/null @@ -1,506 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.plugin; - - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.ICommand; -import org.eclipse.core.resources.IContainer; -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.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; - -/** - * An example incremental project builder that copies additional class files from a library package - * fragment root folder into a Java project's output directory. - * - * General parameters: - * <ul> - * <li>The project should be a Java project.</li> - * <li>The class files are in the "imported_classes" folder of the project.</li> - * <li>This builder should run <b>after </b> the Java builder.</li> - * <li>Full build should copy class files from a secondary library folder into the output folder - * maintaining package hierarchy; existing class files must never be overwritten.</li> - * <li>Only *.class files should be copied (not other resource files).</li> - * <li>Incremental build and auto-build should will perform the copy when there is an add/change in - * the "imported_classes" folder.</li> - * <li>Changing the project's output folder should be handled.</li> - * </ul> - * Note: the builder is not currently invoking the Minimize helper, it is relying on the copy to not - * replace existing class files, and the build path order to ensure that compiled classes override - * imported ones. - */ -public class LibCopyBuilder extends IncrementalProjectBuilder { - /** - * Internal debug tracing. - */ - static boolean DEBUG = false; - - /** - * Builder id of this incremental project builder. - */ - public static final String BUILDER_ID = J2EEPlugin.LIBCOPY_BUILDER_ID; - - /** - * The path where we expect to find the .class files to be copied. - */ - public static final String IMPORTED_CLASSES_PATH = "imported_classes"; //$NON-NLS-1$ - - /** - * The path of the output folder that we last copied class files into, or <code>null</code> if - * this builder has not built this project before. - */ - private IPath lastOutputPath = null; - - private List sourceContainers; - - private boolean needOutputRefresh; - - /** - * Creates a new instance of the library copying builder. - * <p> - * All incremental project builders are required to have a public 0-argument constructor. - * </p> - */ - public LibCopyBuilder() { - super(); - } - - - /** - * - * The <code>LibCopyBuilder</code> implementation of this - * <code>IncrementalProjectBuilder</code> method copies additional class files into the output - * folder. - * <p> - * [Issue: the implementation should report progress.] - * </p> - * <p> - * [Issue: the implementation should probably use a workspace runnable.] - * </p> - */ - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { - sourceContainers = null; - needOutputRefresh = false; - if (DEBUG) { - System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Start_build_project_INFO_") + getProject().getName()); //$NON-NLS-1$ - } - - boolean builderOrderOK = checkBuilderOrdering(); - - if (DEBUG && !builderOrderOK) { - System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Bad_builder_order_for_project_INFO_") + getProject().getName()); //$NON-NLS-1$ - } - - IFolder[] classFolders = getClassesFolders(); - if (classFolders.length == 0) { - // no files to copy - if (DEBUG) - System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__No_imported_classes_folder,_quitting_INFO_")); //$NON-NLS-1$ - return null; - } - - IJavaProject jproject = JavaCore.create(getProject()); - if (jproject == null) { - // not a java project (anymore?) - return null; - } - - IPath outputPath = jproject.getOutputLocation(); - IFolder outputFolder = getProject().getParent().getFolder(outputPath); - if (outputPath.equals(lastOutputPath)) { - if (kind == INCREMENTAL_BUILD || kind == AUTO_BUILD) { - processDelta(getDelta(getProject()), outputFolder, monitor, classFolders); - refreshOutputIfNecessary(outputFolder); - return null; - } - } - - if (DEBUG) { - System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Full/first_build_INFO_")); //$NON-NLS-1$ - } - copyAllClassFolders(monitor, classFolders, outputFolder); - lastOutputPath = outputPath; - refreshOutputIfNecessary(outputFolder); - return null; - } - - /** - * - */ - private void refreshOutputIfNecessary(IFolder outputFolder) throws CoreException { - if (needOutputRefresh && outputFolder != null && outputFolder.exists()) - outputFolder.refreshLocal(IResource.DEPTH_INFINITE, null); - } - - private void copyAllClassFolders(IProgressMonitor monitor, IFolder[] classFolders, IFolder outputFolder) throws CoreException { - for (int i = 0; i < classFolders.length; i++) { - copyClassFiles(classFolders[i], outputFolder, monitor); - } - - } - - - /** - * Process an incremental build delta. - * - * @return <code>true</code> if the delta requires a copy - * @param dest - * the destination folder; may or may not exist - * @param monitor - * the progress monitor, or <code>null</code> if none - * @exception CoreException - * if something goes wrong - */ - protected void processDelta(IResourceDelta delta, final IFolder outputFolder, final IProgressMonitor monitor, final IFolder[] classesFolders) { - if (DEBUG) { - System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Considering_delta_INFO_") + delta); //$NON-NLS-1$ - } - IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() { - private List copiedClassFolders = new ArrayList(classesFolders.length); - - public boolean visit(IResourceDelta subdelta) throws CoreException { - IResource resource = subdelta.getResource(); - if (resource.getType() == IResource.FILE) { - IFolder classesFolder = retrieveClassesFolder(resource, classesFolders); - if (classesFolder != null && !copiedClassFolders.contains(classesFolder)) { - int kind = subdelta.getKind(); - switch (kind) { - case IResourceDelta.ADDED : - case IResourceDelta.CHANGED : - if (DEBUG) { - System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Delta_build_INFO_") + subdelta); //$NON-NLS-1$ - } - copyClassFiles(classesFolder, outputFolder, monitor); - break; - case IResourceDelta.REMOVED : - deleteCorrespondingFile((IFile) resource, classesFolder, outputFolder, monitor); - break; - case IResourceDelta.ADDED_PHANTOM : - break; - case IResourceDelta.REMOVED_PHANTOM : - break; - } - - } - } else if (resource.getType() == IResource.FOLDER && resource.equals(outputFolder)) { - copyAllClassFolders(null, classesFolders, outputFolder); - return false; - } - return true; - } - }; - if (delta != null) { - try { - delta.accept(visitor); - } catch (CoreException e) { - // should not happen - } - } - } - - /** - * @param file - * @param classesFolder - * @param outputFolder - * @param monitor - */ - protected void deleteCorrespondingFile(IFile file, IFolder classesFolder, IFolder outputFolder, IProgressMonitor monitor) throws CoreException { - IPath path = file.getFullPath(); - int segCount = classesFolder.getFullPath().segmentCount(); - path = path.removeFirstSegments(segCount); - IFile javaFile = findCorrespondingJavaFile(path); - if (javaFile != null && javaFile.exists()) - return; //There is nothing to do because the file in the output location is from the - // java compilation not the copy. - IFile outFile = outputFolder.getFile(path); - if (outFile.exists()) - outFile.delete(true, false, monitor); - } - - - /** - * Method retrieveClassesFolder. - * - * @param resource - * @return IFolder - */ - protected IFolder retrieveClassesFolder(IResource resource, IFolder[] classesFolders) { - for (int i = 0; i < classesFolders.length; i++) { - if (classesFolders[i].getName().equals(resource.getProjectRelativePath().segment(0))) - return classesFolders[i]; - } - return null; - } - - - /** - * Checks whether this builder is configured to run <b>after </b> the Java builder. - * - * @return <code>true</code> if the builder order is correct, and <code>false</code> - * otherwise - * @exception CoreException - * if something goes wrong - */ - private boolean checkBuilderOrdering() throws CoreException { - // determine relative builder position from project's buildspec - ICommand[] cs = getProject().getDescription().getBuildSpec(); - int myIndex = -1; - int javaBuilderIndex = -1; - for (int i = 0; i < cs.length; i++) { - if (cs[i].getBuilderName().equals(JavaCore.BUILDER_ID)) { - javaBuilderIndex = i; - } else if (cs[i].getBuilderName().equals(BUILDER_ID)) { - myIndex = i; - } - } - return myIndex > javaBuilderIndex; - } - - /** - * Copies class files from the given source folder to the given destination folder. The - * destination folder will be created if required, but only if at least one class file is - * copied. - * - * @param source - * the source folder; must exist - * @param dest - * the destination folder; may or may not exist - * @param monitor - * the progress monitor, or <code>null</code> if none - * @exception CoreException - * if something goes wrong - */ - private void copyClassFiles(IFolder source, final IFolder dest, final IProgressMonitor monitor) throws CoreException { - if (DEBUG) { - System.out.println(BUILDER_ID + ": Begin copying class files from " + source.getFullPath() + " to " + dest.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$ - } - - final int sourcePathLength = source.getFullPath().segmentCount(); - - class Visitor implements IResourceVisitor { - public boolean visit(IResource res) throws CoreException { - if (res.getType() == IResource.FILE) { - IFile file = (IFile) res; - - // compute relative path from source folder to this file - IPath filePath = file.getFullPath(); - IPath dpath = filePath.removeFirstSegments(sourcePathLength); - IFile targetFile = dest.getFile(dpath); - copyFile(file, targetFile, dpath, monitor); - } - return true; - } - } - - try { - source.accept(new Visitor()); - } catch (CoreException e) { - // should not happen - } - - } - - /** - * Copies the given file to the given destination file. Does nothing if the destination file - * already exists. - * - * @param source - * the source file; must exist - * @param dest - * the destination file; may or may not exist; never overwritten - * @param monitor - * the progress monitor, or <code>null</code> if none - * @exception CoreException - * if something goes wrong - */ - private void copyFile(IFile source, IFile dest, IPath fileRelativePath, IProgressMonitor monitor) throws CoreException { - if (pruneForJavaSource(source, fileRelativePath, monitor)) - return; //no copy necessary. - File sourceFile = null, destFile = null; - if (source.exists()) - sourceFile = source.getLocation().toFile(); - if (dest.exists()) - destFile = dest.getLocation().toFile(); - - if (destFile != null && sourceFile != null) { - if (DEBUG) - System.out.println(BUILDER_ID + ": " + dest.getFullPath() + " already exists."); //$NON-NLS-1$ //$NON-NLS-2$ - if (destFile.lastModified() == sourceFile.lastModified()) - return; - dest.setContents(source.getContents(false), true, false, monitor); //we have to force - // b/c set the mod - // stamp makes it - // think it is out of - // synch. - synchronizeModificationStamps(sourceFile, destFile); - return; - } - if (DEBUG) { - System.out.println(BUILDER_ID + ": Creating " + dest.getFullPath()); //$NON-NLS-1$ - } - - IContainer parent = dest.getParent(); - if (parent.getType() == IResource.FOLDER) { - mkdirs((IFolder) parent, monitor); - } - dest.create(source.getContents(false), false, monitor); - destFile = dest.getLocation().toFile(); - synchronizeModificationStamps(sourceFile, destFile); - dest.setDerived(true); - } - - /** - * Return true if a corresponding .java file is found. Remove the .class file from the - * imported_classes folder (i.e., delete the source file). - * - * @param source - * @param monitor - * @return - */ - private boolean pruneForJavaSource(IFile classFile, IPath fileRelativePath, IProgressMonitor monitor) throws CoreException { - if (classFile.exists()) { - IFile javaFile = findCorrespondingJavaFile(fileRelativePath); - if (javaFile != null && javaFile.exists()) { - ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{javaFile}, null); - classFile.delete(true, false, monitor); - return true; - } - } - return false; - } - - - /** - * @param classFilePath - * @return - */ - private IFile findCorrespondingJavaFile(IPath classFilePath) { - IPath javaPath = convertToJavaPath(classFilePath); - List sourceFolders = getSourceContainers(); - IContainer cont; - IFile javaFile; - for (int i = 0; i < sourceFolders.size(); i++) { - cont = (IContainer) sourceFolders.get(i); - javaFile = cont.getFile(javaPath); - if (javaFile.exists()) - return javaFile; - } - return null; - } - - - private List getSourceContainers() { - if (sourceContainers == null) - sourceContainers = JavaProjectUtilities.getSourceContainers(getProject()); - return sourceContainers; - } - - - /** - * @param classFile - * @return - */ - private IPath convertToJavaPath(IPath classFilePath) { - IPath javaPath = classFilePath.removeFileExtension(); - //handle inner classes...look for outermost java file - String fileName = classFilePath.lastSegment(); - int innerIndex = fileName.indexOf('$'); - if (innerIndex > -1) { - javaPath = javaPath.removeLastSegments(1); - javaPath = javaPath.append(fileName.substring(0, innerIndex)); - } - javaPath = javaPath.addFileExtension("java"); //$NON-NLS-1$ - return javaPath; - } - - - /** - * @param source - * @param dest - */ - private void synchronizeModificationStamps(File sourceFile, File destFile) { - if (destFile != null && sourceFile != null) { - destFile.setLastModified(sourceFile.lastModified()); - needOutputRefresh = true; - } - } - - - /** - * Creates the given folder, and its containing folders, if required. Does nothing if the given - * folder already exists. - * - * @param folder - * the folder to create - * @param monitor - * the progress monitor, or <code>null</code> if none - * @exception CoreException - * if something goes wrong - */ - private void mkdirs(IFolder folder, IProgressMonitor monitor) throws CoreException { - if (folder.exists()) { - return; - } - IContainer parent = folder.getParent(); - if (!parent.exists() && parent.getType() == IResource.FOLDER) { - mkdirs((IFolder) parent, monitor); - } - folder.create(false, true, monitor); - } - - private IFolder[] getClassesFolders() { - IProject project = getProject(); - IJavaProject javaProj = JavaProjectUtilities.getJavaProject(project); - if (javaProj == null) - return new IFolder[0]; - List result = null; - IClasspathEntry[] entries; - try { - entries = javaProj.getResolvedClasspath(true); - } catch (JavaModelException e) { - return new IFolder[0]; - } - for (int i = 0; i < entries.length; i++) { - IClasspathEntry entry = entries[i]; - if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - IPath path = entry.getPath(); - IResource res = project.getWorkspace().getRoot().findMember(path); - if (res != null && res.isAccessible() && res.getType() == IResource.FOLDER && res.getProject().equals(project)) { - if (result == null) - result = new ArrayList(1); - result.add(res); - } - } - } - if (result == null) - return new IFolder[0]; - return (IFolder[]) result.toArray(new IFolder[result.size()]); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java deleted file mode 100644 index e0f298bc2..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.plugin; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageDeclaration; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; -import org.eclipse.jst.j2ee.internal.project.J2EENature; - -/** - * Minimize the number of loose class files from an unzipped class library by removing ones - * corresponding to Java source files. - */ -public class MinimizeLib { - - static boolean DEBUG = true; - - /** - * Helper class for discarding class files for which there is corresponding source. Note: this - * could be a fairly expensive operation. - * <p> - * Assumptions: - * <ul> - * <li>The source files are in the source folders of the project.</li> - * <li>The source folders are source package fragment roots. This allows us to use the Java - * model to find and access source files.</li> - * <li>The class files are in the "imported_classes" root folder of the project.</li> - * <li>We want to delete any class files in the "imported_classes" folder for which there is - * corresponding source file in any source folder.</li> - * </ul> - * </p> - * - * @param project - * the Java project to minimize - */ - public static void minimize(IJavaProject project) { - - if (DEBUG) { - System.out.println(J2EEPluginResourceHandler.getString("Minimizing_project_UI_") + project.getElementName()); //$NON-NLS-1$ - } - - final IFolder classesFolder = project.getProject().getFolder(LibCopyBuilder.IMPORTED_CLASSES_PATH); - - if (!classesFolder.exists()) { - // no classes folder means nothing to prune - if (DEBUG) { - System.out.println(J2EEPluginResourceHandler.getString("No_library_folder_UI_") + classesFolder.getFullPath()); //$NON-NLS-1$ - } - return; - } - - // List of fully qualified type names for which we have source - // (element type: String) - final Set sourceTypeNames = new HashSet(1000); - - J2EENature nature = J2EENature.getRegisteredRuntime(project.getProject()); - if (nature == null) { - // not a valid project to build - if (DEBUG) { - System.out.println(J2EEPluginResourceHandler.getString("Not_a_J2EE_project_UI_") + project.getProject()); //$NON-NLS-1$ - } - return; - } - List sourceFolders = JavaProjectUtilities.getSourceContainers(project.getProject()); - for (Iterator iter = sourceFolders.iterator(); iter.hasNext();) { - IFolder srcFolder = (IFolder) iter.next(); - // use Java model to rip through sources to get list of type names - try { - IPackageFragmentRoot srcRoot = project.getPackageFragmentRoot(srcFolder); - IJavaElement[] pkgs = srcRoot.getChildren(); - for (int i = 0; i < pkgs.length; i++) { - if (pkgs[i] instanceof IPackageFragment) { - IPackageFragment pkg = (IPackageFragment) pkgs[i]; - ICompilationUnit[] cus = pkg.getCompilationUnits(); - for (int j = 0; j < cus.length; j++) { - ICompilationUnit cu = cus[j]; - sourceTypeNames.addAll(Arrays.asList(extractTypeNames(cu))); - } - } - } - } catch (JavaModelException e) { - // unexpected - e.printStackTrace(); - } - - } - - if (sourceTypeNames.isEmpty()) { - // no source types means no pruning possible - if (DEBUG) { - System.out.println(J2EEPluginResourceHandler.getString("No_source_types_UI_")); //$NON-NLS-1$ - } - return; - } - - // verify that none of the type names are problematic (contain "$") - // if the name contains '$' we can't pattern match class file names - for (Iterator it = sourceTypeNames.iterator(); it.hasNext();) { - String sourceTypeName = (String) it.next(); - if (sourceTypeName.indexOf('$') >= 0) { - // we're in trouble - throw new RuntimeException(J2EEPluginResourceHandler.getString("Some_source_types_have___$___in_their_name_ERROR_")); //$NON-NLS-1$ - } - } - - // walk the classes folder deleting class files for which there is source - class Visitor implements IResourceVisitor { - public boolean visit(IResource res) throws CoreException { - if (res.getType() == IResource.FILE) { - IFile file = (IFile) res; - String ext = res.getFileExtension(); - if (ext != null && ext.equals("class")) { //$NON-NLS-1$ - IPath pkgPath = file.getFullPath().removeFirstSegments(2).removeLastSegments(1); - String pkgName = pkgPath.toString().replace('/', '.'); - String baseTypeName = pkgName.length() == 0 ? baseTypeName(file) : pkgName + "." + baseTypeName(file); //$NON-NLS-1$ - if (DEBUG) { - System.out.println("Have source for " + baseTypeName + "? " + (sourceTypeNames.contains(baseTypeName) ? "Yes" : "No")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - if (sourceTypeNames.contains(baseTypeName)) { - deleteClassFile(file); - } - } - } - return true; - } - } - - try { - classesFolder.accept(new Visitor()); - } catch (CoreException e) { - // should not happen - e.printStackTrace(); - } - } - - /** - * Deletes the given class file resource. Does nothing if unable to delete it. - * - * @param classFile - * the class file resource to delete - */ - static void deleteClassFile(IFile classFile) { - if (DEBUG) { - System.out.println("Delete " + classFile.getFullPath()); //$NON-NLS-1$ - } - try { - classFile.delete(true, false, (IProgressMonitor) null); - } catch (CoreException e) { - // unexpected - e.printStackTrace(); - } - } - - /** - * Returns the base type name for the given class file, assuming the standard scheme Java - * compilers use to name generated class files. - * <p> - * For example, - * <ul> - * <li>file <code>Foo.class</code> returns <code>"Foo"</code></li> - * <li>file <code>Foo$1.class</code> returns <code>"Foo"</code></li> - * <li>file <code>Foo$Bar.class</code> returns <code>"Foo"</code></li> - * <li>file <code>Foo$1$Bar.class</code> returns <code>"Foo"</code></li> - * </ul> - * - * @param classFile - * the class file - * @return the name of the corresponding top-level type - */ - static String baseTypeName(IFile classFile) { - String fileName = classFile.getName(); - int x = fileName.lastIndexOf(".class"); //$NON-NLS-1$ - if (x < 0) { - throw new IllegalArgumentException(); - } - // strip off .class suffix - String binaryTypeName = fileName.substring(0, x); - int d = binaryTypeName.indexOf("$"); //$NON-NLS-1$ - if (d < 0) - return binaryTypeName; - // the characters before the '$' is the top-level type name - return binaryTypeName.substring(0, d); - } - - /** - * Returns a list of fully-qualifed names of top-level types declared in the given compilation - * unit. Returns the empty list if the compilation unit is empty or could not be parsed. - * - * @param cu - * the Java compilation unit - * @return the list of fully-qualified names of package-member types - */ - static String[] extractTypeNames(ICompilationUnit cu) { - List typeNames = new ArrayList(); - try { - IPackageDeclaration[] pds = cu.getPackageDeclarations(); - String packageName = pds.length == 0 ? "" : pds[0].getElementName(); //$NON-NLS-1$ - IType[] types = cu.getTypes(); - for (int k = 0; k < types.length; k++) { - IType type = types[k]; - String name = type.getElementName(); - String fqTypeName = packageName.length() == 0 ? name : packageName + "." + name; //$NON-NLS-1$ - typeNames.add(fqTypeName); - } - } catch (JavaModelException e) { - // unexpected - e.printStackTrace(); - } - String[] result = new String[typeNames.size()]; - typeNames.toArray(result); - return result; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/AWorkbenchMOFHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/AWorkbenchMOFHelper.java deleted file mode 100644 index e31bbce13..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/AWorkbenchMOFHelper.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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.j2ee.internal.validation; - - -import java.util.logging.Level; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.internal.plugin.JavaEMFNature; -import org.eclipse.jem.util.logger.LogEntry; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.validation.internal.operations.WorkbenchContext; -import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; - - -/** - * Abstract base class for registration of symbolic model names, and also provides the mechanism for - * registering the load model method which loads a specific type of MOF model, as identified by the - * symbolic model name. - */ -public abstract class AWorkbenchMOFHelper extends WorkbenchContext { - public IResource getResource(Object obj) { - IResource res = null; - if ((obj != null) && (obj instanceof EObject)) { - JavaEMFNature nature = getMOFNature(getProject()); - if (nature != null) { - EObject ro = (EObject) obj; - res = WorkbenchResourceHelper.getFile(ro.eResource()); - } - } - - if ((res == null) || (!res.exists())) { - return super.getResource(obj); - } - - return res; - } - - public JavaEMFNature getMOFNature(IProject project) { - if (project == null) { - return null; - } - - IProjectDescription desc = null; - try { - desc = project.getDescription(); - } catch (CoreException exc) { - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.FINE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("WorkbenchContext.getMOFNature(IProject)"); //$NON-NLS-1$ - entry.setTargetException(exc); - logger.write(Level.FINE, entry); - } - return null; - } - - String[] natureIds = desc.getNatureIds(); - for (int i = 0; i < natureIds.length; i++) { - try { - IProjectNature nature = project.getNature(natureIds[i]); - if (nature instanceof JavaEMFNature) { - return (JavaEMFNature) nature; - } - } catch (CoreException exc) { - // log and attempt next nature - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.FINE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("WorkbenchContext.getMOFNature(IProject)"); //$NON-NLS-1$ - entry.setTargetException(exc); - logger.write(Level.FINE, entry); - } - } - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ApplicationClientHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ApplicationClientHelper.java deleted file mode 100644 index 6f9d67271..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ApplicationClientHelper.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.ApplicationClientNatureRuntime; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile; -import org.eclipse.jst.j2ee.model.internal.validation.ApplicationClientValidator; - - -/** - * Insert the type's description here. Creation date: (4/9/2001 11:22:53 AM) - * - * @author: Administrator - */ -public class ApplicationClientHelper extends J2EEValidationHelper { - - protected ApplicationClientFile appClientFile; - - /** - * ApplicationClientHelper constructor comment. - */ - public ApplicationClientHelper() { - super(); - registerModel(ApplicationClientValidator.APPCLIENT_MODEL_NAME, "loadApplicationClientFile"); //$NON-NLS-1$ - } - - /** - * Given a resource, return its non-eclipse-specific location. If this resource, or type of - * resource, isn't handled by this helper, return null. - */ - public String getPortableName(IResource resource) { - if (!(resource instanceof IFile)) { - return null; - } - - return "application-client.xml"; //$NON-NLS-1$ - } - - /** - * Get the WAR file for validation - */ - public EObject loadApplicationClientFile() { - ApplicationClientNatureRuntime appClientNature = null; - // openFilesCache = new ArrayList(); - IProject proj = getProject(); - if (proj != null) { - appClientNature = ApplicationClientNatureRuntime.getRuntime(getProject()); - if (appClientNature != null) { - try { - appClientFile = (ApplicationClientFile) appClientNature.asArchive(true); - // openFilesCache.add(appClientFile); - } catch (Exception e) { - // nothing to do, we're gonna return null - } - } - - } - return appClientFile; - } - - public void closeApplicationClientFile() { - if (appClientFile != null) - appClientFile.close(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/DependencyUtil.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/DependencyUtil.java deleted file mode 100644 index 17e99e224..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/DependencyUtil.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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.j2ee.internal.validation; - -import java.util.HashSet; -import java.util.Set; -import java.util.logging.Level; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.logger.LogEntry; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; - -/** - * This singleton keeps an internal record of project dependencies. That is, every IProject can - * depend on, and be depended on by, other IProjects. Ditto IJavaProject. This class is updated when - * a project(s) classpath changes. - */ -public final class DependencyUtil { - private static final IProject[] EMPTY_PROJECTS = new IProject[0]; - private static final IJavaProject[] EMPTY_JAVAPROJECTS = new IJavaProject[0]; - - private static Set _tempSet = null; - - /** - * This is a set for temporary calculations. - */ - private static Set getTempSet() { - if (_tempSet == null) { - _tempSet = new HashSet(); - } else { - _tempSet.clear(); - } - return _tempSet; - } - - /** - * Return an array of open IProjects which depend on the given IProject parameter. - */ - public static IProject[] getDependentProjects(IProject project) { - if (project == null) { - return EMPTY_PROJECTS; - } - - IProject[] allProjects = project.getWorkspace().getRoot().getProjects(); - Set tempSet = getTempSet(); - for (int i = 0; i < allProjects.length; i++) { - IProject p = allProjects[i]; - IProject[] requires = getRequiredProjects(p); - for (int j = 0; j < requires.length; j++) { - IProject r = requires[j]; - if (project.equals(r)) { - tempSet.add(p); - break; - } - } - } - IProject[] dependency = new IProject[tempSet.size()]; - tempSet.toArray(dependency); - return dependency; - } - - /** - * Return an array of open IProjects which the given IProject parameter depends on. - */ - public static IProject[] getRequiredProjects(IProject project) { - if (project == null) { - return EMPTY_PROJECTS; - } - - // Check that each project in this list exists and is open - try { - IProject[] refProjects = project.getReferencedProjects(); - if ((refProjects == null) || (refProjects.length == 0)) { - return EMPTY_PROJECTS; - } - - IProject[] temp = new IProject[refProjects.length]; - int count = 0; - for (int i = 0; i < refProjects.length; i++) { - IProject rProject = refProjects[i]; - if (rProject.exists() && rProject.isOpen()) { - temp[count++] = rProject; - } - } - - if (count == 0) { - return EMPTY_PROJECTS; - } - - if (count == temp.length) { - return temp; - } - - IProject[] result = new IProject[count]; - System.arraycopy(temp, 0, result, 0, count); - return result; - } catch (CoreException exc) { - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.SEVERE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("DependencyCache::getRequiredProjects(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - entry.setTargetException(exc); - logger.write(Level.SEVERE, exc); - } - - return EMPTY_PROJECTS; - } - } - - /** - * Return an array of open IJavaProjects which depend on the given IJavaProject parameter. - */ - public static IJavaProject[] getDependentJavaProjects(IJavaProject javaproject) { - if (javaproject == null) { - return EMPTY_JAVAPROJECTS; - } - - // calculate the dependencies now. - try { - IJavaProject[] allProjects = javaproject.getJavaModel().getJavaProjects(); - Set tempSet = getTempSet(); - for (int i = 0; i < allProjects.length; i++) { - IJavaProject p = allProjects[i]; - IJavaProject[] requires = getRequiredJavaProjects(p); - for (int j = 0; j < requires.length; j++) { - IJavaProject r = requires[j]; - if (javaproject.equals(r)) { - tempSet.add(p); - break; - } - } - } - IJavaProject[] dependency = new IJavaProject[tempSet.size()]; - tempSet.toArray(dependency); - return dependency; - } catch (JavaModelException exc) { - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.SEVERE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("DependencyCache::getDependentJavaProjects(" + javaproject.getProject().getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - entry.setTargetException(exc); - logger.write(Level.SEVERE, exc); - } - - return EMPTY_JAVAPROJECTS; - } - } - - /** - * Return an array of open IJavaProjects which the given IJavaProject parameter depends on. - */ - public static IJavaProject[] getRequiredJavaProjects(IJavaProject javaproject) { - if (javaproject == null) { - return EMPTY_JAVAPROJECTS; - } - - try { - IJavaModel jm = javaproject.getJavaModel(); - if (jm == null) { - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.SEVERE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("DependencyCache::getRequiredJavaProjects(" + javaproject.getProject().getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - //entry.setText("IJavaModel == null"); //$NON-NLS-1$ - logger.write(Level.SEVERE, "IJavaModel == null"); //$NON-NLS-1$ - } - return EMPTY_JAVAPROJECTS; - } - - String[] requiredProjects = javaproject.getRequiredProjectNames(); - if ((requiredProjects == null) || (requiredProjects.length == 0)) { - return EMPTY_JAVAPROJECTS; - } - - IJavaProject[] temp = new IJavaProject[requiredProjects.length]; - int count = 0; - for (int i = 0; i < requiredProjects.length; i++) { - String projectName = requiredProjects[i]; - IJavaProject jp = jm.getJavaProject(projectName); - try { - if ((jp == null) || (!jp.getProject().exists())) { - continue; - } - if (!jp.getProject().isAccessible()) { - continue; - } - - if (!jp.getProject().hasNature(JavaCore.NATURE_ID)) { - continue; - } - - temp[count++] = jp; - } catch (CoreException exc) { - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.SEVERE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("DependencyCache::getRequiredJavaProjects(" + javaproject.getProject().getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - entry.setTargetException(exc); - logger.write(Level.SEVERE, exc); - } - continue; - } - } - - if (count == 0) { - return EMPTY_JAVAPROJECTS; - } - - if (count == temp.length) { - return temp; - } - - IJavaProject[] result = new IJavaProject[count]; - System.arraycopy(temp, 0, result, 0, count); - return result; - } catch (JavaModelException exc) { - Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); - if (logger.isLoggingLevel(Level.SEVERE)) { - LogEntry entry = ValidationPlugin.getLogEntry(); - entry.setSourceID("DependencyCache::getRequiredJavaProjects(" + javaproject.getProject().getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - entry.setTargetException(exc); - logger.write(Level.SEVERE, exc); - } - - return EMPTY_JAVAPROJECTS; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/EarHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/EarHelper.java deleted file mode 100644 index f83c62571..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/EarHelper.java +++ /dev/null @@ -1,98 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.internal.application.impl.ApplicationImpl; -import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime; -import org.eclipse.jst.j2ee.model.internal.validation.EarValidator; - - -public class EarHelper extends J2EEValidationHelper { - - protected EARFile earFile; - - /** - * WarHelper constructor comment. - */ - public EarHelper() { - super(); - - registerModel(EarValidator.EAR_MODEL_NAME, "loadEarFile"); //$NON-NLS-1$ - } - - public String getApplicationXMLFile() { - - return ArchiveConstants.APPL_ID; - } - - /** - * Given a resource, return its non-eclipse-specific location. If this resource, or type of - * resource, isn't handled by this helper, return null. - */ - public String getPortableName(IResource resource) { - if (!(resource instanceof IFile)) { - return null; - } - - return "application.xml"; //$NON-NLS-1$ - } - - public String getTargetObjectName(Object obj) { - super.getTargetObjectName(obj); - - if (obj != null && obj instanceof EARFile) { - return getApplicationXMLFile(); - } - if (obj != null && obj instanceof ApplicationImpl) { - return "application.xml"; //$NON-NLS-1$ - } - return null; - } - - /** - * Get the WAR file for validation - */ - public EObject loadEarFile() { - EARNatureRuntime earNature = null; - if (earFile != null && earFile.isOpen()) - return earFile; - // openFilesCache = new java.util.ArrayList(); - IProject proj = getProject(); - if (proj != null) { - - if (EARNatureRuntime.hasRuntime(proj)) { - earNature = EARNatureRuntime.getRuntime(getProject()); - if (earNature != null) { - try { - earFile = earNature.asEARFile(true, false); - // openFilesCache.add(earFile); - } catch (Exception e) { - // nothing to do, we're gonna return null - } - } - } - } - return earFile; - } - - public void closeEARFile() { - if (earFile != null) { - earFile.close(); - earFile = null; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/J2EEValidationHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/J2EEValidationHelper.java deleted file mode 100644 index f4a2f6df8..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/J2EEValidationHelper.java +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.validation.internal.operations.WorkbenchContext; - - -public abstract class J2EEValidationHelper extends WorkbenchContext { - /** - * Constructor for J2EEValidationHelper. - */ - public J2EEValidationHelper() { - super(); - } - - /* - * @see IWorkbenchContext#getFile(Object) - */ - public IResource getResource(Object object) { - Resource resource = null; - if (object != null && object instanceof EObject) - resource = ((EObject) object).eResource(); - if (resource != null) - return WorkbenchResourceHelper.getFile(resource); - return null; - } - - /** - * Given a resource, return its non-eclipse-specific location. If this resource, or type of - * resource, isn't handled by this helper, return null. - */ - protected String getFileName(IFile file, IContainer[] containers) { - if ((file == null) || (containers == null)) { - return null; - } - - for (int c = 0; c < containers.length; c++) { - IPath resourcePath = getContainerRelativePath(file, containers[c]); - if (resourcePath != null) { - // file has been found - return resourcePath.toString(); - } - } - - return null; - } - - /** - * Given a file name, return its corresponding IFile, if one exists. This method checks if the - * IContainer passed in contains a file with the given file name. If the container does not have - * the IFile, null is returned. - */ - protected IFile getFile(String fileName, IContainer[] containers) { - IFile clazzFile = null; - if ((fileName == null) || (containers == null)) { - return null; - } - - for (int c = 0; c < containers.length; c++) { - IContainer container = containers[c]; - IPath filePath = container.getProjectRelativePath(); - clazzFile = getProject().getFile(filePath.append(fileName)); - - if (clazzFile.exists()) { - return clazzFile; - } - } - - return null; - } - - protected IFile getXmlFile(String xmlFileName, J2EENature nature) { - if (nature == null) { - return null; - } - return nature.getMetaFolder().getFile(xmlFileName); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.validation.internal.operations.IWorkbenchContext#getTargetObjectName(java.lang.Object) - */ - public String getTargetObjectName(Object object) { - if (object != null) - return object.toString(); - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ManifestLineValidator.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ManifestLineValidator.java deleted file mode 100644 index ddc79f15e..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ManifestLineValidator.java +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class ManifestLineValidator extends Object { - public static final int MAX_LINE_LENGTH = 72; - protected int lineNumber; - protected int currentByte; - protected int byteCount; - protected InputStream inputStream; - protected List lineNumbers; - protected boolean endsWithLineBreak = true; - - /** - * Constructor for LineValidator. - */ - public ManifestLineValidator(InputStream in) { - super(); - inputStream = new BufferedInputStream(in); - lineNumber = 0; - } - - protected List getLineNumbers() { - if (lineNumbers == null) - lineNumbers = new ArrayList(); - return lineNumbers; - } - - public int[] getLineNumbersExceedingLimit() { - if (lineNumbers == null) - return new int[0]; - - int[] result = new int[lineNumbers.size()]; - for (int i = 0; i < lineNumbers.size(); i++) { - Integer list_element = (Integer) lineNumbers.get(i); - result[i] = list_element.intValue(); - } - return result; - } - - public void validate() throws IOException { - readNext(); - while (currentByte != -1) { - validateNextLine(); - } - } - - public int getLineCount() { - return lineNumber; - } - - protected void readNext() throws IOException { - currentByte = inputStream.read(); - } - - protected void validateNextLine() throws IOException { - lineNumber++; - byteCount = 0; - boolean eolReached = false; - while (currentByte != -1) { - if (currentByte == '\r') { - eolReached = true; - readNext(); - if (currentByte == '\n') { - readNext(); - } - break; - } else if (currentByte == '\n') { - eolReached = true; - readNext(); - break; - } else { - byteCount++; - readNext(); - } - } - if (currentByte == -1 && !eolReached && byteCount > 0) - endsWithLineBreak = false; - if (byteCount > 72) - getLineNumbers().add(new Integer(lineNumber)); - } - - public boolean endsWithLineBreak() { - return endsWithLineBreak; - } - - public boolean hasErrors() { - return !endsWithLineBreak || (lineNumbers != null && !lineNumbers.isEmpty()); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ResourceUtil.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ResourceUtil.java deleted file mode 100644 index a4609a532..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ResourceUtil.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2001, 2004 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.j2ee.internal.validation; - - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.internal.adapters.jdom.JDOMAdaptor; -import org.eclipse.jem.internal.java.adapters.ReadAdaptor; -import org.eclipse.wst.validation.internal.operations.IResourceUtil; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - - -public class ResourceUtil implements IResourceUtil { - public ResourceUtil() { - super(); - } - - public int getLineNo(Object object) { - if (object == null) { - return IMessage.LINENO_UNSET; - } - - if (object instanceof EObject) { // Error discovered using MOF objects - - EObject ro = (EObject) object; - JDOMAdaptor jdomAdapter = null; - - Collection c = ro.eAdapters(); - if (c != null) { - Iterator iterator = c.iterator(); - while (iterator.hasNext()) { - Adapter a = (Adapter) iterator.next(); - if ((a != null) && a.isAdapterForType(ReadAdaptor.TYPE_KEY) && (a instanceof JDOMAdaptor)) { - jdomAdapter = (JDOMAdaptor) a; - } - } - } - - if (jdomAdapter != null) { - int lineNo = jdomAdapter.getLineNo(); - if (lineNo != JDOMAdaptor.INVALID_LINENO) - return lineNo + 1; - } - - } - - return IMessage.LINENO_UNSET; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientHelper.java deleted file mode 100644 index cb352c1fe..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientHelper.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - - -/** - * Creates the helper for the WSAD application client validator. - */ -public class UIApplicationClientHelper extends ApplicationClientHelper { - - /** - * UIApplicationClientHelper - */ - public UIApplicationClientHelper() { - super(); - }// UIApplicationClientHelper - -}// UIApplicationClientHelper diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientMessageConstants.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientMessageConstants.java deleted file mode 100644 index a2e9e3a41..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientMessageConstants.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - -import org.eclipse.jst.j2ee.model.internal.validation.ApplicationClientMessageConstants; - - - -/** - * Messages for the WSAD application client validator - */ -public interface UIApplicationClientMessageConstants extends ApplicationClientMessageConstants { - - public static final String DOCTYPE_1_2 = "1.2"; //$NON-NLS-1$ - public static final String DOCTYPE_1_3 = "1.3"; //$NON-NLS-1$ - public static final String APPCLIENT_INVALID_DOC_TYPE_ERROR_ = "APPCLIENT_INVALID_DOC_TYPE_ERROR_"; //$NON-NLS-1$ -}// UIApplicationClientMessageConstants diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientValidator.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientValidator.java deleted file mode 100644 index 6a9b8e936..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientValidator.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.command.Command; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientEditModel; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.ApplicationClientNatureRuntime; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ValidateXmlCommand; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.model.internal.validation.ApplicationClientValidator; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; - - -/** - * Creates the application client validator for WSAD - */ -public class UIApplicationClientValidator extends ApplicationClientValidator implements UIApplicationClientMessageConstants { - private ApplicationClientNatureRuntime appNature; - - /** - * Default constructor. - */ - public UIApplicationClientValidator() { - super(); - }// UIApplicationClientValidator - - /** - * Create the validate XML - * - * @return Command - */ - public Command createValidateXMLCommand() { - ValidateXmlCommand cmd = (ValidateXmlCommand) super.createValidateXMLCommand(); - cmd.setValidateNested(false); - return cmd; - }// createValidateXMLCommand - - /** - * Get the resource name. - * - * @return String - */ - protected String getResourceName() { - return ((ApplicationClientHelper) _helper).getProject().getName(); - }// getResourceName - - /** - * Get the app client edit model. - * - * @param IProject - * appClientProject - Current project to get the editmodel. - * @return AppClientEditModel - */ - public AppClientEditModel getAppClientEditModel(IProject appClientProject) { - appNature = ApplicationClientNatureRuntime.getRuntime(appClientProject); - return appNature.getAppClientEditModelForRead(this); - }// getAppClientEditModel - - /** - * Does the validation. - */ - public void validate(IValidationContext inHelper, IReporter inReporter) throws ValidationException { - inReporter.removeAllMessages(this); - UIApplicationClientHelper helper = (UIApplicationClientHelper) inHelper; - AppClientEditModel editModel = getAppClientEditModel(helper.getProject()); - try { - super.validate(helper, inReporter); - validateDocType(helper, editModel); - } finally { - if (editModel != null) { - editModel.releaseAccess(this); - }//if - if (appClientFile != null) - appClientFile.close(); - }// try - }// validate - - /** - * Checks if the nature is consistent with doc type. - */ - protected void validateDocType(UIApplicationClientHelper helper, AppClientEditModel editModel) { - if (editModel.getJ2EENature().getJ2EEVersion() >= J2EEVersionConstants.J2EE_1_3_ID && getAppClientDD().getVersionID() < J2EEVersionConstants.J2EE_1_3_ID) { - String[] params = new String[3]; - params[0] = DOCTYPE_1_2; - params[1] = helper.getProject().getName(); - params[2] = DOCTYPE_1_3; - addError(getBaseName(), APPCLIENT_INVALID_DOC_TYPE_ERROR_, params); - } else if (editModel.getJ2EENature().getJ2EEVersion() < J2EEVersionConstants.J2EE_1_3_ID && getAppClientDD().getVersionID() >= J2EEVersionConstants.J2EE_1_3_ID) { - String[] params = new String[3]; - params[0] = DOCTYPE_1_3; - params[1] = helper.getProject().getName(); - params[2] = DOCTYPE_1_2; - addError(getBaseName(), APPCLIENT_INVALID_DOC_TYPE_ERROR_, params); - }// if - }// validateDocTypeVsNature - - protected Object getManifestTarget() { - if (appNature == null) - return null; - - IContainer mofRoot = appNature.getEMFRoot(); - if (mofRoot == null) - return null; - - return mofRoot.getFile(new Path(J2EEConstants.MANIFEST_URI)); - } - -}// UIApplicationClientValidator diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarHelper.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarHelper.java deleted file mode 100644 index eb56772cd..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarHelper.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - - -/** - * Insert the type's description here. Creation date: (9/10/2001 2:12:47 PM) - * - * @author: Administrator - */ -public class UIEarHelper extends EarHelper { - /** - * UIEarHelper constructor comment. - */ - public UIEarHelper() { - super(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarMessageConstants.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarMessageConstants.java deleted file mode 100644 index 309b9cdd1..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarMessageConstants.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - -import org.eclipse.jst.j2ee.model.internal.validation.EARMessageConstants; - - - -/** - * Insert the type's description here. Creation date: (9/10/2001 3:30:22 PM) - * - * @author: Administrator - */ -public interface UIEarMessageConstants extends EARMessageConstants { - public static final String DOCTYPE_1_2 = "1.2"; //$NON-NLS-1$ - public static final String DOCTYPE_1_3 = "1.3"; //$NON-NLS-1$ - public static final String MISSING_PROJECT_FORMODULE_WARN_ = "MISSING_PROJECT_FORMODULE_WARN_"; //$NON-NLS-1$ - public static final String PROJECT_DOES_NOT_EXIST_WARN_ = "PROJECT_DOES_NOT_EXIST_WARN_"; //$NON-NLS-1$ - public static final String MISSING_WEBNATURE_FORMODULE_WARN_ = "MISSING_WEBNATURE_FORMODULE_WARN_"; //$NON-NLS-1$ - public static final String MISSING_CLIENTNATURE_FORMODULE_WARN_ = "MISSING_CLIENTNATURE_FORMODULE_WARN_"; //$NON-NLS-1$ - public static final String MISSING_EJBNATURE_FORMODULE_WARN_ = "MISSING_EJBNATURE_FORMODULE_WARN_"; //$NON-NLS-1$ - public static final String DUPLICATE_MODULE_FOR_PROJECT_NAME_ERROR_ = "DUPLICATE_MODULE_FOR_PROJECT_NAME_ERROR_"; //$NON-NLS-1$ - public static final String INVALID_MANIFEST_CLASSPATH_ONE_WARN_ = "INVALID_MANIFEST_CLASSPATH_ONE_WARN_"; //$NON-NLS-1$ - public static final String INVALID_MANIFEST_CLASSPATH_TWO_WARN_ = "INVALID_MANIFEST_CLASSPATH_TWO_WARN_"; //$NON-NLS-1$ - public static final String INVALID_CONTEXTROOT_WEBMODULE_WARN_ = "INVALID_CONTEXTROOT_WEBMODULE_WARN_"; //$NON-NLS-1$ - public static final String INVALID_MANIFEST_CLASSPATH_DEPENDENCY_WARN_ = "INVALID_MANIFEST_CLASSPATH_DEPENDENCY_WARN_"; //$NON-NLS-1$ - public static final String INVALID_URI_FOR_MODULE_ERROR_ = "INVALID_URI_FOR_MODULE_ERROR_"; //$NON-NLS-1$ - public static final String PROJECT_IS_CLOSED_WARN_ = "PROJECT_IS_CLOSED_WARN_"; //$NON-NLS-1$ - public static final String INVALID_CASE_FOR_MANIFEST_ERROR_ = "INVALID_CASE_FOR_MANIFEST_ERROR_"; //$NON-NLS-1$ - public static final String MESSAGE_UTIL_URI_NAME_COLLISION_ERROR_ = "MESSAGE_UTIL_URI_NAME_COLLISION_ERROR_"; //$NON-NLS-1$ - public static final String MESSAGE_UTIL_PROJECT_NAME_COLLISION_ERROR_ = "MESSAGE_UTIL_PROJECT_NAME_COLLISION_ERROR_"; //$NON-NLS-1$ - public static final String DUPLICATE_UTILJAR_FOR_PROJECT_NAME_ERROR_ = "DUPLICATE_UTILJAR_FOR_PROJECT_NAME_ERROR_"; //$NON-NLS-1$ - public static final String EAR_INVALID_DOC_TYPE_ERROR_ = "EAR_INVALID_DOC_TYPE_ERROR_"; //$NON-NLS-1$ - public static final String URI_ALREADY_EXISTS_IN_EAR_WARN_ = "URI_ALREADY_EXISTS_IN_EAR_WARN_"; //$NON-NLS-1$ - public static final String PROJECT_SERVER_TARGET_DOES_NOT_MATCH_EAR = "PROJECT_SERVER_TARGET_DOES_NOT_MATCH_EAR"; //$NON-NLS-1$ - public static final String NO_SERVER_TARGET_MODULE_IN_EAR_WITH_SERVER_TARGET = "NO_SERVER_TARGET_MODULE_IN_EAR_WITH_SERVER_TARGET"; //$NON-NLS-1$ - public static final String NO_SERVER_TARGET_ON_EAR_WITH_MODULE_SERVER_TARGETS = "NO_SERVER_TARGET_ON_EAR_WITH_MODULE_SERVER_TARGETS";//$NON-NLS-1$ - public static final String INVALID_EAR_SERVER_TARGET_FOR_14_SPEC_LEVEL = "INVALID_EAR_SERVER_TARGET_FOR_14_SPEC_LEVEL";//$NON-NLS-1$ - public static final String INVALID_MODULE_SERVER_TARGET_FOR_14_SPEC_LEVEL = "INVALID_MODULE_SERVER_TARGET_FOR_14_SPEC_LEVEL";//$NON-NLS-1$ - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarValidator.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarValidator.java deleted file mode 100644 index 7e4995362..000000000 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarValidator.java +++ /dev/null @@ -1,801 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 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.j2ee.internal.validation; - - - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.URIConverter; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; -import org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.common.EjbRef; -import org.eclipse.jst.j2ee.common.MessageDestinationRef; -import org.eclipse.jst.j2ee.common.ResourceEnvRef; -import org.eclipse.jst.j2ee.common.ResourceRef; -import org.eclipse.jst.j2ee.common.SecurityRoleRef; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ValidateXmlCommand; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategy; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EEImportConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EELoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.earcreation.ModuleMapHelper; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.model.internal.validation.EarValidator; -import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.componentcore.resources.IFlexibleProject; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.operations.IWorkbenchContext; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.MessageLimitException; - - -/** - * Insert the type's description here. Creation date: (9/10/2001 2:11:02 PM) - * - * @author: Administrator - */ -public class UIEarValidator extends EarValidator implements UIEarMessageConstants { - public static final String VALIDATOR_ID = "org.eclipse.jst.j2ee.internal.validation.UIEarValidator"; //$NON-NLS-1$ - public static final String MANIFEST_GROUP_NAME = "WSAD.EAR.MANIFEST"; //$NON-NLS-1$ - protected UIEarHelper earHelper; - private EARArtifactEdit earEdit = null; - private IProject project = null; - - /** - * UIEarValidator constructor comment. - */ - public UIEarValidator() { - super(); - } - - public Command createValidateXMLCommand() { - - ValidateXmlCommand cmd = (ValidateXmlCommand) super.createValidateXMLCommand(); - cmd.setValidateNested(false); - return cmd; - } - - protected String getResourceName() { - return ((EarHelper) _helper).getProject().getName(); - } - - protected void duplicateProjectMapError(String earProjectName, String moduleUri, String projectName) { - - String[] params = new String[3]; - params[0] = projectName; - params[1] = earProjectName; - params[2] = moduleUri; - addError(getBaseName(), DUPLICATE_MODULE_FOR_PROJECT_NAME_ERROR_, params, appDD); - } - - /** - * - */ - protected void cleanUpSubTaskMessages(EObject ref) { - String groupName = EJB_REF_GROUP_NAME; - if (ref instanceof EjbRef) - ref = (EjbRef) ref; - else if (ref instanceof ResourceRef) { - ref = (ResourceRef) ref; - groupName = RES_REF_GROUP_NAME; - } else if (ref instanceof ServiceRef) { - ref = (ServiceRef) ref; - groupName = SERVICE_REF_GROUP_NAME; - } else if (ref instanceof ResourceEnvRef) { - ref = (ResourceEnvRef) ref; - groupName = RES_ENV_REF_GROUP_NAME; - } else if (ref instanceof SecurityRoleRef) { - ref = (SecurityRoleRef) ref; - groupName = SEC_ROLE_REF_GROUP_NAME; - } else if (ref instanceof MessageDestinationRef) { - ref = (MessageDestinationRef) ref; - groupName = MESSAGE_REF_GROUP_NAME; - } - Resource res = ref.eResource(); - if (res != null) { - IFile file = WorkbenchResourceHelper.getFile(res); - if (file != null) - _reporter.removeMessageSubset(this, file, groupName); - } - } - - protected void cleanUpAllRefSubTaskMessages(Resource res) { - if (res != null) { - IFile file = WorkbenchResourceHelper.getFile(res); - if (file != null) - _reporter.removeMessageSubset(this, file, EJB_REF_GROUP_NAME); - _reporter.removeMessageSubset(this, file, RES_REF_GROUP_NAME); - _reporter.removeMessageSubset(this, file, SERVICE_REF_GROUP_NAME); - _reporter.removeMessageSubset(this, file, SEC_ROLE_REF_GROUP_NAME); - _reporter.removeMessageSubset(this, file, MESSAGE_REF_GROUP_NAME); - _reporter.removeMessageSubset(this, file, RES_ENV_REF_GROUP_NAME); - } - } - - /** - * Insert the method's description here. Creation date: (9/10/2001 2:56:32 PM) - * - * @return org.eclipse.wst.validation.internal.core.core.ear.workbenchimpl.UIEarHelper - */ - public org.eclipse.jst.j2ee.internal.validation.UIEarHelper getEarHelper() { - return earHelper; - } - - protected void invalidClassPathEntryWarning(String entry, Archive anArchive) { - String[] params = new String[2]; - params[0] = anArchive.getURI(); - params[1] = entry; - addWarning(getBaseName(), INVALID_MANIFEST_CLASSPATH_ONE_WARN_, params, getManifestFile(anArchive), MANIFEST_GROUP_NAME); - } - - protected void invalidClassPathEntryWarning(String entry, String resolvedEntry, Archive anArchive) { - String[] params = new String[3]; - params[0] = anArchive.getURI(); - params[1] = entry; - params[2] = resolvedEntry; - addWarning(getBaseName(), INVALID_MANIFEST_CLASSPATH_TWO_WARN_, params, getManifestFile(anArchive), MANIFEST_GROUP_NAME); - } - - protected void invalidDepedencyWarning(String entry, Archive anArchive, ModuleFile m) { - String[] params = new String[3]; - params[0] = m.getURI(); - params[1] = entry; - params[2] = anArchive.getURI(); - addWarning(getBaseName(), INVALID_MANIFEST_CLASSPATH_DEPENDENCY_WARN_, params, getManifestFile(anArchive), MANIFEST_GROUP_NAME); - } - - /** - * Insert the method's description here. Creation date: (9/10/2001 2:56:32 PM) - * - * @param newEarHelper - * org.eclipse.wst.validation.internal.core.core.ear.workbenchimpl.UIEarHelper - */ - public void setEarHelper(org.eclipse.jst.j2ee.internal.validation.UIEarHelper newEarHelper) { - earHelper = newEarHelper; - } - - public void validate(IValidationContext inHelper, IReporter inReporter) throws ValidationException { - inReporter.removeAllMessages(this); - earHelper = (UIEarHelper) inHelper; - project = ((IWorkbenchContext) inHelper).getProject(); - WorkbenchComponent[] workBenchModules = null; - StructureEdit moduleCore = null; - try{ - IFlexibleProject flexProject = ComponentCore.createFlexibleProject(project); - IVirtualComponent[] components = flexProject.getComponents(); - for (int i = 0; i < components.length; i++) { - - IVirtualComponent wbModule = components[i]; - ComponentHandle compHandle = ComponentHandle.create(project,wbModule.getName()); - EARArtifactEdit earEdit = null; - try{ - earEdit = EARArtifactEdit.getEARArtifactEditForRead(compHandle); - if(earEdit != null) { - Application earApp = (Application) earEdit.getDeploymentDescriptorRoot(); - super.validate(inHelper, inReporter, earApp); - validateModuleMaps(earEdit,wbModule); - validateManifests(wbModule,earFile); - validateUtilJarMaps(earEdit,wbModule); - validateUriAlreadyExistsInEar(earEdit,wbModule); - validateDocType(earEdit,wbModule); - } - } - catch (ValidationException ex) { - throw ex; - } catch (Exception e) { - String[] param = new String[1]; - if (project != null) - param[0] = project.getName(); - Logger.getLogger().logError(e); - IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, EAR_VALIDATION_INTERNAL_ERROR_UI_, param); - throw new ValidationException(errorMsg, e); - } finally { - if(earEdit != null) - earEdit.dispose(); - } - } - } finally { - if(moduleCore != null) - moduleCore.dispose(); - } - } - - - protected IProject getProject(Archive anArchive, EARFile earFileParam) { - LoadStrategy loader = anArchive.getLoadStrategy(); - if (!(loader instanceof J2EELoadStrategyImpl)) - return ModuleMapHelper.getProject(anArchive.getURI(), earFileParam); - - return ((J2EELoadStrategyImpl) loader).getProject(); - } - - public void validateManifests(IVirtualComponent component,EARFile earFile) throws ValidationException { - if (earFile == null) - return; - List archives = earFile.getArchiveFiles(); - for (int i = 0; i < archives.size(); i++) { - try { - Archive anArchive = (Archive) archives.get(i); - IProject project = getProject(anArchive, earFile); - if (project != null && project.isAccessible()) { - IFile target = getManifestFile(anArchive); - if (target != null) - _reporter.removeMessageSubset(this, target, MANIFEST_GROUP_NAME); - validateManifestCase(anArchive); - validateManifestLines(anArchive); - validateManifestClasspath(component,anArchive); - } - } catch (MessageLimitException me) { - } - } - } - - public void validateManifestCase(Archive anArchive) { - String mfuri = ArchiveConstants.MANIFEST_URI; - - //Indicates a manifest file with the valid name exists, - //nothing left to do - if (anArchive.containsFile(mfuri)) - return; - - //Otherwise iterate the list of files - //Ensure the archive is read-only first - anArchive.getOptions().setIsReadOnly(true); - List files = anArchive.getFiles(); - String uri = null; - for (int i = 0; i < files.size(); i++) { - File aFile = (File) files.get(i); - uri = aFile.getURI(); - if (mfuri.equalsIgnoreCase(uri) && !mfuri.equals(uri)) { - String[] params = {uri, anArchive.getURI()}; - IResource target = earHelper.getProject().getFile(J2EEConstants.MANIFEST_URI); - addError(getBaseName(), INVALID_CASE_FOR_MANIFEST_ERROR_, params, target); - } - } - - } - - public void validateManifestClasspath(IVirtualComponent component, Archive anArchive) throws ValidationException { - String[] cp = anArchive.getManifest().getClassPathTokenized(); - for (int i = 0; i < cp.length; i++) { - String uri = ArchiveUtil.deriveEARRelativeURI(cp[i], anArchive); - if (uri == null) { - invalidClassPathEntryWarning(cp[i], anArchive); - continue; - } - File f = null; - IFile rf = null; - try { - if (uri.endsWith(J2EEImportConstants.IMPORTED_JAR_SUFFIX)) { - //TODO Needs work here to initialize rf as rf is an IFile and there is no way to get an IFile currently - IVirtualResource resource = component.findMember(new Path(uri)); - if (resource == null || !resource.exists()) { - invalidClassPathEntryWarning(cp[i], uri, anArchive); - } - } - else - f = earFile.getFile(uri); - } catch (java.io.FileNotFoundException ex) { - invalidClassPathEntryWarning(cp[i], earFile.getURI(), anArchive); - continue; - } - if (f != null && f.isArchive() && anArchive.isModuleFile()) { - Archive archive = (Archive) f; - ModuleFile m = (ModuleFile) anArchive; - if (!ArchiveUtil.isValidDependency(archive, m)) - invalidDepedencyWarning(cp[i], archive, m); - } - } - } - - - protected void validateManifestLines(Archive anArchive) throws ValidationException { - if (anArchive == null) - return; - InputStream is = null; - try { - is = anArchive.getInputStream(ArchiveConstants.MANIFEST_URI); - ManifestLineValidator lineVal = new ManifestLineValidator(is); - lineVal.validate(); - addErrorsIfNecessary(anArchive, lineVal); - } catch (FileNotFoundException ex) { - return; - } catch (IOException ex) { - handleManifestException(ex, anArchive); - } finally { - if (is != null) - try { - is.close(); - } catch (IOException ex) { - handleManifestException(ex, anArchive); - } - } - } - - protected void addErrorsIfNecessary(Archive anArchive, ManifestLineValidator mfVal) { - if (!mfVal.hasErrors()) - return; - IFile target = getManifestFile(anArchive); - if (!mfVal.endsWithLineBreak()) - addFileEndError(anArchive, mfVal, target); - int[] lines = mfVal.getLineNumbersExceedingLimit(); - for (int i = 0; i < lines.length; i++) { - addLineLengthError(anArchive, target, lines[i]); - } - } - - protected void addLineLengthError(Archive anArchive, IFile target, int lineNo) { - String[] args = new String[2]; - args[0] = Integer.toString(lineNo); - args[1] = anArchive.getURI(); - if (target != null) - addError(getBaseName(), MANIFEST_LINE_EXCEEDS_LENGTH_ERROR_, args, target, MANIFEST_GROUP_NAME, lineNo); - else - addError(getBaseName(), MANIFEST_LINE_EXCEEDS_LENGTH_ERROR_, args, null, MANIFEST_GROUP_NAME); - } - - protected void addFileEndError(Archive anArchive, ManifestLineValidator mfVal, IFile target) { - String[] args = new String[]{anArchive.getURI()}; - if (target != null) - addError(getBaseName(), MANIFEST_LINE_END_ERROR_, args, getManifestFile(anArchive), MANIFEST_GROUP_NAME, mfVal.getLineCount()); - else - addError(getBaseName(), MANIFEST_LINE_END_ERROR_, args, MANIFEST_GROUP_NAME); - } - - protected void handleManifestException(IOException ex, Archive anArchive) throws ValidationException { - Logger.getLogger().logError(ex); - IMessage message = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_READING_MANIFEST_ERROR_, new String[]{anArchive.getURI()}); - throw new ValidationException(message, ex); - } - - /** - * Validates utiljar maps - */ - public void validateUtilJarMaps(EARArtifactEdit edit, IVirtualComponent workbenchModule) { - List utilJarModules = edit.getUtilityModuleReferences(); - if (!utilJarModules.isEmpty() || !utilJarModules.isEmpty()) { - for (int i = 0; i < utilJarModules.size(); i++) { - IVirtualComponent aUtilJar = ((IVirtualReference) utilJarModules.get(i)).getReferencedComponent(); - if (aUtilJar != null) { - IProject project = J2EEPlugin.getWorkspace().getRoot().getProject(aUtilJar.getProject().getName()); - if (project != null) { - if (!project.exists()) { - String[] params = new String[]{project.getName(), aUtilJar.getRuntimePath().toString(), earHelper.getProject().getName()}; - addWarning(getBaseName(), PROJECT_DOES_NOT_EXIST_WARN_, params); - } else { - //validateModuleProjectForValidServerTarget(project); - if (!project.isOpen()) { - String[] params = new String[]{project.getName()}; - addWarning(getBaseName(), PROJECT_IS_CLOSED_WARN_, params); - } - } - } - } - } - } - validateDuplicateUtilJars(edit,workbenchModule); - validateUtilJarNameCollision(edit,workbenchModule); - validateUtilJarContainsNoSpaces(edit,workbenchModule); - - }// validateUtilJarMaps - - /** - * Checks if the util jar contains spaces or not. - * - * @param EAREditModel - * earEditModel - The ear editmodel. - */ - protected void validateUtilJarContainsNoSpaces(EARArtifactEdit edit, IVirtualComponent module) { - List utilJars = edit.getUtilityModuleReferences(); - - if (utilJars == null) - return; - - for (int i = 0; i < utilJars.size(); i++) { - IVirtualReference utilModule = (IVirtualReference) utilJars.get(i); - if (utilModule != null) { - ComponentHandle handle = ComponentHandle.create(project,utilModule.getReferencedComponent().getName()); - String uri = ModuleURIUtil.fullyQualifyURI(handle).toString(); - if (uri != null && uri.indexOf(" ") != -1) { //$NON-NLS-1$ - String[] params = new String[1]; - params[0] = uri; - addError(getBaseName(), URI_CONTAINS_SPACES_ERROR_, params, appDD); - }// if - }// if - }// for - - }// validateUtilJarContainsNoSpaces - - /** - * Validates if the a util jar has the same name as another module. - * - * @param EAREditModel - * earEditModel - The ear editmodel. - */ - protected void validateUtilJarNameCollision(EARArtifactEdit edit, IVirtualComponent module) { - List utilJars = edit.getUtilityModuleReferences(); - if (utilJars == null) - return; - for (int i = 0; i < utilJars.size(); i++) { - UtilityJARMapping utilModule = (UtilityJARMapping) utilJars.get(i); - - if (utilModule != null) { - if (edit.uriExists(utilModule.getUri())) { - - String[] params = new String[]{utilModule.getUri(), module.getName()}; - addError(getBaseName(), MESSAGE_UTIL_URI_NAME_COLLISION_ERROR_, params); - - } else if (utilModule.getProjectName() != null || utilModule.getProjectName().length() != 0) { - if (edit.uriExists(utilModule.getUri())) { - String[] params = new String[]{utilModule.getUri(), utilModule.getProjectName()}; - addError(getBaseName(), MESSAGE_UTIL_PROJECT_NAME_COLLISION_ERROR_, params); - } - } - } - } - } - - - - /** - * validate is there are duplicate util jars. - * - * @param EAREditModel - * earEditModel - The ear editmodel - */ - protected void validateDuplicateUtilJars(EARArtifactEdit edit, IVirtualComponent module) { - List utilJars = edit.getUtilityModuleReferences(); - Set visitedUtilUri = new HashSet(); - if (utilJars == null) - return; - for (int i = 0; i < utilJars.size(); i++) { - IVirtualReference utilModule = (IVirtualReference)utilJars.get(i); - if (utilModule != null) { - ComponentHandle handle = ComponentHandle.create(project,utilModule.getReferencedComponent().getName()); - String uri = ModuleURIUtil.fullyQualifyURI(handle).toString(); - if (visitedUtilUri.contains(uri)) { - String compName = module.getName(); - duplicateUtilError(module.getName(),uri, compName); - } else - visitedUtilUri.add(uri); - } // if - } // for - } // validateModuleMapsDuplicateUtil - - /** - * Creates an error for duplicate util jars. - * - * @param String - * earProjectName - The ears project name. - * @param String - * moduleUri - The modules uri. - * @param String - * projectName - The project name. - */ - protected void duplicateUtilError(String earProjectName, String moduleUri, String projectName) { - String[] params = new String[3]; - params[0] = projectName; - params[1] = earProjectName; - params[2] = moduleUri; - addError(getBaseName(), DUPLICATE_UTILJAR_FOR_PROJECT_NAME_ERROR_, params); - }// duplicateUtilError - - public void validateModuleMaps(EARArtifactEdit edit, IVirtualComponent module) { - List modules = edit.getJ2EEModuleReferences(); - if (modules.size() > 0) { - for (int i = 0; i < modules.size(); i++) { - IVirtualReference aModuleRef = (IVirtualReference)modules.get(i); - IVirtualComponent component = aModuleRef.getEnclosingComponent(); - boolean uriExists = edit.uriExists(module.getName()); - if (!uriExists) { - String[] params = new String[]{component.getName(), earHelper.getProject().getName()}; - addWarning(getBaseName(), MISSING_PROJECT_FORMODULE_WARN_, params); - } else { - String projectName = component.getName(); - if (projectName == null || projectName.length() == 0) { - String[] params = new String[]{component.getName(), earHelper.getProject().getName()}; - addWarning(getBaseName(), MISSING_PROJECT_FORMODULE_WARN_, params); - } else { - StructureEdit mc = StructureEdit.getStructureEditForRead(earHelper.getProject()); - WorkbenchComponent deployModule = mc.findComponentByName(projectName); - if (deployModule == null) { - String[] params = new String[]{deployModule.getName(),component.getName(), earHelper.getProject().getName()}; - addWarning(getBaseName(), PROJECT_DOES_NOT_EXIST_WARN_, params); - } else if (earHelper.getProject().isOpen()) { - String[] params = new String[]{earHelper.getProject().getName()}; - addWarning(getBaseName(), PROJECT_IS_CLOSED_WARN_, params); - } else { - - //validateModuleProjectsForValidNature(module); - //validateModuleProjectForValidServerTarget(project); - } - } - } - validateModuleURIExtension(module); - } - } - //validateEARServerTargetJ2EESpecLevel(earEditModel); - //validateModuleMapsDuplicateProjects(earEditModel); - } - - - /** - * @param project - * This validation is not needed for Flex project - */ - /*private void validateModuleProjectForValidServerTarget(IProject project) { - IRuntime runtime = ServerCore.getProjectProperties(project).getRuntimeTarget(); - - EARNatureRuntime nature = earEditModel.getEARNature(); - IProject earProject = nature.getProject(); - IRuntime earRuntime = ServerCore.getProjectProperties(earProject).getRuntimeTarget(); - if (earRuntime != null) { - if (runtime != null) { - if (runtime.getId() != earRuntime.getId()) - unmatachedServerTargetOnModuleWarning(project, earProject); - //validateModuleServerTargetJ2EESpecLevel(project, runtime); - } else { - missingServerTargetOnModuleWarning(project, earProject); - } - } else if (runtime != null) { - missingServerTargetOnEARWarning(project, earProject); - } - }*/ - - private void missingServerTargetOnEARWarning(IProject project, IProject earProject) { - String[] params = new String[]{earProject.getName(), project.getName()}; - addWarning(getBaseName(), NO_SERVER_TARGET_ON_EAR_WITH_MODULE_SERVER_TARGETS, params); - } - - private void unmatachedServerTargetOnModuleWarning(IProject project, IProject earProject) { - String[] params = new String[]{project.getName(), earProject.getName()}; - addWarning(getBaseName(), PROJECT_SERVER_TARGET_DOES_NOT_MATCH_EAR, params); - } - - private void missingServerTargetOnModuleWarning(IProject project, IProject earProject) { - String[] params = new String[]{project.getName(), earProject.getName()}; - addWarning(getBaseName(), NO_SERVER_TARGET_MODULE_IN_EAR_WITH_SERVER_TARGET, params); - } - - /** - * @param earProject - * - * TODO This validation is RAD specific hence needs to be moved to a the RAD layered - * plugin references to this method are commented out - * This validation is not needed anymore for flex project - */ - /*private void validateEARServerTargetJ2EESpecLevel(EAREditModel editModel) { - EARNatureRuntime nature = earEditModel.getEARNature(); - IProject earProject = nature.getProject(); - IRuntime earRuntime = ServerCore.getProjectProperties(earProject).getRuntimeTarget(); - if (earRuntime != null) { - try { - if (earProject.hasNature(IEARNatureConstants.NATURE_ID) && nature.getModuleVersion() == J2EEVersionConstants.J2EE_1_4_ID && !earRuntime.getRuntimeType().getVersion().equals("6.0")) { //$NON-NLS-1$ - String[] params = new String[]{earProject.getName(), earRuntime.getName()}; - addError(getBaseName(), INVALID_EAR_SERVER_TARGET_FOR_14_SPEC_LEVEL, params, earProject); - } - } catch (CoreException ce) { - Logger.getLogger().logError(ce); - } - } - }*/ - - /** - * @param project - * TODO This validation is RAD specific hence needs to be moved to a the RAD layered - * plugin references to this method are commented out - * This validation is no needed anymore for Flex project - */ - /*private void validateModuleServerTargetJ2EESpecLevel(IProject project, IRuntime runtime) { - boolean is14SpecLevelProject = false; - if (J2EENature.hasRuntime(project, new String[]{IWebNatureConstants.J2EE_NATURE_ID, IEJBNatureConstants.NATURE_ID, IApplicationClientNatureConstants.NATURE_ID})) { - J2EENature j2eeNature = J2EENature.getRegisteredRuntime(project); - is14SpecLevelProject = j2eeNature.getJ2EEVersion() == J2EEVersionConstants.J2EE_1_4_ID; - if (is14SpecLevelProject && !runtime.getRuntimeType().getVersion().equals("6.0")) { //$NON-NLS-1$ - String[] params = new String[]{project.getName(), runtime.getName()}; - addError(getBaseName(), INVALID_MODULE_SERVER_TARGET_FOR_14_SPEC_LEVEL, params); - } - } - }*/ - - - //The module maps validation needs to be done in the wtpmodules validator for flex project - /*protected void validateModuleMapsDuplicateProjects(WorkbenchComponent module) { - java.util.List moduleMaps = module.getReferencedComponents(); - java.util.Set visitedProjectNames = new java.util.HashSet(); - for (int i = 0; i < moduleMaps.size(); i++) { - WorkbenchComponent map = (WorkbenchComponent) moduleMaps.get(i); - if (map.getModule() != null) { - String moduleUri = map.getModule().getUri(); - String earProjectName = earEditModelParam.getEARNature().getProject().getName(); - String projectName = map.getProjectName(); - if (visitedProjectNames.contains(projectName)) - duplicateProjectMapError(earProjectName, moduleUri, projectName); - else - visitedProjectNames.add(projectName); - } - } - }*/ - - protected void validateModuleURIExtension(IVirtualComponent module) { - - String fileExt = module.getFileExtension(); - if (fileExt != null && fileExt.length() > 0) { - if (module.getComponentTypeId().endsWith(IModuleConstants.JST_EJB_MODULE) && !fileExt.endsWith(".jar")) { //$NON-NLS-1$ - String[] params = new String[1]; - params[0] = module.getName(); - IResource target = earHelper.getProject().getFile(ArchiveConstants.APPLICATION_DD_URI); - addError(getBaseName(), INVALID_URI_FOR_MODULE_ERROR_, params, target); - } else if (module.getComponentTypeId().endsWith(IModuleConstants.JST_WEB_MODULE) && !fileExt.endsWith(".war")) { //$NON-NLS-1$ - String[] params = new String[1]; - params[0] = module.getName(); - IResource target = earHelper.getProject().getFile(ArchiveConstants.APPLICATION_DD_URI); - addError(getBaseName(), INVALID_URI_FOR_MODULE_ERROR_, params, target); - } - } - } - - /* - * This validation is not needed anymore for flex project - * public void validateModuleProjectsForValidNature(WorkbenchComponent module) { - - try { - if (module.getComponentType().getModuleTypeId().equals(IModuleConstants.JST_WEB_MODULE)) { - if (!project.hasNature(IWebNatureConstants.J2EE_NATURE_ID)) { - String[] params = new String[2]; - params[0] = project.getName(); - params[1] = earHelper.getProject().getName(); - addWarning(getBaseName(), MISSING_WEBNATURE_FORMODULE_WARN_, params, appDD); - } else { - WebModuleExtension webExt = EarModuleManager.getWebModuleExtension(); - if (webExt != null && !(webExt.compareWebContextRoot(module, project))) { - String[] params = new String[3]; - params[0] = module.getUri(); - params[1] = earHelper.getProject().getName(); - params[2] = project.getName(); - addWarning(getBaseName(), INVALID_CONTEXTROOT_WEBMODULE_WARN_, params, appDD); - } - } - - } else if (module.getComponentType().getModuleTypeId().equals(IModuleConstants.JST_EJB_MODULE)) { - if (!project.hasNature(IEJBNatureConstants.NATURE_ID)) { - String[] params = new String[2]; - params[0] = project.getName(); - params[1] = earHelper.getProject().getName(); - addWarning(getBaseName(), MISSING_EJBNATURE_FORMODULE_WARN_, params); - } - } else if (module.getComponentType().getModuleTypeId().equals(IModuleConstants.JST_UTILITY_MODULE)) { - if (!ApplicationClientNatureRuntime.hasRuntime(project)) { - String[] params = new String[2]; - params[0] = project.getName(); - params[1] = earHelper.getProject().getName(); - addWarning(getBaseName(), MISSING_CLIENTNATURE_FORMODULE_WARN_, params); - } - } - } catch (org.eclipse.core.runtime.CoreException ce) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ce); - } - - }*/ - - /* - * @see J2EEValidator#cleanup() - */ - public void cleanup() { - if (earHelper != null) - earHelper.closeEARFile(); - } - - protected IFile getManifestFile(Archive anArchive) { - URIConverter conv = anArchive.getResourceSet().getURIConverter(); - if (conv instanceof WorkbenchURIConverter) { - WorkbenchURIConverter wbConv = (WorkbenchURIConverter) conv; - IContainer input = wbConv.getInputContainer(); - if (input == null) - return null; - IProject p = input.getProject(); - if (p == null || JavaProjectUtilities.isBinaryProject(p)) - return null; - IFile result = J2EEProjectUtilities.getManifestFile(p); - if (result != null && result.exists()) - return result; - } - return null; - } - - /** - * Checks if the nature is consistent with doc type. - */ - protected void validateDocType(EARArtifactEdit edit,IVirtualComponent module) { - if (edit == null) - return; - if (edit.getJ2EEVersion() >= J2EEVersionConstants.J2EE_1_3_ID && appDD.getVersionID() < J2EEVersionConstants.J2EE_1_3_ID) { - String[] params = new String[3]; - params[0] = DOCTYPE_1_2; - params[1] = getResourceName(); - params[2] = DOCTYPE_1_3; - addError(getBaseName(), EAR_INVALID_DOC_TYPE_ERROR_, params, appDD); - } else if (edit.getJ2EEVersion() < J2EEVersionConstants.J2EE_1_3_ID && appDD.getVersionID() >= J2EEVersionConstants.J2EE_1_3_ID) { - String[] params = new String[3]; - params[0] = DOCTYPE_1_3; - params[1] = getResourceName(); - params[2] = DOCTYPE_1_2; - addError(getBaseName(), EAR_INVALID_DOC_TYPE_ERROR_, params, appDD); - } - } - - /** - * Validates that conflicting jar does not exist in the ear project. - */ - public void validateUriAlreadyExistsInEar(EARArtifactEdit edit,IVirtualComponent component) { - List modules = edit.getJ2EEModuleReferences(); - if (modules == null) - return; - for (int i = 0; i < modules.size(); i++) { - IVirtualReference reference = (IVirtualReference) modules.get(i); - IVirtualComponent module = reference.getReferencedComponent(); - if (module != null && module.getRuntimePath() != null) { - IProject currentEARProject = earHelper.getProject(); - try { - IFile exFile = currentEARProject.getFile(module.getRuntimePath()); - if (exFile != null && exFile.exists()) { - String[] params = new String[2]; - params[0] = module.getRuntimePath().toString(); - params[1] = currentEARProject.getName(); - addWarning(getBaseName(), URI_ALREADY_EXISTS_IN_EAR_WARN_, params, appDD); - } - } catch (IllegalArgumentException iae) { - Logger.getLogger().logError(iae); - } - } - } - } - -}// UIEarValidator |