/** * Constructor. * * @param method * The method to call. * @param uri * The target URI. */ public ClientResource(Method method, String uri) { this(Context.getCurrent(), method, uri); }
/** * Returns the context. * * @return The context. */ public Context getContext() { return (this.context != null) ? this.context : Context.getCurrent(); }
/** * Constructor. * * @param method * The method to call. * @param uri * The target URI. */ public ClientResource(Method method, java.net.URI uri) { this(Context.getCurrent(), method, uri); }
/** * Constructor. * * @param method * The method to call. * @param reference * The target reference. */ public ClientResource(Method method, Reference reference) { this(Context.getCurrent(), method, reference); }
/** * Constructor. * * @param uri * The target URI. */ public ClientResource(java.net.URI uri) { this(Context.getCurrent(), null, uri); }
/** * Constructor. * * @param reference * The target reference. */ public ClientResource(Reference reference) { this(Context.getCurrent(), null, reference); }
/** * Constructor. * * @param request * The handled request. * @param response * The handled response. */ public ClientResource(Request request, Response response) { this(Context.getCurrent(), request, response); }
/** * Constructor. * * @param uri * The target URI. */ public ClientResource(String uri) { this(Context.getCurrent(), Method.GET, uri); }
/** * * @param appConfig * @throws IllegalArgumentException */ public JaxRsApplication(javax.ws.rs.core.Application appConfig) throws IllegalArgumentException { this(Context.getCurrent(), appConfig); }
/** * Returns the current context's logger. * * @return The current context's logger. */ public static Logger getCurrentLogger() { return (Context.getCurrent() != null) ? Context.getCurrent() .getLogger() : null; }
/** * Returns the current context's logger. * * @return The current context's logger. */ public static Logger getCurrentLogger() { return (Context.getCurrent() != null) ? Context.getCurrent() .getLogger() : Logger.getLogger(Context.class .getCanonicalName()); }
/** * Returns the current context's logger. * * @return The current context's logger. */ public static Logger getCurrentLogger() { return (Context.getCurrent() != null) ? Context.getCurrent() .getLogger() : Engine.getLogger("org.restlet"); }
/** * Returns the context's logger. * * @return The context's logger. */ public Logger getLogger() { Logger result = null; Context context = getContext(); if (context == null) { context = Context.getCurrent(); } if (context != null) { result = context.getLogger(); } if (result == null) { result = Logger.getLogger(getClass().getCanonicalName()); } if (result == null) { result = Logger.getLogger("org.restlet.Restlet"); } return result; }
/** * Writes the datum as a stream of characters. * * @param writer * The writer to use when writing. */ @Override public void write(Writer writer) throws IOException { try { // Load the template // Process the template getTemplate().merge(getContext(), writer); } catch (Exception e) { final Context context = Context.getCurrent(); if (context != null) { context.getLogger().log(Level.WARNING, "Unable to process the template", e); } e.printStackTrace(); throw new IOException("Template processing error. " + e.getMessage()); } }
/** * Returns the Velocity template. * * @return The Velocity template. */ public Template getTemplate() { if (this.template == null) { if (this.templateName != null) { try { getEngine().init(); this.template = getEngine().getTemplate(this.templateName); } catch (Exception e) { final Context context = Context.getCurrent(); if (context != null) { context.getLogger().log(Level.WARNING, "Unable to get template", e); } } } } return this.template; }
/** * Returns the Velocity template. * * @return The Velocity template. */ public Template getTemplate() { if (this.template == null) { if (this.templateName != null) { try { getEngine().init(); this.template = getEngine().getTemplate(this.templateName); } catch (Exception e) { final Context context = Context.getCurrent(); if (context != null) { context.getLogger().log(Level.WARNING, "Unable to get template", e); } } } } return this.template; }
/** * Constructor. * * @param context * The current context. * @param request * The handled request. * @param response * The handled response. */ public ClientResource(Context context, Request request, Response response) { if (context == null) { context = Context.getCurrent(); } // Don't remove this line. // See other constructor ClientResource(Context, Method, Reference) response.setRequest(request); this.maxRedirects = 10; this.retryOnError = true; this.retryDelay = 2000L; this.retryAttempts = 2; this.followingRedirects = true; this.requestEntityBuffering = false; this.responseEntityBuffering = false; init(context, request, response); }
public Representation getRepresentation(final Status status, final Request request, final Response response) { final HashMap<String, Object> dataModel = new HashMap<String, Object>(); final SystemStatus systemStatus = applicationStatusSource.getSystemStatus(); dataModel.put("request", request); dataModel.put("nexusVersion", systemStatus.getVersion()); dataModel.put("nexusRoot", BaseUrlHolder.get()); dataModel.put("statusCode", status.getCode()); dataModel.put("statusName", status.getName()); dataModel.put("errorDescription", StringEscapeUtils.escapeHtml(status.getDescription())); if (null != status.getThrowable()) { dataModel.put("errorStackTrace", StringEscapeUtils.escapeHtml(ExceptionUtils.getStackTrace(status.getThrowable()))); } final VelocityRepresentation representation = new VelocityRepresentation(Context.getCurrent(), "/templates/errorPageContentHtml.vm", getClass().getClassLoader(), dataModel, MediaType.TEXT_HTML); return representation; } }
public Representation getRepresentation( final Status status, final Request request, final Response response ) { final HashMap<String, Object> dataModel = new HashMap<String, Object>(); dataModel.put( "request", request ); dataModel.put( "nexusVersion", nexus.getSystemStatus().getVersion() ); dataModel.put( "nexusRoot", referenceFactory.getContextRoot( request ).toString() ); dataModel.put( "statusCode", status.getCode() ); dataModel.put( "statusName", status.getName() ); dataModel.put( "errorDescription", StringEscapeUtils.escapeHtml( status.getDescription() ) ); if ( null != status.getThrowable() ) { dataModel.put( "errorStackTrace", StringEscapeUtils.escapeHtml( ExceptionUtils.getStackTrace( status.getThrowable() ) ) ); } // Load up the template, and pass in the data VelocityRepresentation representation = new VelocityRepresentation( Context.getCurrent(), "/templates/errorPageContentHtml.vm", dataModel, MediaType.TEXT_HTML ); return representation; } }
/** * Returns the context's logger. * * @return The context's logger. */ public Logger getLogger() { Logger result = null; Context context = getContext(); if (context == null) { context = Context.getCurrent(); } if (context != null) { result = context.getLogger(); } if (result == null) { result = Engine.getLogger(this, "org.restlet"); } return result; }