You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2010/01/21 02:29:28 UTC
svn commit: r901488 - in /directory/sandbox/felixk/apacheds-i18n: ./
avl-partition/
avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/
i18n/ i18n/src/ i18n/src/main/ i18n/src/main/java/ i18n/src/main/java/org/
i18n/src/main/jav...
Author: felixk
Date: Thu Jan 21 01:29:27 2010
New Revision: 901488
URL: http://svn.apache.org/viewvc?rev=901488&view=rev
Log:
Redo i18n stuff
Added:
directory/sandbox/felixk/apacheds-i18n/i18n/ (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/site/
directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties (with props)
Modified:
directory/sandbox/felixk/apacheds-i18n/avl-partition/pom.xml
directory/sandbox/felixk/apacheds-i18n/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
directory/sandbox/felixk/apacheds-i18n/pom.xml
Modified: directory/sandbox/felixk/apacheds-i18n/avl-partition/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/avl-partition/pom.xml?rev=901488&r1=901487&r2=901488&view=diff
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/avl-partition/pom.xml (original)
+++ directory/sandbox/felixk/apacheds-i18n/avl-partition/pom.xml Thu Jan 21 01:29:27 2010
@@ -37,6 +37,12 @@
<dependencies>
<dependency>
<groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-i18n</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-avl</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: directory/sandbox/felixk/apacheds-i18n/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=901488&r1=901487&r2=901488&view=diff
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java (original)
+++ directory/sandbox/felixk/apacheds-i18n/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java Thu Jan 21 01:29:27 2010
@@ -38,6 +38,7 @@
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.entry.ServerStringValue;
import org.apache.directory.server.core.partition.impl.btree.LongComparator;
+import org.apache.directory.server.i18n.Err;
import org.apache.directory.server.xdbm.Index;
import org.apache.directory.server.xdbm.IndexCursor;
import org.apache.directory.server.xdbm.IndexEntry;
@@ -87,25 +88,25 @@
/** the normalized distinguished name index */
private AvlIndex<String, E> ndnIdx;
-
+
/** the user provided distinguished name index */
private AvlIndex<String, E> updnIdx;
-
+
/** the attribute existence index */
private AvlIndex<String, E> existenceIdx;
-
+
/** a system index on aliasedObjectName attribute */
private AvlIndex<String, E> aliasIdx;
-
+
/** a system index on the entries of descendants of root DN*/
private AvlIndex<Long, E> subLevelIdx;
-
+
/** the parent child relationship index */
private AvlIndex<Long, E> oneLevelIdx;
-
+
/** the one level scope alias index */
private AvlIndex<Long, E> oneAliasIdx;
-
+
/** the subtree scope alias index */
private AvlIndex<Long, E> subAliasIdx;
@@ -126,7 +127,7 @@
/** true if initialized */
private boolean initialized;
-
+
/** A pointer on the schemaManager */
private SchemaManager schemaManager;
@@ -224,9 +225,9 @@
String msg = "Entry " + normName.getName() + " contains no entryCsn attribute: " + entry;
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
}
-
+
entryCsnIdx.add( entryCsn.getString(), id );
-
+
// Update the EntryUuid index
EntryAttribute entryUuid = entry.get( SchemaConstants.ENTRY_UUID_AT );
@@ -235,7 +236,7 @@
String msg = "Entry " + normName.getName() + " contains no entryUuid attribute: " + entry;
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
}
-
+
entryUuidIdx.add( entryUuid.getString(), id );
Long tempId = parentId;
@@ -520,11 +521,11 @@
*/
public LdapDN getSuffix()
{
- if( suffixDn == null )
+ if ( suffixDn == null )
{
return null;
}
-
+
try
{
return new LdapDN( suffixDn.getNormName() );
@@ -544,11 +545,11 @@
*/
public LdapDN getUpSuffix()
{
- if( suffixDn == null )
+ if ( suffixDn == null )
{
return null;
}
-
+
try
{
return new LdapDN( suffixDn.getName() );
@@ -565,11 +566,11 @@
public String getSuffixDn()
{
- if( suffixDn == null )
+ if ( suffixDn == null )
{
return null;
}
-
+
return suffixDn.getName();
}
@@ -585,8 +586,8 @@
}
catch ( NamingException e )
{
- LOG.error( "Failed to identify OID for: " + id, e );
- throw new IndexNotFoundException( "Failed to identify OID for: " + id, id, e );
+ LOG.error( Err.i18n( Err.ERR_1, id ), e.getLocalizedMessage() );
+ throw new IndexNotFoundException( Err.i18n( Err.ERR_1, id ), id, e );
}
if ( systemIndices.containsKey( id ) )
@@ -594,8 +595,7 @@
return systemIndices.get( id );
}
- throw new IndexNotFoundException( "A system index on attribute " + id + " ("
- + name + ") does not exist!" );
+ throw new IndexNotFoundException( Err.i18n( Err.ERR_2, id, name ) );
}
@@ -620,8 +620,8 @@
}
catch ( NamingException e )
{
- LOG.error( "Failed to identify OID for: " + id, e );
- throw new IndexNotFoundException( "Failed to identify OID for: " + id, id, e );
+ LOG.error( Err.i18n( Err.ERR_1, id ), e.getLocalizedMessage() );
+ throw new IndexNotFoundException( Err.i18n( Err.ERR_1, id ), id, e );
}
if ( userIndices.containsKey( id ) )
@@ -629,8 +629,7 @@
return userIndices.get( id );
}
- throw new IndexNotFoundException( "A user index on attribute " + id + " ("
- + name + ") does not exist!" );
+ throw new IndexNotFoundException( Err.i18n( Err.ERR_3, id, name ) );
}
@@ -694,7 +693,8 @@
if ( ndnIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
ndnIdx = new AvlIndex<String, E>();
ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
ndnIdx.initialize( attributeType );
@@ -703,7 +703,8 @@
if ( updnIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
updnIdx = new AvlIndex<String, E>();
updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
updnIdx.initialize( attributeType );
@@ -712,7 +713,8 @@
if ( existenceIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
existenceIdx = new AvlIndex<String, E>();
existenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
existenceIdx.initialize( attributeType );
@@ -721,7 +723,8 @@
if ( oneLevelIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
oneLevelIdx = new AvlIndex<Long, E>();
oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
oneLevelIdx.initialize( attributeType );
@@ -730,7 +733,8 @@
if ( oneAliasIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
oneAliasIdx = new AvlIndex<Long, E>();
oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
oneAliasIdx.initialize( attributeType );
@@ -739,7 +743,8 @@
if ( subAliasIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
subAliasIdx = new AvlIndex<Long, E>();
subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
subAliasIdx.initialize( attributeType );
@@ -748,7 +753,8 @@
if ( aliasIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
aliasIdx = new AvlIndex<String, E>();
aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
aliasIdx.initialize( attributeType );
@@ -757,7 +763,8 @@
if ( subLevelIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
subLevelIdx = new AvlIndex<Long, E>();
subLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
subLevelIdx.initialize( attributeType );
@@ -766,7 +773,7 @@
if ( entryCsnIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID );
+ AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID );
entryCsnIdx = new AvlIndex<String, E>();
entryCsnIdx.setAttributeId( SchemaConstants.ENTRY_CSN_AT_OID );
entryCsnIdx.initialize( attributeType );
@@ -784,7 +791,8 @@
if ( objectClassIdx == null )
{
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID );
+ AttributeType attributeType = schemaManager
+ .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID );
objectClassIdx = new AvlIndex<String, E>();
objectClassIdx.setAttributeId( SchemaConstants.OBJECT_CLASS_AT_OID );
objectClassIdx.initialize( attributeType );
@@ -815,8 +823,7 @@
}
else
{
- LOG.error( "Cannot build an index for attribute '{}', no EQUALITY MatchingRule defined",
- attributeType.getName() );
+ LOG.error( Err.i18n( Err.ERR_4, attributeType.getName() ) );
}
}
@@ -1115,11 +1122,11 @@
{
// if the id exists in the index drop all existing attribute
// value index entries and add new ones
- if( objectClassIdx.reverse( id ) )
+ if ( objectClassIdx.reverse( id ) )
{
objectClassIdx.drop( id );
}
-
+
for ( Value<?> value : mods )
{
objectClassIdx.add( value.getString(), id );
@@ -1485,7 +1492,7 @@
{
this.aliasIdx = ( AvlIndex<String, E> ) convert( index );
}
-
+
// FIXME is this attribute ID or its OID
systemIndices.put( index.getAttributeId(), aliasIdx );
}
@@ -1515,7 +1522,7 @@
{
this.ndnIdx = ( AvlIndex<String, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), ndnIdx );
}
@@ -1534,7 +1541,7 @@
{
this.oneAliasIdx = ( AvlIndex<Long, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), oneAliasIdx );
}
@@ -1553,7 +1560,7 @@
{
this.oneLevelIdx = ( AvlIndex<Long, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), oneLevelIdx );
}
@@ -1600,7 +1607,7 @@
{
this.subAliasIdx = ( AvlIndex<Long, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), subAliasIdx );
}
@@ -1619,7 +1626,7 @@
{
this.subLevelIdx = ( AvlIndex<Long, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), subLevelIdx );
}
@@ -1655,7 +1662,7 @@
{
this.updnIdx = ( AvlIndex<String, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), updnIdx );
}
@@ -2083,8 +2090,8 @@
public void setEntryCsnIndex( Index<String, E> index ) throws Exception
{
protect( "entryCsnIndex" );
-
- if( index instanceof AvlIndex )
+
+ if ( index instanceof AvlIndex )
{
this.entryCsnIdx = ( AvlIndex<String, E> ) index;
}
@@ -2092,7 +2099,7 @@
{
this.entryCsnIdx = ( AvlIndex<String, E> ) convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), entryCsnIdx );
}
@@ -2131,7 +2138,7 @@
public void setObjectClassIndex( Index<String, E> index ) throws NamingException
{
protect( "objectClassIndex" );
- if( index instanceof AvlIndex )
+ if ( index instanceof AvlIndex )
{
this.objectClassIdx = ( AvlIndex<String, E> ) index;
}
@@ -2139,7 +2146,7 @@
{
objectClassIdx = convert( index );
}
-
+
systemIndices.put( index.getAttributeId(), objectClassIdx );
}
@@ -2147,7 +2154,7 @@
public void setEntryUuidIndex( Index<String, E> index ) throws NamingException
{
protect( "entryUuidIndex" );
- if( index instanceof AvlIndex )
+ if ( index instanceof AvlIndex )
{
this.entryUuidIdx = ( AvlIndex<String, E> ) index;
}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 21 01:29:27 2010
@@ -0,0 +1 @@
+target
Added: directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml Thu Jan 21 01:29:27 2010
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>apacheds-parent</artifactId>
+ <groupId>org.apache.directory.server</groupId>
+ <version>1.5.6-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-i18n</artifactId>
+ <version>1.5.6-SNAPSHOT</version>
+ <name>ApacheDS I18n</name>
+
+ <description>Internationalization of errors and other messages</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java Thu Jan 21 01:29:27 2010
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+
+/**
+ * Provides i18n handling of error codes.
+ * About formatting see also {@link MessageFormat}
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class Err
+{
+ private final static ResourceBundle res = ResourceBundle.getBundle( "org/apache/directory/server/i18n/errors" );
+
+ public static String ERR_1 = "ERR 1";
+ public static String ERR_2 = "ERR 2";
+ public static String ERR_3 = "ERR 3";
+ public static String ERR_4 = "ERR 4";
+ public static String ERR_5 = "ERR 5";
+ public static String ERR_6 = "ERR 6";
+ public static String ERR_7 = "ERR 7";
+ public static String ERR_8 = "ERR 8";
+ public static String ERR_9 = "ERR 9";
+ public static String ERR_10 = "ERR 10";
+ public static String ERR_11 = "ERR 11";
+ public static String ERR_12 = "ERR 12";
+ public static String ERR_13 = "ERR 13";
+ public static String ERR_14 = "ERR 14";
+ public static String ERR_15 = "ERR 15";
+ public static String ERR_16 = "ERR 16";
+ public static String ERR_17 = "ERR 17";
+ public static String ERR_18 = "ERR 18";
+ public static String ERR_19 = "ERR 19";
+ public static String ERR_20 = "ERR 20";
+
+
+ /**
+ *
+ * Translate an error code with parameter
+ *
+ * @param err The error code
+ * @param argArray The parameters
+ * @return
+ */
+ public static String i18n( String err, Object... args )
+ {
+ try
+ {
+ return MessageFormat.format( res.getString( err ), args );
+ }
+ catch ( Exception e )
+ {
+ StringBuffer sb = new StringBuffer();
+ boolean comma = false;
+ for ( Object obj : args )
+ {
+ if ( comma )
+ {
+ sb.append( "," );
+ }
+ else
+ {
+ comma = true;
+ }
+ sb.append( obj );
+ }
+ return err + " (" + sb.toString() + ")";
+ }
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties Thu Jan 21 01:29:27 2010
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+ERR\ 1=Failed to identify OID for: {0}
+ERR\ 2=A system index on attribute {0} ({1}) does not exist!
+ERR\ 3=A user index on attribute {0} ({1}) does not exist!
+ERR\ 4=Cannot build an index for attribute '{0}', no EQUALITY MatchingRule defined
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties Thu Jan 21 01:29:27 2010
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+ERR\ 1=Err 1
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties Thu Jan 21 01:29:27 2010
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+ERR\ 1=Err 1
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml Thu Jan 21 01:29:27 2010
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!--
+ @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+-->
+<project name="${project.name}">
+ <body>
+ <menu ref="parent" />
+ <menu ref="reports" />
+ </body>
+</project>
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java Thu Jan 21 01:29:27 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Locale;
+
+import org.junit.Test;
+
+
+/**
+ * Test when translation available for current locale -> use locale translation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GermanLanguageTest
+{
+
+ @Test
+ public void testTranslateDeLocale()
+ {
+ Locale.setDefault( Locale.GERMAN );
+ assertEquals( "Das ist Fehler 1", Err.i18n( Err.ERR_1 ) );
+ assertEquals( "Das ist Fehler 2 mit 1 Parameter", Err.i18n( Err.ERR_2, 1 ) );
+ assertEquals( "Das ist Fehler 3 mit 2 Parameter", Err.i18n( Err.ERR_3, 3, 2 ) );
+ assertEquals( "Das ist Fehler 4 mit mehr als 2 Parameter", Err.i18n( Err.ERR_4, 4, "mehr", "als", 2 ) );
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java Thu Jan 21 01:29:27 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+/**
+ * Test when missing error code.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MissingErrorCodeTest
+{
+
+ @Test
+ public void testMissingErrorCode()
+ {
+ assertEquals( "MissingErrorCode ()", Err.i18n( "MissingErrorCode" ) );
+ assertEquals( "MissingErrorCode (1)", Err.i18n( "MissingErrorCode", 1 ) );
+ assertEquals( "MissingErrorCode (3,2)", Err.i18n( "MissingErrorCode", 3, 2 ) );
+ assertEquals( "MissingErrorCode (4,more,than,2)", Err.i18n( "MissingErrorCode", 4, "more", "than", 2 ) );
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java Thu Jan 21 01:29:27 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Locale;
+
+import org.junit.Test;
+
+
+/**
+ * Test when no translation available for current locale -> use default translation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class UnknownLanguageTest
+{
+
+ @Test
+ public void testTranslateUnknownLocale()
+ {
+ Locale.setDefault( Locale.TRADITIONAL_CHINESE );
+ assertEquals( "This is error 1", Err.i18n( Err.ERR_1 ) );
+ assertEquals( "This is error 2 with 1 parameter", Err.i18n( Err.ERR_2, 1 ) );
+ assertEquals( "This is error 3 with 2 parameters", Err.i18n( Err.ERR_3, 3, 2 ) );
+ assertEquals( "This is error 4 with more than 2 parameters", Err.i18n( Err.ERR_4, 4, "more", "than", 2 ) );
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties Thu Jan 21 01:29:27 2010
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+ERR\ 1=This is error 1
+ERR\ 2=This is error 2 with {0} parameter
+ERR\ 3=This is error {0} with {1} parameters
+ERR\ 4=This is error {0} with {1} {2} {3} parameters
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties?rev=901488&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties Thu Jan 21 01:29:27 2010
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+ERR\ 1=Das ist Fehler 1
+ERR\ 2=Das ist Fehler 2 mit {0} Parameter
+ERR\ 3=Das ist Fehler {0} mit {1} Parameter
+ERR\ 4=Das ist Fehler {0} mit {1} {2} {3} Parameter
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: directory/sandbox/felixk/apacheds-i18n/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/pom.xml?rev=901488&r1=901487&r2=901488&view=diff
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/pom.xml (original)
+++ directory/sandbox/felixk/apacheds-i18n/pom.xml Thu Jan 21 01:29:27 2010
@@ -326,6 +326,7 @@
</dependencies>
<modules>
+ <module>i18n</module>
<module>all</module>
<module>utils</module>
<module>jdbm</module>