001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.security.auth;
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 GROUP_MEMBERSHIP_NOT_ALLOWED = 1;
033    
034            public static final int GROUP_MEMBERSHIP_REQUIRED = 2;
035    
036            public static final int ORGANIZATION_MEMBERSHIP_NOT_ALLOWED = 3;
037    
038            public static final int ORGANIZATION_MEMBERSHIP_REQUIRED = 4;
039    
040            public static final int ROLE_MEMBERSHIP_NOT_ALLOWED = 5;
041    
042            public static final int ROLE_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 static final int USER_MEMBERSHIP_NOT_ALLOWED = 9;
049    
050            public static final int USER_MEMBERSHIP_REQUIRED = 10;
051    
052            public MembershipPolicyException(int type) {
053                    _type = type;
054            }
055    
056            public void addGroup(Group group) {
057                    _groups.add(group);
058            }
059    
060            public void addOrganization(Organization organization) {
061                    _organizations.add(organization);
062            }
063    
064            public void addRole(Role role) {
065                    _roles.add(role);
066            }
067    
068            public void addUser(User user) {
069                    _users.add(user);
070            }
071    
072            public void addUserGroup(UserGroup userGroup) {
073                    _userGroups.add(userGroup);
074            }
075    
076            public List<Group> getGroups() {
077                    return _groups;
078            }
079    
080            public List<Organization> getOrganizations() {
081                    return _organizations;
082            }
083    
084            public List<Role> getRoles() {
085                    return _roles;
086            }
087    
088            public int getType() {
089                    return _type;
090            }
091    
092            public List<UserGroup> getUserGroups() {
093                    return _userGroups;
094            }
095    
096            public List<User> getUsers() {
097                    return _users;
098            }
099    
100            private List<Group> _groups = new ArrayList<Group>();
101            private List<Organization> _organizations = new ArrayList<Organization>();
102            private List<Role> _roles = new ArrayList<Role>();
103            private int _type;
104            private List<UserGroup> _userGroups = new ArrayList<UserGroup>();
105            private List<User> _users = new ArrayList<User>();
106    
107    }