Beispiel #1
0
 static void writeEntryToStream(FolderEntry folderEntry, OutputStream outputStream)
     throws IOException {
   // use java Properties to save the files
   Properties properties = new Properties();
   properties.setProperty(CONTENT_TYPE, folderEntry.getContentType().toString());
   properties.setProperty(CONTENT_ID, folderEntry.getContentId());
   properties.setProperty(FOLDER_ID, folderEntry.getFolderId());
   properties.store(outputStream, "saved");
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 static boolean matches(Path pathFile, String contentId, FolderContentType contentType) {
   boolean passFilter = false;
   try (InputStream inputStream = Files.newInputStream(pathFile)) {
     FolderEntry folderEntry = readEntryFromStream(inputStream);
     if (Objects.equals(contentType, folderEntry.getContentType())
         && //
         StringUtils.equalsIgnoreCase(folderEntry.getContentId(), contentId)) {
       passFilter = true;
     }
   } catch (IOException e) {
     throw new TDPException(UNABLE_TO_READ_FOLDER_ENTRY, e, build().put("path", pathFile));
   }
   return passFilter;
 }