Search in sources :

Example 1 with IFrameResource

use of annis.libgui.visualizers.IFrameResource in project ANNIS by korpling.

the class ResourceRequestHandler method handleRequest.

@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException {
    if (request.getPathInfo() != null && request.getPathInfo().startsWith(prefix)) {
        String uuidString = StringUtils.removeStart(request.getPathInfo(), prefix);
        UUID uuid = UUID.fromString(uuidString);
        IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class);
        if (map == null) {
            response.setStatus(404);
        } else {
            IFrameResource res = map.get(uuid);
            if (res != null) {
                response.setStatus(200);
                response.setContentType(res.getMimeType());
                response.getOutputStream().write(res.getData());
            }
        }
        return true;
    }
    return false;
}
Also used : IFrameResource(annis.libgui.visualizers.IFrameResource) IFrameResourceMap(annis.libgui.visualizers.IFrameResourceMap) UUID(java.util.UUID)

Aggregations

IFrameResource (annis.libgui.visualizers.IFrameResource)1 IFrameResourceMap (annis.libgui.visualizers.IFrameResourceMap)1 UUID (java.util.UUID)1