类com.mongodb.MongoGridFSException源码实例Demo

下面列出了怎么用com.mongodb.MongoGridFSException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: camel-quarkus   文件: MongodbGridfsResource.java
@Path("/get/{fileName}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response retrieveFile(@PathParam("fileName") String fileName) {
    String result = null;
    try {
        result = producerTemplate.requestBodyAndHeader("mongodb-gridfs:camelMongoClient?database=test&operation=findOne",
                null,
                Exchange.FILE_NAME, fileName, String.class);
    } catch (Exception e) {
        if (e.getCause() instanceof MongoGridFSException) {
            return Response.status(404).build();
        }
    }
    return Response.ok().entity(result).build();
}
 
源代码2 项目: hawkbit-extensions   文件: MongoDBArtifactStore.java
@SuppressWarnings("squid:S2589")
// False positive: file.getMetadata() can return null
private static final String getContentType(final GridFSFile file) {
    final Document metadata = file.getMetadata();
    String contentType = null;
    if (metadata != null) {
        contentType = metadata.getString(CONTENT_TYPE);
    }
    if (contentType == null) {
        try {
            contentType = file.getContentType();
        } catch (final MongoGridFSException e) {
            throw new ArtifactStoreException("Could not determine content type for file " + file.getId(), e);
        }
    }
    return contentType;
}
 
 类所在包
 同包方法