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

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

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

Response.seeOther介绍

[英]Create a new ResponseBuilder for a redirection. Used in the redirect-after-POST (aka POST/redirect/GET) pattern.
[中]为重定向创建新的ResponseBuilder。用于POST后重定向(又名POST/redirect/GET)模式。

代码示例

代码示例来源:origin: neo4j/neo4j

public Response seeOther( URI uri )
{
  return Response.seeOther( baseUri.resolve( uri ) ).build();
}

代码示例来源:origin: graphhopper/graphhopper

@GET
public Response redirectToWebapp() {
  return Response.seeOther(UriBuilder.fromPath("maps/").build()).build();
}

代码示例来源:origin: jersey/jersey

@GET
public ItemsRepresentation query(
    @Context javax.ws.rs.core.UriInfo info,
    @QueryParam("offset") @DefaultValue("-1") int offset, @DefaultValue("-1") @QueryParam("limit") int limit) {
  if (offset == -1 || limit == -1) {
    offset = offset == -1 ? 0 : offset;
    limit = limit == -1 ? 10 : limit;
    throw new WebApplicationException(
        Response.seeOther(info.getRequestUriBuilder().queryParam("offset", offset)
            .queryParam("limit", limit).build())
            .build()
    );
  }
  return new ItemsRepresentation(itemsModel, offset, limit);
}

代码示例来源:origin: Pay-Group/best-pay-sdk

public Response toResponse() {
  switch (this.httpStatus) {
    case OK:
      return Response.ok(this.data).build();
    case CREATED:
      return Response.created(this.uri).build();
    case ACCEPTED:
      return Response.accepted().build();
    case NO_CONTENT:
      return Response.noContent().build();
    case SEE_OTHER:
      return Response.seeOther(this.uri).build();
    case BAD_REQUEST:
      return Response.status(Status.BAD_REQUEST).entity(EMPTY_STRING).build();
    case FORBIDDEN:
      if (this.data == null) {
        return Response.status(Status.FORBIDDEN).entity(EMPTY_STRING).build();
      } else {
        return Response.status(Status.FORBIDDEN).entity(this.data).build();
      }
    case NOT_FOUND:
      return Response.status(Status.NOT_FOUND).entity(EMPTY_STRING).build();
    default:
      return Response.status(Status.INTERNAL_SERVER_ERROR).entity(EMPTY_STRING).build();
  }
}

代码示例来源:origin: scouter-project/scouter

/**
   * redirect to
   */
  @NoAuth
  @GET
  @Path("/s/{key}")
  public Response redirectByKey(@PathParam("key") String key, @QueryParam("serverId") int serverId) {
    URI targetURIForRedirection = null;
    String boxes = "{\"lg\":[{\"w\":6,\"h\":5,\"x\":0,\"y\":0,\"i\":\"4\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":6,\"h\":5,\"x\":6,\"y\":0,\"i\":\"5\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":6,\"h\":5,\"x\":0,\"y\":5,\"i\":\"3\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":6,\"h\":5,\"x\":6,\"y\":5,\"i\":\"6\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":6,\"h\":5,\"x\":0,\"y\":10,\"i\":\"7\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":6,\"h\":5,\"x\":6,\"y\":10,\"i\":\"8\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false}],\"sm\":[{\"w\":6,\"h\":8,\"x\":0,\"y\":10,\"i\":\"4\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":6,\"h\":8,\"x\":0,\"y\":18,\"i\":\"5\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false}],\"xs\":[{\"w\":4,\"h\":8,\"x\":0,\"y\":15,\"i\":\"4\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":4,\"h\":8,\"x\":0,\"y\":23,\"i\":\"5\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false}],\"xxs\":[{\"w\":2,\"h\":8,\"x\":0,\"y\":15,\"i\":\"4\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":2,\"h\":8,\"x\":0,\"y\":23,\"i\":\"5\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false}],\"md\":[{\"w\":5,\"h\":8,\"x\":0,\"y\":5,\"i\":\"4\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false},{\"w\":5,\"h\":8,\"x\":5,\"y\":5,\"i\":\"5\",\"minW\":1,\"minH\":3,\"moved\":false,\"static\":false}]}";

    String result = kvStoreService.get(SHORTENER_KEY_SPACE, key, ServerManager.getInstance().getServerIfNullDefault(serverId));
    if (StringUtils.isNotBlank(result)) {
      try {
        targetURIForRedirection = new URI(result);
      } catch (URISyntaxException e) {
        e.printStackTrace();
      }
    }

    if (targetURIForRedirection != null) {
      return Response.seeOther(targetURIForRedirection).build();
    } else {
      return Response.status(Response.Status.NOT_FOUND).build();
    }
  }
}

