org.restlet.data.Request.getResourceRef()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.restlet.data.Request.getResourceRef方法的一些代码示例,展示了Request.getResourceRef的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getResourceRef方法的具体详情如下:
包路径:org.restlet.data.Request
类名称:Request
方法名:getResourceRef

Request.getResourceRef介绍

[英]Returns the reference of the target resource. This reference is especially important during routing, dispatching and resource finding. During such processing, its base reference is constantly updated to reflect the reference of the parent Restlet or resource and the remaining part of the URI that must be routed or analyzed. If you need to get the URI reference originally requested by the client, then you should use the #getOriginalRef() method instead. Also, note that beside the update of its base property, the resource reference can be modified during the request processing. For example, the TunnelService associated to an application can extract some special extensions or query parameters and replace them by semantically equivalent properties on the request object. Therefore, the resource reference can become different from the original reference. Finally, when sending out requests via a dispatcher such as Context#getClientDispatcher() or Context#getServerDispatcher(), if the reference contains URI template variables, those variables are automatically resolved using the request's attributes.
[中]返回目标资源的引用。在路由、调度和资源查找期间,此参考尤其重要。在这种处理过程中,它的基本引用会不断更新,以反映父Restlet或资源的引用,以及必须路由或分析的URI的其余部分。如果需要获取客户端最初请求的URI引用,那么应该使用#getOriginalRef()方法。另外,请注意,除了更新其基本属性之外,还可以在请求处理期间修改资源引用。例如,与应用程序关联的TunnelService可以提取一些特殊的扩展或查询参数,并用请求对象上语义等价的属性替换它们。因此,资源引用可能会与原始引用不同。最后,当通过调度程序(如Context#getClientDispatcher()或Context#getServerDispatcher())发送请求时,如果引用包含URI模板变量,则会使用请求的属性自动解析这些变量。

代码示例

代码示例来源:origin: internetarchive/heritrix3

