From 80c58327faaa4873369f6bb949e62792c2f708e0 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 15 Aug 2007 21:34:53 +0000
Subject: [PATCH] This commit is a step toward getting OpenDS internationalized. There are still issues to be resolved before we can declare that we are internationalized but this commit covers the bulk of changes needed at this time.

---
 opends/src/server/org/opends/server/authorization/dseecompat/PatternIP.java |   63 ++++++++++++++-----------------
 1 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/opends/src/server/org/opends/server/authorization/dseecompat/PatternIP.java b/opends/src/server/org/opends/server/authorization/dseecompat/PatternIP.java
index 031b5f0..6df6f6a 100644
--- a/opends/src/server/org/opends/server/authorization/dseecompat/PatternIP.java
+++ b/opends/src/server/org/opends/server/authorization/dseecompat/PatternIP.java
@@ -27,9 +27,9 @@
 
 
 package org.opends.server.authorization.dseecompat;
+import org.opends.messages.Message;
 
-import static org.opends.server.messages.AciMessages.*;
-import static org.opends.server.messages.MessageHandler.getMessage;
+import static org.opends.messages.AccessControlMessages.*;
 import java.util.BitSet;
 import java.util.HashMap;
 import java.net.InetAddress;
@@ -240,22 +240,21 @@
         try {
             //Can only have one prefix value and one address string.
             if((numParts  < 1) || (numParts > 2) ) {
-                int msgID = MSGID_ACI_SYNTAX_INVALID_PREFIX_FORMAT;
-                String message = getMessage(msgID, expr);
-                throw new AciException(msgID, message);
+                Message message =
+                    WARN_ACI_SYNTAX_INVALID_PREFIX_FORMAT.get(expr);
+                throw new AciException(message);
             }
             if(prefixStr != null)
                 prefix = Integer.parseInt(prefixStr);
             //Must be between 0 to maxprefix.
             if((prefix < 0) || (prefix > maxPrefix)) {
-                int msgID=MSGID_ACI_SYNTAX_INVALID_PREFIX_VALUE;
-                String message = getMessage(msgID, expr);
-                throw new AciException(msgID, message);
+                Message message =
+                    WARN_ACI_SYNTAX_INVALID_PREFIX_VALUE.get(expr);
+                throw new AciException(message);
             }
         } catch(NumberFormatException nfex) {
-            int msgID=MSGID_ACI_SYNTAX_PREFIX_NOT_NUMERIC;
-            String msg = getMessage(msgID, expr);
-            throw new AciException(msgID,msg);
+            Message msg = WARN_ACI_SYNTAX_PREFIX_NOT_NUMERIC.get(expr);
+            throw new AciException(msg);
         }
         return prefix;
     }
@@ -305,15 +304,13 @@
         //Look up the string in the valid netmask hash table. If it isn't
         //there it is an error.
         if(!validNetMasks.containsKey(netmaskStr)) {
-            int id=MSGID_ACI_SYNTAX_INVALID_NETMASK;
-            String message = getMessage(id, expr);
-            throw new AciException(id, message);
+            Message message = WARN_ACI_SYNTAX_INVALID_NETMASK.get(expr);
+            throw new AciException(message);
         }
         //Can only have one netmask value and one address string.
         if((numParts  < 1) || (numParts > 2) ) {
-            int msgID = MSGID_ACI_SYNTAX_INVALID_NETMASK_FORMAT;
-            String message = getMessage(msgID, expr);
-            throw new AciException(msgID, message);
+            Message message = WARN_ACI_SYNTAX_INVALID_NETMASK_FORMAT.get(expr);
+            throw new AciException(message);
         }
         String[] s = netmaskStr.split("\\.", -1);
         try {
@@ -323,9 +320,8 @@
                 netmaskBytes[i] = (byte) (val & 0xff);
             }
         } catch (NumberFormatException nfex) {
-            int id=MSGID_ACI_SYNTAX_IPV4_NOT_NUMERIC;
-            String message = getMessage(id, expr);
-            throw new AciException(id, message);
+            Message message = WARN_ACI_SYNTAX_IPV4_NOT_NUMERIC.get(expr);
+            throw new AciException(message);
         }
         return netmaskBytes;
     }
@@ -352,9 +348,8 @@
         String[] s = addrStr.split("\\.", -1);
         try {
             if(s.length != IN4ADDRSZ) {
-                int id=MSGID_ACI_SYNTAX_INVALID_IPV4_FORMAT;
-                String message = getMessage(id, expr);
-                throw new AciException(id, message);
+                Message message = WARN_ACI_SYNTAX_INVALID_IPV4_FORMAT.get(expr);
+                throw new AciException(message);
             }
             for(int i=0; i < IN4ADDRSZ; i++) {
                 String quad=s[i].trim();
@@ -364,17 +359,16 @@
                     long val=Integer.parseInt(quad);
                     //must be between 0-255
                     if((val < 0) ||  (val > 0xff)) {
-                        int id=MSGID_ACI_SYNTAX_INVALID_IPV4_VALUE;
-                        String message = getMessage(id, expr);
-                        throw new AciException(id, message);
+                        Message message =
+                            WARN_ACI_SYNTAX_INVALID_IPV4_VALUE.get(expr);
+                        throw new AciException(message);
                     }
                     addrBytes[i] = (byte) (val & 0xff);
                 }
             }
         } catch (NumberFormatException nfex) {
-            int id=MSGID_ACI_SYNTAX_IPV4_NOT_NUMERIC;
-            String message = getMessage(id, expr);
-            throw new AciException(id, message);
+            Message message = WARN_ACI_SYNTAX_IPV4_NOT_NUMERIC.get(expr);
+            throw new AciException(message);
         }
         return addrBytes;
     }
@@ -394,17 +388,16 @@
     private static byte[]
     procIPv6Addr(String addrStr, String expr) throws AciException {
         if(addrStr.indexOf('*') > -1) {
-            int msgID=MSGID_ACI_SYNTAX_IPV6_WILDCARD_INVALID;
-            String message = getMessage(msgID, expr);
-            throw new AciException(msgID, message);
+            Message message = WARN_ACI_SYNTAX_IPV6_WILDCARD_INVALID.get(expr);
+            throw new AciException(message);
         }
         byte[] addrBytes;
         try {
             addrBytes=InetAddress.getByName(addrStr).getAddress();
         } catch (UnknownHostException ex) {
-            int id=MSGID_ACI_SYNTAX_INVALID_IPV6_FORMAT;
-            String message = getMessage(id, expr, ex.getMessage());
-            throw new AciException(id, message);
+            Message message =
+                WARN_ACI_SYNTAX_INVALID_IPV6_FORMAT.get(expr, ex.getMessage());
+            throw new AciException(message);
         }
         return addrBytes;
     }

--
Gitblit v1.10.0