summaryrefslogtreecommitdiffstats
path: root/base/server/upgrade/10.1.99
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2013-11-28 03:25:24 -0500
committerEndi S. Dewata <edewata@redhat.com>2014-03-17 11:22:15 -0400
commit4c1ce953681c3cac9c6d0b4325a48ba66619f553 (patch)
tree6dc07525b8f2bbf295450c6b883c9a682f927628 /base/server/upgrade/10.1.99
parentae38b34e717b386f06407db9e5a4723472b77775 (diff)
downloadpki-4c1ce953681c3cac9c6d0b4325a48ba66619f553.tar.gz
pki-4c1ce953681c3cac9c6d0b4325a48ba66619f553.tar.xz
pki-4c1ce953681c3cac9c6d0b4325a48ba66619f553.zip
Removed config path from web.xml.
Previously the CMSStartServlet always requires a cfgPath parameter pointing to the CS.cfg location. By default the parameter points to <instance>/conf/<subsystem>/CS.cfg unless it's manually changed by the admin after installation. Recently the servlet has been modified such that if the parameter is not specified it will generate the default path automatically. So it is no longer necessary to keep the cfgPath parameter in the web.xml templates because it will point to the same location. This patch removes the cfgPath parameters from all web.xml templates. This way newly created subsystems will not have this parameter, which will help direct deployment in the future. An upgrade script has been added to remove the parameter from existing instances if it points to the default location. If the parameter points to a different location that means the subsystem has been customized so it will not be changed. Ticket #748, #499
Diffstat (limited to 'base/server/upgrade/10.1.99')
-rwxr-xr-xbase/server/upgrade/10.1.99/05-RemoveConfigPathFromWebXML80
1 files changed, 80 insertions, 0 deletions
diff --git a/base/server/upgrade/10.1.99/05-RemoveConfigPathFromWebXML b/base/server/upgrade/10.1.99/05-RemoveConfigPathFromWebXML
new file mode 100755
index 000000000..959cac878
--- /dev/null
+++ b/base/server/upgrade/10.1.99/05-RemoveConfigPathFromWebXML
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+# Authors:
+# Endi S. Dewata <edewata@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2014 Red Hat, Inc.
+# All rights reserved.
+#
+
+import os
+from lxml import etree
+
+import pki.server.upgrade
+
+
+class RemoveConfigPathFromWebXML(pki.server.upgrade.PKIServerUpgradeScriptlet):
+
+ def __init__(self):
+
+ self.message = 'Remove config path from web.xml'
+
+ def upgrade_subsystem(self, instance, subsystem):
+
+ default_cs_cfg = os.path.join(instance.base_dir, 'conf', subsystem.name, 'CS.cfg')
+ web_xml = os.path.join(instance.base_dir, 'webapps', subsystem.name, 'WEB-INF', 'web.xml')
+
+ if not os.path.exists(web_xml):
+ return
+
+ self.backup(web_xml)
+
+ document = etree.parse(web_xml)
+ self.remove_config_path(document, default_cs_cfg)
+
+ with open(web_xml, 'w') as f:
+ f.write(etree.tostring(document, pretty_print=True))
+
+ def remove_config_path(self, document, default_cs_cfg):
+
+ context = document.getroot()
+
+ # find CMSStartServlet servlet
+ for servlet in context.findall('servlet'):
+
+ servlet_class = servlet.find('servlet-class')
+ value = servlet_class.text.strip()
+
+ if value != 'com.netscape.cms.servlet.base.CMSStartServlet':
+ continue
+
+ # servlet found, find cfgPath parameter
+ for init_param in servlet.findall('init-param'):
+
+ param_name = init_param.find('param-name')
+ value = param_name.text.strip()
+
+ if value != 'cfgPath':
+ continue
+
+ # parameter found, check value
+ param_value = init_param.find('param-value')
+ value = param_value.text.strip()
+
+ # if cfgPath points to the default CS.cfg, remove the parameter
+ if value == default_cs_cfg:
+ servlet.remove(init_param)
+
+ return