001    /**
002     * Copyright (c) 2000-2013 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.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    }