From 335fc154fc1a6216a7885acea9fd34ea48a34ce1 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Mon, 5 Nov 2012 15:59:44 -0500
Subject: [PATCH] Updated tools to deploy combined images and CSS files.

The pkispawn and pkicreate have been updated to deploy the
combined images and CSS files from the common-ui into /pki/images
and /pki/css.

The common Velocity templates and JavaScript files still need to
be deployed from the <subsystem>-ui and common-ui packages into
each subsystem.

Ticket #328
---
 base/deploy/src/scriptlets/instance_layout.py   | 138 ++----------------------
 base/deploy/src/scriptlets/webapp_deployment.py |  68 ++++++++++--
 base/setup/pkicreate                            |  38 +++----
 3 files changed, 89 insertions(+), 155 deletions(-)

diff --git a/base/deploy/src/scriptlets/instance_layout.py b/base/deploy/src/scriptlets/instance_layout.py
index b4d1a5068e208dfec5edf56a4d717181f61aa41c..41327252ae3e29b16960a98a7841b007579e6551 100644
--- a/base/deploy/src/scriptlets/instance_layout.py
+++ b/base/deploy/src/scriptlets/instance_layout.py
@@ -72,22 +72,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             util.directory.create(master['pki_tomcat_webapps_path'])
             util.directory.create(master['pki_tomcat_webapps_common_path'])
 
-            common_images = os.path.join(
-                master['pki_tomcat_webapps_common_path'],
-                "images")
-
-            # Copy /usr/share/pki/common-ui/admin/console/img
-            # to <instance>/webapp/pki/images
-            util.directory.copy(
-                os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    "common-ui",
-                    "admin",
-                    "console",
-                    "img"),
-                common_images,
-                overwrite_flag=True)
-
             # Copy /usr/share/pki/common-ui/css
             # to <instance>/webapp/pki/css
             util.directory.copy(
@@ -100,61 +84,18 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                     "css"),
                 overwrite_flag=True)
 
-            # Copy /usr/share/pki/common-ui/img
+            # Copy /usr/share/pki/common-ui/images
             # to <instance>/webapp/pki/images
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
                     "common-ui",
-                    "img"),
-                common_images,
+                    "images"),
+                os.path.join(
+                    master['pki_tomcat_webapps_common_path'],
+                    "images"),
                 overwrite_flag=True)
 
-            # Copy /usr/share/pki/<subsystem>-ui/webapps/<subsystem>/admin/graphics
-            # to <instance>/webapp/pki/images
-            dir = os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    master['pki_subsystem'].lower() + "-ui",
-                    "webapps",
-                    master['pki_subsystem'].lower(),
-                    "admin",
-                    "graphics")
-            if (util.directory.exists(dir)):
-                util.directory.copy(
-                    dir,
-                    common_images,
-                    overwrite_flag=True)
-
-            # Copy /usr/share/pki/<subsystem>-ui/webapps/<subsystem>/agent/graphics
-            # to <instance>/webapp/pki/images
-            dir = os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    master['pki_subsystem'].lower() + "-ui",
-                    "webapps",
-                    master['pki_subsystem'].lower(),
-                    "agent",
-                    "graphics")
-            if (util.directory.exists(dir)):
-                util.directory.copy(
-                    dir,
-                    common_images,
-                    overwrite_flag=True)
-
-            # Copy /usr/share/pki/<subsystem>-ui/webapps/<subsystem>/ee/graphics
-            # to <instance>/webapp/pki/images
-            dir = os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    master['pki_subsystem'].lower() + "-ui",
-                    "webapps",
-                    master['pki_subsystem'].lower(),
-                    "ee",
-                    "graphics")
-            if (util.directory.exists(dir)):
-                util.directory.copy(
-                    dir,
-                    common_images,
-                    overwrite_flag=True)
-
             util.directory.create(master['pki_tomcat_webapps_root_path'])
             util.directory.copy(
                 os.path.join(
@@ -259,22 +200,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             util.directory.modify(master['pki_instance_lib_log4j_properties'])
             util.directory.modify(master['pki_tomcat_webapps_path'])
 
-            common_images = os.path.join(
-                master['pki_tomcat_webapps_common_path'],
-                "images")
-
-            # Copy /usr/share/pki/common-ui/admin/console/img
-            # to <instance>/webapp/pki/images
-            util.directory.copy(
-                os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    "common-ui",
-                    "admin",
-                    "console",
-                    "img"),
-                common_images,
-                overwrite_flag=True)
-
             # Copy /usr/share/pki/common-ui/css
             # to <instance>/webapp/pki/css
             util.directory.copy(
@@ -287,61 +212,18 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                     "css"),
                 overwrite_flag=True)
 
