Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jans-linux-setup add to extraClasspath #968

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 installed(self):
return os.path.exists(os.path.join(Config.jetty_base, self.service_name, 'start.ini')) or os.path.exists(os.path.join(Config.jetty_base, self.service_name, 'start.d/server.ini'))