Author: rob.stryker(a)jboss.com
Date: 2008-05-15 00:28:17 -0400 (Thu, 15 May 2008)
New Revision: 8092
Modified:
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
Log:
JBIDE-2199 - avoid NPE's, log improper filesets
Modified:
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
===================================================================
---
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2008-05-15
04:27:17 UTC (rev 8091)
+++
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2008-05-15
04:28:17 UTC (rev 8092)
@@ -157,9 +157,11 @@
if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
IArchiveFileSet fileset = (IArchiveFileSet)node;
IPath p = fileset.getGlobalSourcePath();
- if( workspaceRoot.getLocation().isPrefixOf(p)) {
- IProject proj = workspaceRoot.getProject(p.segment(count));
- set.add(proj);
+ if( p != null ) {
+ if( workspaceRoot.getLocation().isPrefixOf(p)) {
+ IProject proj = workspaceRoot.getProject(p.segment(count));
+ set.add(proj);
+ }
}
}
return true;
Modified:
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
---
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-05-15
04:27:17 UTC (rev 8091)
+++
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-05-15
04:28:17 UTC (rev 8092)
@@ -30,6 +30,7 @@
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
@@ -87,14 +88,22 @@
* @see IArchiveFileSet#getGlobalSourcePath()
*/
public IPath getGlobalSourcePath() {
+ IPath ret;
String path = getFileSetDelegate().getDir();
if (path == null || path.equals(".") || path.equals("")) {
- return getProjectPath();
+ ret = getProjectPath();
} else if( isInWorkspace()){
- return ModelUtil.workspacePathToAbsolutePath(new Path(path));
+ ret = ModelUtil.workspacePathToAbsolutePath(new Path(path));
} else {
- return new Path(path);
+ ret = new Path(path);
}
+
+ if( ret == null ) {
+ String message = "Error in fileset: " + toString() + "; No global
source path found.";
+ ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_WARN, message, new
Exception(message));
+ }
+
+ return ret;
}
/*
@@ -120,10 +129,13 @@
}
private boolean matchesPath(DirectoryScannerExtension scanner, IPath path) {
- if( getGlobalSourcePath().isPrefixOf(path)) {
- String s =
path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- return scanner.isUltimatelyIncluded(s);
- }
+ IPath global = getGlobalSourcePath();
+ if( global != null ) {
+ if( global.isPrefixOf(path)) {
+ String s =
path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
+ return scanner.isUltimatelyIncluded(s);
+ }
+ }
return false;
}
@@ -262,5 +274,20 @@
public boolean validateModel() {
return getAllChildren().length == 0 ? true : false;
}
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("{dir=");
+ sb.append(getFileSetDelegate().getDir());
+ sb.append(",includes=");
+ sb.append(getFileSetDelegate().getIncludes());
+ sb.append(",excludes=");
+ sb.append(getFileSetDelegate().getExcludes());
+ sb.append(",inWorkspace=");
+ sb.append(getFileSetDelegate().isInWorkspace());
+ sb.append(",flatten=");
+ sb.append(getFileSetDelegate().isFlattened());
+ return sb.toString();
+ }
}
Show replies by date