Program: 129207
Project: 129207
Buggy source:
public static List<ContextReferenceBean> checkContextFromProcess(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,RepositoryNode currentJobNode){
  IRepositoryViewObject object=currentJobNode.getObject();
  Item nodeItem=object.getProperty().getItem();
  boolean contextIsUsed=false;
  if (nodeItem instanceof ContextItem) {
    contextIsUsed=true;
  }
  List<ContextReferenceBean> list=new ArrayList<ContextReferenceBean>();
  if (deleteActionCache == null) {
    deleteActionCache=DeleteActionCache.getInstance();
    deleteActionCache.createRecords();
  }
  if (object != null && contextIsUsed) {
    Property property=object.getProperty();
    if (property != null) {
      String label=property.getLabel();
      String version=property.getVersion();
      Item item=property.getItem();
      if (!(item instanceof ContextItem)) {
        return list;
      }
      Set<Project> refParentProjects=new HashSet<Project>();
      try {
        refParentProjects.add(ProjectManager.getInstance().getCurrentProject());
        refParentProjects.addAll(ProjectManager.getInstance().getReferencedProjects());
        for (        Project refP : refParentProjects) {
          List<IRepositoryViewObject> objList=new ArrayList<IRepositoryViewObject>();
          List<IRepositoryViewObject> processes=factory.getAll(refP,ERepositoryObjectType.PROCESS);
          List<IRepositoryViewObject> jobletes=factory.getAll(refP,ERepositoryObjectType.JOBLET);
          processes.addAll(jobletes);
          deleteActionCache.setProcessList(processes);
          objList.addAll(processes);
          List<IRepositoryViewObject> connectionc=factory.getAll(refP,ERepositoryObjectType.METADATA_CONNECTIONS);
          objList.addAll(connectionc);
          List<IRepositoryViewObject> edifact=factory.getAll(refP,ERepositoryObjectType.METADATA_EDIFACT);
          objList.addAll(edifact);
          List<IRepositoryViewObject> brms=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_BRMS);
          objList.addAll(brms);
          List<IRepositoryViewObject> delis=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_DELIMITED);
          objList.addAll(delis);
          List<IRepositoryViewObject> ebcdic=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_EBCDIC);
          objList.addAll(ebcdic);
          List<IRepositoryViewObject> excel=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_EXCEL);
          objList.addAll(excel);
          List<IRepositoryViewObject> ftp=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_FTP);
          objList.addAll(ftp);
          List<IRepositoryViewObject> hl7=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_HL7);
          objList.addAll(hl7);
          List<IRepositoryViewObject> ldif=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_LDIF);
          objList.addAll(ldif);
          List<IRepositoryViewObject> positional=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_POSITIONAL);
          objList.addAll(positional);
          List<IRepositoryViewObject> regexp=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_REGEXP);
          objList.addAll(regexp);
          List<IRepositoryViewObject> xmls=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_XML);
          objList.addAll(xmls);
          List<IRepositoryViewObject> mdms=factory.getAll(refP,ERepositoryObjectType.METADATA_MDMCONNECTION);
          objList.addAll(mdms);
          List<IRepositoryViewObject> wsdl=factory.getAll(refP,ERepositoryObjectType.METADATA_WSDL_SCHEMA);
          objList.addAll(wsdl);
          List<IRepositoryViewObject> saleForces=factory.getAll(refP,ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
          objList.addAll(saleForces);
          for (          IRepositoryViewObject process : objList) {
            Property property2=process.getProperty();
            boolean isDelete=factory.getStatus(process) == ERepositoryStatus.DELETED;
            boolean isJob=true;
            Item item2=property2.getItem();
            if (item == item2) {
              continue;
            }
            List<IContext> contextList=null;
            String contextID=null;
            if (!isOpenedItem(item2,deleteActionCache.getOpenProcessMap())) {
              IDesignerCoreService service=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
              if (item2 instanceof ProcessItem) {
                contextList=service.getProcessFromProcessItem((ProcessItem)item2).getContextManager().getListContext();
              }
 else               if (item2 instanceof JobletProcessItem) {
                contextList=service.getProcessFromJobletProcessItem((JobletProcessItem)item2).getContextManager().getListContext();
              }
 else               if (item2 instanceof ConnectionItem) {
                contextID=((ConnectionItem)item2).getConnection().getContextId();
              }
            }
            if (contextList != null) {
              for (              IContext context : contextList) {
                if (context.getContextParameterList().size() <= 0) {
                  continue;
                }
                String source=context.getContextParameterList().get(0).getSource();
                if (source.equals(item.getProperty().getId())) {
                  String path=item2.getState().getPath();
                  String type=process.getRepositoryObjectType().getType();
                  ContextReferenceBean bean=new ContextReferenceBean(property2.getLabel(),type,property2.getVersion(),path,refP.getLabel());
                  bean.setJobFlag(isJob,isDelete);
                  list.add(bean);
                  break;
                }
              }
            }
 else             if (contextID != null) {
              if (contextID.equals(item.getProperty().getId())) {
                String path=item2.getState().getPath();
                String type=process.getRepositoryObjectType().getType();
                ContextReferenceBean bean=new ContextReferenceBean(property2.getLabel(),type,property2.getVersion(),path,refP.getLabel());
                bean.setJobFlag(isJob,isDelete);
                list.add(bean);
                break;
              }
            }
          }
          for (          IProcess2 openedProcess : deleteActionCache.getOpenedProcessList()) {
            List<IContext> contextList=openedProcess.getContextManager().getListContext();
            for (            IContext context : contextList) {
              if (context.getContextParameterList().size() <= 0) {
                continue;
              }
              String source=context.getContextParameterList().get(0).getSource();
              if (source.equals(item.getProperty().getId())) {
                boolean isDelete=factory.getStatus(openedProcess) == ERepositoryStatus.DELETED;
                boolean isJob=true;
                Property property2=openedProcess.getProperty();
                Item item2=property2.getItem();
                String path=item2.getState().getPath();
                ContextReferenceBean bean=new ContextReferenceBean(property2.getLabel(),openedProcess.getRepositoryObjectType().getType(),property2.getVersion(),path,refP.getLabel());
                bean.setJobFlag(isJob,isDelete);
                list.add(bean);
                break;
              }
            }
          }
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
  }
  return list;
}

