/** * Redirects the client to a different URI that SHOULD be retrieved using a * GET method on that resource. This method exists primarily to allow the * output of a POST-activated script to redirect the user agent to a * selected resource. The new URI is not a substitute reference for the * originally requested resource. * * @param targetRef * The target reference. */ @Override public void redirectSeeOther(Reference targetRef) { getWrappedResponse().redirectSeeOther(targetRef); }
/** * Redirects the client to a different URI that SHOULD be retrieved using a * GET method on that resource. This method exists primarily to allow the * output of a POST-activated script to redirect the user agent to a * selected resource. The new URI is not a substitute reference for the * originally requested resource. * * @param targetUri * The target URI. */ @Override public void redirectSeeOther(String targetUri) { getWrappedResponse().redirectSeeOther(targetUri); }
private void sendErrorRedirect(String redirectUri, String code, String msg) { try { getResponse().redirectSeeOther( redirectUri + "?error=" + URLEncoder.encode(code, "UTF-8") + "&error_description=" + URLEncoder.encode(msg, "UTF-8") ); } catch (UnsupportedEncodingException e) { throw new HobsonRuntimeException("Error creating redirect URL", e); } } }
private Representation representNonInformationResource(final MediaType type) { RDFFormat format = RDFMediaTypes.findRdfFormat(type); if (null == format) { throw new IllegalStateException("no RDF format for media type " + type); } String suffix = format.getDefaultFileExtension(); if (null == suffix) { throw new IllegalStateException("no suffix for RDF format " + type); } getResponse().redirectSeeOther(selfURI + "." + suffix); return null; }
private Representation representNonInformationResource(final MediaType type) { RDFFormat format = RDFMediaTypes.findRdfFormat(type); if (null == format) { throw new IllegalStateException("no RDF format for media type " + type); } String suffix = format.getDefaultFileExtension(); if (null == suffix) { throw new IllegalStateException("no suffix for RDF format " + type); } getResponse().redirectSeeOther(selfURI + "." + suffix); return null; }
/** * Shortcut to apply POST/302/GET redirect pattern. * * @param getURI URI of the updated resource * @return An EmptyRepresentation with proper HTTP headers to apply the redirection */ protected final Representation redirectToUpdatedResource( String getURI ) { getResponse().redirectSeeOther( getURI ); return new EmptyRepresentation(); }
/** * Shortcut to apply POST/302/GET redirect pattern. * * @param getURI URI of the created resource * @return An EmptyRepresentation with proper HTTP headers to apply the redirection */ protected final Representation redirectToCreatedResource( String getURI ) { getResponse().redirectSeeOther( getURI ); return new EmptyRepresentation(); }
/** * Redirects the client to a different URI that SHOULD be retrieved using a * GET method on that resource. This method exists primarily to allow the * output of a POST-activated script to redirect the user agent to a * selected resource. The new URI is not a substitute reference for the * originally requested resource. * * @param targetRef * The target reference. */ public void redirectSeeOther(Reference targetRef) { if (getResponse() != null) { getResponse().redirectSeeOther(targetRef); } }
/** * Redirects to the given path, using an absolute URI based on this.getRequest().getRootRef(). * * @param path * The path to redirect to. */ protected void redirectToPath(final String path) { final String rootRef = this.getRequest().getRootRef().toString(false, false); final boolean rootHasSlash = rootRef.endsWith("/"); final boolean pathHasSlash = path.startsWith("/"); if(rootHasSlash && pathHasSlash && path.length() > 1) { this.getResponse().redirectSeeOther(rootRef + path.substring(1)); } else // if((rootHasSlash && !pathHasSlash) || (!rootHasSlash && pathHasSlash)) { this.getResponse().redirectSeeOther(rootRef + path); } } }
/** * Redirects the client to a different URI that SHOULD be retrieved using a * GET method on that resource. This method exists primarily to allow the * output of a POST-activated script to redirect the user agent to a * selected resource. The new URI is not a substitute reference for the * originally requested resource.<br> * <br> * If you pass a relative target URI, it will be resolved with the current * base reference of the request's resource reference (see {@link Request#getResourceRef()} and * {@link Reference#getBaseRef()}. * * @param targetUri * The target URI. */ public void redirectSeeOther(String targetUri) { if (getResponse() != null) { getResponse().redirectSeeOther(targetUri); } }
response.redirectSeeOther(Reference.decode(targetUri)); return; response.redirectSeeOther(this.getFixedRedirectUri()); return; response.redirectSeeOther(FixedRedirectCookieAuthenticator.DEFAULT_FIXED_REDIRECT_URI); return;
/** * Remove this resource. */ @Delete public void removeContact() throws ResourceException { getObjectsFacade().deleteContact(this.user, this.contact); getResponse().redirectSeeOther( getRequest().getResourceRef().getParentRef()); }
/** * Remove this resource. */ @Delete public void removeUser() throws ResourceException { getObjectsFacade().deleteUser(this.user); getResponse().redirectSeeOther( getRequest().getResourceRef().getParentRef()); }
/** * Accept the representation of a new user, and create it. */ @Post public void acceptUser(Representation entity) throws ResourceException { Form form = new Form(entity); User user = new User(); user.setFirstName(form.getFirstValue("firstName")); user.setLastName(form.getFirstValue("lastName")); user.setImage(form.getFirstValue("image")); try { user = getObjectsFacade().createUser(user); getResponse().redirectSeeOther( getChildReference(getRequest().getResourceRef(), user.getId())); } catch (ObjectsException e) { final Map<String, Object> dataModel = new TreeMap<String, Object>(); dataModel.put("users", this.users); dataModel.put("resourceRef", getRequest().getResourceRef()); dataModel.put("rootRef", getRequest().getRootRef()); dataModel.put("firstName", form.getFirstValue("firstName")); dataModel.put("lastName", form.getFirstValue("lastName")); dataModel.put("image", form.getFirstValue("image")); dataModel.put("errorMessage", e.getMessage()); getResponse().setEntity( getTemplateRepresentation("users.html", dataModel, MediaType.TEXT_HTML)); } }
response.redirectSeeOther(targetRef); break;
this.getResponse().redirectSeeOther(referrerRef); this.getResponse().redirectSeeOther(this.getDefaultRedirect());
@Override protected Representation post(Representation entity) throws ResourceException { Form form = new Form(entity); String responseType = form.getFirstValue("response_type"); String username = form.getFirstValue("username"); String password = form.getFirstValue("password"); String redirectUri = form.getFirstValue("redirect_uri"); if (redirectUri == null) { redirectUri = "/console/"; } if ("token".equals(responseType)) { if (username != null && password != null) { try { HobsonUser user = accessManager.authenticate(username, password); String token = accessManager.createToken(user); getResponse().redirectSeeOther(redirectUri + "#access_token=" + token + "&token_type=bearer&id_token=" + token); } catch (HobsonAuthenticationException e) { sendErrorRedirect(redirectUri, "invalid_request", e.getLocalizedMessage()); } } else { sendErrorRedirect(redirectUri, "invalid_request", "Missing username and/or password"); } } else { sendErrorRedirect(redirectUri, "invalid_request", "Invalid response type"); } return new EmptyRepresentation(); }
/** * Update the underlying user according to the given representation. */ @Put public void storeUser(Representation entity) throws ResourceException { Form form = new Form(entity); this.user.setFirstName(form.getFirstValue("firstName")); this.user.setLastName(form.getFirstValue("lastName")); this.user.setImage(form.getFirstValue("image")); getObjectsFacade().updateUser(this.user); getResponse().redirectSeeOther(getRequest().getResourceRef()); }
/** * Update the underlying contact according to the given representation. */ @Put public void storeContact(Representation entity) throws ResourceException { final Form form = new Form(entity); this.contact.setFirstName(form.getFirstValue("firstName")); this.contact.setLastName(form.getFirstValue("lastName")); this.contact.setImage(form.getFirstValue("image")); this.contact.setNickname(form.getFirstValue("nickname")); this.contact.setFoafUri(form.getFirstValue("foafUri")); getObjectsFacade().updateContact(this.user, this.contact); getResponse().redirectSeeOther(getRequest().getResourceRef()); }
/** * Accept the representation of a new contact, and create it. */ @Post public void acceptContact(Representation entity) throws ResourceException { Form form = new Form(entity); Contact contact = new Contact(); contact.setFirstName(form.getFirstValue("firstName")); contact.setLastName(form.getFirstValue("lastName")); contact.setImage(form.getFirstValue("image")); contact.setNickname(form.getFirstValue("nickname")); contact.setFoafUri(form.getFirstValue("foafUri")); contact = getObjectsFacade().createContact(this.user, contact); getResponse().redirectSeeOther( getChildReference(getRequest().getResourceRef(), contact.getId())); }