/** * @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); final ApplicationUser remoteUser = authContext.getUser(); final List<AvatarBean> systemAvatarBeans = createAvatarBeans(allAvatars.getSystemAvatars(), remoteUser, uriResolver); final List<AvatarBean> customAvatarBeans = createAvatarBeans(allAvatars.getCustomAvatars(), remoteUser, uriResolver); Map<String, List<AvatarBean>> result = ImmutableMap.<String, List<AvatarBean>>builder(). put(SYSTEM_AVATARS_FIELD, systemAvatarBeans). put(CUSTOM_AVATARS_FIELD, customAvatarBeans). build(); return Response.ok(result).build(); }
@Override public IssueType createIssueType(GenericValue issueTypeGv) { final IssueTypeImpl issueType = new IssueTypeImpl(issueTypeGv, translationManager, authenticationContext, baseUrl, avatarManager); final Avatar avatar = issueType.getAvatar(); if (avatar != null) { // dirty trick to update iconURL to this in avatar // this shouldn't be here but somewhere in presentation layer where i should transform it to link // (and apply user permissions - thankfully its not needed for issue types). // I cannot inject UniversalAvatars here beacause there is circular dependecy project->issue+types->avatars->project. // if i could put such code to presentation layer it would be possible. of course because of backward compatibility final UniversalAvatarsService universalAvatars = ComponentAccessor.getComponent(UniversalAvatarsService.class); final AvatarImageResolver uriForIssueType = universalAvatars.getImages(Avatar.Type.ISSUETYPE); final URI avatarURI = uriForIssueType.getAvatarRelativeUri(null, avatar, Avatar.Size.SMALL); final String avatarURIString = avatarURI.toASCIIString(); issueType.setIconUrl(avatarURIString); } return issueType; }