@Override public String getId() { return wrapped.getId(); }
@Override public void documentSkippedBecauseUnchanged(Document doc) { ++count; os.println("Not restoring "+count+" of "+total+" ("+doc.getId()+") because it is unchanged"); }
@Override public void updatingDocument(Phase phase, Document doc) { if( phase == Phase.BEFORE ) { ++count; os.println("Restoring "+count+" of "+total+" ("+doc.getId()+")"); } }
@Override public void documentSkippedBecauseModified(Document doc) { ++count; ++skipped; os.println("Can not restore "+doc.getId()+" because the document was modified in the database"); }
@Override public void documentSkippedBecauseModified(Document doc) { gs.getOutStream().println("Update skipped: "+doc.getId()); }
static public Map<String,File> listDocumentsFromDir( GlobalSettings gs ,File docsDir ) throws Exception { Map<String,File> docIds = new HashMap<String,File>(); if( docsDir.exists() && docsDir.isDirectory() ){ // Iterate over each subdirectory, attempting to // load each document String[] subDirNames = docsDir.list( gs.getFilenameFilter() ); for(String subDirName : subDirNames){ File subDir = new File(docsDir, subDirName); if( subDir.exists() && subDir.isDirectory() ) { // OK, let's create a document based on this Document doc = null; try { FSEntryFile entry = new FSEntryFile(subDir); doc = DocumentFile.createDocument(entry); } catch(Exception e){ throw new Exception("Unable to read document at: "+subDir.getName(), e); } docIds.put(doc.getId(), subDir); } } } return docIds; }
public void outputExport(Writer writer) throws Exception { while( retrieval.hasNext() ){ Document doc = retrieval.getNext(); if( null != doc ) { try{ outputDocument(writer, doc); } catch(Exception e) { throw new Exception("Error exporting document: "+doc.getId(), e); } } } }
try { Document doc = DocumentFile.createDocument(entry); String docId = doc.getId();
) throws Exception { String docId = sourceDoc.getId(); if( null == docId ){ throw new Exception("On document update, an _id is required");
String docId = sourceDoc.getId(); if( null == docId ){ throw new Exception("On document update, an _id is required"); logger.debug(sourceDoc.getId()+" creation required"); logger.debug(sourceDoc.getId()+" forced update"); logger.debug(sourceDoc.getId()+" update not required"); logger.debug(sourceDoc.getId()+" not modified"); logger.debug(sourceDoc.getId()+" updating");
@Override public DocumentDigest computeDocumentDigest(Document doc) throws Exception { try { JSONObject json = doc.getJSONObject(); // Initialize digest DocumentDigest dd = new DocumentDigest(); dd.setType(DIGEST_COMPUTER_TYPE); // Compute digest of main document String mainDigest = this.computeDigestFromJsonObject(json); dd.setDocDigest(mainDigest); // Process each attachment Collection<Attachment> attachments = doc.getAttachments(); if( null != attachments ) { for(Attachment attachment : attachments){ String digest = computeAttachmentDigest(attachment); dd.addAttachmentDigest(attachment.getName(), digest); } } return dd; } catch(Exception e) { throw new Exception("Error while computing document digest for "+doc.getId(), e); } }
builder.value(sourceDoc.getId());
public void outputExport(Writer writer) throws Exception { JSONWriter jsonWriter = new JSONWriter(writer); GeoJsonGeometryWriter geoWriter = new GeoJsonGeometryWriter(); WktParser wktParser = new WktParser(); jsonWriter.object(); jsonWriter.key("type"); jsonWriter.value("FeatureCollection"); jsonWriter.key("features"); jsonWriter.array(); while( retrieval.hasNext() ){ Document doc = retrieval.getNext(); if( null != doc ) { try{ outputDocument(jsonWriter, doc, geoWriter, wktParser); } catch(Exception e) { throw new Exception("Error exporting document: "+doc.getId(), e); } } } jsonWriter.endArray(); // end feature collection jsonWriter.endObject(); // end wrapping object }