Search in sources :

Example 1 with MCRPIListJSON

use of org.mycore.pi.frontend.model.MCRPIListJSON in project mycore by MyCoRe-Org.

the class MCRPersistentIdentifierRegistrationResource method listByType.

@GET
@Path("type/{type}")
@Produces(MediaType.APPLICATION_JSON)
public Response listByType(@PathParam("type") String type, @DefaultValue("0") @QueryParam("from") int from, @DefaultValue("50") @QueryParam("size") int size) {
    Response errorResponse = validateParameters(from, size);
    if (errorResponse != null)
        return errorResponse;
    List<MCRPIRegistrationInfo> mcrpiRegistrationInfos = MCRPersistentIdentifierManager.getInstance().getList(type, from, size);
    return Response.status(Response.Status.OK).entity(new Gson().toJson(new MCRPIListJSON(type, from, size, MCRPersistentIdentifierManager.getInstance().getCount(type), mcrpiRegistrationInfos))).build();
}
Also used : Response(javax.ws.rs.core.Response) MCRPIRegistrationInfo(org.mycore.pi.MCRPIRegistrationInfo) MCRPIListJSON(org.mycore.pi.frontend.model.MCRPIListJSON) Gson(com.google.gson.Gson) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with MCRPIListJSON

use of org.mycore.pi.frontend.model.MCRPIListJSON in project mycore by MyCoRe-Org.

the class MCRPersistentIdentifierRegistrationResource method list.

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response list(@DefaultValue("0") @QueryParam("from") int from, @DefaultValue("50") @QueryParam("size") int size) {
    Response errorResponse = validateParameters(from, size);
    if (errorResponse != null)
        return errorResponse;
    List<MCRPIRegistrationInfo> mcrpiRegistrationInfos = MCRPersistentIdentifierManager.getInstance().getList(from, size);
    return Response.status(Response.Status.OK).entity(new Gson().toJson(new MCRPIListJSON(null, from, size, MCRPersistentIdentifierManager.getInstance().getCount(), mcrpiRegistrationInfos))).build();
}
Also used : Response(javax.ws.rs.core.Response) MCRPIRegistrationInfo(org.mycore.pi.MCRPIRegistrationInfo) MCRPIListJSON(org.mycore.pi.frontend.model.MCRPIListJSON) Gson(com.google.gson.Gson) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Gson (com.google.gson.Gson)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Response (javax.ws.rs.core.Response)2 MCRPIRegistrationInfo (org.mycore.pi.MCRPIRegistrationInfo)2 MCRPIListJSON (org.mycore.pi.frontend.model.MCRPIListJSON)2 Path (javax.ws.rs.Path)1