org.apache.cocoon.environment.commandline
Class AbstractCommandLineEnvironment

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.environment.AbstractEnvironment
          extended by org.apache.cocoon.environment.commandline.AbstractCommandLineEnvironment
All Implemented Interfaces:
LogEnabled, Environment, Redirector, SourceResolver
Direct Known Subclasses:
FileSavingEnvironment, LinkSamplingEnvironment

public abstract class AbstractCommandLineEnvironment
extends AbstractEnvironment
implements Redirector

This environment is used to save the requested file to disk.

Version:
$Id: AbstractCommandLineEnvironment.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Stefano Mazzocchi

Field Summary
static String CLI_REQUEST_ID
           
protected  int contentLength
           
protected  String contentType
           
protected  boolean hasRedirected
           
protected  int statusCode
           
 
Fields inherited from class org.apache.cocoon.environment.AbstractEnvironment
action, avalonToCocoonSourceWrapper, context, initializedComponents, manager, objectModel, outputStream, prefix, rootContext, secureOutputStream, sourceResolver, uris, view
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Constructor Summary
AbstractCommandLineEnvironment(String uri, Map attributes, Map parameters, Map headers, String view, File context, CommandLineContext cliContext, OutputStream stream, Logger log)
           
AbstractCommandLineEnvironment(String uri, String view, File context, OutputStream stream, Logger log)
           
 
Method Summary
 String getContentType()
          Get the ContentType
 OutputStream getOutputStream(int bufferSize)
          Return an OutputStream, but allow it to be null for when the pipeline is being streamed to the provided SAX content handler (using CocoonBean)
 int getStatus()
          Get the StatusCode
 boolean hasRedirected()
          Was one of the redirection methods called ?
 boolean isExternal()
          Always return true.
 void redirect(boolean sessionmode, String newURL)
          Redirect the client to a new URL
 void sendStatus(int sc)
          Send a content-less response with the given status code.
 void setContentLength(int contentLength)
          Set the ContentLength
 void setContentType(String contentType)
          Set the ContentType
 void setStatus(int statusCode)
          Set the StatusCode
 
Methods inherited from class org.apache.cocoon.environment.AbstractEnvironment
changeContext, commitResponse, extractAction, extractView, finishingProcessing, getAction, getAttribute, getAttributeNames, getContext, getObjectModel, getOutputStream, getRootContext, getURI, getURIPrefix, getView, globalRedirect, hasAttribute, initComponents, isInternalRedirect, isResponseModified, release, removeAttribute, resolve, resolveURI, resolveURI, setAction, setAttribute, setContext, setContext, setResponseIsNotModified, setURIPrefix, setView, startingProcessing, tryResetResponse
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.environment.Redirector
globalRedirect
 

Field Detail

CLI_REQUEST_ID

public static final String CLI_REQUEST_ID
See Also:
Constant Field Values

contentType

protected String contentType

contentLength

protected int contentLength

hasRedirected

protected boolean hasRedirected

statusCode

protected int statusCode
Constructor Detail

AbstractCommandLineEnvironment

public AbstractCommandLineEnvironment(String uri,
                                      String view,
                                      File context,
                                      OutputStream stream,
                                      Logger log)
                               throws MalformedURLException
Throws:
MalformedURLException

AbstractCommandLineEnvironment

public AbstractCommandLineEnvironment(String uri,
                                      Map attributes,
                                      Map parameters,
                                      Map headers,
                                      String view,
                                      File context,
                                      CommandLineContext cliContext,
                                      OutputStream stream,
                                      Logger log)
                               throws MalformedURLException
Throws:
MalformedURLException
Method Detail

redirect

public void redirect(boolean sessionmode,
                     String newURL)
              throws IOException
Redirect the client to a new URL

Specified by:
redirect in interface Environment
Specified by:
redirect in interface Redirector
Throws:
IOException

sendStatus

public void sendStatus(int sc)
Description copied from interface: Redirector
Send a content-less response with the given status code.

Specified by:
sendStatus in interface Redirector
Parameters:
sc - an http status code.

hasRedirected

public boolean hasRedirected()
Description copied from interface: Redirector
Was one of the redirection methods called ?

Specified by:
hasRedirected in interface Redirector

setStatus

public void setStatus(int statusCode)
Set the StatusCode

Specified by:
setStatus in interface Environment
Overrides:
setStatus in class AbstractEnvironment

getStatus

public int getStatus()
Get the StatusCode


setContentType

public void setContentType(String contentType)
Set the ContentType

Specified by:
setContentType in interface Environment

setContentLength

public void setContentLength(int contentLength)
Set the ContentLength

Specified by:
setContentLength in interface Environment

getContentType

public String getContentType()
Get the ContentType

Specified by:
getContentType in interface Environment

isExternal

public boolean isExternal()
Always return true.

Specified by:
isExternal in interface Environment
Returns:
true if this environment is external

getOutputStream

public OutputStream getOutputStream(int bufferSize)
                             throws IOException
Return an OutputStream, but allow it to be null for when the pipeline is being streamed to the provided SAX content handler (using CocoonBean)

Specified by:
getOutputStream in interface Environment
Overrides:
getOutputStream in class AbstractEnvironment
Throws:
IOException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.