Package org.thymeleaf.context

Examples of org.thymeleaf.context.Context


            final MimeMessage mimeMessage = this.mailSender.createMimeMessage();
            final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, "UTF-8");

            Locale locale = LocaleContextHolder.getLocale();

            Context ctx = new Context(locale);
            if (fromUser != null) {
                ctx.setVariable("adminName", fromUser.getFullName());
            }

            // Convert Invitation List to Map with email addresses being keys
            Map<String, List<Invitation>> emailMap = new HashMap<String, List<Invitation>>();
            for (Invitation invitation : invitations) {
                String key = StringUtils.trimAllWhitespace(invitation.getEmail()).toLowerCase();
                if (emailMap.get(key) == null) {
                    emailMap.put(key, new ArrayList<Invitation>());
                }
                emailMap.get(key).add(invitation);
            }

            Organization parentDomain = null;

            // Loop over each email address and send out a single invitation for each
            for (String emailAddress : emailMap.keySet()) {

                // Create Map separating domains for the email addresses invitations
                Map<String, Set<Invitation>> invitationsMap = new HashMap<String, Set<Invitation>>();
                for (Invitation invitation : emailMap.get(emailAddress)) {
                    if (DomainType.ORGANIZATION.equals(invitation.getDomain().getDomainType())) {
                        if (invitationsMap.get(DomainType.ORGANIZATION.name()) == null) {
                            invitationsMap.put(DomainType.ORGANIZATION.name(), new TreeSet<Invitation>(new InvitationDomainNameComparator()));
                        }
                        invitationsMap.get(DomainType.ORGANIZATION.name()).add(invitation);
                        parentDomain = (Organization) invitation.getDomain();
                    } else if (DomainType.GROUP.equals(invitation.getDomain().getDomainType())) {
                        if (invitationsMap.get(DomainType.GROUP.name()) == null) {
                            invitationsMap.put(DomainType.GROUP.name(), new TreeSet<Invitation>(new InvitationDomainNameComparator()));
                        }
                        invitationsMap.get(DomainType.GROUP.name()).add(invitation);
                        if(parentDomain == null) {
                            Group group = (Group) invitation.getDomain();
                            parentDomain = group.getOrganization();
                        }
                    }
                }

                ctx.setVariable("domainTypes", invitationsMap.keySet());
                ctx.setVariable("groupInvitations", invitationsMap.get(DomainType.GROUP.name()));
                String parentDomainName = parentDomain != null ? parentDomain.getName() : "";
                ctx.setVariable("parentDomainName", StringUtils.trimTrailingWhitespace(parentDomainName));

                User invitee = userService.getByEmail(emailAddress);
                if (invitee == null) {
                    ctx.setVariable("existingUser", false);
                    NameValuePair emailParam = new BasicNameValuePair("email", emailAddress);
                    ctx.setVariable("url", request.generateURL("/auth/register", emailParam));
                } else {
                    ctx.setVariable("existingUser", true);
                    ctx.setVariable("url", request.generateURL(""));
                }
                applyBranding(parentDomain, ctx);

                // Create the HTML body using Thymeleaf
                final String htmlContent = this.templateEngine.process("email-invitationTH", ctx);
View Full Code Here


                Locale locale = LocaleContextHolder.getLocale();
                message.setFrom(fromAddress);

                if (user != null) {
                    Context ctx = new Context(locale);
                    ctx.setVariable("name", user.getFullName());
                    ctx.setVariable("password", password);
                    ctx.setVariable("url", request.generateURL(""));

                    // Create the HTML body using Thymeleaf
                    final String htmlContent = this.templateEngine.process("email-passwordChangedTH", ctx);
                    message.setText(htmlContent, true /* isHtml */);
                    message.setTo(user.getEmail());
View Full Code Here

                if (organization != null) {
                    List<UserDomain> userdomains = userDomainService.getAll(organization.getId(), UserRole.ROLE_ORG_ADMIN);

                    for (UserDomain userDomain : userdomains) {
                        Context ctx = new Context(locale);
                        ctx.setVariable("name", userDomain.getUser().getFullName());
                        ctx.setVariable("userName", userModel.getFullName());
                        ctx.setVariable("applicationName", applicationVersion.getApplication().getName());
                        ctx.setVariable("applicationVersion", applicationVersion.getVersionName());
                        ctx.setVariable("organizationName", organization.getName());
                        ctx.setVariable("url", request.generateURL("/manager"));

                        // Create the HTML body using Thymeleaf
                        final String htmlContent = this.templateEngine.process("email-applicationPublishRequestTH", ctx);
                        applyBranding(organization, ctx);
                        message.setText(htmlContent, true /* isHtml */);
 
View Full Code Here

                Locale locale = LocaleContextHolder.getLocale();
                message.setFrom(fromAddress);

                User user = userService.get(domainUserRequestModel.getUser().getId());
                if (user != null) {
                    Context ctx = new Context(locale);
                    ctx.setVariable("name", user.getFullName());
                    ctx.setVariable("groupName", domainUserRequestModel.getDomain().getName());
                    ctx.setVariable("status", (Status.ACCEPTED.equals(domainUserRequestModel.getStatus()) ? true : false));
                    // Create the HTML body using Thymeleaf
                    final String htmlContent = this.templateEngine.process("email-domainUserAccessConfirmationTH", ctx);
                    message.setText(htmlContent, true /* isHtml */);
                    message.setTo(user.getEmail());

View Full Code Here

                message.setSubject(String.format("Knappsack: %s Registration", organization.getName().trim()));

                Locale locale = LocaleContextHolder.getLocale();
                message.setFrom(fromAddress);

                Context ctx = new Context(locale);
                ctx.setVariable("organization", organization);

                boolean existingUser = false;
                if (userService.getByEmail(userModel.getEmail().trim()) != null) {
                    existingUser = true;
                }
                ctx.setVariable("existingUser", existingUser);
                ctx.setVariable("user", userModel);
                ctx.setVariable("url", request.generateURL(""));
                applyBranding(organization, ctx);

                // Create the HTML body using Thymeleaf
                final String htmlContent = this.templateEngine.process("email-organizationRegistrationTH", ctx);
                message.setText(htmlContent, true /* isHtml */);
 
View Full Code Here

                message.setSubject("Knappsack: Application Visibility");

                Locale locale = LocaleContextHolder.getLocale();
                message.setFrom(fromAddress);

                Context ctx = new Context(locale);
                ctx.setVariable("applicationName", applicationVersion.getApplication().getName());
                ctx.setVariable("url", request.generateURL(String.format("/detail/%s", applicationVersion.getApplication().getId())));
                ctx.setVariable("applicationVersion", applicationVersion.getVersionName());
                applyBranding(application.getOwnedGroup().getOrganization(), ctx);

                List<User> users = userService.get(userIds);
                for (User user : users) {
                    ctx.setVariable("userName", user.getFullName());

                    final String htmlContent = this.templateEngine.process("email-applicationVersionBecameVisibleTH", ctx);
                    message.setText(htmlContent, true /* isHtml */);
                    message.setTo(user.getEmail());

View Full Code Here

                if (users != null) {
                    String orgName = organization.getName();
                    String url = webRequest.generateURL("");
                    long bandwidthLimit = organization.getDomainConfiguration().getMegabyteBandwidthLimit();
                    for (UserModel user : users) {
                        Context ctx = new Context(locale);
                        ctx.setVariable("user", user);
                        ctx.setVariable("organizationName", orgName);
                        ctx.setVariable("url", url);
                        ctx.setVariable("bandwidthLimit", bandwidthLimit);

                        // Create the HTML body using Thymeleaf
                        final String htmlContent = this.templateEngine.process("email-bandwidthLimitTH", ctx);
                        message.setText(htmlContent, true /* isHtml */);
                        message.setTo(user.getEmail());
View Full Code Here

                if (parentApplication != null) {
                    String applicationName = parentApplication.getName();
                    String url = webRequest.generateURL(String.format("/manager/editVersion/%s/%s", parentApplication.getId(), applicationVersion.getId()));
                    List<User> users = userService.get(userIds);
                    for (User user : users) {
                        Context ctx = new Context(locale);
                        ctx.setVariable("user", user);
                        ctx.setVariable("url", url);
                        ctx.setVariable("applicationName", applicationName);
                        ctx.setVariable("applicationVersion", applicationVersion.getVersionName());
                        applyBranding(parentApplication.getOwnedGroup().getOrganization(), ctx);

                        // Create the HTML body using Thymeleaf
                        final String htmlContent = this.templateEngine.process("email-applicationVersionErrorTH", ctx);
                        message.setText(htmlContent, true /* isHtml */);
 
View Full Code Here

                        url = webRequest.generateURL(String.format("/manager/editVersion/%s/%s", parentApplication.getId(), applicationVersion.getId()));
                    }

                    List<User> users = userService.get(userIds);
                    for (User user : users) {
                        Context ctx = new Context(locale);
                        ctx.setVariable("userName", user.getFullName());
                        ctx.setVariable("url", url);
                        ctx.setVariable("resignSuccess", resignSuccess);
                        ctx.setVariable("resignErrorType", (resignErrorType != null ? resignErrorType : ResignErrorType.GENERIC));
                        ctx.setVariable("applicationName", applicationName);
                        ctx.setVariable("applicationVersion", applicationVersion.getVersionName());
                        applyBranding(parentApplication.getOwnedGroup().getOrganization(), ctx);

                        // Create the HTML body using Thymeleaf
                        final String htmlContent = this.templateEngine.process("email-applicationVersionResignCompleteTH", ctx);
                        message.setText(htmlContent, true /* isHtml */);
 
View Full Code Here

                Region region = domainRequest.getRegion();
                if (region != null && region.getEmails() != null && region.getEmails().size() > 0) {
                    emailCount = region.getEmails().size();
                    for (String email : region.getEmails()) {
                        Context ctx = new Context(locale);
                        ctx.setVariable("url", webRequest.generateURL("/manager/requestsPending/" + domainRequest.getDomain().getId()));
                        ctx.setVariable("domain", domainRequest.getDomain());
                        ctx.setVariable("requesterFirstName", domainRequest.getFirstName());
                        ctx.setVariable("requesterLastName", domainRequest.getLastName());
                        ctx.setVariable("requesterEmail", domainRequest.getEmailAddress());
                        ctx.setVariable("requesterAddress", domainRequest.getAddress());
                        ctx.setVariable("requesterCompanyName", domainRequest.getCompanyName());
                        ctx.setVariable("requesterPhone", domainRequest.getPhoneNumber());
                        ctx.setVariable("requesterDeviceType", domainRequest.getDeviceType());
                        ctx.setVariable("requesterRegion", domainRequest.getRegion());

                        List<Language> languages = new ArrayList<Language>();
                        languages.addAll(domainRequest.getLanguages());
                        Collections.sort(languages, new LanguageComparator());
                        ctx.setVariable("requesterLanguages", languages);
                        applyBranding(domainRequest.getDomain(), ctx);

                        // Create the HTML body using Thymeleaf
                        final String htmlContent = this.templateEngine.process("email-domainAccessRequestTH", ctx);
                        message.setText(htmlContent, true /* isHtml */);
                        message.setTo(email);

                        if (sendMessage(mimeMessage)) {
                            numberOfEmails += 1;
                        }
                    }
                } else {
                    List<User> users = domainService.getAllAdmins(domainRequest.getDomain(), true);
                    emailCount = (users == null ? 0 : users.size());

                    if (users != null) {
                        for (User user : users) {
                            Context ctx = new Context(locale);
                            ctx.setVariable("url", webRequest.generateURL("/manager/requestsPending/" + domainRequest.getDomain().getId()));
                            ctx.setVariable("domain", domainRequest.getDomain());
                            ctx.setVariable("requesterFirstName", domainRequest.getFirstName());
                            ctx.setVariable("requesterLastName", domainRequest.getLastName());
                            ctx.setVariable("requesterEmail", domainRequest.getEmailAddress());
                            ctx.setVariable("requesterAddress", domainRequest.getAddress());
                            ctx.setVariable("requesterCompanyName", domainRequest.getCompanyName());
                            ctx.setVariable("requesterPhone", domainRequest.getPhoneNumber());
                            ctx.setVariable("requesterDeviceType", domainRequest.getDeviceType());
                            ctx.setVariable("requesterRegion", domainRequest.getRegion());

                            List<Language> languages = new ArrayList<Language>();
                            languages.addAll(domainRequest.getLanguages());
                            Collections.sort(languages, new LanguageComparator());
                            ctx.setVariable("requesterLanguages", languages);

                            ctx.setVariable("user", user);

                            // Create the HTML body using Thymeleaf
                            final String htmlContent = this.templateEngine.process("email-domainAccessRequestTH", ctx);
                            message.setText(htmlContent, true /* isHtml */);
                            message.setTo(user.getEmail());
View Full Code Here

TOP

Related Classes of org.thymeleaf.context.Context

Copyright © 2018 www.massapicom. 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.