Skip to content

Commit

Permalink
#8600 update find templates api
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed May 17, 2022
1 parent caacaab commit 642720c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/main/java/edu/harvard/iq/dataverse/api/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,33 @@ public Response deleteTemplate(@PathParam("id") long id) {
return ok("Template " + doomed.getName() + " deleted.");
}

@Path("template/{alias}")
@Path("orphanTemplates")
@GET
public Response findOrphanTemplates() {

return findTemplates("9999");
}

@Path("templates")
@GET
public Response findAllTemplates() {
return findTemplates("");
}

@Path("templates/{alias}")
@GET
public Response findTemplates(@PathParam("alias") String alias) {
List<Template> templates;
List<Template> templates;
try {
if (alias.equals("orphanTemplates")) {
if (alias.equals("9999")) {
templates = templateService.findOrphan();
} else if (alias.equals("allTemplates")) {
} else if (alias.isEmpty()) {
templates = templateService.findAll();
} else {
Dataverse owner = dataverseService.findByAlias(alias);
if (owner == null) {
return notFound("Dataverse " + alias + " not found");
}
Dataverse owner = findDataverseOrDie(alias);
templates = templateService.findByOwnerId(owner.getId());
}


JsonArrayBuilder container = Json.createArrayBuilder();
for (Template t : templates) {
JsonObjectBuilder bld = Json.createObjectBuilder();
Expand Down

0 comments on commit 642720c

Please sign in to comment.