01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-api/api/src/java/org/sakaiproject/metaobj/shared/mgt/HttpAccessBase.java $
03: * $Id: HttpAccessBase.java 12728 2006-07-24 17:25:59Z john.ellis@rsmart.com $
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.sakaiproject.metaobj.shared.mgt;
21:
22: import java.util.Collection;
23:
24: import javax.servlet.http.HttpServletRequest;
25: import javax.servlet.http.HttpServletResponse;
26:
27: import org.sakaiproject.entity.api.EntityAccessOverloadException;
28: import org.sakaiproject.entity.api.EntityCopyrightException;
29: import org.sakaiproject.entity.api.EntityNotDefinedException;
30: import org.sakaiproject.entity.api.EntityPermissionException;
31: import org.sakaiproject.entity.api.EntityProducer;
32: import org.sakaiproject.entity.api.HttpAccess;
33: import org.sakaiproject.entity.api.Reference;
34: import org.sakaiproject.entity.cover.EntityManager;
35:
36: /**
37: * Created by IntelliJ IDEA.
38: * User: John Ellis
39: * Date: Nov 7, 2005
40: * Time: 3:14:16 PM
41: * To change this template use File | Settings | File Templates.
42: */
43: public abstract class HttpAccessBase implements HttpAccess {
44:
45: public void handleAccess(HttpServletRequest req,
46: HttpServletResponse res, Reference ref,
47: Collection copyrightAcceptedRefs)
48: throws EntityPermissionException,
49: EntityNotDefinedException, EntityAccessOverloadException,
50: EntityCopyrightException {
51: ReferenceParser parser = createParser(ref);
52: checkSource(ref, parser);
53: ContentEntityWrapper wrapper = (ContentEntityWrapper) ref
54: .getEntity();
55: if (wrapper == null || wrapper.getBase() == null) {
56: throw new EntityNotDefinedException(ref.getReference());
57: } else {
58: Reference realRef = EntityManager.newReference(wrapper
59: .getBase().getReference());
60: EntityProducer producer = realRef.getEntityProducer();
61: producer.getHttpAccess().handleAccess(req, res, realRef,
62: copyrightAcceptedRefs);
63: }
64: }
65:
66: protected ReferenceParser createParser(Reference ref) {
67: return new ReferenceParser(ref.getReference(), ref
68: .getEntityProducer());
69: }
70:
71: protected abstract void checkSource(Reference ref,
72: ReferenceParser parser) throws EntityPermissionException,
73: EntityNotDefinedException, EntityAccessOverloadException,
74: EntityCopyrightException;
75:
76: }
|