当前位置: 首页>>代码示例>>Java>>正文


Java GridFS.remove方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:24,代码来源:MongoFileManager.java

示例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;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:24,代码来源:GridFSBlobHandler.java

示例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;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:17,代码来源:GridFSBlobHandler.java

示例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());
    }
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:21,代码来源:MongoFileManager.java

示例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());
    }
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:21,代码来源:MongoFileManager.java

示例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());
    }

}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:23,代码来源:MongoFileManager.java

示例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());
    }
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:22,代码来源:MongoFileManager.java

示例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());
    }

}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:20,代码来源:MongoFileManager.java

示例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);
}
 
开发者ID:web-education,项目名称:mod-image-resizer,代码行数:23,代码来源:GridFsFileAccess.java

示例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);
}
 
开发者ID:aw20,项目名称:MongoWorkBench,代码行数:19,代码来源:GridFSRemoveFileCommand.java

示例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();
}
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:12,代码来源:GridFSClient.java

示例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));
  }
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:9,代码来源:ArtifactsDAOMongoDBImpl.java

示例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());
    }
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:33,代码来源:MongoFileManager.java

示例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;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:34,代码来源:Delete.java


注:本文中的com.mongodb.gridfs.GridFS.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。