private File getDocumentFile(String documentId, String ext) { String groupId = docIdUtils.getDocumentGroupId(documentId); File docDirFile = new File(rootDirFile, groupId); String docFilename = docIdUtils.getDocumentSequence(documentId) + ext; File docFile = new File(docDirFile, docFilename); return docFile; }
private List<String> getDocumentIds(File setFile) { File[] dataFiles = setFile.listFiles( new FilenameFilter() { String ext = getFetchedFileExt(); public boolean accept(File dir, String name) { if (name.endsWith(ext)) { return true; } else { return false; } } }); List<String> documentIds = new ArrayList<String>(); String groupId = setFile.getName(); if (dataFiles != null) { for (File f : dataFiles) { String name = f.getName(); String itemId = name.substring(0, name.indexOf(".")); String documentId = docIdUtils.getDocumentId(groupId, itemId); documentIds.add(documentId); } } return documentIds; }
public void saveDocument(FetchedDocument doc) { /* create directory for current group if it doesn't exist yet. */ String groupId = docIdUtils.getDocumentGroupId(doc.getDocumentId()); createGroup(groupId); File dataFile = getDataFile(doc.getDocumentId()); saveContent(dataFile, doc.getDocumentContent()); File metadataFile = getPropertiesFile(doc.getDocumentId()); saveMetadata(metadataFile, doc); }