Ejemplo n.º 1
0
  /** @since v6.3 */
  @GET
  @Path("type/{type}/owner/{owningObjectId}")
  public Response getAvatars(
      final @PathParam("type") String avatarType,
      final @PathParam("owningObjectId") String owningObjectId) {
    final Avatar.Type avatarsType = Avatar.Type.getByName(avatarType);
    final TypeAvatarService avatarsForType = universalAvatars.getAvatars(avatarsType);
    if (null == avatarsForType) {
      return Response.status(Response.Status.NOT_FOUND).entity("avatarType").build();
    }
    final AvatarImageResolver uriResolver = universalAvatars.getImages(avatarsType);
    if (null == uriResolver) {
      return Response.status(Response.Status.NOT_FOUND).entity("avatarType").build();
    }

    final SystemAndCustomAvatars allAvatars =
        avatarsForType.getAvatars(authContext.getUser(), owningObjectId);

    Map<String, List<AvatarBean>> result = sytemAndCustomAvatarsToBeanMap(uriResolver, allAvatars);

    return Response.ok(result).build();
  }
Ejemplo n.º 2
0
  /**
   * Deletes avatar
   *
   * @param avatarType Project id or project key
   * @param id database id for avatar
   * @return temporary avatar cropping instructions
   * @since v5.0
   */
  @DELETE
  @Path("type/{type}/owner/{owningObjectId}/avatar/{id}")
  public Response deleteAvatar(
      final @PathParam("type") String avatarType,
      final @PathParam("owningObjectId") String owningObjectId,
      @PathParam("id") final Long id) {
    final Avatar.Type avatarsType = Avatar.Type.getByName(avatarType);
    final TypeAvatarService avatarsForType = universalAvatars.getAvatars(avatarsType);

    if (null == avatarsForType) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }
    if (!avatarsForType.canUserCreateAvatar(authContext.getUser(), owningObjectId)) {
      return Response.status(Response.Status.FORBIDDEN).build();
    }

    final Response avatarFromTemporaryResponse = avatarResourceHelper.deleteAvatar(id);
    return avatarFromTemporaryResponse;
  }