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

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

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

Request.getRootRef介绍

[英]Returns the application root reference.
[中]返回应用程序根引用。

代码示例

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

  1. protected String getStaticRef(String resource) {
  2. String rootRef = getRequest().getRootRef().toString();
  3. return rootRef + "/engine/static/" + resource;
  4. }
  5. }

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

  1. protected String getStaticRef(String resource) {
  2. String rootRef = dirResource.getRequest().getRootRef().toString();
  3. return rootRef + "/engine/static/" + resource;
  4. }

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

  1. protected void writeHtml(Writer writer) {
  2. String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  3. if(!baseRef.endsWith("/")) {
  4. baseRef += "/";
  5. }
  6. Configuration tmpltCfg = getTemplateConfiguration();
  7. ViewModel viewModel = new ViewModel();
  8. viewModel.setFlashes(Flash.getFlashes(getRequest()));
  9. viewModel.put("baseRef",baseRef);
  10. viewModel.put("staticRef", getStaticRef(""));
  11. viewModel.put("baseResourceRef",getRequest().getRootRef().toString()+"/engine/static/");
  12. viewModel.put("model", makeDataModel());
  13. viewModel.put("selectedEngine", chosenEngine);
  14. try {
  15. Template template = tmpltCfg.getTemplate("Script.ftl");
  16. template.process(viewModel, writer);
  17. writer.flush();
  18. } catch (IOException e) {
  19. throw new RuntimeException(e);
  20. } catch (TemplateException e) {
  21. throw new RuntimeException(e);
  22. }
  23. }
  24. }

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

  1. /**
  2. * Returns the application root reference.
  3. *
  4. * @return The application root reference.
  5. */
  6. @Override
  7. public Reference getRootRef() {
  8. return getWrappedRequest().getRootRef();
  9. }

代码示例来源:origin: org.archive.heritrix/heritrix-engine

  1. protected String getStaticRef(String resource) {
  2. String rootRef = getRequest().getRootRef().toString();
  3. return rootRef + "/engine/static/" + resource;
  4. }
  5. }

