Program: 148964
Project: 148964
Buggy source:
public void doImport(TreeObject[] objs,IProgressMonitor monitor){
  monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
  XtentisPort port=null;
  Reader reader=null;
  try {
    port=Util.getPort((TreeObject)sel.getFirstElement());
  }
 catch (  XtentisException e3) {
    e3.printStackTrace();
  }
  Arrays.sort(objs,new Comparator<Object>(){
    public int compare(    Object o1,    Object o2){
      return ((TreeObject)o1).getType() - ((TreeObject)o2).getType();
    }
  }
);
  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();
      model=(WSDataCluster)Unmarshaller.unmarshal(WSDataCluster.class,reader);
      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);
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);
port.putMenu(new WSPutMenu(memu));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.ROLE:
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);
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);
}
}
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);
port.putStoredProcedure(new WSPutStoredProcedure(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
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);
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);
port.putTransformer(new WSPutTransformer(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
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);
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);
}
}
}
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);
  XtentisPort port=null;
  Reader reader=null;
  try {
    port=Util.getPort((TreeObject)sel.getFirstElement());
  }
 catch (  XtentisException e3) {
    e3.printStackTrace();
  }
  Arrays.sort(objs,new Comparator<Object>(){
    public int compare(    Object o1,    Object o2){
      return ((TreeObject)o1).getType() - ((TreeObject)o2).getType();
    }
  }
);
  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();
      model=(WSDataCluster)Unmarshaller.unmarshal(WSDataCluster.class,reader);
      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);
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);
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);
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);
}
}
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);
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);
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);
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);
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);
}
}
}
port.putView(new WSPutView(model));
}
 catch (Exception e2) {
e2.printStackTrace();
}
}
monitor.worked(1);
break;
}
}
monitor.done();
}