javax.ws.rs.core.Response.temporaryRedirect()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(249)

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

Response.temporaryRedirect介绍

[英]Create a new ResponseBuilder for a temporary redirection.
[中]为临时重定向创建新的ResponseBuilder。

代码示例

代码示例来源:origin: Graylog2/graylog2-server

@GET
  @Timed
  @ApiOperation(value = "Redirecting to web console if it runs on same port.")
  @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML})
  public Response redirectToWebConsole() {
    return Response
      .temporaryRedirect(URI.create(HttpConfiguration.PATH_WEB))
      .build();
  }
}

代码示例来源:origin: confluentinc/ksql

@GET
 public Response get(@Context final UriInfo uriInfo) {
  final URI uri = UriBuilder.fromUri(uriInfo.getAbsolutePath())
    .path(postFix)
    .build();

  return Response.temporaryRedirect(uri).build();
 }
}

代码示例来源:origin: Graylog2/graylog2-server

@GET
public Response getIndex(@Context ContainerRequest request, @Context HttpHeaders headers) {
  final URI originalLocation = request.getRequestUri();
  if (originalLocation.getPath().endsWith("/")) {
    return get(request, headers, originalLocation.getPath());
  }
  final URI redirect = UriBuilder.fromPath(originalLocation.getPath() + "/").build();
  return Response.temporaryRedirect(redirect).build();
}

代码示例来源:origin: apache/incubator-druid

@POST
@Path("/redirect")
@Produces(MediaType.APPLICATION_JSON)
public Response redirecting() throws Exception
{
 return Response.temporaryRedirect(new URI(StringUtils.format("http://localhost:%s/simple/direct", port))).build();
}

代码示例来源:origin: com.sun.jersey/jersey-server

/**
 * Redirect to a URI that ends in a slash.
 * @param context The URI rule context
 * @return Redirect or not?
 *
 * TODO use the complete URI.
 */
private boolean redirect(final UriRuleContext context) {
  final HttpResponseContext response = context.getResponse();
  response.setResponse(
    Response.temporaryRedirect(
      context.getUriInfo().getRequestUriBuilder().path("/").build()
    ).build()
  );
  return true;
}

代码示例来源:origin: apache/drill

@Override
 public void filter(ContainerRequestContext requestContext)
   throws IOException {
  final SecurityContext sc = requestContext.getSecurityContext();
  if (!isUserLoggedIn(sc)) {
   try {
    final String destResource = URLEncoder.encode(
      requestContext.getUriInfo().getRequestUri().toString(), "UTF-8");
    final URI loginURI = requestContext.getUriInfo().getBaseUriBuilder()
      .path(LogInLogOutPages.LOGIN_RESOURCE)
      .queryParam(LogInLogOutPages.REDIRECT_QUERY_PARM, destResource)
      .build();
    requestContext
      .abortWith(Response.temporaryRedirect(loginURI).build());
   } catch (final Exception ex) {
    final String errMsg = String.format(
      "Failed to forward the request to login page: %s",
      ex.getMessage());
    LOG.error(errMsg, ex);
    requestContext
      .abortWith(Response.serverError().entity(errMsg).build());
   }
  }
 }
}

代码示例来源:origin: com.sun.jersey/jersey-server

public ContainerRequest filter(ContainerRequest request) {
    if (resourceConfig.getFeature(ResourceConfig.FEATURE_NORMALIZE_URI)) {
      final URI uri = request.getRequestUri();
      final URI normalizedUri = UriHelper.normalize(uri,
          !resourceConfig.getFeature(ResourceConfig.FEATURE_CANONICALIZE_URI_PATH));

      if (uri != normalizedUri) {
        if (resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT)) {
          throw new WebApplicationException(
              Response.temporaryRedirect(normalizedUri).build());
        } else {
          final URI baseUri = UriHelper.normalize(request.getBaseUri(),
            !resourceConfig.getFeature(ResourceConfig.FEATURE_CANONICALIZE_URI_PATH));
          request.setUris(baseUri, normalizedUri);
        }
      }
    }
    return request;
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

createFlagParam);
if(!noredirectParam.getValue()) {
 return Response.temporaryRedirect(uri)
  .type(MediaType.APPLICATION_OCTET_STREAM).build();
} else {
  excludeDatanodes.getValue(), bufferSize);
if(!noredirectParam.getValue()) {
 return Response.temporaryRedirect(uri)
  .type(MediaType.APPLICATION_OCTET_STREAM).build();
} else {
  doAsUser, fullpath, op.getValue(), -1L, -1L, null);
