01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/api-impl/src/java/org/theospi/portfolio/presentation/model/impl/LayoutHttpAccess.java $
03: * $Id:LayoutHttpAccess.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.presentation.model.impl;
21:
22: import org.sakaiproject.content.api.ContentHostingService;
23: import org.sakaiproject.entity.api.EntityAccessOverloadException;
24: import org.sakaiproject.entity.api.EntityCopyrightException;
25: import org.sakaiproject.entity.api.EntityNotDefinedException;
26: import org.sakaiproject.entity.api.EntityPermissionException;
27: import org.sakaiproject.entity.api.Reference;
28: import org.sakaiproject.metaobj.shared.mgt.IdManager;
29: import org.sakaiproject.metaobj.shared.mgt.ReferenceParser;
30: import org.sakaiproject.tool.cover.SessionManager;
31: import org.theospi.portfolio.presentation.PresentationManager;
32: import org.theospi.portfolio.presentation.model.PresentationLayout;
33: import org.theospi.portfolio.security.AuthorizationFailedException;
34: import org.theospi.portfolio.security.mgt.OspHttpAccessBase;
35: import org.theospi.portfolio.shared.model.Node;
36:
37: /**
38: * Created by IntelliJ IDEA.
39: * User: John Ellis
40: * Date: Jan 8, 2006
41: * Time: 4:54:50 PM
42: * To change this template use File | Settings | File Templates.
43: */
44: public class LayoutHttpAccess extends OspHttpAccessBase {
45:
46: private PresentationManager presentationManager;
47: private IdManager idManager;
48:
49: protected void checkSource(Reference ref, ReferenceParser parser)
50: throws EntityPermissionException,
51: EntityNotDefinedException, EntityAccessOverloadException,
52: EntityCopyrightException {
53: try {
54: PresentationLayout layout = presentationManager
55: .getPresentationLayout(getIdManager().getId(
56: parser.getId()));
57: if (layout == null) {
58: throw new EntityNotDefinedException(parser.getId());
59: } else {
60: Node node = getPresentationManager().getNode(
61: layout.getPreviewImageId(), layout);
62: }
63: } catch (AuthorizationFailedException exp) {
64: throw new EntityPermissionException(SessionManager
65: .getCurrentSessionUserId(),
66: ContentHostingService.EVENT_RESOURCE_READ, ref
67: .getReference());
68: }
69: }
70:
71: public PresentationManager getPresentationManager() {
72: return presentationManager;
73: }
74:
75: public void setPresentationManager(
76: PresentationManager presentationManager) {
77: this .presentationManager = presentationManager;
78: }
79:
80: public IdManager getIdManager() {
81: return idManager;
82: }
83:
84: public void setIdManager(IdManager idManager) {
85: this.idManager = idManager;
86: }
87: }
|