public ReportGenResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); getVariants().add(new Variant(MediaType.TEXT_PLAIN)); reportClass = (String)req.getAttributes().get("reportClass"); }
@Override protected Reference determineRootRef(Request request) { try { return new Reference( EngineApplication.this.getEngine() .getJob(TextUtils.urlUnescape( (String)request.getAttributes().get("job"))) .getJobDir().getCanonicalFile().toURI().toString()); } catch (IOException e) { throw new RuntimeException(e); } }}; jobdir.setListingAllowed(true);
public JobRelatedResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); cj = getEngine().getJob((String)req.getAttributes().get("job")); if(cj==null) { throw new ResourceException(404); } }
public JobResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); setModifiable(true); getVariants().add(new Variant(MediaType.TEXT_HTML)); getVariants().add(new Variant(MediaType.APPLICATION_XML)); cj = getEngine().getJob( TextUtils.urlUnescape((String) req.getAttributes().get("job"))); Configuration tmpltCfg = new Configuration(); tmpltCfg.setClassForTemplateLoading(this.getClass(),""); tmpltCfg.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER); setTemplateConfiguration(tmpltCfg); } public void setTemplateConfiguration(Configuration tmpltCfg) {
public BeanBrowseResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); getVariants().add(new Variant(MediaType.TEXT_HTML)); getVariants().add(new Variant(MediaType.APPLICATION_XML)); setModifiable(true); // accept POSTs appCtx = cj.getJobContext(); beanPath = (String)req.getAttributes().get("beanPath"); if (beanPath!=null) { try { beanPath = URLDecoder.decode(beanPath,"UTF-8"); } catch (UnsupportedEncodingException e) { // inconceivable! UTF-8 required all Java impls } } else { beanPath = ""; } Configuration tmpltCfg = new Configuration(); tmpltCfg.setClassForTemplateLoading(this.getClass(),""); tmpltCfg.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER); setTemplateConfiguration(tmpltCfg); } public void setTemplateConfiguration(Configuration tmpltCfg) {
@Override protected String getRepositoryId( Request request ) { return String.valueOf( request.getAttributes().get( REPOSITORY_ID_KEY ) ); }
/** * Pull the repository Id out of the Request. * * @param request * @return */ protected String getRepositoryId( Request request ) { return request.getAttributes().get( REPOSITORY_ID_KEY ).toString(); }
protected String getUserId( Request request ) { return request.getAttributes().get( ACCOUNT_ID_KEY ).toString(); } }
/** * Pull the repository Id out of the Request. */ protected String getRepositoryId(Request request) { return request.getAttributes().get(REPOSITORY_ID_KEY).toString(); }
/** * Returns the object which contains information about the page / resource bring requested. * <p> * This object is created by the rest dispatcher when a request comes in. * </p> */ protected PageInfo getPageInfo() { return (PageInfo) getRequest().getAttributes().get( PageInfo.KEY ); }
/** * DUMMY IMPLEMENTATION, just to satisfy superclass (but why is this class expanding it at all?) */ @Override protected ResourceStore getResourceStore(final Request request) throws NoSuchResourceStoreException, ResourceException { return getUnprotectedRepositoryRegistry().getRepository( request.getAttributes().get(AbstractRepositoryPlexusResource.REPOSITORY_ID_KEY).toString()); } }
@Override protected ResourceStore getResourceStore( final Request request ) throws NoSuchRepositoryException, ResourceException { return getUnprotectedRepositoryRegistry().getRepository( request.getAttributes().get( AbstractRepositoryPlexusResource.REPOSITORY_ID_KEY ).toString() ); }
public ReportGenResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); getVariants().add(new Variant(MediaType.TEXT_PLAIN)); reportClass = (String)req.getAttributes().get("reportClass"); }
@Override protected Repository getResourceStore(final Request request) throws NoSuchResourceStoreException, ResourceException { final String repoId = request.getAttributes().get(REPOSITORY_ID_KEY).toString(); return getUnprotectedRepositoryRegistry().getRepository(repoId); } }
@Override protected ResourceStore getResourceStore( final Request request ) throws NoSuchRepositoryException, ResourceException { return getRepositoryRegistry().getRepositoryWithFacet( request.getAttributes().get( GROUP_ID_KEY ).toString(), GroupRepository.class ); }
@Override protected ResourceStore getResourceStore(final Request request) throws NoSuchRepositoryException, ResourceException { return getRepositoryRegistry().getRepositoryWithFacet(request.getAttributes().get(GROUP_ID_KEY).toString(), GroupRepository.class); }
@Override protected ResourceStore getResourceStore(final Request request) throws NoSuchRepositoryException, ResourceException { return getUnprotectedRepositoryRegistry().getRepository( request.getAttributes().get(AbstractRepositoryPlexusResource.REPOSITORY_ID_KEY).toString()); }
public JobRelatedResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); cj = getEngine().getJob((String)req.getAttributes().get("job")); if(cj==null) { throw new ResourceException(404); } }
public static String findIP( Request request ) { Form form = (Form) request.getAttributes().get( "org.restlet.http.headers" ); String forwardedIP = getFirstForwardedIp( form.getFirstValue( FORWARD_HEADER ) ); if ( forwardedIP != null ) { return forwardedIP; } List<String> ipAddresses = request.getClientInfo().getAddresses(); return resolveIp( ipAddresses ); }
@Test public void testGetById() throws Exception { Request req = new Request(); req.getAttributes().put("request", 2); Response res = new Response(req); resource.init(null, req, res); RequestData data = (RequestData) resource.handleObjectGet(); assertEquals("/two", data.getPath()); }