Program: 28772
Project: 28772
Buggy source:
private boolean set(AdminCommandContext context,SetOperation op){
  String pattern=op.pattern;
  String value=op.value;
  String target=op.target;
  String attrName=op.attrName;
  boolean isProperty=op.isProperty;
  TreeNode[] parentNodes=getAliasedParent(domain,pattern);
  String prefix;
  boolean lookAtSubNodes=true;
  if (parentNodes[0].relativeName.length() == 0 || parentNodes[0].relativeName.equals("String_Node_Str")) {
    prefix="String_Node_Str";
    lookAtSubNodes=false;
  }
 else   if (!pattern.startsWith(parentNodes[0].relativeName)) {
    prefix=pattern.substring(0,pattern.indexOf(parentNodes[0].relativeName));
    pattern=parentNodes[0].relativeName;
  }
 else {
    prefix="String_Node_Str";
    pattern=parentNodes[0].relativeName;
  }
  String targetName=prefix + pattern;
  Map<Dom,String> matchingNodes;
  boolean applyOverrideRules=false;
  Map<Dom,String> dottedNames=new HashMap<Dom,String>();
  if (lookAtSubNodes) {
    for (    TreeNode parentNode : parentNodes) {
      dottedNames.putAll(getAllDottedNodes(parentNode.node));
    }
    matchingNodes=getMatchingNodes(dottedNames,pattern);
    applyOverrideRules=true;
  }
 else {
    matchingNodes=new HashMap<Dom,String>();
    for (    TreeNode parentNode : parentNodes) {
      matchingNodes.put(parentNode.node,pattern);
    }
  }
  if (matchingNodes.isEmpty()) {
    pattern=target.substring(0,trueLastIndexOf(target,'.'));
    if (pattern.endsWith("String_Node_Str")) {
      pattern=pattern.substring(0,trueLastIndexOf(pattern,'.'));
      parentNodes=getAliasedParent(domain,pattern);
      pattern=parentNodes[0].relativeName;
      matchingNodes=getMatchingNodes(dottedNames,pattern);
      if (matchingNodes.isEmpty()) {
        fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",targetName));
        return false;
      }
      Dom parentNode=null;
      for (      Map.Entry<Dom,String> node : matchingNodes.entrySet()) {
        if (node.getValue().equals(pattern)) {
          parentNode=node.getKey();
        }
      }
      if (parentNode == null) {
        fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",targetName));
        return false;
      }
      if (value == null || value.length() == 0) {
        success(context,targetName,value);
        return true;
      }
      Map<String,String> attributes=new HashMap<String,String>();
      attributes.put("String_Node_Str",value);
      attributes.put("String_Node_Str",attrName);
      try {
        ConfigSupport.createAndSet((ConfigBean)parentNode,Property.class,attributes);
        success(context,targetName,value);
        runLegacyChecks(context);
        if (targetService.isThisDAS() && !replicateSetCommand(context,targetName,value))         return false;
        return true;
      }
 catch (      TransactionFailure transactionFailure) {
        fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",transactionFailure.getMessage()),transactionFailure);
        return false;
      }
    }
  }
  Map<ConfigBean,Map<String,String>> changes=new HashMap<ConfigBean,Map<String,String>>();
  boolean setElementSuccess=false;
  boolean delPropertySuccess=false;
  boolean delProperty=false;
  Map<String,String> attrChanges=new HashMap<String,String>();
  if (isProperty) {
    attrName="String_Node_Str";
    if ((value == null) || (value.length() == 0)) {
      delProperty=true;
    }
    attrChanges.put(attrName,value);
  }
  List<Map.Entry> mNodes=new ArrayList(matchingNodes.entrySet());
  if (applyOverrideRules) {
    mNodes=applyOverrideRules(mNodes);
  }
  for (  Map.Entry<Dom,String> node : mNodes) {
    final Dom targetNode=node.getKey();
    for (    String name : targetNode.model.getAttributeNames()) {
      String finalDottedName=node.getValue() + "String_Node_Str" + name;
      if (matches(finalDottedName,pattern)) {
        if (attrName.equals(name) || attrName.replace('_','-').equals(name.replace('_','-'))) {
          if (isDeprecatedAttr(targetNode,name)) {
            warning(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",finalDottedName));
          }
          if (!isProperty) {
            targetName=prefix + finalDottedName;
            if (value != null && value.length() > 0) {
              attrChanges.put(name,value);
            }
 else {
              attrChanges.put(name,null);
            }
          }
 else {
            targetName=prefix + node.getValue();
          }
          if (delProperty) {
            String str=node.getValue();
            if (trueLastIndexOf(str,'.') != -1) {
              str=str.substring(trueLastIndexOf(str,'.') + 1);
            }
            try {
              if (str != null) {
                ConfigSupport.deleteChild((ConfigBean)targetNode.parent(),(ConfigBean)targetNode);
                delPropertySuccess=true;
              }
            }
 catch (            IllegalArgumentException ie) {
              fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",ie.getMessage()),ie);
              return false;
            }
catch (            TransactionFailure transactionFailure) {
              fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",transactionFailure.getMessage()),transactionFailure);
              return false;
            }
          }
 else {
            changes.put((ConfigBean)node.getKey(),attrChanges);
          }
        }
      }
    }
    for (    String name : targetNode.model.getLeafElementNames()) {
      String finalDottedName=node.getValue() + "String_Node_Str" + name;
      if (matches(finalDottedName,pattern)) {
        if (attrName.equals(name) || attrName.replace('_','-').equals(name.replace('_','-'))) {
          if (isDeprecatedAttr(targetNode,name)) {
            warning(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",finalDottedName));
          }
          try {
            setLeafElement((ConfigBean)targetNode,name,value);
          }
 catch (          TransactionFailure ex) {
            fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",ex.getMessage()),ex);
            return false;
          }
          setElementSuccess=true;
          break;
        }
      }
    }
  }
  if (!changes.isEmpty()) {
    try {
      config.apply(changes);
      success(context,targetName,value);
      runLegacyChecks(context);
    }
 catch (    TransactionFailure transactionFailure) {
      fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",transactionFailure.getMessage()),transactionFailure);
      return false;
    }
  }
 else   if (delPropertySuccess || setElementSuccess) {
    success(context,targetName,value);
  }
 else {
    fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",targetName));
    return false;
  }
  if (targetService.isThisDAS() && !replicateSetCommand(context,targetName,value))   return false;
  return true;
}

Fixed version (ground truth):
private boolean set(AdminCommandContext context,SetOperation op){
  String pattern=op.pattern;
  String value=op.value;
  String target=op.target;
  String attrName=op.attrName;
  boolean isProperty=op.isProperty;
  TreeNode[] parentNodes=getAliasedParent(domain,pattern);
  String prefix;
  boolean lookAtSubNodes=true;
  if (parentNodes[0].relativeName.length() == 0 || parentNodes[0].relativeName.equals("String_Node_Str")) {
    prefix="String_Node_Str";
    lookAtSubNodes=false;
  }
 else   if (!pattern.startsWith(parentNodes[0].relativeName)) {
    prefix=pattern.substring(0,pattern.indexOf(parentNodes[0].relativeName));
    pattern=parentNodes[0].relativeName;
  }
 else {
    prefix="String_Node_Str";
    pattern=parentNodes[0].relativeName;
  }
  String targetName=prefix + pattern;
  Map<Dom,String> matchingNodes;
  boolean applyOverrideRules=false;
  Map<Dom,String> dottedNames=new HashMap<Dom,String>();
  if (lookAtSubNodes) {
    for (    TreeNode parentNode : parentNodes) {
      dottedNames.putAll(getAllDottedNodes(parentNode.node));
    }
    matchingNodes=getMatchingNodes(dottedNames,pattern);
    applyOverrideRules=true;
  }
 else {
    matchingNodes=new HashMap<Dom,String>();
    for (    TreeNode parentNode : parentNodes) {
      matchingNodes.put(parentNode.node,pattern);
    }
  }
  if (matchingNodes.isEmpty()) {
    pattern=target.substring(0,trueLastIndexOf(target,'.'));
    if (pattern.endsWith("String_Node_Str")) {
      pattern=pattern.substring(0,trueLastIndexOf(pattern,'.'));
      parentNodes=getAliasedParent(domain,pattern);
      pattern=parentNodes[0].relativeName;
      matchingNodes=getMatchingNodes(dottedNames,pattern);
      if (matchingNodes.isEmpty()) {
        fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",targetName));
        return false;
      }
      Dom parentNode=null;
      for (      Map.Entry<Dom,String> node : matchingNodes.entrySet()) {
        if (node.getValue().equals(pattern)) {
          parentNode=node.getKey();
        }
      }
      if (parentNode == null) {
        fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",targetName));
        return false;
      }
      if (value == null || value.length() == 0) {
        success(context,targetName,value);
        return true;
      }
      Map<String,String> attributes=new HashMap<String,String>();
      attributes.put("String_Node_Str",value);
      attributes.put("String_Node_Str",attrName);
      try {
        if (!(parentNode instanceof ConfigBean)) {
          final ClassCastException cce=new ClassCastException(parentNode.getClass().getName());
          fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",cce.getMessage(),cce));
          return false;
        }
        ConfigSupport.createAndSet((ConfigBean)parentNode,Property.class,attributes);
        success(context,targetName,value);
        runLegacyChecks(context);
        if (targetService.isThisDAS() && !replicateSetCommand(context,targetName,value))         return false;
        return true;
      }
 catch (      TransactionFailure transactionFailure) {
        fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",transactionFailure.getMessage()),transactionFailure);
        return false;
      }
    }
  }
  Map<ConfigBean,Map<String,String>> changes=new HashMap<ConfigBean,Map<String,String>>();
  boolean setElementSuccess=false;
  boolean delPropertySuccess=false;
  boolean delProperty=false;
  Map<String,String> attrChanges=new HashMap<String,String>();
  if (isProperty) {
    attrName="String_Node_Str";
    if ((value == null) || (value.length() == 0)) {
      delProperty=true;
    }
    attrChanges.put(attrName,value);
  }
  List<Map.Entry> mNodes=new ArrayList(matchingNodes.entrySet());
  if (applyOverrideRules) {
    mNodes=applyOverrideRules(mNodes);
  }
  for (  Map.Entry<Dom,String> node : mNodes) {
    final Dom targetNode=node.getKey();
    for (    String name : targetNode.model.getAttributeNames()) {
      String finalDottedName=node.getValue() + "String_Node_Str" + name;
      if (matches(finalDottedName,pattern)) {
        if (attrName.equals(name) || attrName.replace('_','-').equals(name.replace('_','-'))) {
          if (isDeprecatedAttr(targetNode,name)) {
            warning(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",finalDottedName));
          }
          if (!isProperty) {
            targetName=prefix + finalDottedName;
            if (value != null && value.length() > 0) {
              attrChanges.put(name,value);
            }
 else {
              attrChanges.put(name,null);
            }
          }
 else {
            targetName=prefix + node.getValue();
          }
          if (delProperty) {
            String str=node.getValue();
            if (trueLastIndexOf(str,'.') != -1) {
              str=str.substring(trueLastIndexOf(str,'.') + 1);
            }
            try {
              if (str != null) {
                ConfigSupport.deleteChild((ConfigBean)targetNode.parent(),(ConfigBean)targetNode);
                delPropertySuccess=true;
              }
            }
 catch (            IllegalArgumentException ie) {
              fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",ie.getMessage()),ie);
              return false;
            }
catch (            TransactionFailure transactionFailure) {
              fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",transactionFailure.getMessage()),transactionFailure);
              return false;
            }
          }
 else {
            changes.put((ConfigBean)node.getKey(),attrChanges);
          }
        }
      }
    }
    for (    String name : targetNode.model.getLeafElementNames()) {
      String finalDottedName=node.getValue() + "String_Node_Str" + name;
      if (matches(finalDottedName,pattern)) {
        if (attrName.equals(name) || attrName.replace('_','-').equals(name.replace('_','-'))) {
          if (isDeprecatedAttr(targetNode,name)) {
            warning(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",finalDottedName));
          }
          try {
            setLeafElement((ConfigBean)targetNode,name,value);
          }
 catch (          TransactionFailure ex) {
            fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",ex.getMessage()),ex);
            return false;
          }
          setElementSuccess=true;
          break;
        }
      }
    }
  }
  if (!changes.isEmpty()) {
    try {
      config.apply(changes);
      success(context,targetName,value);
      runLegacyChecks(context);
    }
 catch (    TransactionFailure transactionFailure) {
      fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",transactionFailure.getMessage()),transactionFailure);
      return false;
    }
  }
 else   if (delPropertySuccess || setElementSuccess) {
    success(context,targetName,value);
  }
 else {
    fail(context,localStrings.getLocalString("String_Node_Str","String_Node_Str",targetName));
    return false;
  }
  if (targetService.isThisDAS() && !replicateSetCommand(context,targetName,value))   return false;
  return true;
}