Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.flex.util
Class CmsResourceTranslator  view CmsResourceTranslator download CmsResourceTranslator.java

java.lang.Object
  extended bycom.opencms.flex.util.CmsResourceTranslator
All Implemented Interfaces:
com.opencms.boot.I_CmsLogChannels

public class CmsResourceTranslator
extends java.lang.Object
implements com.opencms.boot.I_CmsLogChannels

This class provides a resource name translation facility.

Resource name translation is required for backward compatibility to the old OpenCms (pre 5.0 beta 2) directory layout. It can also be used to translate special characters or names automatically.

It is also used for translating new resource names that contain illegal chars to legal names. This feature is most useful (and currently only used) for uploaded files. It is also applied to uploded ZIP directories that are extracted after upload.

The translations can be configured in the opencms.properties.

The default directory translation setting is:

 directory.translation.rules=s#/default/vfs/content/bodys/(.*)#/default/vfs/system/bodies/$1#, \ 
 s#/default/vfs/pics/system/(.*)#/default/vfs/system/workplace/resources/$1#, \ 
 s#/default/vfs/pics/(.*)#/default/vfs/system/galleries/pics/$1#, \ 
 s#/default/vfs/download/(.*)#/default/vfs/system/galleries/download/$1#, \ 
 s#/default/vfs/externallinks/(.*)#/default/vfs/system/galleries/externallinks/$1#, \ 
 s#/default/vfs/htmlgalleries/(.*)#/default/vfs/system/galleries/htmlgalleries/$1#, \ 
 s#/default/vfs/content/(.*)#/default/vfs/system/modules/default/$1#, \ 
 s#/default/vfs/moduledemos/(.*)#/default/vfs/system/moduledemos/$1#, \ 
 s#/default/vfs/system/workplace/config/language/(.*)#/default/vfs/system/workplace/locales/$1#, \ 
 s#/default/vfs/system/workplace/css/(.*)#/default/vfs/system/workplace/resources/$1#, \
 s#/default/vfs/system/workplace/templates/js/(.*)#/default/vfs/system/workplace/scripts/$1#
 

The default file name translation setting is:

 filename.translation.rules=s#[\s]+#_#g, \
 s#\\#/#g, \
 s#[^0-9a-zA-Z_\.\-\/]#!#g, \
 s#!+#x#g
 

Since:
5.0 beta 2
Version:
$Revision: 1.8 $

Field Summary
private static int DEBUG
          DEBUG flag
private  boolean m_continueMatching
          Flag to indicate if one or more matchings should be tried
private  org.apache.oro.text.PatternCache m_perlPatternCache
          Perl5 patter cache to avoid unecessary re-parsing of properties
private  org.apache.oro.text.perl.Perl5Util m_perlUtil
          Perl5 utility class
private  java.lang.String[] m_translations
          Internal array containing the translations from opencms.properties
 
Fields inherited from interface com.opencms.boot.I_CmsLogChannels
C_FLEX_CACHE, C_FLEX_LOADER, C_LOGGING, C_MODULE_CRITICAL, C_MODULE_DEBUG, C_MODULE_INFO, C_OPENCMS_CACHE, C_OPENCMS_CRITICAL, C_OPENCMS_CRONSCHEDULER, C_OPENCMS_DEBUG, C_OPENCMS_ELEMENTCACHE, C_OPENCMS_INFO, C_OPENCMS_INIT, C_OPENCMS_POOL, C_OPENCMS_STATICEXPORT, C_OPENCMS_STREAMING, C_PREPROCESSOR_IS_LOGGING
 
Constructor Summary
CmsResourceTranslator(java.lang.String[] translations, boolean continueMatching)
          Constructor for the CmsResourceTranslator.
 
Method Summary
 java.lang.String[] getTranslations()
          Returns a copy of the initialized translation rules.
 java.lang.String translateResource(java.lang.String resourceName)
          Translate a resource name according to the expressions set in the opencms.properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_translations

private java.lang.String[] m_translations
Internal array containing the translations from opencms.properties


m_perlUtil

private org.apache.oro.text.perl.Perl5Util m_perlUtil
Perl5 utility class


m_perlPatternCache

private org.apache.oro.text.PatternCache m_perlPatternCache
Perl5 patter cache to avoid unecessary re-parsing of properties


m_continueMatching

private boolean m_continueMatching
Flag to indicate if one or more matchings should be tried


DEBUG

private static final int DEBUG
DEBUG flag

See Also:
Constant Field Values
Constructor Detail

CmsResourceTranslator

public CmsResourceTranslator(java.lang.String[] translations,
                             boolean continueMatching)
Constructor for the CmsResourceTranslator.

Method Detail

translateResource

public java.lang.String translateResource(java.lang.String resourceName)
Translate a resource name according to the expressions set in the opencms.properties. If no match is found, the resource name is returned unchanged.


getTranslations

public java.lang.String[] getTranslations()
Returns a copy of the initialized translation rules.