Skip to content

Commit

Permalink
Clean up RemoveUserDatabase
Browse files Browse the repository at this point in the history
The RemoveUserDatabase has been updated to use ServerConfig
to update server.xml.
  • Loading branch information
edewata committed Nov 11, 2023
1 parent 4093f97 commit 2ff0587
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions base/server/upgrade/10.8.0/04-RemoveUserDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from __future__ import absolute_import
import logging
from lxml import etree
import os

import pki
Expand All @@ -33,8 +32,6 @@ def __init__(self):
super(RemoveUserDatabase, self).__init__()
self.message = 'Remove unused UserDatabase from server.xml'

self.parser = etree.XMLParser(remove_blank_text=True)

def upgrade_instance(self, instance):

self.upgrade_server_xml(instance)
Expand All @@ -60,13 +57,12 @@ def upgrade_server_xml(self, instance):
logger.info('Upgrading %s', instance.server_xml)
self.backup(instance.server_xml)

document = etree.parse(instance.server_xml, self.parser)
server_config = instance.get_server_config()

logger.info('Removing LockOutRealm')
instance.remove_lockout_realm(document)
server_config.remove_realm('org.apache.catalina.realm.LockOutRealm')

logger.info('Removing UserDatabase')
instance.remove_default_user_database(document)
server_config.remove_global_naming_resource('UserDatabase')

with open(instance.server_xml, 'wb') as f:
document.write(f, pretty_print=True, encoding='utf-8')
server_config.save()

0 comments on commit 2ff0587

Please sign in to comment.