代码示例来源:origin: org.archive.heritrix/heritrix-engine

  1. protected String getStaticRef(String resource) {
  2. String rootRef = dirResource.getRequest().getRootRef().toString();
  3. return rootRef + "/engine/static/" + resource;
  4. }

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

  1. /**
  2. * Returns the resource-path for the given request, does not include "service/local" prefix.
  3. * Should never start with "/".
  4. */
  5. private String getResourcePath(final Request request) {
  6. // do not use getContentRoot() here, we do not want force base-url messing up resource path extraction
  7. String rootUri = request.getRootRef().getTargetRef().toString();
  8. if (!rootUri.endsWith("/")) {
  9. rootUri += "/";
  10. }
  11. String resourceUri = request.getResourceRef().getTargetRef().toString();
  12. String path = resourceUri.substring(rootUri.length());
  13. if (path.startsWith("/")) {
  14. path = path.substring(1, path.length());
  15. }
  16. // in a runtime instance the root-ref will include service/local since restlet is no longer mounted at root
  17. // so this should be stripped off as part of substring above
  18. checkState(!path.startsWith("service/local"));
  19. return path;
  20. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

  1. @Override
  2. public void handleGet()
  3. {
  4. getResponse().redirectSeeOther(String.format("%s/", getRequest().getRootRef()));
  5. }

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

  1. protected Reference createRedirectReference( Request request )
  2. {
  3. String uriPart =
  4. request.getResourceRef().getTargetRef().toString().substring(
  5. request.getRootRef().getTargetRef().toString().length() );
  6. // trim leading slash
  7. if ( uriPart.startsWith( "/" ) )
  8. {
  9. uriPart = uriPart.substring( 1 );
  10. }
  11. Reference result = updateBaseRefPath( new Reference( getContextRoot( request ), uriPart ) ).getTargetRef();
  12. return result;
  13. }

代码示例来源:origin: org.geoserver/rest

  1. String baseURL = request.getRootRef().getParentRef().toString();
  2. String rootPath = request.getRootRef().toString().substring(baseURL.length());
  3. String pagePath = request.getResourceRef().toString().substring(baseURL.length());
  4. String basePath = null;

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

  1. @Override
  2. public Reference getContextRoot( Request request )
  3. {
  4. Reference result = null;
  5. if ( globalRestApiSettings.isEnabled() && globalRestApiSettings.isForceBaseUrl()
  6. && StringUtils.isNotEmpty( globalRestApiSettings.getBaseUrl() ) )
  7. {
  8. result = new Reference( globalRestApiSettings.getBaseUrl() );
  9. }
  10. else
  11. {
  12. result = request.getRootRef();
  13. }
  14. // fix for when restlet is at webapp root
  15. if ( StringUtils.isEmpty( result.getPath() ) )
  16. {
  17. result.setPath( "/" );
  18. }
  19. return result;
  20. }

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

  1. templatingContext.put( "nexusRoot", request.getRootRef().toString() );

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

  1. baseURL = Request.getCurrent().getRootRef().getParentRef().getParentRef().toString();

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

  1. @Override
  2. public Reference getContextRoot(Request request) {
  3. Reference result = null;
  4. if (globalRestApiSettings.isEnabled() && globalRestApiSettings.isForceBaseUrl()
  5. && StringUtils.isNotEmpty(globalRestApiSettings.getBaseUrl())) {
  6. result = new Reference(globalRestApiSettings.getBaseUrl());
  7. }
  8. else {
  9. // TODO: NEXUS-6045 hack, Restlet app root is now "/service/local", so going up 2 levels!
  10. result = request.getRootRef().getParentRef().getParentRef();
  11. }
  12. // fix for when restlet is at webapp root
  13. if (StringUtils.isEmpty(result.getPath())) {
  14. result.setPath("/");
  15. }
  16. return result;
  17. }

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

  1. private String getResourceUri(Request req, ContentListResource resource, StorageItem child) {
  2. // NEXUS-4244: simply force both baseURLs, coming from nexus.xml and extracted from current request
  3. // to end with slash ("/").
  4. Reference root = getContextRoot(req);
  5. if (StringUtils.isBlank(root.getPath()) || !root.getPath().endsWith("/")) {
  6. root.setPath(StringUtils.defaultString(root.getPath(), "") + "/");
  7. }
  8. Reference requestRoot = req.getRootRef().getParentRef().getParentRef();
  9. if (StringUtils.isBlank(requestRoot.getPath()) || !requestRoot.getPath().endsWith("/")) {
  10. requestRoot.setPath(StringUtils.defaultString(requestRoot.getPath(), "") + "/");
  11. }
  12. final Reference ref = req.getResourceRef().getTargetRef();
  13. String uri = ref.toString();
  14. if (ref.getQuery() != null) {
  15. uri = uri.substring(0, uri.length() - ref.getQuery().length() - 1);
  16. }
  17. if (!uri.endsWith("/")) {
  18. uri += "/";
  19. }
  20. uri += child.getName();
  21. if (!resource.isLeaf()) {
  22. uri += "/";
  23. }
  24. if (root == requestRoot || root.equals(requestRoot)) {
  25. return uri;
  26. }
  27. else {
  28. return uri.replace(requestRoot.toString(), root.toString());
  29. }
  30. }

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

  1. baseURL = Request.getCurrent().getRootRef().toString();

代码示例来源:origin: org.archive.heritrix/heritrix-engine

  1. protected void writeHtml(Writer writer) {
  2. String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  3. if(!baseRef.endsWith("/")) {
  4. baseRef += "/";
  5. }
  6. Configuration tmpltCfg = getTemplateConfiguration();
  7. ViewModel viewModel = new ViewModel();
  8. viewModel.setFlashes(Flash.getFlashes(getRequest()));
  9. viewModel.put("baseRef",baseRef);
  10. viewModel.put("staticRef", getStaticRef(""));
  11. viewModel.put("baseResourceRef",getRequest().getRootRef().toString()+"/engine/static/");
  12. viewModel.put("model", makeDataModel());
  13. viewModel.put("selectedEngine", chosenEngine);
  14. try {
  15. Template template = tmpltCfg.getTemplate("Script.ftl");
  16. template.process(viewModel, writer);
  17. writer.flush();
  18. } catch (IOException e) {
  19. throw new RuntimeException(e);
  20. } catch (TemplateException e) {
  21. throw new RuntimeException(e);
  22. }
  23. }
  24. }

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

  1. Reference requestRoot = req.getRootRef();
  2. if ( StringUtils.isBlank( requestRoot.getPath() ) || !requestRoot.getPath().endsWith( "/" ) )

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

  1. this.request.getRootRef());
  2. } else if (variableName.equals("p")) {
  3. if (this.request.getProtocol() != null) {

相关文章