コード例 #1
0
 /**
  * Convert a string to an InputStream
  *
  * @param location Location of data to convert to an InputStream
  * @return the location converted to an InputStream
  * @throws AnzoException
  */
 private InputStream getLocationAsStream(String location) throws AnzoException {
   InputStream initializationStream = null;
   if (location.startsWith(resourcePrefix)) {
     String resourceLocation = location.substring(resourcePrefix.length());
     initializationStream = this.getClass().getResourceAsStream(resourceLocation);
     if (initializationStream == null) {
       throw new AnzoException(ExceptionConstants.SERVER.INIT_FILE, resourceLocation);
     }
   } else {
     File initializationFile = new File(location);
     try {
       initializationStream =
           SmartEncodingInputStream.createSmartStream(new FileInputStream(initializationFile));
     } catch (FileNotFoundException e2) {
       throw new AnzoException(
           ExceptionConstants.SERVER.INIT_FILE, initializationFile.getAbsolutePath());
     }
   }
   return initializationStream;
 }
コード例 #2
0
 /*
  * Initialize default system information with data from RepositoryInitializationFile if no system graph information was
  * provided
  */
 private void initializeProvidedRoles(NodeCentricOperationContext context, URI serverURI)
     throws AnzoException {
   SegmentedStatementCollector sc = new SegmentedStatementCollector();
   try {
     if (log.isWarnEnabled()) {
       log.warn(
           LogUtils.RDB_MARKER,
           "Initializing database from files: {}",
           Arrays.toString(rdfInitFiles.toArray()));
     }
     for (String file : rdfInitFiles) {
       ReadWriteUtils.parseStatements(
           SmartEncodingInputStream.createSmartReader(getLocationAsStream(file)),
           RDFFormat.forFileName(file),
           "",
           sc);
     }
   } catch (AnzoException mse) {
     throw new AnzoRuntimeException(mse);
   }
   resetGraph(sc.getStatements(), context, serverURI);
 }