Program: 118594
Project: 118594
Buggy source:
private JSONObject collectProjectDetails() throws PersistenceException, JSONException {
  JSONObject jObject=new JSONObject();
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  final IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  JSONObject repoStats=new JSONObject();
  for (  DynaEnum type : ERepositoryObjectType.values()) {
    if (type instanceof ERepositoryObjectType && ((ERepositoryObjectType)type).isResourceItem()) {
      try {
        List<IRepositoryViewObject> all=factory.getAll(currentProject,(ERepositoryObjectType)type);
        int nb=all.size();
        if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_PATTERN_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_RULES.equals(type)|| "String_Node_Str".equals(type.getType())) {
          continue;
        }
        if (ERepositoryObjectType.ROUTINES.equals(type)) {
          nb=0;
          List<IRepositoryViewObject> newList=new ArrayList<IRepositoryViewObject>();
          for (          IRepositoryViewObject object : all) {
            RoutineItem rItem=(RoutineItem)object.getProperty().getItem();
            if (!rItem.isBuiltIn()) {
              nb++;
              newList.add(object);
            }
          }
          all=newList;
        }
        if (ERepositoryObjectType.SQLPATTERNS.equals(type)) {
          nb=0;
          for (          IRepositoryViewObject object : all) {
            SQLPatternItem spItem=(SQLPatternItem)object.getProperty().getItem();
            if (!spItem.isSystem()) {
              nb++;
            }
          }
        }
        if ("String_Node_Str".equals(type.getType())) {
          nb=0;
          for (          IRepositoryViewObject object : all) {
            String path=object.getProperty().getItem().getState().getPath();
            if (!"String_Node_Str".equals(path)) {
              nb++;
            }
          }
        }
        if (nb > 0) {
          JSONObject typeStats=new JSONObject();
          typeStats.put("String_Node_Str",nb);
          if (ERepositoryObjectType.getAllTypesOfProcess().contains(type)) {
            JSONObject jobDetails=new JSONObject();
            collectJobDetails(all,jobDetails);
            typeStats.put("String_Node_Str",jobDetails);
          }
          if (ERepositoryObjectType.ROUTINES.equals(type) || ((ERepositoryObjectType)type).getFolder().startsWith("String_Node_Str") || ERepositoryObjectType.CONTEXT.equals(type)|| type.equals(ERepositoryObjectType.JOBLET)) {
            int nbUsed=0;
            for (            IRepositoryViewObject object : all) {
              List<Relation> relations=RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getId());
              relations.addAll(RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getLabel()));
              if (relations.size() > 0) {
                nbUsed++;
              }
            }
            typeStats.put("String_Node_Str",nbUsed);
          }
          if (ERepositoryObjectType.METADATA_CONNECTIONS.equals(type)) {
            JSONObject objects=new JSONObject();
            for (            IRepositoryViewObject object : all) {
              DatabaseConnectionItem item=(DatabaseConnectionItem)object.getProperty().getItem();
              String dbType=((DatabaseConnection)item.getConnection()).getDatabaseType();
              int nbDbTypes=1;
              if (objects.has(dbType)) {
                nbDbTypes=objects.getInt(dbType);
                nbDbTypes++;
              }
              objects.put(dbType,nbDbTypes);
            }
            typeStats.put("String_Node_Str",objects);
          }
          repoStats.put(type.getType(),typeStats);
        }
      }
 catch (      Exception e) {
        ExceptionHandler.process(e);
      }
    }
  }
  jObject.put("String_Node_Str",repoStats);
  jObject.put("String_Node_Str",ProjectManager.getInstance().getProjectType(currentProject));
  int nbRef=ProjectManager.getInstance().getAllReferencedProjects().size();
  if (nbRef > 0) {
    jObject.put("String_Node_Str",nbRef);
  }
  return jObject;
}

Fixed version (ground truth):
private JSONObject collectProjectDetails() throws PersistenceException, JSONException {
  JSONObject jObject=new JSONObject();
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  final IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  JSONObject repoStats=new JSONObject();
  for (  DynaEnum type : ERepositoryObjectType.values()) {
    if (type instanceof ERepositoryObjectType && ((ERepositoryObjectType)type).isResourceItem()) {
      try {
        List<IRepositoryViewObject> all=factory.getAll(currentProject,(ERepositoryObjectType)type);
        int nb=all.size();
        if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_PATTERN_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_RULES.equals(type)|| "String_Node_Str".equals(type.getType())) {
          continue;
        }
        if (ERepositoryObjectType.ROUTINES.equals(type)) {
          nb=0;
          List<IRepositoryViewObject> newList=new ArrayList<IRepositoryViewObject>();
          for (          IRepositoryViewObject object : all) {
            RoutineItem rItem=(RoutineItem)object.getProperty().getItem();
            if (!rItem.isBuiltIn()) {
              nb++;
              newList.add(object);
            }
          }
          all=newList;
        }
        if (ERepositoryObjectType.SQLPATTERNS.equals(type)) {
          nb=0;
          for (          IRepositoryViewObject object : all) {
            SQLPatternItem spItem=(SQLPatternItem)object.getProperty().getItem();
            if (!spItem.isSystem()) {
              nb++;
            }
          }
        }
        if ("String_Node_Str".equals(type.getType())) {
          nb=0;
          for (          IRepositoryViewObject object : all) {
            String path=object.getProperty().getItem().getState().getPath();
            if (!"String_Node_Str".equals(path)) {
              nb++;
            }
          }
        }
        if (nb > 0) {
          JSONObject typeStats=new JSONObject();
          typeStats.put("String_Node_Str",nb);
          if (ERepositoryObjectType.getAllTypesOfProcess().contains(type)) {
            JSONObject jobDetails=new JSONObject();
            collectJobDetails(all,jobDetails);
            typeStats.put("String_Node_Str",jobDetails);
          }
          if (ERepositoryObjectType.ROUTINES.equals(type) || ((ERepositoryObjectType)type).getFolder().startsWith("String_Node_Str") || ERepositoryObjectType.CONTEXT.equals(type)|| type.equals(ERepositoryObjectType.JOBLET)) {
            int nbUsed=0;
            for (            IRepositoryViewObject object : all) {
              List<Relation> relations=RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getId());
              relations.addAll(RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getLabel()));
              if (relations.size() > 0) {
                nbUsed++;
              }
            }
            typeStats.put("String_Node_Str",nbUsed);
          }
          if (ERepositoryObjectType.METADATA_CONNECTIONS.equals(type)) {
            JSONObject objects=new JSONObject();
            for (            IRepositoryViewObject object : all) {
              DatabaseConnectionItem item=(DatabaseConnectionItem)object.getProperty().getItem();
              String dbType=((DatabaseConnection)item.getConnection()).getDatabaseType();
              int nbDbTypes=1;
              if (objects.has(dbType)) {
                nbDbTypes=objects.getInt(dbType);
                nbDbTypes++;
              }
              objects.put(dbType,nbDbTypes);
            }
            typeStats.put("String_Node_Str",objects);
          }
          repoStats.put(type.getType(),typeStats);
        }
      }
 catch (      Exception e) {
        ExceptionHandler.process(e);
      }
    }
  }
  jObject.put(PROJECTS.getKey(),repoStats);
  jObject.put(TYPE.getKey(),ProjectManager.getInstance().getProjectType(currentProject));
  int nbRef=ProjectManager.getInstance().getAllReferencedProjects().size();
  if (nbRef > 0) {
    jObject.put("String_Node_Str",nbRef);
  }
  return jObject;
}