Examples of Photograph


Examples of org.fenixedu.academic.domain.Photograph

    @Atomic
    static public void run(byte[] contents, ContentType contentType) {
        check(RolePredicates.PERSON_PREDICATE);
        Person person = AccessControl.getPerson();
        person.setPersonalPhoto(new Photograph(PhotoType.USER, contentType, contents));
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Photograph

     * @throws FileNotFoundException
     * @throws IOException
     */
    @Atomic
    static public void upload(final PhotographUploadBean photo, final Person person) throws FileNotFoundException, IOException {
        person.setPersonalPhoto(new Photograph(PhotoType.USER, ContentType.getContentType(photo.getContentType()), ByteStreams
                .toByteArray(photo.getFileInputStream())));
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Photograph

        storePersonalPhoto(contents, contentType, person);
    }

    private static void storePersonalPhoto(byte[] contents, ContentType contentType, Person person) {
        person.setPersonalPhoto(new Photograph(PhotoType.INSTITUTIONAL, contentType, contents));
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Photograph

    @Atomic
    static public void uploadPhoto(final PhotographUploadBean photoBean, final Person person) throws FileNotFoundException,
            IOException {
        check(AcademicPredicates.MANAGE_PHD_PROCESSES);
        person.setPersonalPhoto(new Photograph(PhotoType.INSTITUTIONAL, ContentType.getContentType(photoBean.getContentType()),
                ByteStreams.toByteArray(photoBean.getFileInputStream())));

    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Photograph

            throws IOException {

        User user = User.findByUsername(username);

        if (user != null && user.getPerson() != null) {
            final Photograph personalPhoto =
                    user.getPerson().isPhotoAvailableToCurrentUser() ? user.getPerson().getPersonalPhoto() : null;

            HttpHeaders headers = new HttpHeaders();
            String etag = "W/\"" + (personalPhoto == null ? "mm-av" : personalPhoto.getExternalId()) + "-" + size + "\"";
            headers.setETag(etag);
            headers.setExpires(DateTime.now().plusHours(12).getMillis());
            headers.setCacheControl("max-age=43200");

            if (etag.equals(ifNoneMatch)) {
                return new ResponseEntity<>(headers, HttpStatus.NOT_MODIFIED);
            }

            if (personalPhoto != null) {
                headers.set("Content-Type", personalPhoto.getOriginal().getPictureFileFormat().getMimeType());
                return new ResponseEntity<>(personalPhoto.getCustomAvatar(size, size, PictureMode.ZOOM), headers, HttpStatus.OK);
            } else {
                try (InputStream mm =
                        PhotographController.class.getClassLoader().getResourceAsStream("META-INF/resources/img/mysteryman.png")) {
                    headers.set("Content-Type", "image/png");
                    return new ResponseEntity<>(Avatar.process(mm, "image/png", size), headers, HttpStatus.OK);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.