From 7889a4d9ed35a20c629af1f8e2b947dc76b0f00d Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Wed, 28 Jan 2009 07:58:19 +0000
Subject: [PATCH] Update the ServiceTag data configuration with an optional configuration directory 

---
 opendj-sdk/opends/src/server/org/opends/server/servicetag/SwordFishIdConfiguration.java |   48 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/servicetag/SwordFishIdConfiguration.java b/opendj-sdk/opends/src/server/org/opends/server/servicetag/SwordFishIdConfiguration.java
index 0e4a765..fabac3c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/servicetag/SwordFishIdConfiguration.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/servicetag/SwordFishIdConfiguration.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 package org.opends.server.servicetag;
 
@@ -42,8 +42,8 @@
 public class SwordFishIdConfiguration {
 
     /**
-    * The tracer object for the debug logger.
-    */
+     * The tracer object for the debug logger.
+     */
     private static final DebugTracer TRACER = getTracer();
 
     // Singleton
@@ -56,21 +56,31 @@
 
     // Private constructor
     private SwordFishIdConfiguration() {
-        // Build the full path to the properties files
-        String confDir =
-                DirectoryServer.getInstanceRoot() +
-                File.separatorChar +
-                "config" +
-                File.separatorChar +
-                "servicetag";
 
-        File config = new File(confDir);
-        if (!config.exists() || (!config.isDirectory())) {
-            return;
-        }
-        if (config.isDirectory()) {
+        try {
 
-            this.listProperties = config.listFiles();
+            // Build the full path to the properties files
+            // if resources dir exists then read the property files
+            // else use the default in config dir
+            File serviceTag = new File(
+                    DirectoryServer.getServerRoot() +
+                    File.separatorChar +
+                    "resources" +
+                    File.separatorChar +
+                    "servicetag");
+
+            if ((!serviceTag.exists()) || (!serviceTag.isDirectory())) {
+                serviceTag = new File(DirectoryServer.getInstanceRoot() +
+                        File.separatorChar +
+                        "config" +
+                        File.separatorChar +
+                        "servicetag");
+                if ((!serviceTag.exists()) || (!serviceTag.isDirectory())) {
+                    return;
+                }
+            }
+
+            this.listProperties = serviceTag.listFiles();
             for (int i = 0; i < listProperties.length; i++) {
                 try {
                     if (listProperties[i].getAbsolutePath().
@@ -80,10 +90,14 @@
                     }
                 } catch (Throwable t) {
                     if (debugEnabled()) {
-                       TRACER.debugCaught(DebugLogLevel.WARNING, t);
+                        TRACER.debugCaught(DebugLogLevel.WARNING, t);
                     }
                 }
             }
+        } catch (Exception ex) {
+            if (debugEnabled()) {
+                TRACER.debugCaught(DebugLogLevel.WARNING, ex);
+            }
         }
     }
 

--
Gitblit v1.10.0