1    /*
2     * Copyright 2008 :torweg free software group
3     * 
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU 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 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.torweg.pulse.component.core.accesscontrol.admin;
19   
20   import org.jdom.Element;
21   import org.torweg.pulse.accesscontrol.AbstractAccessControlObject;
22   import org.torweg.pulse.accesscontrol.CommandMatcher;
23   import org.torweg.pulse.accesscontrol.Group;
24   import org.torweg.pulse.accesscontrol.Permission;
25   import org.torweg.pulse.accesscontrol.User;
26   import org.torweg.pulse.accesscontrol.attributes.AbstractAttribute;
27   import org.torweg.pulse.accesscontrol.attributes.AbstractValue;
28   import org.torweg.pulse.bundle.Result;
29   
30   /**
31    * the {@code Result} of the {@code AccessControlEditor}.
32    * <p>
33    * Used to initialize the WEST-Panel within the <em>pulse</em>
34    * -web-site-administration.
35    * </p>
36    * 
37    * @author Daniel Dietz
38    * @version $Revision: 1809 $
39    */
40   public class AccessControlEditorResult implements Result {
41   
42       /**
43        * the user.
44        */
45       private User user;
46   
47       /**
48        * the role.
49        */
50       private AbstractAccessControlObject role;
51   
52       /**
53        * the group.
54        */
55       private Group group;
56   
57       /**
58        * the attribute.
59        */
60       private AbstractAttribute<?> attribute;
61   
62       /**
63        * the attributevalue.
64        */
65       private AbstractValue<?> attributeValue;
66   
67       /**
68        * the commandMatcher.
69        */
70       private CommandMatcher commandMatcher;
71   
72       /**
73        * the permission.
74        */
75       private Permission permission;
76   
77       /**
78        * @see org.torweg.pulse.bundle.JDOMable#deserializeToJDOM()
79        * @return the {@code Result} of the {@code AccessControlEditor}s
80        *         as {@code Element}
81        */
82       public final Element deserializeToJDOM() {
83           Element result = new Element("result").setAttribute("class", this
84                   .getClass().getCanonicalName());
85           if (this.user != null) {
86               result.addContent(user.deserializeToJDOM());
87           }
88           if (this.role != null) {
89               result.addContent(role.deserializeToJDOM());
90           }
91           if (this.group != null) {
92               result.addContent(group.deserializeToJDOM());
93           }
94           if (this.commandMatcher != null) {
95               result.addContent(commandMatcher.deserializeToJDOM());
96           }
97           if (this.permission != null) {
98               result.addContent(permission.deserializeToJDOM());
99           }
100          if (this.attribute != null) {
101              result.addContent(this.attribute.deserializeToJDOM());
102          }
103          if (this.attributeValue != null) {
104              result.addContent(this.attributeValue.deserializeToJDOM());
105          }
106          return result;
107      }
108  
109      /**
110       * sets the {@code User} for the result.
111       * 
112       * @param u
113       *            the user
114       */
115      public final void setUser(final User u) {
116          this.user = u;
117      }
118  
119      /**
120       * sets the {@code Role} for the result.
121       * 
122       * @param r
123       *            the role
124       */
125      public final void setRole(final AbstractAccessControlObject r) {
126          this.role = r;
127      }
128  
129      /**
130       * sets the {@code Group} for the result.
131       * 
132       * @param g
133       *            the group
134       */
135      public final void setGroup(final Group g) {
136          this.group = g;
137      }
138  
139      /**
140       * sets the {@code CommmandMatcher} for the result.
141       * 
142       * @param cm
143       *            the commandMatcher
144       */
145      public final void setCommmandMatcher(final CommandMatcher cm) {
146          this.commandMatcher = cm;
147      }
148  
149      /**
150       * sets the {@code Permission} for the result.
151       * 
152       * @param p
153       *            the permission
154       */
155      public final void setPermission(final Permission p) {
156          this.permission = p;
157      }
158  
159      /**
160       * sets the attribute for the result.
161       * 
162       * @param attr
163       *            the attribute to set
164       */
165      public final void setAttribute(final AbstractAttribute<?> attr) {
166          this.attribute = attr;
167      }
168  
169      /**
170       * sets the value for the result.
171       * 
172       * @param val
173       *            the value to set
174       */
175      public final void setAttributeValue(final AbstractValue<?> val) {
176          this.attributeValue = val;
177      }
178  
179  }
180