001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.security.membershippolicy;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.model.Group;
019    import com.liferay.portal.model.Organization;
020    import com.liferay.portal.model.Role;
021    import com.liferay.portal.model.User;
022    import com.liferay.portal.model.UserGroup;
023    
024    import java.util.ArrayList;
025    import java.util.List;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class MembershipPolicyException extends PortalException {
031    
032            public static final int ORGANIZATION_MEMBERSHIP_NOT_ALLOWED = 1;
033    
034            public static final int ORGANIZATION_MEMBERSHIP_REQUIRED = 2;
035    
036            public static final int ROLE_MEMBERSHIP_NOT_ALLOWED = 3;
037    
038            public static final int ROLE_MEMBERSHIP_REQUIRED = 4;
039    
040            public static final int SITE_MEMBERSHIP_NOT_ALLOWED = 5;
041    
042            public static final int SITE_MEMBERSHIP_REQUIRED = 6;
043    
044            public static final int USER_GROUP_MEMBERSHIP_NOT_ALLOWED = 7;
045    
046            public static final int USER_GROUP_MEMBERSHIP_REQUIRED = 8;
047    
048            public MembershipPolicyException(int type) {
049                    _type = type;
050            }
051    
052            public void addGroup(Group group) {
053                    _groups.add(group);
054            }
055    
056            public void addOrganization(Organization organization) {
057                    _organizations.add(organization);
058            }
059    
060            public void addRole(Role role) {
061                    _roles.add(role);
062            }
063    
064            public void addUser(User user) {
065                    _users.add(user);
066            }
067    
068            public void addUserGroup(UserGroup userGroup) {
069                    _userGroups.add(userGroup);
070            }
071    
072            public List<Group> getGroups() {
073                    return _groups;
074            }
075    
076            public List<Organization> getOrganizations() {
077                    return _organizations;
078            }
079    
080            public List<Role> getRoles() {
081                    return _roles;
082            }
083    
084            public int getType() {
085                    return _type;
086            }
087    
088            public List<UserGroup> getUserGroups() {
089                    return _userGroups;
090            }
091    
092            public List<User> getUsers() {
093                    return _users;
094            }
095    
096            private List<Group> _groups = new ArrayList<Group>();
097            private List<Organization> _organizations = new ArrayList<Organization>();
098            private List<Role> _roles = new ArrayList<Role>();
099            private int _type;
100            private List<UserGroup> _userGroups = new ArrayList<UserGroup>();
101            private List<User> _users = new ArrayList<User>();
102    
103    }