public UpdateUserEntity(UserEntity userEntity) { this.firstname = userEntity.getFirstname(); this.lastname = userEntity.getLastname(); this.email = userEntity.getEmail(); this.picture = userEntity.getPicture(); }
@Override public PictureEntity getPicture(String id) { UserEntity user = findById(id); if (user.getPicture() != null) { String picture = user.getPicture(); if (picture.matches("^(http|https)://.*$")) { return new UrlPictureEntity(picture); } else { try { InlinePictureEntity imageEntity = new InlinePictureEntity(); String[] parts = picture.split(";", 2); imageEntity.setType(parts[0].split(":")[1]); String base64Content = picture.split(",", 2)[1]; imageEntity.setContent(DatatypeConverter.parseBase64Binary(base64Content)); return imageEntity; } catch (Exception ex) { LOGGER.warn("Unable to get user picture for id[{}]", id); } } } // Return default inline user avatar InlinePictureEntity imageEntity = new InlinePictureEntity(); imageEntity.setType("image/png"); try { imageEntity.setContent(IOUtils.toByteArray(new FileInputStream(defaultAvatar))); } catch (IOException ioe) { LOGGER.error("Default icon for API does not exist", ioe); } return imageEntity; }
@Override public PictureEntity getPicture(String id) { UserEntity user = findById(id); if (user.getPicture() != null) { String picture = user.getPicture(); if (picture.matches("^(http|https)://.*$")) { return new UrlPictureEntity(picture); } else { try { InlinePictureEntity imageEntity = new InlinePictureEntity(); String[] parts = picture.split(";", 2); imageEntity.setType(parts[0].split(":")[1]); String base64Content = picture.split(",", 2)[1]; imageEntity.setContent(DatatypeConverter.parseBase64Binary(base64Content)); return imageEntity; } catch (Exception ex) { LOGGER.warn("Unable to get user picture for id[{}]", id); } } } // Return default inline user avatar InlinePictureEntity imageEntity = new InlinePictureEntity(); imageEntity.setType("image/png"); try { imageEntity.setContent(IOUtils.toByteArray(new FileInputStream(defaultAvatar))); } catch (IOException ioe) { LOGGER.error("Default icon for API does not exist", ioe); } return imageEntity; }