-            # Copy /usr/share/pki/common-ui/img
+            # Copy /usr/share/pki/common-ui/images
             # to <instance>/webapp/pki/images
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
                     "common-ui",
-                    "img"),
-                common_images,
+                    "images"),
+                os.path.join(
+                    master['pki_tomcat_webapps_common_path'],
+                    "images"),
                 overwrite_flag=True)
 
-            # Copy /usr/share/pki/<subsystem>-ui/webapps/<subsystem>/admin/graphics
-            # to <instance>/webapp/pki/images
-            dir = os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    master['pki_subsystem'].lower() + "-ui",
-                    "webapps",
-                    master['pki_subsystem'].lower(),
-                    "admin",
-                    "graphics")
-            if (util.directory.exists(dir)):
-                util.directory.copy(
-                    dir,
-                    common_images,
-                    overwrite_flag=True)
-
-            # Copy /usr/share/pki/<subsystem>-ui/webapps/<subsystem>/agent/graphics
-            # to <instance>/webapp/pki/images
-            dir = os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    master['pki_subsystem'].lower() + "-ui",
-                    "webapps",
-                    master['pki_subsystem'].lower(),
-                    "agent",
-                    "graphics")
-            if (util.directory.exists(dir)):
-                util.directory.copy(
-                    dir,
-                    common_images,
-                    overwrite_flag=True)
-
-            # Copy /usr/share/pki/<subsystem>-ui/webapps/<subsystem>/ee/graphics
-            # to <instance>/webapp/pki/images
-            dir = os.path.join(
-                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    master['pki_subsystem'].lower() + "-ui",
-                    "webapps",
-                    master['pki_subsystem'].lower(),
-                    "ee",
-                    "graphics")
-            if (util.directory.exists(dir)):
-                util.directory.copy(
-                    dir,
-                    common_images,
-                    overwrite_flag=True)
-
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
diff --git a/base/deploy/src/scriptlets/webapp_deployment.py b/base/deploy/src/scriptlets/webapp_deployment.py
index 507d23c32a1e523f104d4a1f544c246056f7d4ab..28aa31dc54e98d32d54bedd6fa17404aab2e1f8a 100644
--- a/base/deploy/src/scriptlets/webapp_deployment.py
+++ b/base/deploy/src/scriptlets/webapp_deployment.py
@@ -44,14 +44,42 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 return self.rv
             config.pki_log.info(log.WEBAPP_DEPLOYMENT_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            # deploy war file
+
+            # deploy webapp
             util.directory.create(master['pki_tomcat_webapps_subsystem_path'])
+
+            # Copy /usr/share/pki/common-ui/admin/console/config
+            # to <instance>/webapp/<subsystem>/admin/console/config
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    "common-ui"),
-                master['pki_tomcat_webapps_subsystem_path'],
+                    "common-ui",
+                    "admin",
+                    "console",
+                    "config"),
+                os.path.join(
+                    master['pki_tomcat_webapps_subsystem_path'],
+                    "admin",
+                    "console",
+                    "config"),
+                overwrite_flag=True)
+
+            # Copy /usr/share/pki/common-ui/admin/console/js
+            # to <instance>/webapp/<subsystem>/admin/console/js
+            util.directory.copy(
+                os.path.join(
+                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
+                    "common-ui",
+                    "admin",
+                    "console",
+                    "js"),
+                os.path.join(
+                    master['pki_tomcat_webapps_subsystem_path'],
+                    "admin",
+                    "console",
+                    "js"),
                 overwrite_flag=True)
