@Get public Representation represent() { StringRepresentation sr = new StringRepresentation("xml string.."); sr.setMediaType(MediaType.APPLICATION_XML); return sr; }
sb.append("<input style=\"background-color: #10649e; margin: 0; padding: 1em 3em; font-weight: 200; border: none; letter-spacing: 2px; border-radius: 3px; color: #fff;\" type=submit value=LOGIN> </div> </form> </div> </body> </html>"); StringRepresentation sr = new StringRepresentation(sb); sr.setMediaType(MediaType.TEXT_HTML); return sr; } else {
/** * Constructor. * * @param text * The string value. * @param mediaType * The media type. * @param language * The language. * @param characterSet * The character set. */ public StringRepresentation(CharSequence text, MediaType mediaType, Language language, CharacterSet characterSet) { super(mediaType); setMediaType(mediaType); if (language != null) { getLanguages().add(language); } setCharacterSet(characterSet); setText(text); }
/** * Constructor. * * @param text * The string value. * @param mediaType * The media type. * @param language * The language. * @param characterSet * The character set. */ public StringRepresentation(CharSequence text, MediaType mediaType, Language language, CharacterSet characterSet) { super(mediaType); setMediaType(mediaType); if (language != null) { getLanguages().add(language); } setCharacterSet(characterSet); setText(text); }
/** * Returns the representation of the given error. The format of the JSON * document is according to 5.2. Error Response. * * @param ex * Any OAuthException with error * @return The representation of the given error. */ public static Representation responseErrorRepresentation(OAuthException ex) { try { return new JsonRepresentation(ex.createErrorDocument()); } catch (JSONException e) { StringRepresentation r = new StringRepresentation( "{\"error\":\"server_error\",\"error_description:\":\"" + e.getLocalizedMessage() + "\"}"); r.setMediaType(MediaType.APPLICATION_JSON); return r; } }
/** * Returns the representation of the given error. The format of the JSON * document is according to 5.2. Error Response. * * @param ex * Any OAuthException with error * @return The representation of the given error. */ public static Representation responseErrorRepresentation(OAuthException ex) { try { return new JsonRepresentation(ex.createErrorDocument()); } catch (JSONException e) { StringRepresentation r = new StringRepresentation( "{\"error\":\"server_error\",\"error_description:\":\"" + e.getLocalizedMessage() + "\"}"); r.setMediaType(MediaType.APPLICATION_JSON); return r; } }