Skip to content

Commit

Permalink
fix( jans-linux-setup): added to extraClasspath (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar authored Mar 4, 2022
1 parent 9a76f23 commit bfb0bfe
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions jans-linux-setup/jans_setup/setup_app/installers/jetty.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def get_jetty_info(self):

return jettyArchive, jetty_dist

@property
def web_app_xml_fn(self):
return os.path.join(self.jetty_base, self.service_name, 'webapps', self.service_name+'.xml')


def installJettyService(self, serviceConfiguration, supportCustomizations=False, supportOnlyPageCustomizations=False):
serviceName = serviceConfiguration['name']
Expand All @@ -130,7 +134,6 @@ def installJettyService(self, serviceConfiguration, supportCustomizations=False,
jettyServiceBase = '%s/%s' % (self.jetty_base, serviceName)
jettyModules = serviceConfiguration['jetty']['modules']
jettyModulesList = jettyModules.split(',')
self.web_app_xml_fn = os.path.join(self.jetty_base, serviceName, 'webapps', serviceName+'.xml')

jettyModulesList = [m.strip() for m in jettyModules.split(',')]
if self.jetty_dist_string == 'jetty-home':
Expand Down Expand Up @@ -368,20 +371,29 @@ def add_extra_class(self, class_path, xml_fn=None):
xml_fn = self.web_app_xml_fn
tree = ET.parse(xml_fn)
root = tree.getroot()
path_list = []

for app_set in root.findall("Set"):
if app_set.get('name') == 'extraClasspath' and app_set.text.endswith(os.path.basename(class_path)):
if app_set.get('name') == 'extraClasspath':
path_list = [cp.strip() for cp in app_set.text.split(',')]
break
else:
child = ET.Element("Set")
child.set('name', 'extraClasspath')
child.text = class_path
root.append(child)

with open(xml_fn, 'wb') as f:
f.write(b'<?xml version="1.0" encoding="ISO-8859-1"?>\n')
f.write(b'<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">\n')
f.write(ET.tostring(root, method='xml'))
app_set = ET.Element("Set")
app_set.set('name', 'extraClasspath')

root.append(app_set)

for cp in class_path.split(','):
if os.path.basename(cp) not in ','.join(path_list):
path_list.append(cp.strip())

app_set.text = ','.join(path_list)

with open(xml_fn, 'wb') as f:
f.write(b'<?xml version="1.0" encoding="ISO-8859-1"?>\n')
f.write(b'<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">\n')
f.write(ET.tostring(root, method='xml'))


def get_plugins(self):
plugins = []
Expand Down

0 comments on commit bfb0bfe

Please sign in to comment.