代码示例来源:origin: OAuth-Apis/apis

private Response sendAuthorizationCodeResponse(AuthorizationRequest authReq) {
 String uri = authReq.getRedirectUri();
 String authorizationCode = getAuthorizationCodeValue();
 authReq.setAuthorizationCode(authorizationCode);
 authorizationRequestRepository.save(authReq);
 uri = uri + appendQueryMark(uri) + "code=" + authorizationCode + appendStateParameter(authReq);
 return Response
     .seeOther(UriBuilder.fromUri(uri).build())
     .cacheControl(cacheControlNoStore())
     .header("Pragma", "no-cache")
     .build();
}

代码示例来源:origin: OAuth-Apis/apis

private Response sendImplicitGrantResponse(AuthorizationRequest authReq, AccessToken accessToken) {
 String uri = authReq.getRedirectUri();
 String fragment = String.format("access_token=%s&token_type=bearer&expires_in=%s&scope=%s", 
  accessToken.getToken(), accessToken.getExpiresIn(), StringUtils.join(authReq.getGrantedScopes(), ',')) + 
  appendStateParameter(authReq);
 if (authReq.getClient().isIncludePrincipal()) {
  fragment += String.format("&principal=%s", authReq.getPrincipal().getDisplayName()) ;
 }
 return Response
     .seeOther(UriBuilder.fromUri(uri)
     .fragment(fragment).build())
     .cacheControl(cacheControlNoStore())
     .header("Pragma", "no-cache")
     .build();
}

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

@GET
@Override
@Produces({RDF_XML, TURTLE, X_TURTLE, APPLICATION_JSON, RDF_JSON})
public Response getMetaGraph(@Context HttpHeaders headers) {
  return Response.seeOther(URI.create("/ontonet")).build();
}

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

protected Response createErrorResponse(String state,
                    String redirectUri,
                    String error) {
  StringBuilder sb = getUriWithFragment(redirectUri);
  sb.append(OAuthConstants.ERROR_KEY).append("=").append(error);
  if (state != null) {
    sb.append("&");
    sb.append(OAuthConstants.STATE).append("=").append(state);
  }
  return Response.seeOther(URI.create(sb.toString())).build();
}

代码示例来源:origin: org.opendaylight.netconf/sal-rest-docgen

/**
 * Redirects to embedded swagger ui.
 */
@Override
public synchronized Response getApiExplorer(UriInfo uriInfo) {
  return Response
      .seeOther(uriInfo.getBaseUriBuilder().path("../explorer/index.html").build())
      .build();
}

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

protected Response createErrorResponse(String state,
                    String redirectUri,
                    String error) {
  if (redirectUri == null) {
    return Response.status(401).entity(error).build();
  }
  UriBuilder ub = getRedirectUriBuilder(state, redirectUri);
  ub.queryParam(OAuthConstants.ERROR_KEY, error);
  return Response.seeOther(ub.build()).build();
}

代码示例来源:origin: epam/DLab

@GET
@Path("/init")
public Response redirectedUrl() {
  return Response
      .seeOther(URI.create(securityService.get(SecurityAPI.INIT_LOGIN_OAUTH_GCP, String.class)))
      .build();
}

