001: /*
002: * Copyright 2004 Outerthought bvba and Schaubroeck nv
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.outerj.daisy.repository.commonimpl.acl;
017:
018: import org.outerj.daisy.repository.acl.Acl;
019: import org.outerj.daisy.repository.acl.AclResultInfo;
020: import org.outerj.daisy.repository.acl.AclPermission;
021: import org.outerj.daisy.repository.Document;
022: import org.outerj.daisy.repository.RepositoryException;
023: import org.outerj.daisy.repository.VariantKey;
024: import org.outerj.daisy.repository.commonimpl.AuthenticatedUser;
025: import org.outerj.daisy.repository.commonimpl.DocId;
026:
027: /**
028: * Provides support for classes providing
029: * {@link org.outerj.daisy.repository.acl.AccessManager AccessManager} functionality.
030: *
031: * <p>Most methods in this class correspond to the methods in
032: * {@link org.outerj.daisy.repository.acl.AccessManager AccessManager}, but take
033: * an additonal User argument. So check the javadoc over there for explanations of
034: * these methods.
035: */
036: public class CommonAccessManager {
037: private AclStrategy aclStrategy;
038:
039: public CommonAccessManager(AclStrategy aclStrategy) {
040: this .aclStrategy = aclStrategy;
041: }
042:
043: public Acl getLiveAcl(AuthenticatedUser user)
044: throws RepositoryException {
045: AclImpl acl = aclStrategy
046: .loadAcl(AclStrategy.LIVE_ACL_ID, user);
047: acl.makeReadOnly();
048: return acl;
049: }
050:
051: public Acl getStagingAcl(AuthenticatedUser user)
052: throws RepositoryException {
053: return aclStrategy.loadAcl(AclStrategy.STAGING_ACL_ID, user);
054: }
055:
056: public void copyStagingToLive(AuthenticatedUser user)
057: throws RepositoryException {
058: aclStrategy.copyStagingToLive(user);
059: }
060:
061: public void copyLiveToStaging(AuthenticatedUser user)
062: throws RepositoryException {
063: aclStrategy.copyLiveToStaging(user);
064: }
065:
066: public AclResultInfo getAclInfoOnLive(AuthenticatedUser user,
067: long userId, long[] roleIds, DocId docId, long branchId,
068: long languageId) throws RepositoryException {
069: return aclStrategy.getAclInfo(user, AclStrategy.LIVE_ACL_ID,
070: userId, roleIds, docId, branchId, languageId);
071: }
072:
073: public AclResultInfo getAclInfoOnStaging(AuthenticatedUser user,
074: long userId, long[] roleIds, DocId docId, long branchId,
075: long languageId) throws RepositoryException {
076: return aclStrategy.getAclInfo(user, AclStrategy.STAGING_ACL_ID,
077: userId, roleIds, docId, branchId, languageId);
078: }
079:
080: public AclResultInfo getAclInfoOnLive(AuthenticatedUser user,
081: long userId, long[] roleIds, Document document)
082: throws RepositoryException {
083: return aclStrategy.getAclInfo(user, AclStrategy.LIVE_ACL_ID,
084: userId, roleIds, document);
085: }
086:
087: public AclResultInfo getAclInfoOnStaging(AuthenticatedUser user,
088: long userId, long[] roleIds, Document document)
089: throws RepositoryException {
090: return aclStrategy.getAclInfo(user, AclStrategy.STAGING_ACL_ID,
091: userId, roleIds, document);
092: }
093:
094: public long[] filterDocumentTypes(AuthenticatedUser user,
095: long[] documentTypeIds, long collectionId)
096: throws RepositoryException {
097: return aclStrategy.filterDocumentTypes(user, documentTypeIds,
098: collectionId);
099: }
100:
101: public VariantKey[] filterDocuments(AuthenticatedUser user,
102: VariantKey[] variantKeys, AclPermission permision,
103: boolean nonLive) throws RepositoryException {
104: return aclStrategy.filterDocuments(user, variantKeys,
105: permision, nonLive);
106: }
107: }
|