Skip to content

Commit

Permalink
ci: try fix db doc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bamthomas committed Jan 6, 2025
1 parent 72cdba0 commit eb3a4a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ jobs:
command: |
echo "postgres:5432:$PGDB:$PGUSER:$PGPASSWORD" > ~/.pgpass && chmod 600 ~/.pgpass
createdb -U $PGUSER -h postgres $PGDB
mvn -pl commons-test -am install
mvn -pl datashare-db liquibase:update
mvn -pl datashare-db liquibase:update -Dmaven.test.skip=true
./datashare-db/scr/build_db_doc.sh > ~/datashare-docs/developers/backend/database.md
- run:
name: Add/Commit changes to the doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import net.codestory.http.annotations.Get;
import net.codestory.http.annotations.Prefix;
import org.icij.datashare.Entity;
import org.icij.datashare.ftm.FtmDocument;
import org.icij.datashare.text.Document;
import org.icij.datashare.text.indexing.Indexer;

import java.util.Objects;

import static java.util.Optional.ofNullable;
import static net.codestory.http.errors.NotFoundException.notFoundIfNull;

@Singleton
@Prefix("/api/ftm")
public class FtmResource {
Expand All @@ -23,11 +30,12 @@ public FtmResource(Indexer indexer) {
this.indexer = indexer;
}

@Operation(description = "Get the FtM document from its project and id (content hash)")
@Operation(description = "Get the [FtM](https://followthemoney.tech/) document from its project and id (content hash)")
@ApiResponse(responseCode = "200", description = "returns the JSON document", useReturnTypeSchema = true)
@ApiResponse(responseCode = "404", description = "if no document is found with provided id")
@Get("/:project/:docId")
public FtmDocument getDocument(@Parameter(name = "project", description = "project identifier", in = ParameterIn.PATH) String project,
@Parameter(name = "docId", description = "document identifier", in = ParameterIn.PATH) String docId) throws Exception {
return new FtmDocument(indexer.get(project, docId));
return notFoundIfNull(ofNullable(indexer.get(project, docId)).map(d -> new FtmDocument((Document) d)).orElse(null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public void test_doc_id() {
.not().contain("null");
}

@Test
public void test_doc_id_not_found() {
get("/api/ftm/prj/unknown_doc_id").should().respond(404);
}

@Before
public void setUp() {
initMocks(this);
Expand Down

0 comments on commit eb3a4a0

Please sign in to comment.