From 7a7849258c50ebbecb252e707fecd4e83a9fa398 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Mon, 17 Sep 2012 13:04:45 -0500
Subject: [PATCH] Fixed problems with optional pki-symkey.

The deployment and init scripts have been fixed to create and check
the links to symkey.jar only if the pki-symkey is installed.

Ticket #331
---
 base/deploy/scripts/operations                | 5 ++++-
 base/deploy/src/scriptlets/instance_layout.py | 8 +++++---
 base/setup/scripts/functions                  | 5 ++++-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/base/deploy/scripts/operations b/base/deploy/scripts/operations
index 61e4e5de95ff7757f13ce9e58c975764bed1a8eb..d620218ee3d2e40279ba127754cfed8d79bc59f9 100644
--- a/base/deploy/scripts/operations
+++ b/base/deploy/scripts/operations
@@ -1058,13 +1058,16 @@ verify_symlinks()
         [resteasy-jaxrs.jar]=${resteasy_java_dir}/resteasy-jaxrs.jar
         [resteasy-jettison-provider.jar]=${resteasy_java_dir}/resteasy-jettison-provider.jar
         [scannotation.jar]=${java_dir}/scannotation.jar
-        [symkey.jar]=${jni_dir}/symkey.jar
         [tomcatjss.jar]=${java_dir}/tomcat7jss.jar
         [velocity.jar]=${java_dir}/velocity.jar
         [xerces-j2.jar]=${java_dir}/xerces-j2.jar
         [xml-commons-apis.jar]=${java_dir}/xml-commons-apis.jar
         [xml-commons-resolver.jar]=${java_dir}/xml-commons-resolver.jar)
 
+    if [ -e ${jni_dir}/symkey.jar ]; then
+        common_jar_symlinks[symkey.jar]=${jni_dir}/symkey.jar
+    fi
+
     # '${pki_systemd_dir}' symlinks
     systemd_symlinks[${pki_systemd_link}]=${systemd_dir}/${pki_systemd_service}
 
diff --git a/base/deploy/src/scriptlets/instance_layout.py b/base/deploy/src/scriptlets/instance_layout.py
index 245df5a5f4563eb4308cf926f556bf24d0edb9cd..45704fcd8b2431f4efe2585f0a4437bf46908d04 100644
--- a/base/deploy/src/scriptlets/instance_layout.py
+++ b/base/deploy/src/scriptlets/instance_layout.py
@@ -125,8 +125,9 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 master['pki_resteasy_jettison_provider_jar_link'])
             util.symlink.create(master['pki_scannotation_jar'],
                 master['pki_scannotation_jar_link'])
-            util.symlink.create(master['pki_symkey_jar'],
-                master['pki_symkey_jar_link'])
+            if os.path.exists(master['pki_symkey_jar']):
+                util.symlink.create(master['pki_symkey_jar'],
+                    master['pki_symkey_jar_link'])
             util.symlink.create(master['pki_tomcatjss_jar'],
                 master['pki_tomcatjss_jar_link'])
             util.symlink.create(master['pki_velocity_jar'],
@@ -225,7 +226,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             util.symlink.modify(
                 master['pki_resteasy_jettison_provider_jar_link'])
             util.symlink.modify(master['pki_scannotation_jar_link'])
-            util.symlink.modify(master['pki_symkey_jar_link'])
+            if os.path.exists(master['pki_symkey_jar']):
+                util.symlink.modify(master['pki_symkey_jar_link'])
             util.symlink.modify(master['pki_tomcatjss_jar_link'])
             util.symlink.modify(master['pki_velocity_jar_link'])
             util.symlink.modify(master['pki_xerces_j2_jar_link'])
diff --git a/base/setup/scripts/functions b/base/setup/scripts/functions
index 71685fe6d421fa5c930df9f0b10b3096c1754c24..f5b6615b44c651887bd5b2729c2301f3238f0bc9 100644
--- a/base/setup/scripts/functions
+++ b/base/setup/scripts/functions
@@ -971,12 +971,15 @@ verify_symlinks()
         [pki-cmscore.jar]=/usr/share/java/pki/pki-cmscore.jar
         [pki-cmsutil.jar]=/usr/share/java/pki/pki-cmsutil.jar
         [pki-nsutil.jar]=/usr/share/java/pki/pki-nsutil.jar
-        [symkey.jar]=${jni_dir}/symkey.jar
         [velocity.jar]=/usr/share/java/velocity.jar
         [xerces-j2.jar]=/usr/share/java/xerces-j2.jar
         [xml-commons-apis.jar]=/usr/share/java/xml-commons-apis.jar
         [xml-commons-resolver.jar]=/usr/share/java/xml-commons-resolver.jar)
 
+    if [ -e ${jni_dir}/symkey.jar ]; then
+        webapps_jar_symlinks[symkey.jar]=${jni_dir}/symkey.jar
+    fi
+
     # '${pki_systemd_dir}' symlinks
     systemd_symlinks[${pki_systemd_link}]=${systemd_dir}/${pki_systemd_service}
 
-- 
1.7.11.2

