
Document Store API是一个基于Dropwizard的应用程序,用于对MongoDB进行读写操作。该应用提供两种内容读取端点:/content-read/{uuid}用于按API设计契约返回格式化内容,确保响应格式符合规范;/content/{uuid}用于直接读取MongoDB中的原始文档,无格式限制。此外,应用还支持独立的列表(list)操作,其读写逻辑与内容操作分离。
%m%n以适配监控工具适用于需要高效文档存储与检索的后端服务,如内容管理系统、新闻资讯平台等场景,支持结构化文档和列表数据的管理需求。
编译构建JAR包
sh# 跳过测试编译 mvn clean package -Djava.net.preferIPv4Stack=true -Dmaven.test.skip=true # 仅运行非集成测试 mvn clean package -Djava.net.preferIPv4Stack=true -Dshort # 运行所有测试(需本地MongoDB) docker-compose up mongodb -d MONGO_TEST_URL=localhost:27017 -Djava.net.preferIPv4Stack=true mvn clean package
启动应用
shjava -jar target/document-store-api-0.0.1-SNAPSHOT.jar server config-local.yml
Docker镜像构建
需传递Nexus服务器认证参数:
shdocker build -t coco/document-store-api --build-arg SONATYPE_USER=upp-nexus --build-arg SONATYPE_PASSWORD=AvailableInLastPass .
注意:自2016-10-18起,不再部署至UCS环境。
内容操作(Content)
创建/更新内容(PUT)
http://localhost:14180/content/{uuid}Content-Type: application/jsonjson{ "uuid": "3b7b7702-debf-11e4-b9ec-00144feab7de", "title": "Ukraine looks to foreign-born ministers to kick-start reform", "titles": null, "byline": "Roman Olearchyk, Kiev, and Neil Buckley, London", "brands": [ { "id": "http://api.ft.com/things/dbb0bdae-1f0c-11e4-b0cb-b2227cce2b54" } ], "identifiers": [ { "authority": "http://api.ft.com/system/FTCOM-METHODE", "identifierValue": "3b7b7702-debf-11e4-b9ec-00144feab7de" } ], "publishedDate": "2015-04-15T08:33:02.000Z", "body": "<body><content data-embedded=\"true\" id=\"937885ac-e2bc-11e4-347b-978e959e1c97\" type=\"http://www.ft.com/ontology/content/ImageSet\"></content><p>Late last year, US-born Natalie Jaresko was in the Kiev office of the investment firm she founded in 2006 when headhunters came to call. Within days she was named as finance minister of war-torn country.</p></body>", "description": null, "mediaType": null, "pixelWidth": null, "pixelHeight": null, "internalBinaryUrl": null, "members": null, "mainImage": "937885ac-e2bc-11e4-347b-978e959e1c97" }
删除内容(DELETE)
http://localhost:14180/content/{uuid}Content-Type: application/json获取内容(GET)
GET http://localhost:14180/content/{uuid},返回与PUT请求体格式一致的JSONPOST /{collection}?mget=true,请求体为UUID数组,返回找到的内容数组(未找到则返回空数组)
json[ "fd204ed1-d53d-4b24-99a7-fc62a6778808", "4f97b689-d3e4-4ae2-ac34-9abc97a46c28", "c86ccb61-38d2-42bd-bb2f-9c69e1fca178" ]
GET http://localhost:14180/content?uuid={uuid1}&uuid={uuid2}...,受URI长度限制(2083字符)按标识符查询内容
GET http://localhost:14180/content-query?identifierAuthority={authority}&identifierValue={identifierValue}GET /content-query?identifierAuthority=http://api.ft.com/system/FT-LABS-WP-1-335&identifierValue=http://www.ft.com/fastft/2015/12/09/south-african-rand-dives-after-finance-ministers-exit/ HTTP/1.1列表操作(List)
创建/更新列表(PUT)
http://localhost:14180/lists/{uuid}Content-Type: application/jsonjson{ "uuid": "3c99c2ba-a6ae-11e2-95b1-00144feabdc0", "title": "Test List", "concept": { "uuid": "78d878ac-6226-47e4-84b1-39a127e3cc11", "prefLabel": "Markets" }, "listType": "TopStories", "items" : [ { "uuid": "0237b884-d124-11e2-be7b-00144feab7de" }, { "uuid": "68340f9f-67c3-33cd-97b1-f07bea7ce714" }, { "webUrl": "http://video.ft.com/3887333300001/Thames-tour-shows-changing-London-skyline/life-and-arts" } ] }
concept和listType为可选字段;若提供concept,则uuid和prefLabel为必填;数据存储中不允许存在相同concept和listType的多个列表,重复时将触发Splunk告警。获取列表(GET)
GET http://localhost:14180/lists/{uuid}GET http://localhost:14180/lists?curatedTopStoriesFor={concept-uuid}(支持多种列表类型,如curatedOpinionAndAnalysisFor),返回单条结果(多条匹配时返回一条并记录错误日志)删除列表(DELETE)
http://localhost:14180/lists/{uuid}Content-Type: application/json如需添加新资源类型,需在DocumentStoreApiApplication中为所需操作添加新的链处理器,处理器(Handler)和目标(Targets)可在多链中复用。
使用slf4j-json-logger库,日志格式固定为%m%n(详见https://github.com/savoirtech/slf4j-json-logger#logging-configuration%EF%BC%89%EF%BC%8C%E4%BB%A5%E9%80%82%E9%85%8DSplunk%E7%AD%89%E7%9B%91%E6%8E%A7%E5%B7%A5%E5%85%B7%E7%9A%84%E4%BA%8B%E4%BB%B6%E6%9F%A5%E8%AF%A2%E3%80%82


探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务