Skip to content

Commit

Permalink
added endpoint to list all active cases. close #2762.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Jan 4, 2025
1 parent 97014b1 commit 8604f15
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ You should also get your employer (if you work as a programmer) or school,
public interface CasesEndpointLocalV1 {

Response listCases();
Response listActiveCases();

Response getCase(String id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,54 @@ public Response listCases() {
}

}

/**
* Lists all active (non-archived) cases
*
* @response 401 User not authorized
* @response 403 User not authenticated
*/
@Override
@GET
@Produces(MediaType.APPLICATION_JSON+";charset=utf-8")
@Path("/list/active")
@RolesAllowed({"readArchiveFileRole"})
public Response listActiveCases() {
// http://localhost:8080/j-lawyer-io/rest/cases/list
try {

InitialContext ic = new InitialContext();
ArchiveFileServiceLocal cases = (ArchiveFileServiceLocal) ic.lookup("java:global/j-lawyer-server/j-lawyer-server-ejb/ArchiveFileService!com.jdimension.jlawyer.services.ArchiveFileServiceLocal");
ArrayList<String> ids = cases.getAllArchiveFileIds();
ArrayList<RestfulCaseOverviewV1> rcoList = new ArrayList<>();
for (String id : ids) {
ArchiveFileBean afb=null;
try {
afb = cases.getArchiveFile(id);
} catch (Throwable t) {
log.error("Case not accessible: " + id, t);
continue;
}

if(afb.isArchived())
continue;

RestfulCaseOverviewV1 rco = new RestfulCaseOverviewV1();
rco.setId(id);
rco.setExternalId(afb.getExternalId());
rco.setName(afb.getName());
rco.setReason(afb.getReason());
rco.setFileNumber(afb.getFileNumber());
rco.setDateChanged(afb.getDateChanged());
rcoList.add(rco);
}
return Response.ok(rcoList).build();
} catch (Exception ex) {
log.error("Can not list cases", ex);
return Response.serverError().build();
}

}

/**
* Returns all case metadata based on its ID
Expand Down

0 comments on commit 8604f15

Please sign in to comment.