Package com.sparc.knappsack.forms

Examples of com.sparc.knappsack.forms.BatchInvitationForm


        return BatchInvitationForm.class.isAssignableFrom(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        BatchInvitationForm form = (BatchInvitationForm) target;

        User user = userService.getUserFromSecurityContext();
        if (user == null || user.getActiveOrganization() == null) {
            errors.reject("batchInvitationValidator.error.generic");
            return;
        }

        // Check if User Roles are valid
        if (form.getOrganizationUserRole() == null || !UserRole.getAllSelectableForDomainType(DomainType.ORGANIZATION).contains(form.getOrganizationUserRole())) {
            errors.rejectValue(ORGANIZATION_USER_ROLE_FIELD, "batchInvitationValidator.userRole.organization.invalid");
            return;
        } else if (UserRole.ROLE_ORG_GUEST.equals(form.getOrganizationUserRole()) && CollectionUtils.isEmpty(form.getGroupIds())) {
            errors.rejectValue(GROUP_IDS_FIELD, "batchInvitationValidator.orgGuest.groupIds.empty");
        }

        // Validate security
        validateSecurity(errors, form, user);

        if (errors.hasErrors()) {
            return;
        }

        List<Contact> validContacts = new ArrayList<Contact>(); /*List of valid contacts*/
        List<Contact> invalidContacts = new ArrayList<Contact>(); /*List of invalid contacts*/

        for (int index = 0; index < form.getContacts().size(); index++) {
            Contact contact = form.getContacts().get(index);

            Errors contactErrors = new BeanPropertyBindingResult(form, "batchInvitationForm");
            contact.setEmail(trimWhitespace(contact.getEmail()));

            // Validate email
View Full Code Here


            if (contactsOutlook != null && !contactsOutlook.isEmpty()) {
                contacts.addAll(invitationService.parseContactsOutlook(contactsOutlook));
            }

            BatchInvitationForm batchInvitationForm = new BatchInvitationForm();

            Errors errors = new BeanPropertyBindingResult(batchInvitationForm, "batchInvitationForm");
            Set<Contact> validContacts = new HashSet<Contact>();
            for (Contact contact : contacts) {
                boolean isValid = invitationValidator.isValidContact(contact, errors);
                if (isValid) {
                    validContacts.add(contact);
                }
            }

            model.addAttribute("org.springframework.validation.BindingResult.batchInvitationForm", errors);

            batchInvitationForm.getContacts().addAll(new ArrayList<Contact>(validContacts));

            model.addAttribute("batchInvitationForm", batchInvitationForm);
        }

        User user = userService.getUserFromSecurityContext();
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.forms.BatchInvitationForm

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.