001package org.apache.turbine.modules.layouts;
002
003
004/*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements.  See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership.  The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License.  You may obtain a copy of the License at
012 *
013 *   http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied.  See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023
024import org.apache.turbine.modules.Layout;
025import org.apache.turbine.pipeline.PipelineData;
026import org.apache.turbine.util.RunData;
027import org.apache.turbine.util.TurbineException;
028
029/**
030 * This layout allows an action to manipulate the ServletOutputStream directly.
031 * It requires that data.declareDirectResponse() has been called to indicate
032 * that the OutputStream is being handled elsewhere.
033 *
034 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
035 * @version $Id$
036 */
037public class DirectResponseLayout implements Layout
038{
039    /**
040     * Ensures that a direct response has been declared.
041     *
042     * @param pipelineData Turbine information.
043     * @throws TurbineException if a direct response has not been declared.
044     */
045    @Override
046    public void doBuild(PipelineData pipelineData)
047            throws Exception
048    {
049        RunData data = pipelineData.getRunData();
050        if (!data.isOutSet())
051        {
052            throw new TurbineException(
053                "data.declareDirectResponse() has not been called");
054        }
055    }
056}