本文整理汇总了Java中com.mongodb.gridfs.GridFS.remove方法的典型用法代码示例。如果您正苦于以下问题:Java GridFS.remove方法的具体用法?Java GridFS.remove怎么用?Java GridFS.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.gridfs.GridFS
的用法示例。
在下文中一共展示了GridFS.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertAnnexDocument
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* Inserts publication annex document.
*/
public void insertAnnexDocument(BinaryFile bf, String dateString) throws ParseException {
try {
GridFS gfs = new GridFS(db, MongoCollectionsInterface.PUB_ANNEXES);
BasicDBObject whereQuery = new BasicDBObject();
whereQuery.put("repositoryDocId", bf.getRepositoryDocId());
whereQuery.put("filename", bf.getFileName());
gfs.remove(whereQuery);
//version ?
GridFSInputFile gfsFile = gfs.createFile(bf.getStream(), true);
gfsFile.put("uploadDate", Utilities.parseStringDate(dateString));
gfsFile.setFilename(bf.getFileName());
gfsFile.put("source", bf.getSource());
gfsFile.put("version", bf.getRepositoryDocVersion());
gfsFile.put("repositoryDocId", bf.getRepositoryDocId());
gfsFile.put("anhalyticsId", bf.getAnhalyticsId());
gfsFile.save();
} catch (ParseException e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例2: storeBlob
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
@Override
public Boolean storeBlob(CallingContext context, String docPath, InputStream newContent, Boolean append) {
GridFS gridFS = getGridFS();
GridFSInputFile file;
if (!append) {
gridFS.remove(docPath);
file = createNewFile(docPath, newContent);
} else {
GridFSDBFile existing = gridFS.findOne(docPath);
if (existing != null) {
try {
file = updateExisting(context, docPath, newContent, gridFS, existing);
} catch (IOException e) {
file = null;
log.error(String.format("Error while appending to docPath %s: %s", docPath, ExceptionToString.format(e)));
}
} else {
file = createNewFile(docPath, newContent);
}
}
return file != null;
}
示例3: deleteBlob
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
@Override
public Boolean deleteBlob(CallingContext context, String docPath) {
GridFS gridFS = getGridFS();
String lockKey = createLockKey(gridFS, docPath);
LockHandle lockHandle = grabLock(context, lockKey);
boolean retVal = false;
try {
if (gridFS.findOne(docPath) != null) {
gridFS.remove(docPath);
retVal = true;
}
} finally {
releaseLock(context, lockKey, lockHandle);
}
return retVal;
}
示例4: insertGrobidTei
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* Inserts grobid tei using GridFS.
*/
public void insertGrobidTei(String teiString, String repositoryDocId, String anhalyticsId, String version, String source, String type, String date) {
try {
GridFS gfs = new GridFS(db, MongoCollectionsInterface.GROBID_TEIS);
gfs.remove(repositoryDocId + ".tei.xml");
GridFSInputFile gfsFile = gfs.createFile(new ByteArrayInputStream(teiString.getBytes()), true);
gfsFile.put("uploadDate", Utilities.parseStringDate(date));
gfsFile.setFilename(repositoryDocId + ".tei.xml");
gfsFile.put("repositoryDocId", repositoryDocId);
gfsFile.put("anhalyticsId", anhalyticsId);
gfsFile.put("source", source);
gfsFile.put("version", version);
gfsFile.put("documentType", type);
gfsFile.save();
} catch (ParseException e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例5: insertMetadataTei
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* Inserts TEI metadata document in the GridFS.
*/
public void insertMetadataTei(String tei, String doi, String pdfUrl, String source, String repositoryDocId, String version, String type, String date) {
try {
GridFS gfs = new GridFS(db, MongoCollectionsInterface.METADATAS_TEIS);
gfs.remove(repositoryDocId + ".tei.xml");
GridFSInputFile gfsFile = gfs.createFile(new ByteArrayInputStream(tei.getBytes()), true);
gfsFile.put("uploadDate", Utilities.parseStringDate(date));
gfsFile.setFilename(repositoryDocId + ".tei.xml");
gfsFile.put("repositoryDocId", repositoryDocId);
gfsFile.put("anhalyticsId", generateAnhalyticsId(repositoryDocId, doi, pdfUrl));
gfsFile.put("source", source);
gfsFile.put("version", version);
gfsFile.put("documentType", type);
gfsFile.save();
} catch (ParseException e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例6: insertBinaryDocument
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* Inserts PDF binary document in the GridFS.
*/
public void insertBinaryDocument(BinaryFile bf, String date) {
try {
GridFS gfs = new GridFS(db, MongoCollectionsInterface.BINARIES);
gfs.remove(bf.getFileName());
GridFSInputFile gfsFile = gfs.createFile(bf.getStream(), true);
gfsFile.put("uploadDate", Utilities.parseStringDate(date));
gfsFile.setFilename(bf.getFileName());
gfsFile.put("repositoryDocId", bf.getRepositoryDocId());
gfsFile.put("anhalyticsId", bf.getAnhalyticsId());
gfsFile.put("source", bf.getSource());
gfsFile.put("version", bf.getRepositoryDocVersion());
gfsFile.put("documentType", bf.getDocumentType());
gfsFile.setContentType(bf.getFileType());
gfsFile.save();
} catch (ParseException e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例7: updateTei
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* Updates already existing tei with new (more enriched one, fulltext..).
*/
public void updateTei(String newTei, String repositoryDocId, String collection) {
try {
GridFS gfs = new GridFS(db, collection);
GridFSDBFile gdf = gfs.findOne(repositoryDocId + ".tei.xml");
GridFSInputFile gfsNew = gfs.createFile(new ByteArrayInputStream(newTei.getBytes()), true);
gfsNew.put("uploadDate", gdf.getUploadDate());
gfsNew.setFilename(gdf.get("repositoryDocId") + ".tei.xml");
gfsNew.put("repositoryDocId", gdf.get("repositoryDocId"));
gfsNew.put("documentType", gdf.get("documentType"));
gfsNew.put("anhalyticsId", gdf.get("anhalyticsId"));
gfsNew.put("source", gdf.get("source"));
gfsNew.save();
gfs.remove(gdf);
} catch (Exception e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例8: insertExternalTeiDocument
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* inserts a Arxiv/istex TEI document in the GridFS.
*/
public void insertExternalTeiDocument(InputStream file, String identifier, String repository, String namespace, String dateString) {
try {
GridFS gfs = new GridFS(db, namespace);
GridFSInputFile gfsFile = gfs.createFile(file, true);
gfs.remove(identifier + ".pdf");
gfsFile.put("uploadDate", Utilities.parseStringDate(dateString));
gfsFile.setFilename(identifier + ".tei.xml");
gfsFile.put("identifier", identifier);
gfsFile.put("repository", repository);
gfsFile.setContentType("application/tei+xml");
gfsFile.save();
} catch (ParseException e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例9: write
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
@Override
public void write(String dest, ImageFile img, Handler<String> handler) {
String [] path = parsePath(dest);
if (path == null || path.length < 1) {
handler.handle(null);
return;
}
String id;
if (path.length == 2 && path[1] != null && !path[1].trim().isEmpty()) {
id = path[1];
} else {
id = UUID.randomUUID().toString();
}
GridFS fs = new GridFS(db, path[0]);
try {
saveFile(img, id, fs);
} catch (DuplicateKeyException e) {
fs.remove(new BasicDBObject("_id", id));
saveFile(img, id, fs);
}
handler.handle(id);
}
示例10: execute
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
@Override
public void execute() throws Exception {
MongoClient mdb = MongoFactory.getInst().getMongo( sName );
if ( mdb == null )
throw new Exception("no server selected");
if ( sDb == null )
throw new Exception("no database selected");
MongoFactory.getInst().setActiveDB(sDb);
DB db = mdb.getDB(sDb);
GridFS gfs = new GridFS( db, sColl.substring(0,sColl.lastIndexOf(".")) );
gfs.remove( new ObjectId(id) );
setMessage("fileRemoved="+id);
}
示例11: testClear
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
protected static void testClear(GridFS gridFS) {
DBCursor cursor = gridFS.getFileList();
while (cursor.hasNext()) {
DBObject dbObject = cursor.next();
String filename = (String)cursor.next().get("filename");
System.out.println(filename);
System.out.println(dbObject.toString());
gridFS.remove(filename);
}
cursor.close();
}
示例12: removeGridFsFile
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
private void removeGridFsFile(Id id) {
DB db = (DB) connections.getConnection("mongodb.dma");
GridFS fs = new GridFS(db);
GridFSDBFile file = fs.findOne(new BasicDBObject("_id", id.num()));
if (file != null) {
fs.remove(new BasicDBObject("_id", id.num()));
}
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:9,代码来源:DefaultMediaAssetService.java
示例13: removeArtifacts
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
@Override
public void removeArtifacts(DBKey dbKey, Set<String> artifactsToRemove) {
GridFS gfs = getGridFS(dbKey);
for (String artifactId : artifactsToRemove) {
LOGGER.debug("Removing artifact {} from {}", artifactId, dbKey);
gfs.remove(new ObjectId(artifactId));
}
}
示例14: insertTei
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
/**
* Inserts generated tei using GridFS.
*/
public void insertTei(TEIFile tei, String date, String collection) {
try {
GridFS gfs = new GridFS(db, collection);
gfs.remove(tei.getFileName());
GridFSInputFile gfsFile = gfs.createFile(new ByteArrayInputStream(tei.getTei().getBytes()), true);
gfsFile.put("uploadDate", Utilities.parseStringDate(date));
gfsFile.setFilename(tei.getFileName());
gfsFile.put("repositoryDocId", tei.getRepositoryDocId());
if (collection.equals(MongoCollectionsInterface.METADATAS_TEIS)) {
String anhalyticsID = generateAnhalyticsId(tei.getRepositoryDocId(), tei.getDoi(), (tei.getPdfdocument() != null) ? tei.getPdfdocument().getUrl() : null);
gfsFile.put("anhalyticsId", anhalyticsID);
if (tei.getPdfdocument() != null) {
tei.getPdfdocument().setAnhalyticsId(anhalyticsID);
}
for (BinaryFile annex : tei.getAnnexes()) {
annex.setAnhalyticsId(anhalyticsID);
}
} else {
gfsFile.put("anhalyticsId", tei.getAnhalyticsId());
}
gfsFile.put("source", tei.getSource());
gfsFile.put("version", tei.getRepositoryDocVersion());
gfsFile.put("documentType", tei.getDocumentType());
gfsFile.setContentType(tei.getFileType());
gfsFile.save();
} catch (ParseException e) {
logger.error(e.getMessage(), e.getCause());
}
}
示例15: execute
import com.mongodb.gridfs.GridFS; //导入方法依赖的package包/类
public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {
// Get the necessary Mongo references
DB db = getDB(_session,argStruct);
GridFS gridfs = getGridFS(_session, argStruct, db);
// Get the file information
String filename = getNamedStringParam(argStruct, "filename", null);
if ( filename != null ){
gridfs.remove(filename);
return cfBooleanData.TRUE;
}
// Get the _id
String _id = getNamedStringParam(argStruct, "_id", null);
if ( _id != null ){
gridfs.remove( new ObjectId(_id) );
return cfBooleanData.TRUE;
}
// Get the Query
cfData mTmp = getNamedParam(argStruct, "query", null);
if ( mTmp != null ){
gridfs.remove(getDBObject(mTmp));
return cfBooleanData.TRUE;
}
throwException(_session, "Please specify file, _id or a query");
return null;
}