org.apache.lenya.cms.cocoon.source
Class SourceUtil

java.lang.Object
  extended by org.apache.lenya.cms.cocoon.source.SourceUtil

public final class SourceUtil
extends java.lang.Object

Version:
$Id: SourceUtil.java 507914 2007-02-15 12:15:30Z andreas $

Constructor Summary
SourceUtil()
           
 
Method Summary
static void checkin(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Checks in a transactionable source.
static void checkout(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Checks out a repository source.
static void copy(org.apache.avalon.framework.service.ServiceManager manager, java.lang.String sourceUri, java.lang.String destUri)
          Copies a Source without buffering.
static void copy(org.apache.excalibur.source.Source source, org.apache.excalibur.source.ModifiableSource destination, boolean useBuffer)
           Copies one Source to another using a source buffer i.e. the source Source is buffered before it is copied to its final destination.
static void copy(org.apache.excalibur.source.SourceResolver resolver, java.lang.String sourceUri, java.io.OutputStream destOutputStream)
           
static void copy(org.apache.excalibur.source.SourceResolver resolver, java.lang.String sourceUri, java.lang.String destUri)
          Copies a Source without buffering.
static void copy(org.apache.excalibur.source.SourceResolver resolver, java.lang.String sourceUri, java.lang.String destUri, boolean useBuffer)
          Copies one Source to another.
static void delete(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Deletes a source if it exists.
static void deleteEmptyCollections(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Deletes all empty collections in a subtree.
static boolean exists(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Checks if a source exists.
static long getContentLength(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
           
static long getLastModified(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Returns the last modification date of a source.
static java.lang.String getMimeType(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
           
static void lock(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Locks a transactionable source.
static org.w3c.dom.Document readDOM(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Reads a DOM from a source.
static void registerDirty(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Registers a source as dirty.
static void unlock(java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Unlocks a transactionable source.
static void writeDOM(org.w3c.dom.Document document, java.io.OutputStream oStream)
           
static void writeDOM(org.w3c.dom.Document document, java.lang.String sourceUri, org.apache.avalon.framework.service.ServiceManager manager)
          Writes a DOM to a source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceUtil

public SourceUtil()
Method Detail

copy

public static void copy(org.apache.excalibur.source.Source source,
                        org.apache.excalibur.source.ModifiableSource destination,
                        boolean useBuffer)
                 throws java.io.IOException

Copies one Source to another using a source buffer i.e. the source Source is buffered before it is copied to its final destination.

The optional buffering is sometimes useful, if the source Source somehow depends on the destination Source. This situation may occur e.g. if source Source is a Cocoon pipeline.

NOTE: o.a.e..s.SourceUtil.copy does not close streams on an exception!!

Parameters:
source -
destination -
useBuffer - If true, the source data will be read into a buffer before it is written to the final destination.
Throws:
java.io.IOException - If an error occures.

copy

public static void copy(org.apache.excalibur.source.SourceResolver resolver,
                        java.lang.String sourceUri,
                        java.lang.String destUri,
                        boolean useBuffer)
                 throws java.io.IOException,
                        org.apache.excalibur.source.SourceException
Copies one Source to another. The source Source is optionally buffered.

Parameters:
resolver - The SourceResolver to use for lookin up Sources.
sourceUri - The source to be copied.
destUri - The URI to copy to.
useBuffer - If true, the source Source is buffered before copied to the final destination.
Throws:
java.io.IOException - If an error occures.
org.apache.excalibur.source.SourceException - If the destination is not modifiable.
See Also:
copy(Source, ModifiableSource, boolean)

copy

public static void copy(org.apache.excalibur.source.SourceResolver resolver,
                        java.lang.String sourceUri,
                        java.lang.String destUri)
                 throws java.io.IOException
Copies a Source without buffering.

Parameters:
resolver - A SourceResolver instance.
sourceUri - The source URI to copy from.
destUri - The destination URI to copy to.
Throws:
java.io.IOException - If an error occures.
See Also:
copy(SourceResolver, String, String, boolean)

copy

public static void copy(org.apache.avalon.framework.service.ServiceManager manager,
                        java.lang.String sourceUri,
                        java.lang.String destUri)
                 throws java.io.IOException,
                        org.apache.avalon.framework.service.ServiceException
Copies a Source without buffering.

Parameters:
manager - A service manager.
sourceUri - The source URI to copy from.
destUri - The destination URI to copy to.
Throws:
java.io.IOException - If an error occures.
org.apache.avalon.framework.service.ServiceException
See Also:
copy(SourceResolver, String, String, boolean)

readDOM

public static org.w3c.dom.Document readDOM(java.lang.String sourceUri,
                                           org.apache.avalon.framework.service.ServiceManager manager)
                                    throws org.apache.avalon.framework.service.ServiceException,
                                           org.apache.excalibur.source.SourceNotFoundException,
                                           javax.xml.parsers.ParserConfigurationException,
                                           org.xml.sax.SAXException,
                                           java.io.IOException
Reads a DOM from a source.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Returns:
A document or null if the source does not exist.
Throws:
org.apache.avalon.framework.service.ServiceException - if an error occurs.
org.apache.excalibur.source.SourceNotFoundException - if an error occurs.
javax.xml.parsers.ParserConfigurationException - if an error occurs.
org.xml.sax.SAXException - if an error occurs.
java.io.IOException - if an error occurs.

writeDOM

public static void writeDOM(org.w3c.dom.Document document,
                            java.lang.String sourceUri,
                            org.apache.avalon.framework.service.ServiceManager manager)
                     throws javax.xml.transform.TransformerConfigurationException,
                            javax.xml.transform.TransformerException,
                            org.apache.avalon.framework.service.ServiceException,
                            java.net.MalformedURLException,
                            java.io.IOException
Writes a DOM to a source.

Parameters:
document - The document.
sourceUri - The source URI.
manager - The service manager.
Throws:
javax.xml.transform.TransformerConfigurationException - if an error occurs.
javax.xml.transform.TransformerException - if an error occurs.
org.apache.avalon.framework.service.ServiceException - if the source resolver could not be obtained.
java.net.MalformedURLException - if the source URI is not valid.
java.io.IOException - if an error occurs.

writeDOM

public static void writeDOM(org.w3c.dom.Document document,
                            java.io.OutputStream oStream)
                     throws javax.xml.transform.TransformerConfigurationException,
                            javax.xml.transform.TransformerException,
                            java.io.IOException
Parameters:
document - The XML document.
oStream - The output stream.
Throws:
javax.xml.transform.TransformerConfigurationException - if an error occurs.
javax.xml.transform.TransformerException - if an error occurs.
java.io.IOException - if an error occurs.

delete

public static void delete(java.lang.String sourceUri,
                          org.apache.avalon.framework.service.ServiceManager manager)
                   throws org.apache.avalon.framework.service.ServiceException,
                          java.net.MalformedURLException,
                          java.io.IOException
Deletes a source if it exists.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Throws:
org.apache.avalon.framework.service.ServiceException - if an error occurs.
java.net.MalformedURLException - if an error occurs.
java.io.IOException - if an error occurs.

deleteEmptyCollections

public static void deleteEmptyCollections(java.lang.String sourceUri,
                                          org.apache.avalon.framework.service.ServiceManager manager)
                                   throws org.apache.avalon.framework.service.ServiceException,
                                          java.net.MalformedURLException,
                                          java.io.IOException
Deletes all empty collections in a subtree.

Parameters:
sourceUri - The root source URI.
manager - The service manager.
Throws:
org.apache.avalon.framework.service.ServiceException
java.net.MalformedURLException
java.io.IOException

exists

public static boolean exists(java.lang.String sourceUri,
                             org.apache.avalon.framework.service.ServiceManager manager)
                      throws org.apache.avalon.framework.service.ServiceException,
                             java.net.MalformedURLException,
                             java.io.IOException
Checks if a source exists.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Returns:
A boolean value.
Throws:
org.apache.avalon.framework.service.ServiceException - if an error occurs.
java.net.MalformedURLException - if an error occurs.
java.io.IOException - if an error occurs.

getLastModified

public static long getLastModified(java.lang.String sourceUri,
                                   org.apache.avalon.framework.service.ServiceManager manager)
                            throws org.apache.avalon.framework.service.ServiceException,
                                   java.net.MalformedURLException,
                                   java.io.IOException
Returns the last modification date of a source.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Returns:
A long value.
Throws:
org.apache.avalon.framework.service.ServiceException - if an error occurs.
java.net.MalformedURLException - if an error occurs.
java.io.IOException - if an error occurs.

checkout

public static void checkout(java.lang.String sourceUri,
                            org.apache.avalon.framework.service.ServiceManager manager)
                     throws RepositoryException,
                            org.apache.avalon.framework.service.ServiceException,
                            java.net.MalformedURLException,
                            java.io.IOException
Checks out a repository source.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Throws:
RepositoryException - If an error occurs.
org.apache.avalon.framework.service.ServiceException - If an error occurs.
java.net.MalformedURLException - If an error occurs.
java.io.IOException - If an error occurs.

checkin

public static void checkin(java.lang.String sourceUri,
                           org.apache.avalon.framework.service.ServiceManager manager)
                    throws RepositoryException,
                           org.apache.avalon.framework.service.ServiceException,
                           java.net.MalformedURLException,
                           java.io.IOException
Checks in a transactionable source.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Throws:
RepositoryException - If an error occurs.
org.apache.avalon.framework.service.ServiceException - If an error occurs.
java.net.MalformedURLException - If an error occurs.
java.io.IOException - If an error occurs.

lock

public static void lock(java.lang.String sourceUri,
                        org.apache.avalon.framework.service.ServiceManager manager)
                 throws RepositoryException
Locks a transactionable source.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Throws:
RepositoryException - If an error occurs.

unlock

public static void unlock(java.lang.String sourceUri,
                          org.apache.avalon.framework.service.ServiceManager manager)
                   throws RepositoryException
Unlocks a transactionable source.

Parameters:
sourceUri - The source URI.
manager - The service manager.
Throws:
RepositoryException - If an error occurs.

registerDirty

public static void registerDirty(java.lang.String sourceUri,
                                 org.apache.avalon.framework.service.ServiceManager manager)
Registers a source as dirty.

Parameters:
sourceUri - The source URI.
manager - The service manager.

getContentLength

public static long getContentLength(java.lang.String sourceUri,
                                    org.apache.avalon.framework.service.ServiceManager manager)
                             throws org.apache.avalon.framework.service.ServiceException,
                                    java.net.MalformedURLException,
                                    java.io.IOException
Parameters:
sourceUri - The source URI.
manager - The service manager.
Returns:
A content length.
Throws:
org.apache.avalon.framework.service.ServiceException
java.net.MalformedURLException
java.io.IOException

getMimeType

public static java.lang.String getMimeType(java.lang.String sourceUri,
                                           org.apache.avalon.framework.service.ServiceManager manager)
                                    throws org.apache.avalon.framework.service.ServiceException,
                                           java.net.MalformedURLException,
                                           java.io.IOException
Parameters:
sourceUri - The source URI.
manager - The service manager.
Returns:
A mime type.
Throws:
org.apache.avalon.framework.service.ServiceException
java.io.IOException
java.net.MalformedURLException

copy

public static void copy(org.apache.excalibur.source.SourceResolver resolver,
                        java.lang.String sourceUri,
                        java.io.OutputStream destOutputStream)
                 throws java.net.MalformedURLException,
                        java.io.IOException
Parameters:
resolver -
sourceUri -
destOutputStream -
Throws:
java.net.MalformedURLException
java.io.IOException


Copyright 1999-2006 Apache Software Foundation. All Rights Reserved.