Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjustinchen2006-06-16 01:11:54 +0000
committerjustinchen2006-06-16 01:11:54 +0000
commit90ecbb3a4e688c3fdaf5071d8c467a58703be2e2 (patch)
tree322877e9ca97cb1f164d1ab15111e5b050b5e222
parent96ded67a15a0f75c3fbee02cf299edd6f5501f0d (diff)
downloadwebtools.jsf-90ecbb3a4e688c3fdaf5071d8c467a58703be2e2.tar.gz
webtools.jsf-90ecbb3a4e688c3fdaf5071d8c467a58703be2e2.tar.xz
webtools.jsf-90ecbb3a4e688c3fdaf5071d8c467a58703be2e2.zip
Fix for 146046, No indication of failure when JSF Library jars are missing and a library is referenced.
Log an entry for each missing JAR in a referenced JSF library when dependencies are added. Missing JARs are also filtered out and added as dependencies. However, same practice does not apply when removing dependencies. It is intended to perform a clean up w/ all JARs.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java2
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java12
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties4
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java85
4 files changed, 87 insertions, 16 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java
index 9d1fac092..35795d488 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java
@@ -44,6 +44,8 @@ public class Messages extends NLS {
public static String ArchiveFileImpl_CannotCloseFile;
public static String ArchiveFileImpl_CannotLocatePluginRelativeFile;
+ public static String JSFUtils_MissingJAR;
+
public static String PluginProvidedJSFLibraryCreationHelper_ErrorCreating;
public static String PluginProvidedJSFLibraryCreationHelper_ErrorMultipleDefinition;
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java
index 45f684c72..00b571bef 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jst.jsf.core.internal.jsflibraryconfig;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
@@ -23,7 +24,9 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
@@ -36,8 +39,11 @@ import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.common.ClasspathModel;
import org.eclipse.jst.j2ee.internal.common.operations.UpdateJavaBuildPathOperation;
import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
+import org.eclipse.jst.jsf.core.internal.Messages;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
@@ -76,10 +82,10 @@ public class J2EEModuleDependencyDelegate {
* @param monitor
*/
public void addProjectDependency(JSFLibrary jsfLibrary, boolean toDeploy, IProgressMonitor monitor) {
- IPath[] jarPaths = JSFUtils.getJARPathforJSFLib(jsfLibrary);
+ IPath[] jarPaths = JSFUtils.getJARPathforJSFLibwFilterMissingJars(jsfLibrary, true);
this.updateProjectDependency(jarPaths, toDeploy, monitor);
}
-
+
/**
* Remove given <b>jsfLibrary</b> from project dependency.
*
@@ -87,7 +93,7 @@ public class J2EEModuleDependencyDelegate {
* @param monitor
*/
public void removeProjectDependency(JSFLibrary jsfLibrary, IProgressMonitor monitor) {
- IPath[] elements = JSFUtils.getJARPathforJSFLib(jsfLibrary);
+ IPath[] elements = JSFUtils.getJARPathforJSFLib(jsfLibrary, false);
this.removeProjectDependency_(elements, monitor);
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties
index ed3e9ae82..f68ca7993 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties
@@ -38,4 +38,6 @@ JSFUtils_ErrorClosingConfigFile=Error closing config file
JSFAppConfigUtils_ErrorOpeningJarFile=Error opening JarFile "{0}"
-JARFileJSFAppConfigProvider_ErrorLoadingModel=Error loading model for file "{0}" \ No newline at end of file
+JARFileJSFAppConfigProvider_ErrorLoadingModel=Error loading model for file "{0}"
+JSFUtils_MissingJAR= Missing JSF Library Jar: {0} in {1}
+
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java
index 427354ea5..b4a00d281 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java
@@ -16,6 +16,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -38,6 +39,7 @@ import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
import org.eclipse.jst.jsf.core.internal.Messages;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
/**
@@ -51,15 +53,15 @@ public class JSFUtils {
public static final String JSF_CONFIG_CONTEXT_PARAM = "javax.faces.CONFIG_FILES"; //$NON-NLS-1$
public static final String JSF_DEFAULT_CONFIG_PATH = "/WEB-INF/faces-config.xml"; //$NON-NLS-1$
- public static final String PP_JSF_FACET_INSTALLED = "is.jsf.project";
- public static final String PP_JSF_DEPLOY_ME = "deploy.jsf.libraries";
- public static final String PP_JSF_IMPL_LIB = "jsf.impl.lib";
- public static final String PP_JSF_NONIMPL_LIB = "jsf.nonimpl.lib";
- public static final String PP_JSF_AVAIL_COMP_LIB = "jsf.comp.lib.avail";
- public static final String PP_JSF_SEL_COMP_LIB = "jsf.comp.lib.selected";
+ public static final String PP_JSF_FACET_INSTALLED = "is.jsf.project"; //$NON-NLS-1$
+ public static final String PP_JSF_DEPLOY_ME = "deploy.jsf.libraries"; //$NON-NLS-1$
+ public static final String PP_JSF_IMPL_LIB = "jsf.impl.lib"; //$NON-NLS-1$
+ public static final String PP_JSF_NONIMPL_LIB = "jsf.nonimpl.lib"; //$NON-NLS-1$
+ public static final String PP_JSF_AVAIL_COMP_LIB = "jsf.comp.lib.avail"; //$NON-NLS-1$
+ public static final String PP_JSF_SEL_COMP_LIB = "jsf.comp.lib.selected"; //$NON-NLS-1$
- public static final String PP_JSF_IMPLEMENTATION_LIBRARIES = "jsf.implementation.libraries";
- public static final String PP_JSF_COMPONENT_LIBRARIES = "jsf.component.libraries";
+ public static final String PP_JSF_IMPLEMENTATION_LIBRARIES = "jsf.implementation.libraries"; //$NON-NLS-1$
+ public static final String PP_JSF_COMPONENT_LIBRARIES = "jsf.component.libraries"; //$NON-NLS-1$
/**
@@ -326,15 +328,74 @@ public class JSFUtils {
}
}
- public static IPath[] getJARPathforJSFLib(JSFLibrary jsfLib) {
+ /**
+ * Construct an array that hold paths for all JARs in a JSF library.
+ * However, archive files that no longer exist are filtered out.
+ *
+ * @param jsfLib
+ * @param logMissingJar true to log an error for each invalid JAR.
+ * @return elements
+ */
+ public static IPath[] getJARPathforJSFLibwFilterMissingJars(JSFLibrary jsfLib, boolean logMissingJar) {
+ EList archiveFiles = jsfLib.getArchiveFiles();
+ int numJars = numberofValidJar(archiveFiles);
+ IPath[] elements = new IPath[numJars];
+ ArchiveFile ar = null;
+ int idxValidJar = 0;
+ for (int i= 0; i < archiveFiles.size(); i++) {
+ ar = (ArchiveFile)archiveFiles.get(i);
+ if ( !ar.exists() ) {
+ if (logMissingJar) {
+ logErroronMissingJAR(jsfLib, ar);
+ }
+ } else {
+ elements[idxValidJar] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute();
+ idxValidJar++;
+ }
+ }
+ return elements;
+ }
+
+ /**
+ * Construct an array that hold paths for all JARs in a JSF library.
+ *
+ * @param jsfLib
+ * @param logMissingJar true to log an error for each invalid JAR.
+ * @return elements
+ */
+ public static IPath[] getJARPathforJSFLib(JSFLibrary jsfLib, boolean logMissingJar) {
EList archiveFiles = jsfLib.getArchiveFiles();
int numJars = archiveFiles.size();
- String name = null;
IPath[] elements = new IPath[numJars];
+ ArchiveFile ar = null;
for (int i= 0; i < numJars; i++) {
- elements[i] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute();
+ ar = (ArchiveFile)archiveFiles.get(i);
+ if ( !ar.exists() && logMissingJar ) {
+ logErroronMissingJAR(jsfLib, ar);
+ }
+ elements[i] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute();
}
return elements;
- }
+ }
+
+ private static int numberofValidJar(EList archiveFiles) {
+ int total = 0;
+ final Iterator it = archiveFiles.iterator();
+ ArchiveFile ar = null;
+ while(it.hasNext()) {
+ ar = (ArchiveFile) it.next();
+ if (ar.exists()) {
+ total++;
+ }
+ }
+ return total;
+ }
+
+ private static void logErroronMissingJAR(JSFLibrary jsfLib, ArchiveFile ar) {
+ String msg = NLS.bind(Messages.JSFUtils_MissingJAR,
+ ar.getName(),
+ jsfLib.getName());
+ JSFCorePlugin.log(IStatus.ERROR, msg);
+ }
}

Back to the top