protected void discardRepository(Repository rep) { File dataDir = rep.getDataDir(); if (dataDir != null && dataDir.isDirectory()) { try { FileUtil.deleteDir(dataDir); } catch (IOException e) { } } }
/** * Deletes all files and directories in the specified directory. Nothing * happens when the specified File is not a directory. * * @return true when all children were successfully deleted, when there were * no children or when the file was not a directory. */ public static boolean deleteChildren(File directory) { boolean result = true; if (directory.isDirectory()) { File[] list = directory.listFiles(); for (int i = list.length; i-- > 0;) { result = result && deltree(list[i]); } } return result; }
public void updateIndex(List<File> files, String baseURI, String endpoint) { log.info("UpdateIndexBegin"); try { for (File file : files) { String type = FileUtil.getFileExtension(file.getName()); if (type.equals(TTL)) indexTTLFile(file, baseURI); iwriter.commit(); } } catch (Exception e) { log.error("Error while creating TripleIndex.", e); } }
tmpDir = FileUtil.createTempDir("sparql11-test-evaluation");
/** * Gets the relative representations of a file compared to another. * * @param subj * The File to find the relative form for. * @param relativeTo * The File 'subj' should be made relative to. * @return The relative representation of subj. */ public static File getRelativeFile(File subj, File relativeTo) { return new File(getRelativePath(subj, relativeTo)); }
tmpDir = FileUtil.createTempDir("sparql11-test-evaluation");
@Override public void run(TestResult result) { try { super.run(result); } finally { if (tmpDir != null) { try { FileUtil.deleteDir(tmpDir); } catch (IOException e) { System.err.println("Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage()); } } } } };
public interface Factory { SPARQLSyntaxTest createSPARQLSyntaxTest(String testURI, String testName, String testAction, boolean positiveTest); }
/** * Deletes the given file and everything under it. * * @return Whether all files were deleted succesfully. */ public static boolean deltree(File directory) { if (directory == null || !directory.exists()) { return true; } boolean result = true; if (directory.isFile()) { result = directory.delete(); } else { File[] list = directory.listFiles(); for (int i = list.length; i-- > 0;) { if (!deltree(list[i])) { result = false; } } if (!directory.delete()) { result = false; } } return result; }
public void createIndex(List<File> files, String idxDirectory, String baseURI) { try { urlAnalyzer = new SimpleAnalyzer(LUCENE_VERSION); literalAnalyzer = new LiteralAnalyzer(LUCENE_VERSION); Map<String, Analyzer> mapping = new HashMap<String, Analyzer>(); mapping.put(FIELD_NAME_URI, urlAnalyzer); mapping.put(FIELD_NAME_SURFACE_FORM, literalAnalyzer); mapping.put(FIELD_NAME_URI_COUNT, literalAnalyzer); mapping.put(FIELD_NAME_CONTEXT, literalAnalyzer); PerFieldAnalyzerWrapper perFieldAnalyzer = new PerFieldAnalyzerWrapper(urlAnalyzer, mapping); File indexDirectory = new File(idxDirectory); indexDirectory.mkdir(); directory = new MMapDirectory(indexDirectory); IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, perFieldAnalyzer); iwriter = new IndexWriter(directory, config); iwriter.commit(); for (File file : files) { String type = FileUtil.getFileExtension(file.getName()); if (type.equals(TTL)) indexTTLFile(file, baseURI); iwriter.commit(); } } catch (Exception e) { log.error("Error while creating TripleIndex.", e); } }
@Override public void run(TestResult result) { try { super.run(result); } finally { if (tmpDir != null) { try { FileUtil.deleteDir(tmpDir); } catch (IOException e) { System.err.println("Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage()); } } } } };
tmpDir = FileUtil.createTempDir("sparql11-test-evaluation");
@Override protected void finalize() throws Throwable { if (disk == this) { try { if (connection != null) { connection.commit(); connection.close(); } repository.shutDown(); } catch (RepositoryException e) { logger.error(e.toString(), e); } finally { FileUtil.deltree(repository.getDataDir()); repository = null; connection = null; disk = null; } } super.finalize(); } };
public void createIndex(List<File> files, String idxDirectory, String baseURI) { try { urlAnalyzer = new SimpleAnalyzer(LUCENE_VERSION); literalAnalyzer = new LiteralAnalyzer(LUCENE_VERSION); Map<String, Analyzer> mapping = new HashMap<String, Analyzer>(); mapping.put(TripleIndex.FIELD_NAME_SUBJECT, urlAnalyzer); mapping.put(TripleIndex.FIELD_NAME_PREDICATE, urlAnalyzer); mapping.put(TripleIndex.FIELD_NAME_OBJECT_URI, urlAnalyzer); mapping.put(TripleIndex.FIELD_NAME_OBJECT_LITERAL, literalAnalyzer); PerFieldAnalyzerWrapper perFieldAnalyzer = new PerFieldAnalyzerWrapper(urlAnalyzer, mapping); File indexDirectory = new File(idxDirectory); indexDirectory.mkdir(); directory = new MMapDirectory(indexDirectory); IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, perFieldAnalyzer); iwriter = new IndexWriter(directory, config); iwriter.commit(); for (File file : files) { String type = FileUtil.getFileExtension(file.getName()); if (type.equals(TTL)) indexTTLFile(file, baseURI); if (type.equals(TSV)) indexTSVFile(file); iwriter.commit(); } iwriter.close(); ireader = DirectoryReader.open(directory); } catch (Exception e) { log.error("Error while creating TripleIndex.", e); } }
@Override public void run(TestResult result) { try { super.run(result); } finally { if (tmpDir != null) { try { FileUtil.deleteDir(tmpDir); } catch (IOException e) { System.err.println("Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage()); } } } } };
if ("jar".equals(url.getProtocol())) { try { tmpDir = FileUtil.createTempDir("sparql-syntax"); JarURLConnection con = (JarURLConnection)url.openConnection(); JarFile jar = con.getJarFile();
@Override public void run(TestResult result) { try { super.run(result); } finally { if (tmpDir != null) { try { FileUtil.deleteDir(tmpDir); } catch (IOException e) { System.err.println("Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage()); } } } } };
tmpDir = FileUtil.createTempDir("sparql-evaluation");
@Override public void run(TestResult result) { try { super.run(result); } finally { if (tmpDir != null) { try { FileUtil.deleteDir(tmpDir); } catch (IOException e) { System.err.println("Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage()); } } } } };
@Override public void run(TestResult result) { try { super.run(result); } finally { if (tmpDir != null) { try { FileUtil.deleteDir(tmpDir); } catch (IOException e) { System.err.println("Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage()); } } } } };