Exemple #1
0
 private static FolderEntry readEntryFromStream(InputStream inputStream) throws IOException {
   // use java Properties to save the files
   Properties properties = new Properties();
   properties.load(inputStream);
   FolderEntry folderEntry = new FolderEntry();
   folderEntry.setContentId(properties.getProperty(CONTENT_ID));
   folderEntry.setContentType(FolderContentType.fromName(properties.getProperty(CONTENT_TYPE)));
   folderEntry.setFolderId(properties.getProperty(FOLDER_ID));
   return folderEntry;
 }
Exemple #2
0
 /**
  * Tries to read a file for a dataprep {@link FolderEntry}.
  *
  * @param pathFile the location of the file
  * @return the folder entry or throws an exception if it cannot be read
  */
 static FolderEntry toFolderEntry(Path pathFile) {
   FolderEntry folderEntry;
   try (InputStream inputStream = Files.newInputStream(pathFile)) {
     Properties properties = new Properties();
     properties.load(inputStream);
     folderEntry = new FolderEntry();
     folderEntry.setFolderId(properties.getProperty(FOLDER_ID));
     folderEntry.setContentType(FolderContentType.fromName(properties.getProperty(CONTENT_TYPE)));
     folderEntry.setContentId(properties.getProperty(CONTENT_ID));
   } catch (IOException e) {
     throw new TDPException(UNABLE_TO_READ_FOLDER_ENTRY, e, build().put("path", pathFile));
   }
   return folderEntry;
 }