Package com.sparc.knappsack.util

Examples of com.sparc.knappsack.util.WebRequest


    }

    @Override
    public boolean sendApplicationVersionErrorEmail(Long applicationVersionId, List<Long> userIds) {
        boolean emailsSent = false;
        WebRequest webRequest = WebRequest.getInstance();

        ApplicationVersion applicationVersion = applicationVersionService.get(applicationVersionId);
        if(applicationVersion == null) {
            log.error("No ApplicationVersion with ID: " + applicationVersionId);
            return true;
        }

        if (sendEmail && applicationVersion.getApplication() != null && AppState.ERROR.equals(applicationVersion.getAppState()) && userIds != null) {
            final MimeMessage mimeMessage = this.mailSender.createMimeMessage();
            final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, "UTF-8");
            try {
                int numberOfEmails = 0;
                message.setSubject("Knappsack: Application Version Error");

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

                Application parentApplication = applicationVersion.getApplication();
                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);
View Full Code Here


    }

    @Override
    public boolean sendApplicationVersionResignCompleteEmail(Long applicationVersionId, boolean resignSuccess, ResignErrorType resignErrorType, List<Long> userIds) {
        boolean emailsSent = false;
        WebRequest webRequest = WebRequest.getInstance();
        if (sendEmail && applicationVersionId != null && userIds != null) {

            ApplicationVersion applicationVersion = applicationVersionService.get(applicationVersionId);
            if(applicationVersion == null) {
                log.error("No ApplicationVersion with ID: " + applicationVersionId);
                return true;
            }
            Application application = applicationVersion.getApplication();
            if(application == null) {
                log.error("No application found for ApplicationVersion with ID: " + applicationVersionId);
            }

            final MimeMessage mimeMessage = this.mailSender.createMimeMessage();
            final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, "UTF-8");
            try {
                int numberOfEmails = 0;
                if (resignSuccess) {
                    message.setSubject("Knappsack: Application Resign Complete");
                } else {
                    message.setSubject("Knappsack: Application Resign Error");
                }

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

                Application parentApplication = applicationVersion.getApplication();
                if (parentApplication != null) {
                    String applicationName = parentApplication.getName();
                    String url;
                    if (resignSuccess) {
                        url = webRequest.generateURL(String.format("/detail/%s", parentApplication.getId()));
                    } else {
                        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);
View Full Code Here

    }

    @Override
    public boolean sendDomainAccessRequestEmail(Long domainRequestId) {
        boolean emailsSent = false;
        WebRequest webRequest = WebRequest.getInstance();
        if (sendEmail && webRequest != null && domainRequestId != null) {

            DomainRequest domainRequest = domainRequestService.get(domainRequestId);
            if(domainRequest == null) {
                log.error("No DomainUserRequest found with ID: " + domainRequestId);
                return true;
            }

            if(domainRequest.getDomain() == null) {
                log.error("No Domain found for DomainRequest with ID: " + domainRequestId);
                return true;
            }

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

            try {
                int numberOfEmails = 0;
                message.setSubject("Knappsack: Domain Request");

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

                int emailCount = 0;

                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());
View Full Code Here

    }

    @Override
    public boolean resign(IOSKeyVaultEntry keyVaultEntry, ApplicationVersion applicationVersion, AppState requestedAppState) {
        boolean success = false;
        WebRequest webRequest = WebRequest.getInstance();
        if (keyVaultEntry != null && keyVaultEntry instanceof IOSKeyVaultEntry && applicationVersion != null && requestedAppState != null && webRequest != null) {
            SQSResignerModel model = new SQSResignerModel();

            model.setBucket(getBucketName(applicationVersion));
            model.setApplicationType(keyVaultEntry.getApplicationType());
            model.setFileToSign(applicationVersion.getInstallationFile().getRelativePath());
            model.setDistributionCert(keyVaultEntry.getDistributionCert().getRelativePath());
            model.setDistributionKey((keyVaultEntry).getDistributionKey().getRelativePath());
            model.setDistributionKeyPassword((keyVaultEntry).getDistributionKeyPassword());
            model.setDistributionProfile((keyVaultEntry).getDistributionProfile().getRelativePath());

            NameValuePair requestedAppStateParam = new BasicNameValuePair("appState", requestedAppState.name());
            NameValuePair initiationUserParam = new BasicNameValuePair("user", applicationVersion.getChangedBy());
            model.setCallbackUrl(webRequest.generateURL(String.format("/resigner/webhook/%s", applicationVersion.getId()), requestedAppStateParam, initiationUserParam));

            if (checkAllRequiredFields(model)) {
                success = super.resign(model);
            }
        }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.util.WebRequest

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.