public void setID(DocumentID<Local> id) { documentMap.put(ID_KEY, id.getID()); }
private String getFileUrl(String fileName, DocumentID<Local> docid) throws UnsupportedEncodingException { return fileUrl + "&" + HttpEndpointConstants.FILENAME_PARAM + "=" + fileName + "&" + HttpEndpointConstants.DOCID_PARAM + "=" + URLEncoder.encode(docid.toJSON(), "UTF-8"); }
public boolean equals(DocumentID<?> id) { return this.id.equals(id.getID()); }
@SuppressWarnings("unchecked") public List<String> getFileNames(DocumentID<?> docid) { try { HttpResponse response = core.get(fileUrl + "&" + HttpEndpointConstants.DOCID_PARAM + "=" + URLEncoder.encode(docid.toJSON(), "UTF-8")); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { try { return (List<String>) SerializationUtils.toObject(EntityUtils.toString(response.getEntity())); } catch (JsonException e) { throw new IOException(e); } } else { logUnexpected("getFileNames()", response); return null; } } catch (IOException e) { throw new RuntimeException(e); } }
@Override public boolean equals(Object o) { if(id==null) { return o == null; } if(o instanceof DocumentID || DocumentID.class.isAssignableFrom(o.getClass())) { return id.equals(((DocumentID<?>) o).getID()); } return id.equals(o); }
@SuppressWarnings("rawtypes") @Override public boolean equals(Object o) { if(o instanceof DocumentID) { return id.equals(((DocumentID) o).getID()); } return false; }
@Override public void setID(DocumentID<MongoType> id) { documentMap.put(ID_KEY, id.getID()); }
@Override public void delete(DatabaseDocument<MongoType> d) { BasicDBObject dbo = new BasicDBObject(MongoDocument.MONGO_ID_KEY, d.getID().getID()); documents.remove(dbo, concern); }
@Override public DocumentFile<MemoryType> getDocumentFile( DatabaseDocument<MemoryType> d, String fileName) { for (DocumentFile<MemoryType> f : files) { if (f.getDocumentId().getID().equals(d.getID().getID()) && f.getFileName().equals(fileName)) { try { return copy(f); } catch (IOException e) { logger.error("Error copying the streams", e); } } } return null; }
public final void requireID(DocumentID<MongoType> o) { if(o==null) { return; } qb = qb.put(MongoDocument.MONGO_ID_KEY).is(o.getID()); id = o; }
@Override public void setID(DocumentID<MemoryType> id) { doc.setID(new LocalDocumentID(id.getID())); }
@Override public void putAll(Document<?> d) { if(d.getID() != null) { documentMap.put(ID_KEY, d.getID().getID()); } if(d.getAction()!=null) { documentMap.put(ACTION_KEY, d.getAction()); } for(Map.Entry<String, Object> e : d.getMetadataMap().entrySet()) { putMetadataField(e.getKey(), e.getValue()); } for(String s : d.getContentFields()) { putContentField(s, d.getContentField(s)); } }
@Override public boolean isEqual(Document<?> d) { if(d.getID()!=null) { if(!d.getID().getID().equals(getID().getID())) { return false; } } else { if(getID()!=null) { return false; } } if(d.getAction()!=getAction()) { return false; } if(equalMetadata(d) && equalContent(d)) { return true; } return false; }
@Override public boolean update(DatabaseDocument<MemoryType> d) { MemoryDocument md = (MemoryDocument) d; MemoryDocument inDb = getDocumentById(d.getID()); if (inDb == null) { set.put(md, false); inDb = getDocumentById(d.getID()); } if (inDb == null) { logger.error("Can't find document with id '" + d.getID().getID() + "', unable to update."); return false; } if (md.isTouchedAction()) { inDb.setAction(md.getAction()); } for (String s : getTouchedContentSnapshot(md)) { if (md.getContentField(s) != null) { inDb.putContentField(s, md.getContentField(s)); } else { inDb.removeContentField(s); } } for (String s : getTouchedMetadataSnapshot(md)) { inDb.putMetadataField(s, md.getMetadataMap().get(s)); } md.markSynced(); return true; }
private DocumentFile<MongoType> getDocumentFile(DocumentID<MongoType> id, String filename) { DBObject query = QueryBuilder.start(DOCUMENT_KEY).is(id.getID()).and(FILENAME_KEY).is(filename).get(); GridFSDBFile file = documentfs.findOne(query); if(file==null) { return null; } DocumentFile<MongoType> df = new DocumentFile<MongoType>(id, file.getFilename(), file.getInputStream(), (String)file.get(STAGE_KEY), file.getUploadDate()); if(file.containsField(MIMETYPE_KEY)) { df.setMimetype((String) file.get(MIMETYPE_KEY)); } if(file.containsField(ENCODING_KEY)) { df.setEncoding((String) file.get(ENCODING_KEY)); } return df; }