+
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
@@ -105,14 +133,42 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         if master['pki_subsystem'] in config.PKI_TOMCAT_SUBSYSTEMS:
             config.pki_log.info(log.WEBAPP_DEPLOYMENT_RESPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            # redeploy war file
+
+            # redeploy webapp
             util.directory.modify(master['pki_tomcat_webapps_subsystem_path'])
+
+            # Copy /usr/share/pki/common-ui/admin/console/config
+            # to <instance>/webapp/<subsystem>/admin/console/config
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
-                    "common-ui"),
-                master['pki_tomcat_webapps_subsystem_path'],
+                    "common-ui",
+                    "admin",
+                    "console",
+                    "config"),
+                os.path.join(
+                    master['pki_tomcat_webapps_subsystem_path'],
+                    "admin",
+                    "console",
+                    "config"),
+                overwrite_flag=True)
+
+            # Copy /usr/share/pki/common-ui/admin/console/js
+            # to <instance>/webapp/<subsystem>/admin/console/js
+            util.directory.copy(
+                os.path.join(
+                    config.PKI_DEPLOYMENT_SOURCE_ROOT,
+                    "common-ui",
+                    "admin",
+                    "console",
+                    "js"),
+                os.path.join(
+                    master['pki_tomcat_webapps_subsystem_path'],
+                    "admin",
+                    "console",
+                    "js"),
                 overwrite_flag=True)
+
             util.directory.copy(
                 os.path.join(
                     config.PKI_DEPLOYMENT_SOURCE_ROOT,
diff --git a/base/setup/pkicreate b/base/setup/pkicreate
index 767960778db7ee7534943577564b21cc74570d16..ac037f0a2e5809cb0222aae484f7748dc876db81 100755
--- a/base/setup/pkicreate
+++ b/base/setup/pkicreate
@@ -2065,14 +2065,6 @@ sub process_pki_directories
                                     $default_dir_permissions, $default_file_permissions,
                                     $pki_user, $pki_group);
 
-        # Copy /usr/share/pki/common-ui/admin/console/img
-        # to <instance>/docroot/pki/images
-        return 0 if !copy_directory(
-            "$common_ui_subsystem_path/admin/console/img",
-            "$docroot_instance_path/pki/images",
-            $default_dir_permissions, $default_file_permissions,
-            $pki_user, $pki_group);
-
         # Copy /usr/share/pki/common-ui/css
         # to <instance>/docroot/pki/css
         return 0 if !copy_directory(
@@ -2081,18 +2073,10 @@ sub process_pki_directories
             $default_dir_permissions, $default_file_permissions,
             $pki_user, $pki_group);
 
-        # Copy /usr/share/pki/common-ui/img
+        # Copy /usr/share/pki/common-ui/images
         # to <instance>/docroot/pki/images
         return 0 if !copy_directory(
-            "$common_ui_subsystem_path/img",
-            "$docroot_instance_path/pki/images",
-            $default_dir_permissions, $default_file_permissions,
-            $pki_user, $pki_group);
-
-        # Copy /usr/share/pki/<subsystem>-ui/docroot/<subsystem>/admin/console/img
-        # to <instance>/docroot/pki/images
-        return 0 if !copy_directory(
-            "$ui_subsystem_path/docroot/$subsystem_type/admin/console/img",
+            "$common_ui_subsystem_path/images",
             "$docroot_instance_path/pki/images",
             $default_dir_permissions, $default_file_permissions,
             $pki_user, $pki_group);
@@ -2124,9 +2108,21 @@ sub process_pki_directories
                                     $default_dir_permissions, $default_file_permissions,
                                     $pki_user, $pki_group);
 
-        return 0 if !copy_directory($common_ui_subsystem_path, $webapps_subsystem_instance_path,
-                                    $default_dir_permissions, $default_file_permissions,
-                                    $pki_user, $pki_group);
+        # Copy /usr/share/pki/common-ui/admin/console/config
+        # to <instance>/webapp/<subsystem>/admin/console/config
+        return 0 if !copy_directory(
+            "$common_ui_subsystem_path/admin/console/config",
+            "$webapps_subsystem_instance_path/admin/console/config",
+            $default_dir_permissions, $default_file_permissions,
+            $pki_user, $pki_group);
+
+        # Copy /usr/share/pki/common-ui/admin/console/js
+        # to <instance>/webapp/<subsystem>/admin/console/js
+        return 0 if !copy_directory(
+            "$common_ui_subsystem_path/admin/console/js",
+            "$webapps_subsystem_instance_path/admin/console/js",
+            $default_dir_permissions, $default_file_permissions,
+            $pki_user, $pki_group);
 
         return 0 if !copy_directory($ui_subsystem_path, $pki_instance_path,
                                     $default_dir_permissions, $default_file_permissions,
-- 
1.7.12.1

