Program: 89304
Project: 89304
Buggy source:
/** 
 * Execute custom Java logic
 * @param req  Web Script request
 * @param status  Web Script status
 * @param cache  Web Script cache
 * @param isRM  indicates whether the request comes from an RM site or not
 * @return custom service model
 */
private Map<String,Object> executeImpl(WebScriptRequest req,Status status,Cache cache,boolean isRM){
  String classFilter=getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER));
  String namespacePrefix=getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX));
  String name=getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME));
  String className=null;
  Map<QName,ClassDefinition> classdef=new HashMap<QName,ClassDefinition>();
  Map<QName,Collection<PropertyDefinition>> propdef=new HashMap<QName,Collection<PropertyDefinition>>();
  Map<QName,Collection<AssociationDefinition>> assocdef=new HashMap<QName,Collection<AssociationDefinition>>();
  Map<String,Object> model=new HashMap<String,Object>();
  List<QName> qnames=new ArrayList<QName>();
  QName classQname=null;
  QName myModel=null;
  if (classFilter == null) {
    classFilter="String_Node_Str";
  }
  if (!isValidClassFilter(classFilter)) {
    throw new WebScriptException(Status.STATUS_NOT_FOUND,"String_Node_Str" + classFilter + "String_Node_Str");
  }
  if (namespacePrefix == null && name != null) {
    throw new WebScriptException(Status.STATUS_NOT_FOUND,"String_Node_Str");
  }
  if (namespacePrefix != null) {
    if (name != null) {
      className=namespacePrefix + "String_Node_Str" + name;
      if (!isValidClassname(className)) {
        throw new WebScriptException(Status.STATUS_NOT_FOUND,"String_Node_Str" + name + "String_Node_Str");
      }
      classQname=QName.createQName(getFullNamespaceURI(className));
      classdef.put(classQname,this.dictionaryservice.getClass(classQname));
      propdef.put(classQname,this.dictionaryservice.getClass(classQname).getProperties().values());
      assocdef.put(classQname,this.dictionaryservice.getClass(classQname).getAssociations().values());
    }
 else {
      String namespaceUri=namespaceService.getNamespaceURI(namespacePrefix);
      for (      QName qnameObj : this.dictionaryservice.getAllModels()) {
        if (qnameObj.getNamespaceURI().equals(namespaceUri)) {
          name=qnameObj.getLocalName();
          myModel=QName.createQName(getFullNamespaceURI(namespacePrefix + "String_Node_Str" + name));
          if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) {
            qnames.addAll(this.dictionaryservice.getAspects(myModel));
            qnames.addAll(this.dictionaryservice.getTypes(myModel));
          }
 else           if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) {
            qnames.addAll(this.dictionaryservice.getTypes(myModel));
          }
 else           if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) {
            qnames.addAll(this.dictionaryservice.getAspects(myModel));
          }
        }
      }
    }
  }
  if (myModel == null) {
    if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) {
      qnames.addAll(getAspects(isRM));
      qnames.addAll(getTypes(isRM));
    }
 else     if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) {
      qnames.addAll(getTypes(isRM));
    }
 else     if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) {
      qnames.addAll(getAspects(isRM));
    }
  }
  if (classdef.isEmpty()) {
    for (    QName qnameObj : qnames) {
      classdef.put(qnameObj,this.dictionaryservice.getClass(qnameObj));
      propdef.put(qnameObj,this.dictionaryservice.getClass(qnameObj).getProperties().values());
      assocdef.put(qnameObj,this.dictionaryservice.getClass(qnameObj).getAssociations().values());
    }
  }
  List<ClassDefinition> classDefinitions=new ArrayList<ClassDefinition>(classdef.values());
  Collections.sort(classDefinitions,new DictionaryComparators.ClassDefinitionComparator(dictionaryservice));
  model.put(MODEL_PROP_KEY_CLASS_DEFS,classDefinitions);
  model.put(MODEL_PROP_KEY_PROPERTY_DETAILS,propdef.values());
  model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS,assocdef.values());
  model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP,dictionaryservice);
  return model;
}

