Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation')
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/AWorkbenchMOFHelper.java92
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ApplicationClientHelper.java87
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/DependencyUtil.java242
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/EarHelper.java102
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/J2EEValidationHelper.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ManifestLineValidator.java103
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ResourceUtil.java59
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientHelper.java27
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientMessageConstants.java25
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientValidator.java90
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarHelper.java27
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarMessageConstants.java49
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarValidator.java780
13 files changed, 0 insertions, 1797 deletions
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 cbbc5f934..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/ApplicationClientHelper.java
+++ /dev/null
@@ -1,87 +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.IResource;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.common.componentcore.util.ComponentUtilities;
-import org.eclipse.jst.j2ee.applicationclient.componentcore.util.AppClientArtifactEdit;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.model.internal.validation.ApplicationClientValidator;
-import org.eclipse.wst.common.componentcore.ArtifactEdit;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.ComponentHandle;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-
-/**
- * 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 AppClient file for validation
- */
-
- public EObject loadApplicationClientFile() {
-
- ComponentHandle handle = getComponentHandle();
- IVirtualComponent comp = ComponentCore.createComponent(handle.getProject(), handle.getName());
- ArtifactEdit edit = ComponentUtilities.getArtifactEditForRead(comp);
-
- try {
- Archive archive = ((AppClientArtifactEdit) edit).asArchive(false);
- return archive;
- } catch (OpenFailureException e1) {
- Logger.getLogger().log(e1);
- }finally {
- if (edit != null) {
- edit.dispose();
- }
- }
- return null;
- }
-
- 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 696f9feeb..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/EarHelper.java
+++ /dev/null
@@ -1,102 +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.IResource;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.common.componentcore.util.ComponentUtilities;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.application.impl.ApplicationImpl;
-import org.eclipse.jst.j2ee.model.internal.validation.EarValidator;
-import org.eclipse.wst.common.componentcore.ArtifactEdit;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.ComponentHandle;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-
-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() {
-
- ComponentHandle handle = getComponentHandle();
- IVirtualComponent comp = ComponentCore.createComponent(handle.getProject(), handle.getName());
- ArtifactEdit edit = ComponentUtilities.getArtifactEditForRead(comp);
-
- try {
- Archive archive = ((EARArtifactEdit) edit).asArchive(false);
- return archive;
- } catch (OpenFailureException e1) {
- Logger.getLogger().log(e1);
- }finally {
- if (edit != null) {
- edit.dispose();
- }
- }
- return null;
- }
-
- 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 3eee39696..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/J2EEValidationHelper.java
+++ /dev/null
@@ -1,114 +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.wst.common.componentcore.resources.ComponentHandle;
-import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;
-import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
-
-
-public abstract class J2EEValidationHelper extends WorkbenchContext {
- private ComponentHandle componentHandle = null;
- /**
- * 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;
- }
-
- public ComponentHandle getComponentHandle() {
- return componentHandle;
- }
-
- public void setComponentHandle(ComponentHandle componentHandle) {
- this.componentHandle = componentHandle;
- }
-
-} \ 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 a85b68276..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIApplicationClientValidator.java
+++ /dev/null
@@ -1,90 +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.IProject;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.model.internal.validation.ApplicationClientValidator;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-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.IVirtualFile;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-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 {
-
-
- /**
- * Default constructor.
- */
- public UIApplicationClientValidator() {
- super();
- }// UIApplicationClientValidator
-
-
- /**
- * Does the validation.
- */
-
- public void validate(IValidationContext inHelper, IReporter inReporter) throws org.eclipse.wst.validation.internal.core.ValidationException {
-
- UIApplicationClientHelper helper = (UIApplicationClientHelper) inHelper;
-
- IProject proj = ((IWorkbenchContext) inHelper).getProject();
- IFlexibleProject flexProject = ComponentCore.createFlexibleProject(proj);
- IVirtualComponent[] virComps = flexProject.getComponents();
-
- for(int i = 0; i < virComps.length; i++) {
- IVirtualComponent wbModule = virComps[i];
- if(!wbModule.getComponentTypeId().equals(IModuleConstants.JST_APPCLIENT_MODULE))
- continue;
-
- ComponentHandle handle = ComponentHandle.create(proj, wbModule.getName());
- IVirtualFile ddFile = wbModule.getRootFolder().getFile(J2EEConstants.APP_CLIENT_DD_URI);
- if( ddFile.exists()) {
- helper.setComponentHandle(handle);
- super.validate(helper, inReporter);
- }
- //validateDocType(helper, editModel);
- }
- }
-
-
- /**
- * 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
-
-
-}// 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 dfd8cfc4d..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/validation/UIEarValidator.java
+++ /dev/null
@@ -1,780 +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.WorkbenchURIConverter;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.workbench.utility.JemProjectUtilities;
-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.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.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.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.IVirtualFile;
-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;
-
-
-/**
- * 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 org.eclipse.wst.validation.internal.core.ValidationException {
- earHelper = ((UIEarHelper) inHelper);
- IProject proj = ((IWorkbenchContext) inHelper).getProject();
- IFlexibleProject flexProject = ComponentCore.createFlexibleProject(proj);
- IVirtualComponent[] virComps = flexProject.getComponents();
-
- for(int i = 0; i < virComps.length; i++) {
- IVirtualComponent wbModule = virComps[i];
- if(!wbModule.getComponentTypeId().equals(IModuleConstants.JST_EAR_MODULE))
- continue;
-
- ComponentHandle handle = ComponentHandle.create(proj, wbModule.getName());
- IVirtualFile ddFile = wbModule.getRootFolder().getFile(J2EEConstants.APPLICATION_DD_URI);
- if( ddFile.exists()) {
- earHelper.setComponentHandle(handle);
- super.validate(inHelper, inReporter);
- }
-// validateModuleMaps(earEdit,earModule);
-// validateManifests(earModule,earFile);
-// validateUtilJarMaps(earEdit,earModule);
-// validateUriAlreadyExistsInEar(earEdit,earModule);
-// validateDocType(earEdit,earModule);
- }
- }
-
-
-
-// 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.getRootFolder().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();
- StructureEdit mc = null;
- if (modules.size() > 0) {
- for (int i = 0; i < modules.size(); i++) {
- try {
- 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 {
- 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);
- } finally {
- if (mc != null)
- mc.dispose();
- }
- }
- }
- //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.getRootFolder().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 || JemProjectUtilities.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.getRootFolder().getRuntimePath() != null) {
- IProject currentEARProject = earHelper.getProject();
- try {
- IFile exFile = currentEARProject.getFile(module.getRootFolder().getRuntimePath());
- if (exFile != null && exFile.exists()) {
- String[] params = new String[2];
- params[0] = module.getRootFolder().getRuntimePath().toString();
- params[1] = currentEARProject.getName();
- addWarning(getBaseName(), URI_ALREADY_EXISTS_IN_EAR_WARN_, params, appDD);
- }
- } catch (IllegalArgumentException iae) {
- Logger.getLogger().logError(iae);
- }
- }
- }
- }
-
-}// UIEarValidator

Back to the top