代码示例来源:origin: com.peterphi.std.guice/stdlib-guice-webapp

@Override
public Response loadConfig(final String properties)
{
  // Modify the in-memory config to point at the user-specified properties file
  config.set(GuiceProperties.LOG4J_PROPERTIES_FILE, properties);
  Log4JModule.manualReconfigure(config);
  // Now redirect back to the main logging page
  return Response.seeOther(URI.create(restEndpoint.toString() + "/guice/logging")).build();
}

代码示例来源:origin: FroMage/redpipe

@RequiresPermissions("create")
@Path("/create")
@POST
public Response create(@FormParam("name") String name){
  URI location;
  if (name == null || name.isEmpty()) {
    location = Router.getURI(WikiResource::index);
  }else{
    location = Router.getURI(WikiResource::renderPage, name);
  }
  return Response.seeOther(location).build();
}

代码示例来源:origin: org.tiogasolutions.push/tioga-push-engine-core

@POST
@Path("/delete")
public Response deleteClient() throws Exception {
 Domain domain = getDomain();
 execContext.getDomainStore().delete(domain);
 return Response.seeOther(new URI("manage/account")).build();
}

代码示例来源:origin: com.cosmicpush/push-server-engine

@POST
 @Path("/password")
 public Response changePassword(@FormParam("oldPassword") String oldPassword, @FormParam("newPassword") String newPassword, @FormParam("confirmed") String confirmed) throws Exception {

  ChangePasswordAction action = new ChangePasswordAction(oldPassword, newPassword, confirmed);
  account.apply(action);
  execContext.getAccountStore().update(account);

  execContext.setLastMessage("You password has been updated.");
  return Response.seeOther(new URI("manage/account")).build();
 }
}

代码示例来源:origin: FroMage/redpipe

@RequiresPermissions("delete")
@Path("/delete")
@POST
public Single<Response> delete(@FormParam("id") String id){
  return fiber(() -> {
    await(dao.deleteById(Integer.valueOf(id)));
    URI location = Router.getURI(WikiResource::index);
    return Response.seeOther(location).build();
  });
}

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

protected Response doProcessSamlResponse(String encodedSamlResponse,
                     String relayState,
                     boolean postBinding) {
  RequestState requestState = processRelayState(relayState);
  String contextCookie = createSecurityContext(requestState,
                        encodedSamlResponse,
                        relayState,
                        postBinding);
  // Finally, redirect to the service provider endpoint
  URI targetURI = getTargetURI(requestState.getTargetAddress());
  return Response.seeOther(targetURI).header("Set-Cookie", contextCookie).build();
}

代码示例来源:origin: com.jiuxian/mossrose-ui

@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
  final String currentLocker = competitive.currentLocker();
  final String localIp = NetworkUtils.getLocalIp();
  if (!Objects.equals(currentLocker, localIp)) {
    URI masterLocation = requestContext.getUriInfo().getAbsolutePathBuilder().host(currentLocker).build();
    LOGGER.info("Redirect url to {}.", masterLocation);
    Response response = javax.ws.rs.core.Response.seeOther(masterLocation).build();
    requestContext.abortWith(response);
  }
}

代码示例来源:origin: org.tiogasolutions.push/tioga-push-engine-core

@GET
@Path("/sign-out")
@Produces(MediaType.TEXT_HTML)
public Response signOut(@CookieParam(SessionStore.SESSION_COOKIE_NAME) String sessionId) throws Exception {
 if (sessionId != null) {
  execContext.getSessionStore().remove(sessionId);
 }
 NewCookie sessionCookie = SessionStore.toCookie(getUriInfo(), null);
 URI other = getUriInfo().getBaseUriBuilder().queryParam("r", REASON_SIGNED_OUT).build();
 return Response.seeOther(other).cookie(sessionCookie).build();
}

相关文章