Program: 148825
Project: 148825
Buggy source:
public void doImport(TreeObject[] objs,IProgressMonitor monitor){
  monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
  Reader reader=null;
  Arrays.sort(objs,new Comparator<Object>(){
    public int compare(    Object o1,    Object o2){
      return ((TreeObject)o1).getType() - ((TreeObject)o2).getType();
    }
  }
);
  boolean isOverrideAll=false;
  Display dis=Display.getCurrent();
  for (  TreeObject item : objs) {
    String[] subItems;
switch (item.getType()) {
case TreeObject.DATA_CLUSTER:
      monitor.subTask("String_Node_Str");
    subItems=item.getItems();
  for (  String subItem : subItems) {
    try {
      reader=new FileReader(importFolder + "String_Node_Str" + subItem);
      WSDataCluster model=new WSDataCluster();
      final String dataClusterName=model.getName();
      model=(WSDataCluster)Unmarshaller.unmarshal(WSDataCluster.class,reader);
      if (port.existsDataCluster(new WSExistsDataCluster(new WSDataClusterPK(model.getName()))).is_true()) {
        if (!isOverrideAll) {
          int result=isOveride(model.getName(),TreeObject.DATACONTAINER);
          if (result == IDialogConstants.CANCEL_ID) {
            return;
          }
          if (result == IDialogConstants.YES_TO_ALL_ID) {
            isOverrideAll=true;
          }
          if (result == IDialogConstants.NO_ID) {
            break;
          }
        }
      }
      port.putDataCluster(new WSPutDataCluster(model));
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
    importClusterContents(item,port);
  }
break;
case TreeObject.DATA_CLUSTER_CONTENTS:
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSItem wsItem=new WSItem();
wsItem=(WSItem)Unmarshaller.unmarshal(WSItem.class,reader);
if (wsItem != null) {
  port.putItem(new WSPutItem(wsItem.getWsDataClusterPK(),wsItem.getContent(),new WSDataModelPK(wsItem.getDataModelName()),true));
}
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
break;
case TreeObject.DATA_MODEL:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSDataModel model=new WSDataModel();
model=(WSDataModel)Unmarshaller.unmarshal(WSDataModel.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.DATAMODEL_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putDataModel(new WSPutDataModel(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSMenu memu=new WSMenu();
memu=(WSMenu)Unmarshaller.unmarshal(WSMenu.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(memu.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(memu.getName(),TreeObject.MENU_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putMenu(new WSPutMenu(memu));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.ROLE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSRole role=new WSRole();
role=(WSRole)Unmarshaller.unmarshal(WSRole.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(role.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(role.getName(),TreeObject.ROLE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putRole(new WSPutRole(role));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
}
break;
case TreeObject.ROUTING_RULE:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSRoutingRule routingRule=new WSRoutingRule();
routingRule=(WSRoutingRule)Unmarshaller.unmarshal(WSRoutingRule.class,reader);
if (routingRule.getWsRoutingRuleExpressions() != null) {
for (WSRoutingRuleExpression rule : routingRule.getWsRoutingRuleExpressions()) {
if (rule.getWsOperator() == null) rule.setWsOperator(WSRoutingRuleOperator.CONTAINS);
}
}
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(routingRule.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(routingRule.getName(),TreeObject.ROUTINGRULE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putRoutingRule(new WSPutRoutingRule(routingRule));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSStoredProcedure model=new WSStoredProcedure();
model=(WSStoredProcedure)Unmarshaller.unmarshal(WSStoredProcedure.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.STOREDPROCEDURE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putStoredProcedure(new WSPutStoredProcedure(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSSynchronizationPlan model=new WSSynchronizationPlan();
model=(WSSynchronizationPlan)Unmarshaller.unmarshal(WSSynchronizationPlan.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.SYNCHRONIZATIONPLAN_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putSynchronizationPlan(new WSPutSynchronizationPlan(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
}
break;
case TreeObject.TRANSFORMER:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSTransformer model=new WSTransformer();
model=(WSTransformer)Unmarshaller.unmarshal(WSTransformer.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.TRANSFORMER_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putTransformer(new WSPutTransformer(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSUniverse model=new WSUniverse();
model=(WSUniverse)Unmarshaller.unmarshal(WSUniverse.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.UNIVERSE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putUniverse(new WSPutUniverse(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
}
break;
case TreeObject.VIEW:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSView model=new WSView();
model=(WSView)Unmarshaller.unmarshal(WSView.class,reader);
if (model.getWhereConditions() != null) {
for (WSWhereCondition ws : model.getWhereConditions()) {
if (ws.getOperator() == null) {
ws.setOperator(WSWhereOperator.CONTAINS);
}
if (ws.getStringPredicate() == null) {
ws.setStringPredicate(WSStringPredicate.NONE);
}
}
}
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.VIEW_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putView(new WSPutView(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
}
}
monitor.done();
}

Fixed version (ground truth):
public void doImport(TreeObject[] objs,IProgressMonitor monitor){
  monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
  Reader reader=null;
  Arrays.sort(objs,new Comparator<Object>(){
    public int compare(    Object o1,    Object o2){
      return ((TreeObject)o1).getType() - ((TreeObject)o2).getType();
    }
  }
);
  boolean isOverrideAll=false;
  Display dis=Display.getCurrent();
  for (  TreeObject item : objs) {
    String[] subItems;
switch (item.getType()) {
case TreeObject.DATA_CLUSTER:
      monitor.subTask("String_Node_Str");
    subItems=item.getItems();
  for (  String subItem : subItems) {
    try {
      reader=new FileReader(importFolder + "String_Node_Str" + subItem);
      WSDataCluster model=new WSDataCluster();
      final String dataClusterName=model.getName();
      model=(WSDataCluster)Unmarshaller.unmarshal(WSDataCluster.class,reader);
      if (port.existsDataCluster(new WSExistsDataCluster(new WSDataClusterPK(model.getName()))).is_true()) {
        if (!isOverrideAll) {
          int result=isOveride(model.getName(),TreeObject.DATACONTAINER);
          if (result == IDialogConstants.CANCEL_ID) {
            return;
          }
          if (result == IDialogConstants.YES_TO_ALL_ID) {
            isOverrideAll=true;
          }
          if (result == IDialogConstants.NO_ID) {
            break;
          }
        }
      }
      port.putDataCluster(new WSPutDataCluster(model));
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
    importClusterContents(item,port);
  }
break;
case TreeObject.DATA_CLUSTER_CONTENTS:
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSItem wsItem=new WSItem();
wsItem=(WSItem)Unmarshaller.unmarshal(WSItem.class,reader);
if (wsItem != null) {
  port.putItem(new WSPutItem(wsItem.getWsDataClusterPK(),wsItem.getContent(),new WSDataModelPK(wsItem.getDataModelName()),true));
}
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
break;
case TreeObject.DATA_MODEL:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSDataModel model=new WSDataModel();
model=(WSDataModel)Unmarshaller.unmarshal(WSDataModel.class,reader);
if (port.existsDataModel(new WSExistsDataModel(new WSDataModelPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.DATAMODEL_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putDataModel(new WSPutDataModel(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSMenu memu=new WSMenu();
memu=(WSMenu)Unmarshaller.unmarshal(WSMenu.class,reader);
if (port.existsMenu(new WSExistsMenu(new WSMenuPK(memu.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(memu.getName(),TreeObject.MENU_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putMenu(new WSPutMenu(memu));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.ROLE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSRole role=new WSRole();
role=(WSRole)Unmarshaller.unmarshal(WSRole.class,reader);
if (port.existsRole(new WSExistsRole(new WSRolePK(role.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(role.getName(),TreeObject.ROLE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putRole(new WSPutRole(role));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
}
break;
case TreeObject.ROUTING_RULE:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSRoutingRule routingRule=new WSRoutingRule();
routingRule=(WSRoutingRule)Unmarshaller.unmarshal(WSRoutingRule.class,reader);
if (routingRule.getWsRoutingRuleExpressions() != null) {
for (WSRoutingRuleExpression rule : routingRule.getWsRoutingRuleExpressions()) {
if (rule.getWsOperator() == null) rule.setWsOperator(WSRoutingRuleOperator.CONTAINS);
}
}
if (port.existsRoutingRule(new WSExistsRoutingRule(new WSRoutingRulePK(routingRule.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(routingRule.getName(),TreeObject.ROUTINGRULE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putRoutingRule(new WSPutRoutingRule(routingRule));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSStoredProcedure model=new WSStoredProcedure();
model=(WSStoredProcedure)Unmarshaller.unmarshal(WSStoredProcedure.class,reader);
if (port.existsStoredProcedure(new WSExistsStoredProcedure(new WSStoredProcedurePK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.STOREDPROCEDURE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putStoredProcedure(new WSPutStoredProcedure(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSSynchronizationPlan model=new WSSynchronizationPlan();
model=(WSSynchronizationPlan)Unmarshaller.unmarshal(WSSynchronizationPlan.class,reader);
if (port.existsSynchronizationPlan(new WSExistsSynchronizationPlan(new WSSynchronizationPlanPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.SYNCHRONIZATIONPLAN_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putSynchronizationPlan(new WSPutSynchronizationPlan(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
}
break;
case TreeObject.TRANSFORMER:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSTransformer model=new WSTransformer();
model=(WSTransformer)Unmarshaller.unmarshal(WSTransformer.class,reader);
if (port.existsTransformer(new WSExistsTransformer(new WSTransformerPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.TRANSFORMER_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putTransformer(new WSPutTransformer(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSUniverse model=new WSUniverse();
model=(WSUniverse)Unmarshaller.unmarshal(WSUniverse.class,reader);
if (port.existsUniverse(new WSExistsUniverse(new WSUniversePK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.UNIVERSE_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putUniverse(new WSPutUniverse(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
}
break;
case TreeObject.VIEW:
monitor.subTask("String_Node_Str");
subItems=item.getItems();
for (String subItem : subItems) {
try {
reader=new FileReader(importFolder + "String_Node_Str" + subItem);
WSView model=new WSView();
model=(WSView)Unmarshaller.unmarshal(WSView.class,reader);
if (model.getWhereConditions() != null) {
for (WSWhereCondition ws : model.getWhereConditions()) {
if (ws.getOperator() == null) {
ws.setOperator(WSWhereOperator.CONTAINS);
}
if (ws.getStringPredicate() == null) {
ws.setStringPredicate(WSStringPredicate.NONE);
}
}
}
if (port.existsView(new WSExistsView(new WSViewPK(model.getName()))).is_true()) {
if (!isOverrideAll) {
int result=isOveride(model.getName(),TreeObject.VIEW_);
if (result == IDialogConstants.CANCEL_ID) {
return;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll=true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
}
port.putView(new WSPutView(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
}
}
monitor.done();
}