View Javadoc
1   /***************************************************************************
2    * Copyright (C) 2003-2009 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (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 General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   *
17   **************************************************************************/
18  package org.exoplatform.services.cms.taxonomy;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  /**
24   * Created by The eXo Platform SARL Author : Hoang Van Hung hunghvit@gmail.com
25   * Apr 3, 2009
26   */
27  public class TaxonomyTreeData implements Comparable<TaxonomyTreeData> {
28  
29    private String             taxoTreeName;
30  
31    private String             repository;
32  
33    private String             taxoTreeWorkspace;
34  
35    private String             taxoTreePermissions;
36  
37    private String             taxoTreeHomePath;
38  
39    private String             taxoTreeActionName;
40  
41    private String             taxoTreeActionTargetPath;
42  
43    private String             taxoTreeActionTargetWorkspace;
44  
45    private String             taxoTreeActionTypeName;
46  
47    private boolean            edit               = false;
48  
49    public static final String ACTION_TAXONOMY_TREE = "exo:taxonomyAction";
50  
51    public TaxonomyTreeData() {
52  
53    }
54  
55    /**
56     * @return the name of repository
57     */
58    public String getRepository() {
59      return repository;
60    }
61  
62    /**
63     * Register repository to drive
64     *
65     * @param rp repository name
66     */
67    public void setRepository(String rp) {
68      repository = rp;
69    }
70  
71    /**
72     * @return the permissions of drive
73     */
74    public String getPermissions() {
75      return this.taxoTreePermissions;
76    }
77  
78    /**
79     * Check the state of permission is existing or not
80     * @param allPermissions the string array permission of drive
81     * @param permission permission name
82     * @return the state of permission is existing or not.
83     */
84    public boolean hasPermission(String[] allPermissions, String permission) {
85      List<String> permissionList = new ArrayList<String>();
86      for (String per : allPermissions) {
87        permissionList.add(per.trim());
88      }
89      if (permission == null)
90        return false;
91      if (permission.indexOf(":/") > -1) {
92        String[] array = permission.split(":/");
93        if (array == null || array.length < 2)
94          return false;
95        if (permissionList.contains("*:/" + array[1]))
96          return true;
97      }
98      return permissionList.contains(permission);
99    }
100 
101   public int compareTo(TaxonomyTreeData arg) {
102     return taxoTreeName.compareToIgnoreCase(arg.getTaxoTreeName());
103   }
104 
105 
106   /**
107    * Get taxonomy tree home path
108    * @return taxoTreeHomePath
109    */
110   public String getTaxoTreeHomePath() {
111     return taxoTreeHomePath;
112   }
113 
114   /**
115    * Register home path to taxonomy Tree
116    * @param taxoTreeHomePath the home path of drive
117    */
118   public void setTaxoTreeHomePath(String taxoTreeHomePath) {
119     this.taxoTreeHomePath = taxoTreeHomePath;
120   }
121 
122   /**
123    * get taxonomy tree name
124    */
125   public String getTaxoTreeName() {
126     return taxoTreeName;
127   }
128 
129   /**
130    * Register taxonomy tree name
131    * @param taxoTreeName the name of taxonomy tree
132    */
133   public void setTaxoTreeName(String taxoTreeName) {
134     this.taxoTreeName = taxoTreeName;
135   }
136 
137   public String getTaxoTreePermissions() {
138     return taxoTreePermissions;
139   }
140 
141   /**
142    * Register permission to taxonomy tree
143    * @param permission
144    */
145   public void setTaxoTreePermissions(String permission) {
146     this.taxoTreePermissions = permission;
147   }
148 
149   /**
150    * @return the name of workspace
151    */
152   public String getTaxoTreeWorkspace() {
153     return taxoTreeWorkspace;
154   }
155 
156   /**
157    * Register workspace to tree
158    * @param taxoTreeWorkspace the workspace name
159    */
160   public void setTaxoTreeWorkspace(String taxoTreeWorkspace) {
161     this.taxoTreeWorkspace = taxoTreeWorkspace;
162   }
163 
164   /**
165    * Get action name of Taxonomy tree
166    */
167   public String getTaxoTreeActionName() {
168     return taxoTreeActionName;
169   }
170 
171   /**
172    * Set action name of Taxonomy tree
173    * @param taxoTreeActionName
174    */
175   public void setTaxoTreeActionName(String taxoTreeActionName) {
176     this.taxoTreeActionName = taxoTreeActionName;
177   }
178 
179   public String getTaxoTreeActionTypeName() {
180     return taxoTreeActionTypeName;
181   }
182 
183   public void setTaxoTreeActionTypeName(String taxoTreeActionTypeName) {
184     this.taxoTreeActionTypeName = taxoTreeActionTypeName;
185   }
186 
187   /**
188    * Check data in edited state or not
189    */
190   public boolean isEdit() {
191     return edit;
192   }
193 
194   /**
195    * Set edit state
196    * @param edit
197    */
198   public void setEdit(boolean edit) {
199     this.edit = edit;
200   }
201 }