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.AccessManager;
019: import org.outerj.daisy.repository.acl.Acl;
020: import org.outerj.daisy.repository.acl.AclResultInfo;
021: import org.outerj.daisy.repository.acl.AclPermission;
022: import org.outerj.daisy.repository.commonimpl.AuthenticatedUser;
023: import org.outerj.daisy.repository.commonimpl.DocId;
024: import org.outerj.daisy.repository.commonimpl.CommonRepository;
025: import org.outerj.daisy.repository.Document;
026: import org.outerj.daisy.repository.RepositoryException;
027: import org.outerj.daisy.repository.VariantKey;
028: import org.outerj.daisy.repository.variant.Branch;
029: import org.outerj.daisy.repository.variant.Language;
030:
031: public class AccessManagerImpl implements AccessManager {
032: private CommonAccessManager delegate;
033: private CommonRepository repository;
034: private AuthenticatedUser user;
035:
036: public AccessManagerImpl(CommonAccessManager delegate,
037: CommonRepository repository, AuthenticatedUser user) {
038: this .delegate = delegate;
039: this .repository = repository;
040: this .user = user;
041: }
042:
043: public Acl getLiveAcl() throws RepositoryException {
044: return delegate.getLiveAcl(user);
045: }
046:
047: public Acl getStagingAcl() throws RepositoryException {
048: return delegate.getStagingAcl(user);
049: }
050:
051: public void copyStagingToLive() throws RepositoryException {
052: delegate.copyStagingToLive(user);
053: }
054:
055: public void copyLiveToStaging() throws RepositoryException {
056: delegate.copyLiveToStaging(user);
057: }
058:
059: public AclResultInfo getAclInfo(Document document)
060: throws RepositoryException {
061: return delegate.getAclInfoOnLive(user, user.getId(), user
062: .getActiveRoleIds(), document);
063: }
064:
065: public AclResultInfo getAclInfoOnLive(long userId, long[] roleIds,
066: String documentId) throws RepositoryException {
067: return getAclInfoOnLive(userId, roleIds, documentId,
068: Branch.MAIN_BRANCH_ID, Language.DEFAULT_LANGUAGE_ID);
069: }
070:
071: public AclResultInfo getAclInfoOnStaging(long userId,
072: long[] roleIds, String documentId)
073: throws RepositoryException {
074: return getAclInfoOnStaging(userId, roleIds, documentId,
075: Branch.MAIN_BRANCH_ID, Language.DEFAULT_LANGUAGE_ID);
076: }
077:
078: public AclResultInfo getAclInfoOnLive(long userId, long[] roleIds,
079: String documentId, long branchId, long languageId)
080: throws RepositoryException {
081: DocId docId = DocId.parseDocIdThrowNotFound(documentId,
082: repository);
083: return delegate.getAclInfoOnLive(user, userId, roleIds, docId,
084: branchId, languageId);
085: }
086:
087: public AclResultInfo getAclInfoOnLive(long userId, long[] roleIds,
088: VariantKey key) throws RepositoryException {
089: return getAclInfoOnLive(userId, roleIds, key.getDocumentId(),
090: key.getBranchId(), key.getLanguageId());
091: }
092:
093: public AclResultInfo getAclInfoOnStaging(long userId,
094: long[] roleIds, String documentId, long branchId,
095: long languageId) throws RepositoryException {
096: DocId docId = DocId.parseDocIdThrowNotFound(documentId,
097: repository);
098: return delegate.getAclInfoOnStaging(user, userId, roleIds,
099: docId, branchId, languageId);
100: }
101:
102: public AclResultInfo getAclInfoOnStaging(long userId,
103: long[] roleIds, VariantKey key) throws RepositoryException {
104: return getAclInfoOnStaging(userId, roleIds,
105: key.getDocumentId(), key.getBranchId(), key
106: .getLanguageId());
107: }
108:
109: public AclResultInfo getAclInfoOnLive(long userId, long[] roleIds,
110: Document document) throws RepositoryException {
111: return delegate.getAclInfoOnLive(user, userId, roleIds,
112: document);
113: }
114:
115: public AclResultInfo getAclInfoOnStaging(long userId,
116: long[] roleIds, Document document)
117: throws RepositoryException {
118: return delegate.getAclInfoOnStaging(user, userId, roleIds,
119: document);
120: }
121:
122: public long[] filterDocumentTypes(long[] documentTypeIds,
123: long collectionId) throws RepositoryException {
124: return delegate.filterDocumentTypes(user, documentTypeIds,
125: collectionId);
126: }
127:
128: public VariantKey[] filterDocuments(VariantKey[] variantKeys)
129: throws RepositoryException {
130: return delegate.filterDocuments(user, variantKeys,
131: AclPermission.READ, false);
132: }
133:
134: public VariantKey[] filterDocuments(VariantKey[] variantKeys,
135: AclPermission permission, boolean nonLive)
136: throws RepositoryException {
137: return delegate.filterDocuments(user, variantKeys, permission,
138: nonLive);
139: }
140:
141: public VariantKey[] filterDocuments(VariantKey[] variantKeys,
142: AclPermission permission) throws RepositoryException {
143: return delegate.filterDocuments(user, variantKeys, permission,
144: false);
145: }
146: }
|