001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/shared/mgt/impl/MetaobjHttpAccess.java $
003: * $Id: MetaobjHttpAccess.java 27703 2007-03-23 17:09:01Z john.ellis@rsmart.com $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.metaobj.shared.mgt.impl;
021:
022: import java.io.IOException;
023: import java.net.URL;
024: import java.util.Collection;
025:
026: import javax.servlet.http.HttpServletRequest;
027: import javax.servlet.http.HttpServletResponse;
028: import javax.xml.transform.Templates;
029: import javax.xml.transform.Transformer;
030: import javax.xml.transform.TransformerConfigurationException;
031: import javax.xml.transform.TransformerException;
032: import javax.xml.transform.TransformerFactory;
033: import javax.xml.transform.stream.StreamResult;
034: import javax.xml.transform.stream.StreamSource;
035:
036: import org.apache.commons.logging.Log;
037: import org.apache.commons.logging.LogFactory;
038: import org.jdom.Document;
039: import org.jdom.Element;
040: import org.jdom.transform.JDOMSource;
041: import org.sakaiproject.entity.api.EntityAccessOverloadException;
042: import org.sakaiproject.entity.api.EntityCopyrightException;
043: import org.sakaiproject.entity.api.EntityNotDefinedException;
044: import org.sakaiproject.entity.api.EntityPermissionException;
045: import org.sakaiproject.entity.api.Reference;
046: import org.sakaiproject.metaobj.shared.mgt.HttpAccessBase;
047: import org.sakaiproject.metaobj.shared.mgt.ReferenceParser;
048: import org.sakaiproject.metaobj.shared.mgt.StructuredArtifactDefinitionManager;
049: import org.sakaiproject.tool.api.ActiveTool;
050: import org.sakaiproject.tool.api.Tool;
051: import org.sakaiproject.tool.api.ToolSession;
052: import org.sakaiproject.tool.api.ToolException;
053: import org.sakaiproject.tool.cover.ActiveToolManager;
054: import org.sakaiproject.tool.cover.SessionManager;
055: import org.sakaiproject.util.Web;
056: import org.sakaiproject.content.api.ResourceEditingHelper;
057:
058: /**
059: * Created by IntelliJ IDEA.
060: * User: John Ellis
061: * Date: Feb 21, 2006
062: * Time: 1:25:15 PM
063: * To change this template use File | Settings | File Templates.
064: */
065: public class MetaobjHttpAccess extends HttpAccessBase {
066:
067: protected final transient Log logger = LogFactory
068: .getLog(getClass());
069:
070: public void handleAccess(HttpServletRequest req,
071: HttpServletResponse res, Reference ref,
072: Collection copyrightAcceptedRefs)
073: throws EntityPermissionException,
074: EntityNotDefinedException, EntityAccessOverloadException,
075: EntityCopyrightException {
076: String helperId = "sakai.metaobj.formView";
077:
078: ToolSession toolSession = SessionManager
079: .getCurrentToolSession();
080:
081: if (toolSession == null) {
082: toolSession = SessionManager.getCurrentSession()
083: .getToolSession(
084: req.getSession(true).hashCode() + "");
085: SessionManager.setCurrentToolSession(toolSession);
086: }
087:
088: ActiveTool helperTool = ActiveToolManager
089: .getActiveTool(helperId);
090: toolSession.setAttribute(helperTool.getId()
091: + Tool.HELPER_DONE_URL, "javascript:alert('hi')");
092:
093: toolSession.setAttribute(ResourceEditingHelper.ATTACHMENT_ID,
094: ref.getId());
095:
096: String context = req.getContextPath() + req.getServletPath();
097: String toolPath = "/formView.osp";
098: try {
099: helperTool.help(req, res, context, toolPath);
100: } catch (ToolException e) {
101: throw new RuntimeException(e);
102: }
103: }
104:
105: protected void checkSource(Reference ref, ReferenceParser parser)
106: throws EntityPermissionException,
107: EntityNotDefinedException, EntityAccessOverloadException,
108: EntityCopyrightException {
109:
110: }
111:
112: public void init() {
113: logger.info("init()");
114: }
115:
116: }
|