public String getBeansRefPath() {
  Reference ref = getRequest().getResourceRef();
  String path = ref.getPath(); 
  int i = path.indexOf("/beans/");
  if(i>0) {
    return path.substring(0,i+"/beans/".length());
  }
  if(!path.endsWith("/")) {
    path += "/";
  }
  return path; 
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * Constructs a nested Map data structure with the information represented
 * by this Resource. The result is particularly suitable for use with with
 * {@link XmlMarshaller}.
 * 
 * @return the nested Map data structure
 */
protected CrawlJobModel makeDataModel() {
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if (!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  return new CrawlJobModel(cj,baseRef);
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * Constructs a nested Map data structure with the information represented
 * by this Resource. The result is particularly suitable for use with with
 * {@link XmlMarshaller}.
 * 
 * @return the nested Map data structure
 */
protected EngineModel makeDataModel() {
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  
  return new EngineModel(getEngine(), baseRef);
}

代码示例来源:origin: internetarchive/heritrix3

Reference baseRef = getRequest().getResourceRef().getBaseRef();

代码示例来源:origin: internetarchive/heritrix3

Reference baseRef = getRequest().getResourceRef().getBaseRef();

代码示例来源:origin: internetarchive/heritrix3

protected void writeHtml(Writer writer) {
    String baseRef = getRequest().getResourceRef().getBaseRef().toString();
    if(!baseRef.endsWith("/")) {
      baseRef += "/";
    }
    Configuration tmpltCfg = getTemplateConfiguration();

    ViewModel viewModel = new ViewModel();
    viewModel.setFlashes(Flash.getFlashes(getRequest()));
    viewModel.put("baseRef",baseRef);
    viewModel.put("model",makeDataModel());

    try {
      Template template = tmpltCfg.getTemplate("Beans.ftl");
      template.process(viewModel, writer);
      writer.flush();
    } catch (IOException e) { 
      throw new RuntimeException(e); 
    } catch (TemplateException e) { 
      throw new RuntimeException(e); 
    }
    
  }
}

代码示例来源:origin: internetarchive/heritrix3

protected void writeHtml(Writer writer) {
  EngineModel model = makeDataModel();
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  Configuration tmpltCfg = getTemplateConfiguration();
  ViewModel viewModel = new ViewModel();
  viewModel.setFlashes(Flash.getFlashes(getRequest()));
  viewModel.put("baseRef",baseRef);
  viewModel.put("fileSeparator", File.separator);
  viewModel.put("engine", model);
  try {
    Template template = tmpltCfg.getTemplate("Engine.ftl");
    template.process(viewModel, writer);
    writer.flush();
  } catch (IOException e) { 
    throw new RuntimeException(e); 
  } catch (TemplateException e) { 
    throw new RuntimeException(e); 
  }
}

代码示例来源:origin: internetarchive/heritrix3

public List<Variant> getVariants() {
  List<Variant> variants = super.getVariants();
  Form f = getRequest().getResourceRef().getQueryAsForm();
  String format = f.getFirstValue("format");
  if("textedit".equals(format)) {

代码示例来源:origin: internetarchive/heritrix3

protected void writeHtml(Writer writer) {
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  Configuration tmpltCfg = getTemplateConfiguration();
  ViewModel viewModel = new ViewModel();
  viewModel.setFlashes(Flash.getFlashes(getRequest()));
  viewModel.put("baseRef",baseRef);
  viewModel.put("job", makeDataModel());
  viewModel.put("heapReport", getEngine().heapReportData());
  try {
    Template template = tmpltCfg.getTemplate("Job.ftl");
    template.process(viewModel, writer);
    writer.flush();
  } catch (IOException e) { 
    throw new RuntimeException(e); 
  } catch (TemplateException e) { 
    throw new RuntimeException(e); 
  }
  
}

代码示例来源:origin: internetarchive/heritrix3

public void acceptRepresentation(Representation entity) throws ResourceException {
  if (appCtx == null) {
    throw new ResourceException(404);
  }
  // copy op?
  Form form = getRequest().getEntityAsForm();
  beanPath = form.getFirstValue("beanPath");
  
  String newVal = form.getFirstValue("newVal");
  if(newVal!=null) {
    int i = beanPath.indexOf(".");
    String beanName = i<0?beanPath:beanPath.substring(0,i);
    Object namedBean = appCtx.getBean(beanName);
    BeanWrapperImpl bwrap = new BeanWrapperImpl(namedBean);
    String propPath = beanPath.substring(i+1);
    Object coercedVal = bwrap.convertIfNecessary(newVal, bwrap.getPropertyValue(propPath).getClass()); 
    bwrap.setPropertyValue(propPath, coercedVal);
  }
  Reference ref = getRequest().getResourceRef();
  ref.setPath(getBeansRefPath());
  ref.addSegment(beanPath);
  getResponse().redirectSeeOther(ref);
}

代码示例来源:origin: internetarchive/heritrix3

protected void writeHtml(Writer writer) {
    
    String baseRef = getRequest().getResourceRef().getBaseRef().toString();
    if(!baseRef.endsWith("/")) {
      baseRef += "/";
    }
    Configuration tmpltCfg = getTemplateConfiguration();

    ViewModel viewModel = new ViewModel();
    viewModel.setFlashes(Flash.getFlashes(getRequest()));
    viewModel.put("baseRef",baseRef);
    viewModel.put("staticRef", getStaticRef(""));
    viewModel.put("baseResourceRef",getRequest().getRootRef().toString()+"/engine/static/");
    viewModel.put("model", makeDataModel());
    viewModel.put("selectedEngine", chosenEngine);

    try {
      Template template = tmpltCfg.getTemplate("Script.ftl");
      template.process(viewModel, writer);
      writer.flush();
    } catch (IOException e) { 
      throw new RuntimeException(e); 
    } catch (TemplateException e) { 
      throw new RuntimeException(e); 
    }

  }
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * Constructs a nested Map data structure with the information represented
 * by this Resource. The result is particularly suitable for use with with
 * {@link XmlMarshaller}.
 * 
 * @return the nested Map data structure
 */
protected ScriptModel makeDataModel() {
  
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  Reference baseRefRef = new Reference(baseRef);
  
  ScriptModel model = new ScriptModel(scriptingConsole,
      new Reference(baseRefRef, "..").getTargetRef().toString(),
      getAvailableScriptEngines());
  return model;
}

代码示例来源:origin: internetarchive/heritrix3

new Reference(getRequest().getResourceRef().getBaseRef(), "..").getTargetRef().toString(), 
beanPath, 
bean,

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the reference of the target resource.
 * 
 * @return The reference of the target resource.
 */
@Override
public Reference getResourceRef() {
  return getWrappedRequest().getResourceRef();
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the parsed query of the request's target resource reference as a
 * form (series of parameters).
 * 
 * @return The parsed query.
 * @see Reference#getQueryAsForm()
 */
public Form getQuery() {
  return getRequest().getResourceRef().getQueryAsForm();
}

代码示例来源:origin: org.sonatype.nexus/nexus-rest-api

protected boolean isDescribe( Request request )
{
  // check do we need describe
  return request.getResourceRef().getQueryAsForm().getFirst( IS_DESCRIBE_PARAMETER ) != null;
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the optional matrix of the request's target resource reference as
 * a form (series of parameters).
 * 
 * @return The parsed query.
 * @see Reference#getMatrixAsForm()
 */
public Form getMatrix() {
  return getRequest().getResourceRef().getMatrixAsForm();
}

代码示例来源:origin: com.noelios.restlet/com.noelios.restlet.ext.servlet

@Override
public void handle(Request request, Response response) {
  final String scheme = request.getResourceRef().getScheme();
  if (Protocol.WAR.getSchemeName().equalsIgnoreCase(scheme)) {
    super.handle(request, response);
  } else {
    throw new IllegalArgumentException(
        "Protocol \""
            + scheme
            + "\" not supported by the connector. Only WAR is supported.");
  }
}

代码示例来源:origin: org.restlet/org.restlet

@Override
  protected int beforeHandle(Request request, Response response) {
    final int result = super.beforeHandle(request, response);
    // Set the request's root reference
    request.setRootRef(request.getResourceRef().getBaseRef());
    // Save the hash code of the current host
    setCurrent(VirtualHost.this.hashCode());
    return result;
  }
};

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

protected RepositoryTargetResource getNexusToRestResource(Target target, Request request) {
 RepositoryTargetResource resource = new RepositoryTargetResource();
 resource.setId(target.getId());
 resource.setName(target.getName());
 resource.setResourceURI(request.getResourceRef().getPath());
 resource.setContentClass(target.getContentClass().getId());
 List<String> patterns = new ArrayList<String>(target.getPatternTexts());
 for (String pattern : patterns) {
  resource.addPattern(pattern);
 }
 return resource;
}

相关文章