org.apache.lenya.cms.cocoon.acting
Class UploadAction

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.acting.AbstractAction
          extended by org.apache.cocoon.acting.AbstractConfigurableAction
              extended by org.apache.lenya.cms.cocoon.acting.UploadAction
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.cocoon.acting.Action

public class UploadAction
extends org.apache.cocoon.acting.AbstractConfigurableAction

The class UploadAction implements an action that allows for asset and content upload. An upload consists of a file upload plus optionally a file creation for the meta data of the asset. Also see org.apache.lenya.cms.authoring.UploadHelper


Field Summary
static java.lang.String CONTENT_PREFIX
           
static java.lang.String[] DUBLIN_CORE_PARAMETERS
           
static java.lang.String FILE_NAME_REGEXP
           
static java.lang.String UPLOADASSET_PARAM_NAME
           
static java.lang.String UPLOADASSET_PARAM_PREFIX
           
static java.lang.String UPLOADASSET_RETURN_FILESIZE
           
static java.lang.String UPLOADASSET_RETURN_MIMETYPE
           
 
Fields inherited from class org.apache.cocoon.acting.AbstractConfigurableAction
settings
 
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
 
Fields inherited from interface org.apache.cocoon.acting.Action
ROLE
 
Constructor Summary
UploadAction()
           
 
Method Summary
 java.util.Map act(org.apache.cocoon.environment.Redirector redirector, org.apache.cocoon.environment.SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
          Retrieve the file from the request and store it in the corresponding directory, optionally create a meta file and optionally insert an image tag in the requesting document.
static boolean canReadMimeType(java.lang.String mimeType)
          Returns true if the specified mime type can be read
protected  void createMetaData(java.io.File metaDataFile, java.util.Map dublinCoreParams, java.util.Map lenyaMetaParams)
          Create the meta data file given the dublin core parameters.
protected  java.util.Map getDublinCoreParameters(org.apache.cocoon.environment.Request request)
          Retrieves optional parameters for the meta file which contains dublin core information from the request.
protected  void logRequestParameters(org.apache.cocoon.environment.Request request)
          Logs the request parameters.
protected  void saveAsset(java.io.File assetFile, org.apache.cocoon.servlet.multipart.Part part)
          Saves the asset to a file.
 
Methods inherited from class org.apache.cocoon.acting.AbstractConfigurableAction
configure
 
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
 

Field Detail

UPLOADASSET_PARAM_NAME

public static final java.lang.String UPLOADASSET_PARAM_NAME
See Also:
Constant Field Values

UPLOADASSET_PARAM_PREFIX

public static final java.lang.String UPLOADASSET_PARAM_PREFIX
See Also:
Constant Field Values

UPLOADASSET_RETURN_FILESIZE

public static final java.lang.String UPLOADASSET_RETURN_FILESIZE
See Also:
Constant Field Values

UPLOADASSET_RETURN_MIMETYPE

public static final java.lang.String UPLOADASSET_RETURN_MIMETYPE
See Also:
Constant Field Values

CONTENT_PREFIX

public static final java.lang.String CONTENT_PREFIX
See Also:
Constant Field Values

FILE_NAME_REGEXP

public static final java.lang.String FILE_NAME_REGEXP
See Also:
Constant Field Values

DUBLIN_CORE_PARAMETERS

public static final java.lang.String[] DUBLIN_CORE_PARAMETERS
Constructor Detail

UploadAction

public UploadAction()
Method Detail

act

public java.util.Map act(org.apache.cocoon.environment.Redirector redirector,
                         org.apache.cocoon.environment.SourceResolver resolver,
                         java.util.Map objectModel,
                         java.lang.String source,
                         org.apache.avalon.framework.parameters.Parameters parameters)
                  throws java.lang.Exception
Retrieve the file from the request and store it in the corresponding directory, optionally create a meta file and optionally insert an image tag in the requesting document.

Parameters:
redirector - a Redirector value
resolver - a SourceResolver value
objectModel - a Map value
source - a String value
parameters - a Parameters value
Returns:
a Map containing the referer or null if the name of the file to be uploaded contains characters that are not allowed (@see FILE_NAME_REGEXP).
Throws:
java.lang.Exception - if an error occurs

canReadMimeType

public static boolean canReadMimeType(java.lang.String mimeType)
Returns true if the specified mime type can be read


saveAsset

protected void saveAsset(java.io.File assetFile,
                         org.apache.cocoon.servlet.multipart.Part part)
                  throws java.lang.Exception
Saves the asset to a file.

Parameters:
assetFile - The asset file.
part - The part of the multipart request.
Throws:
java.lang.Exception - if an error occurs.

logRequestParameters

protected void logRequestParameters(org.apache.cocoon.environment.Request request)
Logs the request parameters.

Parameters:
request - The request.

getDublinCoreParameters

protected java.util.Map getDublinCoreParameters(org.apache.cocoon.environment.Request request)
Retrieves optional parameters for the meta file which contains dublin core information from the request.

Parameters:
request - The request.
Returns:
A map.

createMetaData

protected void createMetaData(java.io.File metaDataFile,
                              java.util.Map dublinCoreParams,
                              java.util.Map lenyaMetaParams)
                       throws javax.xml.transform.TransformerConfigurationException,
                              javax.xml.transform.TransformerException,
                              java.io.IOException,
                              javax.xml.parsers.ParserConfigurationException
Create the meta data file given the dublin core parameters.

Parameters:
metaDataFile - the file where the meta data file is to be created
dublinCoreParams - a Map containing the dublin core values
Throws:
javax.xml.transform.TransformerConfigurationException - if an error occurs.
javax.xml.transform.TransformerException - if an error occurs.
java.io.IOException - if an error occurs
javax.xml.parsers.ParserConfigurationException - if an error occurs.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.