Fixed version (ground truth):
public static List<ContextReferenceBean> checkContextFromProcess(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,RepositoryNode currentJobNode){
  IRepositoryViewObject object=currentJobNode.getObject();
  Item nodeItem=null;
  if (object != null && object.getProperty() != null) {
    nodeItem=object.getProperty().getItem();
  }
  boolean contextIsUsed=false;
  if (nodeItem != null && nodeItem instanceof ContextItem) {
    contextIsUsed=true;
  }
  List<ContextReferenceBean> list=new ArrayList<ContextReferenceBean>();
  if (deleteActionCache == null) {
    deleteActionCache=DeleteActionCache.getInstance();
    deleteActionCache.createRecords();
  }
  if (object != null && contextIsUsed) {
    Property property=object.getProperty();
    if (property != null) {
      String label=property.getLabel();
      String version=property.getVersion();
      Item item=property.getItem();
      if (!(item instanceof ContextItem)) {
        return list;
      }
      Set<Project> refParentProjects=new HashSet<Project>();
      try {
        refParentProjects.add(ProjectManager.getInstance().getCurrentProject());
        refParentProjects.addAll(ProjectManager.getInstance().getReferencedProjects());
        for (        Project refP : refParentProjects) {
          List<IRepositoryViewObject> objList=new ArrayList<IRepositoryViewObject>();
          List<IRepositoryViewObject> processes=factory.getAll(refP,ERepositoryObjectType.PROCESS);
          List<IRepositoryViewObject> jobletes=factory.getAll(refP,ERepositoryObjectType.JOBLET);
          processes.addAll(jobletes);
          deleteActionCache.setProcessList(processes);
          objList.addAll(processes);
          List<IRepositoryViewObject> connectionc=factory.getAll(refP,ERepositoryObjectType.METADATA_CONNECTIONS);
          objList.addAll(connectionc);
          List<IRepositoryViewObject> edifact=factory.getAll(refP,ERepositoryObjectType.METADATA_EDIFACT);
          objList.addAll(edifact);
          List<IRepositoryViewObject> brms=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_BRMS);
          objList.addAll(brms);
          List<IRepositoryViewObject> delis=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_DELIMITED);
          objList.addAll(delis);
          List<IRepositoryViewObject> ebcdic=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_EBCDIC);
          objList.addAll(ebcdic);
          List<IRepositoryViewObject> excel=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_EXCEL);
          objList.addAll(excel);
          List<IRepositoryViewObject> ftp=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_FTP);
          objList.addAll(ftp);
          List<IRepositoryViewObject> hl7=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_HL7);
          objList.addAll(hl7);
          List<IRepositoryViewObject> ldif=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_LDIF);
          objList.addAll(ldif);
          List<IRepositoryViewObject> positional=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_POSITIONAL);
          objList.addAll(positional);
          List<IRepositoryViewObject> regexp=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_REGEXP);
          objList.addAll(regexp);
          List<IRepositoryViewObject> xmls=factory.getAll(refP,ERepositoryObjectType.METADATA_FILE_XML);
          objList.addAll(xmls);
          List<IRepositoryViewObject> mdms=factory.getAll(refP,ERepositoryObjectType.METADATA_MDMCONNECTION);
          objList.addAll(mdms);
          List<IRepositoryViewObject> wsdl=factory.getAll(refP,ERepositoryObjectType.METADATA_WSDL_SCHEMA);
          objList.addAll(wsdl);
          List<IRepositoryViewObject> saleForces=factory.getAll(refP,ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
          objList.addAll(saleForces);
          for (          IRepositoryViewObject process : objList) {
            Property property2=process.getProperty();
            boolean isDelete=factory.getStatus(process) == ERepositoryStatus.DELETED;
            boolean isJob=true;
            Item item2=property2.getItem();
            if (item == item2) {
              continue;
            }
            List<IContext> contextList=null;
            String contextID=null;
            if (!isOpenedItem(item2,deleteActionCache.getOpenProcessMap())) {
              IDesignerCoreService service=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
              if (item2 instanceof ProcessItem) {
                contextList=service.getProcessFromProcessItem((ProcessItem)item2).getContextManager().getListContext();
              }
 else               if (item2 instanceof JobletProcessItem) {
                contextList=service.getProcessFromJobletProcessItem((JobletProcessItem)item2).getContextManager().getListContext();
              }
 else               if (item2 instanceof ConnectionItem) {
                contextID=((ConnectionItem)item2).getConnection().getContextId();
              }
            }
            if (contextList != null) {
              for (              IContext context : contextList) {
                if (context.getContextParameterList().size() <= 0) {
                  continue;
                }
                String source=context.getContextParameterList().get(0).getSource();
                if (source.equals(item.getProperty().getId())) {
                  String path=item2.getState().getPath();
                  String type=process.getRepositoryObjectType().getType();
                  ContextReferenceBean bean=new ContextReferenceBean(property2.getLabel(),type,property2.getVersion(),path,refP.getLabel());
                  bean.setJobFlag(isJob,isDelete);
                  list.add(bean);
                  break;
                }
              }
            }
 else             if (contextID != null) {
              if (contextID.equals(item.getProperty().getId())) {
                String path=item2.getState().getPath();
                String type=process.getRepositoryObjectType().getType();
                ContextReferenceBean bean=new ContextReferenceBean(property2.getLabel(),type,property2.getVersion(),path,refP.getLabel());
                bean.setJobFlag(isJob,isDelete);
                list.add(bean);
                break;
              }
            }
          }
          for (          IProcess2 openedProcess : deleteActionCache.getOpenedProcessList()) {
            List<IContext> contextList=openedProcess.getContextManager().getListContext();
            for (            IContext context : contextList) {
              if (context.getContextParameterList().size() <= 0) {
                continue;
              }
              String source=context.getContextParameterList().get(0).getSource();
              if (source.equals(item.getProperty().getId())) {
                boolean isDelete=factory.getStatus(openedProcess) == ERepositoryStatus.DELETED;
                boolean isJob=true;
                Property property2=openedProcess.getProperty();
                Item item2=property2.getItem();
                String path=item2.getState().getPath();
                ContextReferenceBean bean=new ContextReferenceBean(property2.getLabel(),openedProcess.getRepositoryObjectType().getType(),property2.getVersion(),path,refP.getLabel());
                bean.setJobFlag(isJob,isDelete);
                list.add(bean);
                break;
              }
            }
          }
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
  }
  return list;
}