public JSONArray getArray(String url) throws RESTException { StatusCode errorStatus = StatusCode.FAILED_CONNECTION; try { return new JSONArray(baseGet(url)); } catch (RESTException e) { errorStatus = e.getStatusCode(); throw new RESTException(e.getMessage(), errorStatus); } catch (JSONException e) { throw new RESTException(e.getMessage(), errorStatus); } }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @RequiresXsrfCheck @Path("type/{type}/owner/{owningObjectId}/temp") @Produces({MediaType.TEXT_HTML}) public Response storeTemporaryAvatarUsingMultiPart( final @PathParam("type") String avatarType, final @PathParam("owningObjectId") String owningObjectId, final @MultipartFormParam("avatar") FilePart filePart, final @Context HttpServletRequest request) { try { try { final Avatar.Type avatarsType = Avatar.Type.getByName(avatarType); if (null == avatarsType) { throw new NoSuchElementException("avatarType"); } final ApplicationUser remoteUser = authContext.getUser(); // get from paramter!! Avatar.Size avatarTargetSize = Avatar.Size.LARGE; final Response storeTemporaryAvatarResponse = avatarTemporaryHelper.storeTemporaryAvatar( remoteUser, avatarsType, owningObjectId, avatarTargetSize, filePart, request); return storeTemporaryAvatarResponse; } catch (NoSuchElementException x) { return Response.status(Response.Status.NOT_FOUND).entity(x.getMessage()).build(); } } catch (RESTException x) { String errorMsgs = x.toString(); String sep = ""; return Response.status(Response.Status.OK) .entity( "<html><body>" + "<textarea>" + "{" + "\"errorMessages\": [" + errorMsgs + "]" + "}" + "</textarea>" + "</body></html>") .cacheControl(never()) .build(); } }