Search in sources :

Example 1 with MCRIIIFPresentationManifestQuickAccess

use of org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess in project mycore by MyCoRe-Org.

the class MCRIIIFPresentationResource method getManifestQuickAccess.

protected MCRIIIFPresentationManifestQuickAccess getManifestQuickAccess(String impl, String identifier) {
    MCRIIIFPresentationManifestQuickAccess quickAccess;
    if ((quickAccess = cache.getIfUpToDate(impl + identifier, TimeUnit.HOURS.toMillis(1))) == null) {
        long startTime = new Date().getTime();
        MCRIIIFManifest manifest = MCRIIIFPresentationImpl.getInstance(impl).getManifest(identifier);
        long endTime = new Date().getTime();
        long timeNeeded = endTime - startTime;
        LOGGER.info("Manifest {}:{} generation needed: {}ms", impl, identifier, timeNeeded);
        quickAccess = new MCRIIIFPresentationManifestQuickAccess(manifest);
        cache.put(impl + identifier, quickAccess);
        correctIDs(manifest, impl, identifier);
    } else {
        LOGGER.info("Manifest {}:{} served from cache", impl, identifier);
    }
    return quickAccess;
}
Also used : MCRIIIFManifest(org.mycore.iiif.presentation.model.basic.MCRIIIFManifest) MCRIIIFPresentationManifestQuickAccess(org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess) Date(java.util.Date)

Example 2 with MCRIIIFPresentationManifestQuickAccess

use of org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess in project mycore by MyCoRe-Org.

the class MCRIIIFPresentationResource method getManifest.

@GET
@Produces(MCRIIIFMediaType.APPLICATION_LD_JSON)
@Path("{" + IDENTIFIER_PARAM + "}/manifest")
public Response getManifest(@PathParam(IMPL_PARAM) String impl, @PathParam(IDENTIFIER_PARAM) String identifier) throws CloneNotSupportedException {
    MCRIIIFPresentationManifestQuickAccess quickAccess = getManifestQuickAccess(impl, identifier);
    String manifestAsJSON = getGson().toJson(quickAccess.getManifest());
    return addHeaders(Response.ok()).entity(manifestAsJSON).build();
}
Also used : MCRIIIFPresentationManifestQuickAccess(org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with MCRIIIFPresentationManifestQuickAccess

use of org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess in project mycore by MyCoRe-Org.

the class MCRIIIFPresentationResource method getAnnotation.

@GET
@Produces(MCRIIIFMediaType.APPLICATION_LD_JSON)
@Path("{" + IDENTIFIER_PARAM + "}/annotation/{" + NAME_PARAM + "}")
public Response getAnnotation(@PathParam(IMPL_PARAM) String impl, @PathParam(IDENTIFIER_PARAM) String identifier, @PathParam(NAME_PARAM) String name) {
    MCRIIIFPresentationManifestQuickAccess quickAccess = getManifestQuickAccess(impl, identifier);
    String annotationAsJSON = getGson().toJson(quickAccess.getAnnotationBase(name));
    return addHeaders(Response.ok()).entity(annotationAsJSON).build();
}
Also used : MCRIIIFPresentationManifestQuickAccess(org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with MCRIIIFPresentationManifestQuickAccess

use of org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess in project mycore by MyCoRe-Org.

the class MCRIIIFPresentationResource method getSequence.

@GET
@Produces(MCRIIIFMediaType.APPLICATION_LD_JSON)
@Path("{" + IDENTIFIER_PARAM + "}/sequence/{" + NAME_PARAM + "}")
public Response getSequence(@PathParam(IMPL_PARAM) String impl, @PathParam(IDENTIFIER_PARAM) String identifier, @PathParam(NAME_PARAM) String name) {
    MCRIIIFPresentationManifestQuickAccess quickAccess = getManifestQuickAccess(impl, identifier);
    String sequenceAsJSON = getGson().toJson(quickAccess.getSequence(name));
    return addHeaders(Response.ok()).entity(sequenceAsJSON).build();
}
Also used : MCRIIIFPresentationManifestQuickAccess(org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with MCRIIIFPresentationManifestQuickAccess

use of org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess in project mycore by MyCoRe-Org.

the class MCRIIIFPresentationResource method getCanvas.

@GET
@Produces(MCRIIIFMediaType.APPLICATION_LD_JSON)
@Path("{" + IDENTIFIER_PARAM + "}/canvas/{" + NAME_PARAM + "}")
public Response getCanvas(@PathParam(IMPL_PARAM) String impl, @PathParam(IDENTIFIER_PARAM) String identifier, @PathParam(NAME_PARAM) String name) {
    MCRIIIFPresentationManifestQuickAccess quickAccess = getManifestQuickAccess(impl, identifier);
    String canvasAsJSON = getGson().toJson(quickAccess.getCanvas(name));
    return addHeaders(Response.ok()).entity(canvasAsJSON).build();
}
Also used : MCRIIIFPresentationManifestQuickAccess(org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

MCRIIIFPresentationManifestQuickAccess (org.mycore.iiif.presentation.MCRIIIFPresentationManifestQuickAccess)6 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 Date (java.util.Date)1 MCRIIIFManifest (org.mycore.iiif.presentation.model.basic.MCRIIIFManifest)1