@@ -92,7 +92,6 @@ public static void applyConfigChange(Path jbossHome, List<String> configs, boole
9292 ConfigLogger .info ("Processing config for: " + plugin .getConfigName ());
9393
9494 applyLayerChanges (jbossHome , plugin , enable );
95-
9695 applyConfigurationChanges (jbossHome , plugin , enable );
9796 }
9897 }
@@ -255,7 +254,6 @@ private static void applyConfigurationChanges(Path jbossHome, ConfigPlugin plugi
255254 domainPaths .add (Paths .get ("domain" , "configuration" , "domain.xml" ));
256255
257256 String message = (enable ? "\t Enable " : "\t Disable " ) + plugin .getConfigName () + " configuration in: " ;
258-
259257 String lineSeparator = System .getProperty ("line.separator" );
260258
261259 SAXBuilder jdom = new SAXBuilder ();
@@ -374,16 +372,33 @@ private static byte[] loadBytesFromURL(URL resource) throws IOException {
374372 return out .toByteArray ();
375373 }
376374
377- @ SuppressWarnings ( "unchecked" )
375+ @ Deprecated
378376 public static Element findElementWithAttributeValue (Element element , String name , Namespace ns , String attrName , String attrValue ) {
379- if (element .getName ().equals (name ) && element .getNamespace ().equals (ns )) {
380- Attribute attribute = element .getAttribute (attrName );
381- if (attribute != null && attrValue .equals (attribute .getValue ())) {
382- return element ;
377+ return findElementWithAttributeValue (element , name , attrName , attrValue , ns );
378+ }
379+
380+ @ SuppressWarnings ("unchecked" )
381+ public static Element findElementWithAttributeValue (Element element , String name , String attrName , String attrValue , Namespace ... supportedNamespaces ) {
382+ for (Namespace ns : supportedNamespaces ) {
383+ if (element .getName ().equals (name ) && element .getNamespace ().equals (ns )) {
384+ Attribute attribute = element .getAttribute (attrName );
385+ if (attribute != null && attrValue .equals (attribute .getValue ())) {
386+ return element ;
387+ }
388+ }
389+ for (Element ch : (List <Element >) element .getChildren ()) {
390+ Element result = findElementWithAttributeValue (ch , name , attrName , attrValue , supportedNamespaces );
391+ if (result != null ) {
392+ return result ;
393+ }
383394 }
384395 }
385- for (Element ch : (List <Element >) element .getChildren ()) {
386- Element result = findElementWithAttributeValue (ch , name , ns , attrName , attrValue );
396+ return null ;
397+ }
398+
399+ public static Element findChildElement (Element parent , String name , Namespace ... supportedNamespaces ) {
400+ for (Namespace ns : supportedNamespaces ) {
401+ Element result = parent .getChild (name , ns );
387402 if (result != null ) {
388403 return result ;
389404 }
@@ -408,18 +423,24 @@ public static Map<String, Element> mapByAttributeName(List<Element> elements, St
408423 return rc ;
409424 }
410425
411- @ SuppressWarnings ( "unchecked" )
426+ @ Deprecated
412427 public static List <Element > findProfileElements (Document doc , Namespace ns ) {
428+ return findProfileElements (doc , new Namespace [] {ns });
429+ }
430+
431+ @ SuppressWarnings ("unchecked" )
432+ public static List <Element > findProfileElements (Document doc , Namespace ... supportedNamespaces ) {
413433 List <Element > result = new ArrayList <>();
414- Element profile = doc .getRootElement ().getChild ("profile" , ns );
415- if (profile != null ) {
416- result .add (profile );
417- }
418- Element profiles = doc .getRootElement ().getChild ("profiles" , ns );
419- if (profiles != null ) {
420- result .addAll (profiles .getChildren ("profile" , ns ));
434+ for (Namespace ns : supportedNamespaces ) {
435+ Element profile = doc .getRootElement ().getChild ("profile" , ns );
436+ if (profile != null ) {
437+ result .add (profile );
438+ }
439+ Element profiles = doc .getRootElement ().getChild ("profiles" , ns );
440+ if (profiles != null ) {
441+ result .addAll (profiles .getChildren ("profile" , ns ));
442+ }
421443 }
422444 return result ;
423445 }
424-
425446}
0 commit comments