Asset Management
- Introduction
- Asset upload
- Asset insertion (via "enable asset upload" screen)
- Asset insertion (via Bitflux editor)
- Asset removal
- Involved classes, XSPs and XSLTs
Introduction
Asset management is the process by which assets, such as pdf files or images are uploaded to the server and inserted into a document.
Assets can be either inserted directly into a document or can be uploaded for later insertion. Direct insertion happens when editing the document, upload and removal can be done in the asset tab in the site area.
Asset upload
The upload of assets is done quite simply with a multipart
request. The Upload screen is generated by an xsp
(asset.xsp
) which handles asset upload, image
upload, asset insertion and image insertion. This screen then
generates the multipart request which is eventually handled by
the AssetUploadAction
. This action stores the asset
in the resources directory and generates a meta file with the
dublin core meta data that was passed in as request parameter or
with data that was extracted from the request (mime type,
size). Where the asset is stored is determined by the
ResourcesManager
.
Asset insertion (via "enable asset upload" screen)
Once the asset is uploaded, a reference to it has to be inserted in the original document. Images and "plain" assets are handled slighly different but the basic mechanism is the same.
The insertion is done via an ant task
(insert-asset
). This task generates a temporary
XSLT stylesheet using generate-insertAsset-xsl.xsl
as a meta stylesheet and an XML template which defines the XML
snippet that will be inserted in the refering document. The path
to the XML template is passed as a parameter to the ant
task. Usually these templates are located in
config/asset
. The generated temporary stylesheet is
then applied to the document where the reference to the asset is
to be inserted. It will insert the appropriate XML snippet.
Asset insertion (via Bitflux editor)
Images and assets can also be inserted from within the Bitflux editor.
The insertion is done via a XSLT stylesheet
(image.xsl
or asset.xsl
in xslt/bxe
).
These stylesheets create a popup window that let the user select an asset or image
and insert it into the currently opened document via javascript.
Asset removal
Assets can be removed in the asset tab in the site area. This removes the asset from the resources directory. It does not however remove any references to it.
Removal is done with an ant task (remove-asset
)
which simply deletes the asset from the resources directory.
Involved classes, XSPs and XSLTs
The following classes, XSPs and XSLTs are involved in the asset upload:
- src/webapp/lenya/content/authoring/asset.xsp, src/webapp/lenya/xslt/authoring/asset.xsl
- Take care of displaying the proper asset upload screen. There are different screens for image and asset upload and for upload with or without subsequent insertion.
- org.apache.lenya.cms.cocoon.acting.UploadAction
- Handles the upload request, stores the asset in
resources/authoring/$document-id/$resource-name
, and creates a file containing the dublin core meta data for the asset. - $publication-id/config/assets/*
- Define the XML snippets that is to be inserted in lieu of a refernce to an asset.
- src/webapp/lenya/xslt/util/generate-insertAsset-xsl.xsl
- The meta stylesheet which generates the XSLT the will insert the proper XML snippet to link to the asset in the refering document.
- $publication-id/config/tasks/targets.xml
- Defines the
insert-asset
target which handles asset insertion. Also defines theremove-asset
target. - org.apache.lenya.cms.publication.ResourcesManager
- Manages resources and hides away some of the iplementaion details where resources and their meta data is stored.