public Response seeOther( URI uri ) { return Response.seeOther( baseUri.resolve( uri ) ).build(); }
@GET public Response redirectToWebapp() { return Response.seeOther(UriBuilder.fromPath("maps/").build()).build(); }
@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); }
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(); } }
/** * 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(); } } }
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(); }
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(); }
@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(); }
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(); }
/** * Redirects to embedded swagger ui. */ @Override public synchronized Response getApiExplorer(UriInfo uriInfo) { return Response .seeOther(uriInfo.getBaseUriBuilder().path("../explorer/index.html").build()) .build(); }
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(); }
@GET @Path("/init") public Response redirectedUrl() { return Response .seeOther(URI.create(securityService.get(SecurityAPI.INIT_LOGIN_OAUTH_GCP, String.class))) .build(); }
@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(); }
@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(); }
@POST @Path("/delete") public Response deleteClient() throws Exception { Domain domain = getDomain(); execContext.getDomainStore().delete(domain); return Response.seeOther(new URI("manage/account")).build(); }
@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(); } }
@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(); }); }
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(); }
@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); } }
@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(); }