Ejemplo n.º 1
0
  @Override
  public void importFile(File inFile, IRI documentIRI, Authorizations authorizations)
      throws Exception {
    if (!inFile.exists()) {
      throw new LumifyException("File " + inFile + " does not exist");
    }
    File inDir = inFile.getParentFile();

    FileInputStream inFileIn = new FileInputStream(inFile);
    try {
      importFile(inFileIn, documentIRI, inDir, authorizations);
    } finally {
      inFileIn.close();
    }
  }
Ejemplo n.º 2
0
 protected File findOwlFile(File dir) {
   File[] files = dir.listFiles();
   if (files == null) {
     return null;
   }
   for (File child : files) {
     if (child.isDirectory()) {
       File found = findOwlFile(child);
       if (found != null) {
         return found;
       }
     } else if (child.getName().toLowerCase().endsWith(".owl")) {
       return child;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
  @Override
  public void writePackage(File file, IRI documentIRI, Authorizations authorizations)
      throws Exception {
    ZipFile zipped = new ZipFile(file);
    if (zipped.isValidZipFile()) {
      File tempDir = Files.createTempDir();
      try {
        LOGGER.info("Extracting: %s to %s", file.getAbsoluteFile(), tempDir.getAbsolutePath());
        zipped.extractAll(tempDir.getAbsolutePath());

        File owlFile = findOwlFile(tempDir);
        importFile(owlFile, documentIRI, authorizations);
      } finally {
        FileUtils.deleteDirectory(tempDir);
      }
    } else {
      importFile(file, documentIRI, authorizations);
    }
  }
Ejemplo n.º 4
0
 private void setIconProperty(
     Concept concept,
     File inDir,
     String glyphIconFileName,
     String propertyKey,
     Authorizations authorizations)
     throws IOException {
   if (glyphIconFileName != null) {
     File iconFile = new File(inDir, glyphIconFileName);
     if (!iconFile.exists()) {
       throw new RuntimeException("Could not find icon file: " + iconFile.toString());
     }
     InputStream iconFileIn = new FileInputStream(iconFile);
     try {
       StreamingPropertyValue value = new StreamingPropertyValue(iconFileIn, byte[].class);
       value.searchIndex(false);
       value.store(true);
       concept.setProperty(
           propertyKey, value, OntologyRepository.VISIBILITY.getVisibility(), authorizations);
     } finally {
       iconFileIn.close();
     }
   }
 }