View Javadoc
1   /*
2    * Copyright (C) 2003-2013 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero General Public License
15   * along with this program. If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.core.bean;
18  
19  import org.exoplatform.services.jcr.access.PermissionType;
20  
21  /**
22   * Created by The eXo Platform SAS
23   * Author : eXoPlatform
24   *          vuna@exoplatform.com
25   * Mar 23, 2013  
26   */
27  public class PermissionBean {
28  
29    private String usersOrGroups ;
30    private boolean read ;
31    private boolean addNode ;
32    private boolean remove ;
33  
34    public String getUsersOrGroups() { return usersOrGroups ; }
35    public void setUsersOrGroups(String s) { usersOrGroups = s ; }
36  
37    public boolean isAddNode() { return addNode ; }
38    public void setAddNode(boolean b) { addNode = b ; }
39  
40    public boolean isRead() { return read ; }
41    public void setRead(boolean b) { read = b ; }
42  
43    public boolean isRemove() { return remove ; }
44    public void setRemove(boolean b) { remove = b ; }
45    
46    /* (non-Javadoc)
47     * @see java.lang.Object#equals(java.lang.Object)
48     */
49    @Override
50    public boolean equals(Object obj) {
51      // TODO Auto-generated method stub
52      return this.usersOrGroups.equals(((PermissionBean)obj).usersOrGroups);
53    }
54    
55    public void setPermissions(String[] permArray) {
56      if (permArray == null) return;
57      for (String entry : permArray) {
58        if (PermissionType.READ.equals(entry)) this.setRead(true);
59        if (PermissionType.REMOVE.equals(entry)) this.setRemove(true);
60        if (PermissionType.ADD_NODE.equals(entry)) this.setAddNode(true);
61      }
62    }
63    
64    @Override
65    public int hashCode() {
66      return this.usersOrGroups.hashCode();
67    }
68  }