Fixed version (ground truth):
/** 
 * Execute custom Java logic
 * @param req  Web Script request
 * @param isRM  indicates whether the request comes from an RM site or not
 * @return custom service model
 */
private Map<String,Object> executeImpl(WebScriptRequest req,boolean isRM){
  String classFilter=getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER));
  String namespacePrefix=getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX));
  String name=getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME));
  String className=null;
  Map<QName,ClassDefinition> classdef=new HashMap<QName,ClassDefinition>();
  Map<QName,Collection<PropertyDefinition>> propdef=new HashMap<QName,Collection<PropertyDefinition>>();
  Map<QName,Collection<AssociationDefinition>> assocdef=new HashMap<QName,Collection<AssociationDefinition>>();
  Map<String,Object> model=new HashMap<String,Object>();
  List<QName> qnames=new ArrayList<QName>();
  QName classQname=null;
  QName myModel=null;
  if (classFilter == null) {
    classFilter="String_Node_Str";
  }
  if (!isValidClassFilter(classFilter)) {
    throw new WebScriptException(Status.STATUS_NOT_FOUND,"String_Node_Str" + classFilter + "String_Node_Str");
  }
  if (namespacePrefix == null && name != null) {
    throw new WebScriptException(Status.STATUS_NOT_FOUND,"String_Node_Str");
  }
  if (namespacePrefix != null) {
    if (name != null) {
      className=namespacePrefix + "String_Node_Str" + name;
      if (!isValidClassname(className)) {
        throw new WebScriptException(Status.STATUS_NOT_FOUND,"String_Node_Str" + name + "String_Node_Str");
      }
      classQname=QName.createQName(getFullNamespaceURI(className));
      classdef.put(classQname,this.dictionaryservice.getClass(classQname));
      propdef.put(classQname,this.dictionaryservice.getClass(classQname).getProperties().values());
      assocdef.put(classQname,this.dictionaryservice.getClass(classQname).getAssociations().values());
    }
 else {
      String namespaceUri=namespaceService.getNamespaceURI(namespacePrefix);
      for (      QName qnameObj : this.dictionaryservice.getAllModels()) {
        if (qnameObj.getNamespaceURI().equals(namespaceUri)) {
          name=qnameObj.getLocalName();
          myModel=QName.createQName(getFullNamespaceURI(namespacePrefix + "String_Node_Str" + name));
          if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) {
            qnames.addAll(this.dictionaryservice.getAspects(myModel));
            qnames.addAll(this.dictionaryservice.getTypes(myModel));
          }
 else           if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) {
            qnames.addAll(this.dictionaryservice.getTypes(myModel));
          }
 else           if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) {
            qnames.addAll(this.dictionaryservice.getAspects(myModel));
          }
        }
      }
    }
  }
  if (myModel == null) {
    if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1)) {
      qnames.addAll(getAspects(isRM));
      qnames.addAll(getTypes(isRM));
    }
 else     if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3)) {
      qnames.addAll(getTypes(isRM));
    }
 else     if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2)) {
      qnames.addAll(getAspects(isRM));
    }
  }
  if (classdef.isEmpty()) {
    for (    QName qnameObj : qnames) {
      classdef.put(qnameObj,this.dictionaryservice.getClass(qnameObj));
      propdef.put(qnameObj,this.dictionaryservice.getClass(qnameObj).getProperties().values());
      assocdef.put(qnameObj,this.dictionaryservice.getClass(qnameObj).getAssociations().values());
    }
  }
  List<ClassDefinition> classDefinitions=new ArrayList<ClassDefinition>(classdef.values());
  Collections.sort(classDefinitions,new DictionaryComparators.ClassDefinitionComparator(dictionaryservice));
  model.put(MODEL_PROP_KEY_CLASS_DEFS,classDefinitions);
  model.put(MODEL_PROP_KEY_PROPERTY_DETAILS,propdef.values());
  model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS,assocdef.values());
  model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP,dictionaryservice);
  return model;
}