if(!noredirectParam.getValue()) {
 return Response.temporaryRedirect(uri)
  .type(MediaType.APPLICATION_OCTET_STREAM).build();
} else {

代码示例来源:origin: addthis/hydra

@GET
public Response getIndex() {
  try {
    URI indexPath = new URI(INDEX_PATH);
    return Response.temporaryRedirect(new URI(INDEX_PATH)).build();
  } catch (Exception ex) {
    return Response.serverError().entity(ex).build();
  }
}

代码示例来源:origin: com.netflix.pytheas/pytheas-core

public Response redirect(String resource) {
  try {
    String redirect = StringUtils.join(
        Arrays.asList(uriInfo.getRequestUri().toString(),
               resource), 
               "/");
    
    return Response.temporaryRedirect(new URI(redirect)).build();
  } catch (URISyntaxException e) {
    return Response.serverError().build();
  }
}

代码示例来源:origin: com.github.phillip-kruger/apiee-core

@GET
@Produces(MediaType.TEXT_HTML)
public Response getSwaggerUINaked(){
  URI fw = uriInfo.getRequestUriBuilder().path(INDEX_HTML).build();
  return Response.temporaryRedirect(fw).build();
}

代码示例来源:origin: org.microprofile-ext.openapi-ext/swagger-ui

@GET
@Produces(MediaType.TEXT_HTML)
@Operation(hidden = true)
public Response getSwaggerUINaked(){
  URI fw = uriInfo.getRequestUriBuilder().path(INDEX_HTML).build();
  return Response.temporaryRedirect(fw).build();
}

代码示例来源:origin: com.github.phillip-kruger.microprofile-extentions/openapi-ext

@GET
@Produces(MediaType.TEXT_HTML)
@Operation(hidden = true)
public Response getSwaggerUINaked(){
  URI fw = uriInfo.getRequestUriBuilder().path(INDEX_HTML).build();
  return Response.temporaryRedirect(fw).build();
}

代码示例来源:origin: com.github.phillip-kruger.microprofile-extensions/openapi-ext

@GET
@Produces(MediaType.TEXT_HTML)
@Operation(hidden = true)
public Response getSwaggerUINaked(){
  URI fw = uriInfo.getRequestUriBuilder().path(INDEX_HTML).build();
  return Response.temporaryRedirect(fw).build();
}

代码示例来源:origin: org.graylog2/graylog2-server

@GET
public Response getIndex(@Context ContainerRequest request) {
  final URI originalLocation = request.getRequestUri();
  if (originalLocation.getPath().endsWith("/")) {
    return get(request, originalLocation.getPath());
  }
  final URI redirect = UriBuilder.fromPath(originalLocation.getPath() + "/").build();
  return Response.temporaryRedirect(redirect).build();
}

代码示例来源:origin: org.keycloak/keycloak-broker-oidc

@Override
public Response performLogin(AuthenticationRequest request) {
  try {
    URI authorizationUrl = createAuthorizationUrl(request).build();
    return Response.temporaryRedirect(authorizationUrl).build();
  } catch (Exception e) {
    throw new IdentityBrokerException("Could not create authentication request.", e);
  }
}

代码示例来源:origin: com.atlassian.plugins/hipchat-mocked-server

@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@POST
public Response performLogin(@CookieParam("redirect") String redirectTo) {
  return Response.temporaryRedirect(URI.create(redirectTo))
      .cookie(new NewCookie("loggedin", "true"))
      .build();
}

代码示例来源:origin: io.syndesis.rest/rest-endpoint

static Response fail(final HttpServletRequest request, final HttpServletResponse response,
  final URI redirect, final String providerId, final String message) {
  removeCredentialCookies(request, response);
  final URI redirectWithStatus = addFragmentTo(redirect, failure(providerId, message));
  return Response.temporaryRedirect(redirectWithStatus).build();
}

代码示例来源:origin: apache/cxf

@GET
@Path("tempredirect")
public Response tempRedirectAndSetCookies() {
  URI uri = UriBuilder.fromPath("whatever/redirection")
    .queryParam("css1", "http://bar").build();
  return Response.temporaryRedirect(uri)
          .header("Set-Cookie", "a=b").header("Set-Cookie", "c=d")
          .build();
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-auth

@GET
@Path("callback")
public Response callback() throws OAuthAuthenticationException, BadRequestException {
 final URL requestUrl = getRequestUrl(uriInfo);
 final Map<String, List<String>> parameters = getQueryParametersFromState(getState(requestUrl));
 final String providerName = getParameter(parameters, "oauth_provider");
 final String redirectAfterLogin = getParameter(parameters, "redirect_after_login");
 getAuthenticator(providerName).callback(requestUrl);
 return Response.temporaryRedirect(URI.create(redirectAfterLogin)).build();
}

相关文章