protected void reorderAppDeploymentsAfterConfigurationVersion(Element domain){
  List<Element> appDeployments=xmlTool.selectElementsMatchingXPath("weblogic:app-deployment",domain);
  for (  Element appDeployment : appDeployments) {
    domain.removeChild(appDeployment);
  }
  Element configurationVersion=xmlTool.selectElementMatchingXPath("weblogic:configuration-version",domain);
  Node before=null;
  NodeList children=domain.getChildNodes();
  for (int i=0; i < children.getLength(); i++) {
    if (configurationVersion.equals(children.item(i)) && i < children.getLength() - 1) {
      before=children.item(i + 1);
    }
  }
  if (before != null) {
    for (    Element appDeployment : appDeployments) {
      domain.insertBefore(appDeployment,before);
    }
  }
 else {
    for (    Element appDeployment : appDeployments) {
      domain.appendChild(appDeployment);
    }
  }
}

protected void reorderAppDeploymentsAfterConfigurationVersion ( Element domain ) { List < Element > appDeployments = xmlTool . selectElementsMatchingXPath ( "weblogic:app-deployment" , domain ) ; for ( Element appDeployment : appDeployments ) { domain . removeChild ( appDeployment ) ; } Element configurationVersion = xmlTool . selectElementMatchingXPath ( "weblogic:configuration-version" , domain ) ; Node before = null ; NodeList children = domain . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { if ( configurationVersion . equals ( children . item ( i ) ) && i < children . getLength ( ) - 1 ) { before = children . item ( i + 1 ) ; } } if ( before != null ) { for ( Element appDeployment : appDeployments ) { domain . insertBefore ( appDeployment , before ) ; } } else { for ( Element appDeployment : appDeployments ) { domain . appendChild ( appDeployment ) ; } } }
per current schema of the weblogic domain , app - deployment elements need to come directly after the configuration - version element .
