001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.content;
034:
035: import org.apache.commons.lang.ArrayUtils;
036:
037: import java.io.Serializable;
038: import java.util.Arrays;
039: import java.util.Collections;
040: import java.util.List;
041:
042: /**
043: * Security related information about a content (primary key)
044: *
045: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046: */
047: public class FxContentSecurityInfo implements Serializable {
048:
049: private static final long serialVersionUID = -5140606563012031397L;
050:
051: /**
052: * Primary key this info relates to
053: */
054: private FxPK pk;
055:
056: /**
057: * user id of the owner of the content
058: */
059: private long ownerId;
060:
061: /**
062: * Id of preview image, only relevant for security if > 0
063: */
064: private long previewId;
065:
066: /**
067: * Id of the FxType used
068: */
069: private long typeId;
070:
071: /**
072: * Id of the mandator this content belongs to
073: */
074: private long mandatorId;
075:
076: /**
077: * binary encoded type permissions
078: */
079: private byte permissions;
080:
081: /**
082: * ACL assigned to the type
083: */
084: private int typeACL;
085:
086: /**
087: * ACL of the used step
088: */
089: private int stepACL;
090:
091: /**
092: * ACL of the content itself
093: */
094: private int contentACL;
095:
096: /**
097: * Property ACL of the preview, only relevant for security if <code>previewId</code> > 0
098: */
099: private int previewACL;
100:
101: /**
102: * All used and relevant property ACL's. will be empty if property permissions are disabled for
103: * the type
104: */
105: private List<Long> usedPropertyACL;
106:
107: /**
108: * Constructor
109: *
110: * @param pk the primary key this info relates to
111: * @param ownerId owner of the content
112: * @param previewId Id of preview image, only relevant for security if > 0
113: * @param typeId id of the used type
114: * @param mandatorId id of the mandator
115: * @param typePermissions byte encoded type permission handling
116: * @param typeACL ACL of the type
117: * @param stepACL ACL of the step
118: * @param contentACL ACL of the content instance
119: * @param previewACL Property ACL of the preview, only relevant for security if <code>previewId</code> > 0
120: * @param usedPropertyACL relevant property ACL's
121: */
122: public FxContentSecurityInfo(FxPK pk, long ownerId, long previewId,
123: long typeId, long mandatorId, byte typePermissions,
124: int typeACL, int stepACL, int contentACL, int previewACL,
125: long[] usedPropertyACL) {
126: this .pk = pk;
127: this .ownerId = ownerId;
128: this .previewId = previewId;
129: this .typeId = typeId;
130: this .mandatorId = mandatorId;
131: this .permissions = typePermissions;
132: this .typeACL = typeACL;
133: this .stepACL = stepACL;
134: this .contentACL = contentACL;
135: this .previewACL = previewACL;
136: this .usedPropertyACL = Collections.unmodifiableList(Arrays
137: .asList(ArrayUtils.toObject(usedPropertyACL)));
138: }
139:
140: /**
141: * Get the primary key of the content instance this info relates to
142: *
143: * @return primary key of the content instance this info relates to
144: */
145: public FxPK getPk() {
146: return pk;
147: }
148:
149: /**
150: * Get the owner of the content
151: *
152: * @return owner of the content
153: */
154: public long getOwnerId() {
155: return ownerId;
156: }
157:
158: /**
159: * Getter for the used type id
160: *
161: * @return used type id
162: */
163: public long getTypeId() {
164: return typeId;
165: }
166:
167: /**
168: * Get the id of the mandator
169: *
170: * @return mandator id
171: */
172: public long getMandatorId() {
173: return mandatorId;
174: }
175:
176: /**
177: * Get the ACL of the type
178: *
179: * @return ACL of the type
180: */
181: public int getTypeACL() {
182: return typeACL;
183: }
184:
185: /**
186: * Get the ACL of the step
187: *
188: * @return ACL of the step
189: */
190: public int getStepACL() {
191: return stepACL;
192: }
193:
194: /**
195: * Get the ACL of the content instance
196: *
197: * @return ACL of the content instance
198: */
199: public int getContentACL() {
200: return contentACL;
201: }
202:
203: /**
204: * Get all used and relevant property ACL's. will be empty if property permissions are disabled for
205: * the type
206: *
207: * @return relevant property ACL's
208: */
209: public List<Long> getUsedPropertyACL() {
210: return usedPropertyACL;
211: }
212:
213: /**
214: * Use permissions at all?
215: *
216: * @return if permissions are used at all
217: */
218: public boolean usePermissions() {
219: return permissions != 0;
220: }
221:
222: /**
223: * Get the binary id of the preview
224: *
225: * @return binary id of the preview
226: */
227: public long getPreviewId() {
228: return previewId;
229: }
230:
231: /**
232: *
233: * @return
234: */
235: public int getPreviewACL() {
236: return previewACL;
237: }
238:
239: /**
240: * Use content instance permissions?
241: *
242: * @return if content instance permissions are used
243: */
244: public boolean useInstancePermissions() {
245: return (permissions & FxPermissionUtils.PERM_MASK_INSTANCE) == FxPermissionUtils.PERM_MASK_INSTANCE;
246: }
247:
248: /**
249: * Use property permissions?
250: *
251: * @return if property permissions are used
252: */
253: public boolean usePropertyPermissions() {
254: return (permissions & FxPermissionUtils.PERM_MASK_PROPERTY) == FxPermissionUtils.PERM_MASK_PROPERTY;
255: }
256:
257: /**
258: * Use step permissions?
259: *
260: * @return if step permissions are used
261: */
262: public boolean useStepPermissions() {
263: return (permissions & FxPermissionUtils.PERM_MASK_STEP) == FxPermissionUtils.PERM_MASK_STEP;
264: }
265:
266: /**
267: * Use type permissions?
268: *
269: * @return if type permissions are used
270: */
271: public boolean useTypePermissions() {
272: return (permissions & FxPermissionUtils.PERM_MASK_TYPE) == FxPermissionUtils.PERM_MASK_TYPE;
273: }
274: }
|