Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRené Purrio2018-01-17 08:03:49 +0000
committerRené Purrio2018-01-17 08:03:49 +0000
commitedb01a788585e35cb247f67161b4944a9d1be364 (patch)
treec05cafa5ce06eb2fb37e580594334e9005d39a99
parenta0bbfb0b2a5a40b73eaeabdf3221f079e7ef38f7 (diff)
downloadeclipse.platform.ua-edb01a788585e35cb247f67161b4944a9d1be364.tar.gz
eclipse.platform.ua-edb01a788585e35cb247f67161b4944a9d1be364.tar.xz
eclipse.platform.ua-edb01a788585e35cb247f67161b4944a9d1be364.zip
Change-Id: Iddfb24c63e3454c3de9e539db25c379c7775f06c Signed-off-by: René Purrio <rpurrio@itemis.de>
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java3
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java3
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java9
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java20
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetManager.java3
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/HelpData.java8
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java7
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/XMLProcessorTest.java14
8 files changed, 56 insertions, 11 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java
index f254fc69d..d050bf870 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java
@@ -100,6 +100,9 @@ public class IndexToolApplication implements IApplication {
private static void delete(File file) throws IOException {
if (file.isDirectory()) {
File files[] = file.listFiles();
+ if(files == null) {
+ throw new IOException("Content from directory '" + file.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
for (int i = 0; i < files.length; i++) {
delete(files[i]);
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
index 0903ed4ef..c8fd3e5ca 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
@@ -210,6 +210,9 @@ public class SearchIndex implements IHelpSearchIndex {
private void deleteDir(File indexDir) {
File[] files = indexDir.listFiles();
+ if(files == null) {
+ files = new File[0];
+ }
for (File file : files) {
if (file.isDirectory())
deleteDir(file);
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java b/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java
index 53d2b8339..4416ecaf3 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java
@@ -10,7 +10,11 @@
*******************************************************************************/
package org.eclipse.help.internal.standalone;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.List;
/**
@@ -176,6 +180,9 @@ public class Eclipse extends Thread {
throw new Exception("Plugins directory " + pluginsDir.getAbsolutePath() //$NON-NLS-1$
+ " does not exists. Pass a correct -eclipsehome option"); //$NON-NLS-1$
File[] plugins = pluginsDir.listFiles();
+ if(plugins == null) {
+ throw new IOException("Content from plugins directory '" + pluginsDir.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
for (int i = 0; i < plugins.length; i++) {
String file = plugins[i].getName();
if (file.startsWith("org.eclipse.equinox.launcher_") && file.endsWith(".jar") && !plugins[i].isDirectory()) //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java b/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java
index 776ddb487..0ab6701a2 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java
@@ -352,7 +352,7 @@ public class HelpIndexBuilder {
* nl/language/country/ locale dirs that contain files. We will
* produce an index for each one.
*/
- private void computeLocaleDirs(boolean fragment) {
+ private void computeLocaleDirs(boolean fragment) throws CoreException {
if (!fragment) {
LocaleDir dir = new LocaleDir(null, "/"); //$NON-NLS-1$
dir.addDirectory(destination);
@@ -366,7 +366,7 @@ public class HelpIndexBuilder {
File nl = new File(destination, "nl"); //$NON-NLS-1$
if (!nl.exists() || !nl.isDirectory())
return;
- File [] languages = nl.listFiles();
+ File [] languages = listFiles(nl);
HashSet<String> locales = new HashSet<>();
for (int i=0; i<languages.length; i++) {
File language = languages[i];
@@ -374,7 +374,7 @@ public class HelpIndexBuilder {
continue;
if (!isValidLanguage(language.getName()))
continue;
- File [] countries = language.listFiles();
+ File [] countries = listFiles(language);
for (int j=0; j<countries.length; j++) {
File country = countries[j];
String locale;
@@ -403,10 +403,10 @@ public class HelpIndexBuilder {
}
}
- private void computeSystem(File systemRoot, String [] values) {
+ private void computeSystem(File systemRoot, String [] values) throws CoreException {
if (systemRoot.exists() && systemRoot.isDirectory()) {
// check
- File [] files = systemRoot.listFiles();
+ File [] files = listFiles(systemRoot);
for (int i=0; i<files.length; i++) {
File sdir = files[i];
if (!sdir.isDirectory())
@@ -643,7 +643,7 @@ public class HelpIndexBuilder {
private void prepareDirectory(File indexDirectory) throws CoreException {
if (indexDirectory.exists()) {
- File[] files = indexDirectory.listFiles();
+ File[] files = listFiles(indexDirectory);
for (int i = 0; i < files.length; i++) {
File file = files[i];
boolean result = file.delete();
@@ -766,4 +766,12 @@ public class HelpIndexBuilder {
IStatus.OK, message, t);
throw new CoreException(status);
}
+
+ private File[] listFiles(File file) throws CoreException {
+ File[] fileList = file.listFiles();
+ if(fileList == null) {
+ throwCoreException("Content from directory '" + file.getAbsolutePath() + "' can not be listed.", null); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return fileList;
+ }
}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetManager.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetManager.java
index 6a018e9e0..276ba4f48 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetManager.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetManager.java
@@ -110,6 +110,9 @@ public class ScopeSetManager extends Observable {
if (dir.exists() && dir.isDirectory()) {
File[] files = dir.listFiles((FilenameFilter) (dir1, name) -> name.endsWith(ScopeSet.EXT)
|| name.endsWith(HistoryScopeSet.EXT));
+ if(files == null) {
+ files = new File[0];
+ }
for (int i = 0; i < files.length; i++) {
File file = files[i];
String name = file.getName();
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java b/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java
index d18c16103..909798061 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java
@@ -152,7 +152,13 @@ public class HelpData {
* Allow unit tests to override for providing test data.
*/
public InputStream getHelpDataFile(String filePath) throws IOException {
- return Platform.getProduct().getDefiningBundle().getEntry(filePath).openStream();
+ IProduct product = Platform.getProduct();
+ Bundle definingBundle = product != null ? product.getDefiningBundle() : null;
+ URL entry = definingBundle != null ? definingBundle.getEntry(filePath) : null;
+ if(entry == null) {
+ throw new IOException("No entry to '"+filePath+"' could be found or caller does not have the appropriate permissions.");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return entry.openStream();
}
/*
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java
index 8baec7e6a..176f6bbdd 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URL;
import java.nio.charset.StandardCharsets;
import javax.xml.parsers.ParserConfigurationException;
@@ -48,7 +49,11 @@ public class DynamicXHTMLProcessorTest {
protected InputStream getProcessedInput(String path, Bundle bundle)
throws IOException, SAXException, ParserConfigurationException,
TransformerException, TransformerConfigurationException {
- try (InputStream in = bundle.getEntry(path).openStream()) {
+ URL url = bundle.getEntry(path);
+ if(url == null ) {
+ throw new IOException("No entry to '"+path+"' could be found or caller does not have the appropriate permissions.");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ try (InputStream in = url.openStream()) {
String href = '/' + bundle.getBundleId() + path;
return DynamicXHTMLProcessor.process(href, in, "en", true);
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/XMLProcessorTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/XMLProcessorTest.java
index c146999c1..0628d7026 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/XMLProcessorTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/XMLProcessorTest.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.dynamic;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.base.HelpEvaluationContext;
@@ -45,8 +47,16 @@ public class XMLProcessorTest {
};
XMLProcessor processor = new XMLProcessor(handlers);
Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
- try (InputStream in = bundle.getEntry(FileUtil.getResultFile(path)).openStream();
- InputStream in2 = processor.process(bundle.getEntry(path).openStream(),
+ URL url1 = bundle.getEntry(FileUtil.getResultFile(path));
+ if(url1 == null) {
+ throw new IOException("No entry to '"+FileUtil.getResultFile(path)+"' could be found or caller does not have the appropriate permissions.");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ URL url2 = bundle.getEntry(path);
+ if(url2 == null) {
+ throw new IOException("No entry to '"+path+"' could be found or caller does not have the appropriate permissions.");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ try (InputStream in = url1.openStream();
+ InputStream in2 = processor.process(url2.openStream(),
'/' + bundle.getSymbolicName() + '/' + path, "UTF-8")) {
XMLUtil.assertXMLEquals("XML content was not processed correctly: " + path, in, in2);
}

Back to the top