public void handleAccess(EntityView view, HttpServletRequest req, HttpServletResponse res) { String format = view.getFormat(); if (format.equals(Formats.HTML) || format.equals(Formats.RSS)) { // Okey dokey, do nothing but say all is well try { res.getWriter().print(prefix + ": EntityViewAccessProviderMock"); } catch (IOException e) { log.error(e.getMessage(), e); } ((EntityHttpServletResponse) res).setStatus(HttpServletResponse.SC_OK); } else { throw new FormatUnsupportedException("No support for format: " + format, view.getEntityReference()+"", format); } }
public void handleAccess(EntityView view, HttpServletRequest req, HttpServletResponse res) { String format = view.getFormat(); if (format.equals(Formats.HTML) || format.equals(Formats.RSS)) { // Okey dokey, do nothing but say all is well try { res.getWriter().print(prefix + ": EntityViewAccessProviderMock"); } catch (IOException e) { log.error(e.getMessage(), e); } ((EntityHttpServletResponse) res).setStatus(HttpServletResponse.SC_OK); } else { throw new FormatUnsupportedException("No support for format: " + format, view.getEntityReference()+"", format); } }
res.setHeader("x-entity-reference", view.getEntityReference().toString()); res.setHeader("x-entity-url", view.getEntityURL()); res.setHeader("x-entity-format", view.getFormat());
res.setHeader("x-entity-reference", view.getEntityReference().toString()); res.setHeader("x-entity-url", view.getEntityURL()); res.setHeader("x-entity-format", view.getFormat());
String format = view.getFormat();
String format = view.getFormat();
req.setAttribute("entity-format", view.getFormat()); } catch (EntityEncodingException e) { throw new EntityException("EntityEncodingException: Unable to handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + "): " + e.getMessage(), view.getEntityReference()+"", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (IllegalArgumentException e) { throw new EntityException("IllegalArgumentException: Unable to handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + "): " + e.getMessage(), view.getEntityReference()+"", HttpServletResponse.SC_BAD_REQUEST); } catch (IllegalStateException e) { throw new EntityException("IllegalStateException: Unable to handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + "): " + e.getMessage(), view.getEntityReference()+"", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); if (formatInvalidFailure) { throw new FormatUnsupportedException("Nothing (AP and internal) available to handle the requested format", view.getEntityReference()+"", view.getFormat()); throw new EntityException( "AccessProvider: Method/Format unsupported: Will not handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + ")", view.getEntityReference()+"", HttpServletResponse.SC_NOT_ACCEPTABLE );
req.setAttribute("entity-format", view.getFormat()); } catch (EntityEncodingException e) { throw new EntityException("EntityEncodingException: Unable to handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + "): " + e.getMessage(), view.getEntityReference()+"", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (IllegalArgumentException e) { throw new EntityException("IllegalArgumentException: Unable to handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + "): " + e.getMessage(), view.getEntityReference()+"", HttpServletResponse.SC_BAD_REQUEST); } catch (IllegalStateException e) { throw new EntityException("IllegalStateException: Unable to handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + "): " + e.getMessage(), view.getEntityReference()+"", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); if (formatInvalidFailure) { throw new FormatUnsupportedException("Nothing (AP and internal) available to handle the requested format", view.getEntityReference()+"", view.getFormat()); throw new EntityException( "AccessProvider: Method/Format unsupported: Will not handle " + (output ? "output" : "input") + " request for format "+view.getFormat()+" for this path (" + path + ") for prefix (" + prefix + ") for entity (" + view.getEntityReference() + "), request url (" + view.getOriginalEntityUrl() + ")", view.getEntityReference()+"", HttpServletResponse.SC_NOT_ACCEPTABLE );