KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > commonimpl > acl > CommonAccessManager


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.repository.commonimpl.acl;
17
18 import org.outerj.daisy.repository.acl.Acl;
19 import org.outerj.daisy.repository.acl.AclResultInfo;
20 import org.outerj.daisy.repository.acl.AclPermission;
21 import org.outerj.daisy.repository.Document;
22 import org.outerj.daisy.repository.RepositoryException;
23 import org.outerj.daisy.repository.VariantKey;
24 import org.outerj.daisy.repository.commonimpl.AuthenticatedUser;
25
26 /**
27  * Provides support for classes providing
28  * {@link org.outerj.daisy.repository.acl.AccessManager AccessManager} functionality.
29  *
30  * <p>Most methods in this class correspond to the methods in
31  * {@link org.outerj.daisy.repository.acl.AccessManager AccessManager}, but take
32  * an additonal User argument. So check the javadoc over there for explanations of
33  * these methods.
34  */

35 public class CommonAccessManager {
36     private AclStrategy aclStrategy;
37
38     public CommonAccessManager(AclStrategy aclStrategy) {
39         this.aclStrategy = aclStrategy;
40     }
41
42     public Acl getLiveAcl(AuthenticatedUser user) throws RepositoryException {
43         AclImpl acl = aclStrategy.loadAcl(AclStrategy.LIVE_ACL_ID, user);
44         acl.makeReadOnly();
45         return acl;
46     }
47
48     public Acl getStagingAcl(AuthenticatedUser user) throws RepositoryException {
49         return aclStrategy.loadAcl(AclStrategy.STAGING_ACL_ID, user);
50     }
51
52     public void copyStagingToLive(AuthenticatedUser user) throws RepositoryException {
53         aclStrategy.copyStagingToLive(user);
54     }
55
56     public void copyLiveToStaging(AuthenticatedUser user) throws RepositoryException {
57         aclStrategy.copyLiveToStaging(user);
58     }
59
60     public AclResultInfo getAclInfoOnLive(AuthenticatedUser user, long userId, long[] roleIds, long documentId, long branchId, long languageId) throws RepositoryException {
61         return aclStrategy.getAclInfo(user, AclStrategy.LIVE_ACL_ID, userId, roleIds, documentId, branchId, languageId);
62     }
63
64     public AclResultInfo getAclInfoOnStaging(AuthenticatedUser user, long userId, long[] roleIds, long documentId, long branchId, long languageId) throws RepositoryException {
65         return aclStrategy.getAclInfo(user, AclStrategy.STAGING_ACL_ID, userId, roleIds, documentId, branchId, languageId);
66     }
67
68     public AclResultInfo getAclInfoOnLive(AuthenticatedUser user, long userId, long[] roleIds, Document document) throws RepositoryException {
69         return aclStrategy.getAclInfo(user, AclStrategy.LIVE_ACL_ID, userId, roleIds, document);
70     }
71
72     public AclResultInfo getAclInfoOnStaging(AuthenticatedUser user, long userId, long[] roleIds, Document document) throws RepositoryException {
73         return aclStrategy.getAclInfo(user, AclStrategy.STAGING_ACL_ID, userId, roleIds, document);
74     }
75
76     public long[] filterDocumentTypes(AuthenticatedUser user, long[] documentTypeIds, long collectionId) throws RepositoryException {
77         return aclStrategy.filterDocumentTypes(user, documentTypeIds, collectionId);
78     }
79
80     public VariantKey[] filterDocuments(AuthenticatedUser user, VariantKey[] variantKeys, AclPermission permision) throws RepositoryException {
81         return aclStrategy.filterDocuments(user, variantKeys, permision);
82     }
83 }
84
Popular Tags