Package utils

Examples of utils.ValidationResult


public class EnrollOrganizationApp extends Controller {

    @Transactional
    public static Result enroll(String organizationName) {
        ValidationResult result = validateForEnroll(organizationName);
        if (result.hasError()) {
            return result.getResult();
        }

        Organization organization = Organization.findByName(organizationName);
        if (!User.enrolled(organization)) {
            User user = UserApp.currentUser();
View Full Code Here


    }

    private static ValidationResult validateForEnroll(String organizationName) {
        Organization organization = Organization.findByName(organizationName);
        if (organization == null) {
            return new ValidationResult(badRequest(), true);
        }

        User user = UserApp.currentUser();
        if (!OrganizationUser.isGuest(organization, user)) {
            return new ValidationResult(badRequest(), true);
        }

        return new ValidationResult(null, false);
    }
View Full Code Here

        return new ValidationResult(null, false);
    }

    @Transactional
    public static Result cancelEnroll(String organizationName) {
        ValidationResult result = validateForCancelEnroll(organizationName);
        if (result.hasError()) {
            return result.getResult();
        }

        Organization organization = Organization.findByName(organizationName);
        if (User.enrolled(organization)) {
            User user = UserApp.currentUser();
View Full Code Here

    }

    private static ValidationResult validateForCancelEnroll(String organizationName) {
        Organization organization = Organization.findByName(organizationName);
        if (organization == null) {
            return new ValidationResult(badRequest(), true);
        }

        User user = UserApp.currentUser();
        if (!OrganizationUser.isGuest(organization, user)) {
            return new ValidationResult(badRequest(), true);
        }

        return new ValidationResult(null, false);
    }
View Full Code Here

    }

    @Transactional
    @With(AnonymousCheckAction.class)
    public static Result leave(String organizationName) {
        ValidationResult result = validateForLeave(organizationName);

        if (!result.hasError()) {
            OrganizationUser.delete(Organization.findByName(organizationName).id, UserApp.currentUser().id);
        }

        return result.getResult();
    }
View Full Code Here

    public static ValidationResult validateForLeave(String organizationName) {
        Organization organization = Organization.findByName(organizationName);

        if (organization == null) {
            return new ValidationResult(notFound(getJsonErrorMsg("organization.member.unknownOrganization")), true);
        }

        if (OrganizationUser.isAdmin(organization.id, UserApp.currentUser().id)) {
            if (OrganizationUser.findAdminsOf(organization).size() == 1) {
                return new ValidationResult(forbidden(getJsonErrorMsg("organization.member.atLeastOneAdmin")), true);
            }
        }

        return new ValidationResult(okWithLocation(routes.OrganizationApp.organization(organizationName).url()), false);
    }
View Full Code Here

        Form<Project> filledNewProjectForm = form(Project.class).bindFromRequest();
        String owner = filledNewProjectForm.field("owner").value();
        Organization organization = Organization.findByName(owner);
        User user = User.findByLoginId(owner);

        ValidationResult result = validateForm(filledNewProjectForm, organization, user);
        if (result.hasError()) {
            return result.getResult();
        }

        String gitUrl = filledNewProjectForm.data().get("url");
        Project project = filledNewProjectForm.get();
View Full Code Here

            newProjectForm.reject("name", "project.name.alert");
            hasError = true;
            result = badRequest(importing.render("title.newProject", newProjectForm, orgUserList));
        }

        return new ValidationResult(result, hasError);
    }
View Full Code Here

TOP

Related Classes of utils.ValidationResult

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.