Package models

Examples of models.Organization


        validate(newOrgForm);
        if (newOrgForm.hasErrors()) {
            flash(Constants.WARNING, newOrgForm.error("name").message());
            return badRequest(create.render("title.newOrganization", newOrgForm));
        } else {
            Organization org = newOrgForm.get();
            org.created = new Date();
            org.save();

            UserApp.currentUser().createOrganization(org);
            return redirect(routes.OrganizationApp.organization(org.name));
        }
    }
View Full Code Here


     * show specific group's main page
     * @param organizationName group name
     * @return {@link Result}
     */
    public static Result organization(String organizationName) {
        Organization org = Organization.findByName(organizationName);
        if (org == null) {
            return notFound(ErrorViews.NotFound.render("error.notfound.organization"));
        }
        return ok(view.render(org));
    }
View Full Code Here

        if (result != null) {
            return result;
        }

        User user = User.findByLoginId(addMemberForm.get().loginId);
        Organization organization = Organization.findByName(organizationName);
        OrganizationUser.assignRole(user.id, organization.id, RoleType.ORG_MEMBER.roleType());
        organization.cleanEnrolledUsers();
        NotificationEvent.afterOrganizationMemberRequest(organization, user, RequestState.ACCEPT);

        return redirect(routes.OrganizationApp.members(organizationName));
    }
View Full Code Here

        if (addMemberForm.hasErrors() || userToBeAdded.isAnonymous()) {
            flash(Constants.WARNING, "organization.member.unknownUser");
            return redirect(routes.OrganizationApp.members(organizationName));
        }

        Organization organization = Organization.findByName(organizationName);
        if (organization == null) {
            flash(Constants.WARNING, "organization.member.unknownOrganization");
            return redirect(routes.OrganizationApp.members(organizationName));
        }
View Full Code Here

        Result result = validateForDeleteMember(organizationName, userId);
        if (result != null) {
            return result;
        }

        Organization organization = Organization.findByName(organizationName);
        OrganizationUser.delete(organization.id, userId);

        if (UserApp.currentUser().id.equals(userId)) {
            return okWithLocation(routes.OrganizationApp.organization(organizationName).url());
        } else {
View Full Code Here

            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }
    }

    private static Result validateForDeleteMember(String organizationName, Long userId) {
        Organization organization = Organization.findByName(organizationName);
        if (organization == null) {
            return notFound(ErrorViews.NotFound.render("organization.member.unknownOrganization", organization));
        }

        if (!OrganizationUser.exist(organization.id, userId)) {
            flash(Constants.WARNING, "organization.member.isNotAMember");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }

        User currentUser = UserApp.currentUser();
        if (!AccessControl.isAllowed(currentUser, organization.asResource(), Operation.UPDATE)
                && !currentUser.id.equals(userId)) {
            flash(Constants.WARNING, "organization.member.needManagerRole");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }

        if (OrganizationUser.isAdmin(organization.id, userId) && organization.getAdmins().size() == 1) {
            flash(Constants.WARNING, "organization.member.atLeastOneAdmin");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }

        return null;
View Full Code Here

        Result result = validateForEditMember(roleForm, organizationName, userId);
        if (result != null) {
            return result;
        }

        Organization organization = Organization.findByName(organizationName);
        OrganizationUser.assignRole(userId, organization.id, roleForm.get().id);

        return status(Http.Status.NO_CONTENT);
    }
View Full Code Here

        if (roleForm.hasErrors()) {
            flash(Constants.WARNING, "organization.member.unknownRole");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }

        Organization organization = Organization.findByName(organizationName);
        if (organization == null) {
            return notFound(ErrorViews.NotFound.render("organization.member.unknownOrganization", organization));
        }

        if (!OrganizationUser.exist(organization.id, userId)) {
            flash(Constants.WARNING, "organization.member.isNotAMember");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }

        User currentUser = UserApp.currentUser();
        if (!AccessControl.isAllowed(currentUser, organization.asResource(), Operation.UPDATE)) {
            flash(Constants.WARNING, "organization.member.needManagerRole");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }
        if (OrganizationUser.isAdmin(organization.id, userId) && organization.getAdmins().size() == 1) {
            flash(Constants.WARNING, "organization.member.atLeastOneAdmin");
            return okWithLocation(routes.OrganizationApp.members(organizationName).url());
        }

        return null;
View Full Code Here

        return result.getResult();
    }

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

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

        Result result = validateForSetting(organizationName);
        if (result != null) {
            return result;
        }

        Organization organization = Organization.findByName(organizationName);

        return ok(members.render(organization, Role.findOrganizationRoles()));
    }
View Full Code Here

TOP

Related Classes of models.Organization

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.