Program: 148837
Project: 148837
Buggy source:
public void doexport(TreeObject[] objs,IProgressMonitor monitor){
  if (objs.length == 0)   return;
  monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
  Exports eps=new Exports();
  List<TreeObject> exports=new ArrayList<TreeObject>();
  XtentisPort port;
  try {
    port=Util.getPort(objs[0]);
    for (    TreeObject obj : objs) {
      StringWriter sw;
      ArrayList<String> items;
switch (obj.getType()) {
case TreeObject.DATA_CLUSTER:
        monitor.subTask("String_Node_Str");
      items=new ArrayList<String>();
    WSDataClusterPK pk=(WSDataClusterPK)obj.getWsKey();
  WSDataCluster cluster=port.getDataCluster(new WSGetDataCluster(pk));
sw=new StringWriter();
Marshaller.marshal(cluster,sw);
writeString(sw.toString(),TreeObject.DATACONTAINER + "String_Node_Str" + cluster.getName());
items.add(TreeObject.DATACONTAINER + "String_Node_Str" + cluster.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
monitor.subTask("String_Node_Str" + pk.getPk() + "String_Node_Str");
List<String> items1=new ArrayList<String>();
WSItemPKsByCriteriaResponseResults[] results=port.getItemPKsByCriteria(new WSGetItemPKsByCriteria(pk,null,null,null,(long)-1,(long)-1,0,Integer.MAX_VALUE)).getResults();
if (results == null) continue;
for (WSItemPKsByCriteriaResponseResults item : results) {
WSItem wsitem=port.getItem(new WSGetItem(item.getWsItemPK()));
StringWriter sw1=new StringWriter();
Marshaller.marshal(wsitem,sw1);
String uniqueId=pk.getPk() + "String_Node_Str" + wsitem.getConceptName()+ "String_Node_Str";
for (String id : wsitem.getIds()) {
uniqueId=uniqueId + "String_Node_Str" + id;
}
writeString(sw1.toString(),TreeObject.DATACONTAINER_COTENTS + "String_Node_Str" + pk.getPk()+ "String_Node_Str"+ uniqueId);
items1.add(TreeObject.DATACONTAINER_COTENTS + "String_Node_Str" + pk.getPk()+ "String_Node_Str"+ uniqueId);
}
TreeObject obj1=new TreeObject("String_Node_Str",null,TreeObject.DATA_CLUSTER_CONTENTS,null,null);
obj1.setItems(items1.toArray(new String[items1.size()]));
exports.add(obj1);
monitor.worked(1);
break;
case TreeObject.DATA_MODEL:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSDataModel model=port.getDataModel(new WSGetDataModel((WSDataModelPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(model,sw);
writeString(sw.toString(),TreeObject.DATAMODEL_ + "String_Node_Str" + model.getName());
items.add(TreeObject.DATAMODEL_ + "String_Node_Str" + model.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSMenu menu=port.getMenu(new WSGetMenu((WSMenuPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(menu,sw);
writeString(sw.toString(),TreeObject.MENU_ + "String_Node_Str" + menu.getName());
items.add(TreeObject.MENU_ + "String_Node_Str" + menu.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.ROLE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSRole role=port.getRole(new WSGetRole((WSRolePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(role,sw);
writeString(sw.toString(),TreeObject.ROLE_ + "String_Node_Str" + role.getName());
items.add(TreeObject.ROLE_ + "String_Node_Str" + role.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
break;
case TreeObject.ROUTING_RULE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSRoutingRule RoutingRule=port.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(RoutingRule,sw);
writeString(sw.toString(),TreeObject.ROUTINGRULE_ + "String_Node_Str" + RoutingRule.getName());
items.add(TreeObject.ROUTINGRULE_ + "String_Node_Str" + RoutingRule.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSStoredProcedure StoredProcedure=port.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(StoredProcedure,sw);
writeString(sw.toString(),TreeObject.STOREDPROCEDURE_ + "String_Node_Str" + StoredProcedure.getName());
items.add(TreeObject.STOREDPROCEDURE_ + "String_Node_Str" + StoredProcedure.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSSynchronizationPlan SynchronizationPlan=port.getSynchronizationPlan(new WSGetSynchronizationPlan((WSSynchronizationPlanPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(SynchronizationPlan,sw);
writeString(sw.toString(),TreeObject.SYNCHRONIZATIONPLAN_ + "String_Node_Str" + SynchronizationPlan.getName());
items.add(TreeObject.SYNCHRONIZATIONPLAN_ + "String_Node_Str" + SynchronizationPlan.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
break;
case TreeObject.TRANSFORMER:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSTransformer transformer=port.getTransformer(new WSGetTransformer(new WSTransformerPK(((WSTransformerV2PK)obj.getWsKey()).getPk())));
sw=new StringWriter();
Marshaller.marshal(transformer,sw);
writeString(sw.toString(),TreeObject.TRANSFORMER_ + "String_Node_Str" + transformer.getName());
items.add(TreeObject.TRANSFORMER_ + "String_Node_Str" + transformer.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSUniverse universe=port.getUniverse(new WSGetUniverse((WSUniversePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(universe,sw);
writeString(sw.toString(),TreeObject.UNIVERSE_ + "String_Node_Str" + universe.getName());
items.add(TreeObject.UNIVERSE_ + "String_Node_Str" + universe.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
break;
case TreeObject.VIEW:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSView View=port.getView(new WSGetView((WSViewPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(View,sw);
writeString(sw.toString(),TreeObject.VIEW_ + "String_Node_Str" + View.getName());
items.add(TreeObject.VIEW_ + "String_Node_Str" + View.getName());
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
}
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
StringWriter sw=new StringWriter();
try {
Marshaller.marshal(eps,sw);
writeString(sw.toString(),"String_Node_Str");
}
 catch (Exception e) {
}
monitor.done();
}
 catch (Exception e) {
}
}

Fixed version (ground truth):
public void doexport(TreeObject[] objs,IProgressMonitor monitor){
  if (objs.length == 0)   return;
  monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
  Exports eps=new Exports();
  List<TreeObject> exports=new ArrayList<TreeObject>();
  XtentisPort port;
  try {
    port=Util.getPort(objs[0]);
    for (    TreeObject obj : objs) {
      StringWriter sw;
      ArrayList<String> items;
switch (obj.getType()) {
case TreeObject.DATA_CLUSTER:
        monitor.subTask("String_Node_Str");
      items=new ArrayList<String>();
    WSDataClusterPK pk=(WSDataClusterPK)obj.getWsKey();
  WSDataCluster cluster=port.getDataCluster(new WSGetDataCluster(pk));
sw=new StringWriter();
Marshaller.marshal(cluster,sw);
String encodedID=URLEncoder.encode(cluster.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.DATACONTAINER + "String_Node_Str" + encodedID);
items.add(TreeObject.DATACONTAINER + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
monitor.subTask("String_Node_Str" + pk.getPk() + "String_Node_Str");
List<String> items1=new ArrayList<String>();
WSItemPKsByCriteriaResponseResults[] results=port.getItemPKsByCriteria(new WSGetItemPKsByCriteria(pk,null,null,null,(long)-1,(long)-1,0,Integer.MAX_VALUE)).getResults();
if (results == null) continue;
for (WSItemPKsByCriteriaResponseResults item : results) {
WSItem wsitem=port.getItem(new WSGetItem(item.getWsItemPK()));
StringWriter sw1=new StringWriter();
Marshaller.marshal(wsitem,sw1);
String uniqueId=pk.getPk() + "String_Node_Str" + wsitem.getConceptName()+ "String_Node_Str";
for (String id : wsitem.getIds()) {
uniqueId=uniqueId + "String_Node_Str" + id;
}
encodedID=URLEncoder.encode(uniqueId,"String_Node_Str");
writeString(sw1.toString(),TreeObject.DATACONTAINER_COTENTS + "String_Node_Str" + pk.getPk()+ "String_Node_Str"+ encodedID);
items1.add(TreeObject.DATACONTAINER_COTENTS + "String_Node_Str" + pk.getPk()+ "String_Node_Str"+ encodedID);
}
TreeObject obj1=new TreeObject("String_Node_Str",null,TreeObject.DATA_CLUSTER_CONTENTS,null,null);
obj1.setItems(items1.toArray(new String[items1.size()]));
exports.add(obj1);
monitor.worked(1);
break;
case TreeObject.DATA_MODEL:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSDataModel model=port.getDataModel(new WSGetDataModel((WSDataModelPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(model,sw);
encodedID=URLEncoder.encode(model.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.DATAMODEL_ + "String_Node_Str" + encodedID);
items.add(TreeObject.DATAMODEL_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSMenu menu=port.getMenu(new WSGetMenu((WSMenuPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(menu,sw);
encodedID=URLEncoder.encode(menu.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.MENU_ + "String_Node_Str" + encodedID);
items.add(TreeObject.MENU_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.ROLE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSRole role=port.getRole(new WSGetRole((WSRolePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(role,sw);
encodedID=URLEncoder.encode(role.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.ROLE_ + "String_Node_Str" + encodedID);
items.add(TreeObject.ROLE_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
break;
case TreeObject.ROUTING_RULE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSRoutingRule RoutingRule=port.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(RoutingRule,sw);
encodedID=URLEncoder.encode(RoutingRule.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.ROUTINGRULE_ + "String_Node_Str" + encodedID);
items.add(TreeObject.ROUTINGRULE_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSStoredProcedure StoredProcedure=port.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(StoredProcedure,sw);
encodedID=URLEncoder.encode(StoredProcedure.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.STOREDPROCEDURE_ + "String_Node_Str" + encodedID);
items.add(TreeObject.STOREDPROCEDURE_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSSynchronizationPlan SynchronizationPlan=port.getSynchronizationPlan(new WSGetSynchronizationPlan((WSSynchronizationPlanPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(SynchronizationPlan,sw);
encodedID=URLEncoder.encode(SynchronizationPlan.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.SYNCHRONIZATIONPLAN_ + "String_Node_Str" + encodedID);
items.add(TreeObject.SYNCHRONIZATIONPLAN_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
break;
case TreeObject.TRANSFORMER:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSTransformer transformer=port.getTransformer(new WSGetTransformer(new WSTransformerPK(((WSTransformerV2PK)obj.getWsKey()).getPk())));
sw=new StringWriter();
Marshaller.marshal(transformer,sw);
encodedID=URLEncoder.encode(transformer.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.TRANSFORMER_ + "String_Node_Str" + encodedID);
items.add(TreeObject.TRANSFORMER_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSUniverse universe=port.getUniverse(new WSGetUniverse((WSUniversePK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(universe,sw);
encodedID=URLEncoder.encode(universe.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.UNIVERSE_ + "String_Node_Str" + encodedID);
items.add(TreeObject.UNIVERSE_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
break;
case TreeObject.VIEW:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
WSView View=port.getView(new WSGetView((WSViewPK)obj.getWsKey()));
sw=new StringWriter();
Marshaller.marshal(View,sw);
encodedID=URLEncoder.encode(View.getName(),"String_Node_Str");
writeString(sw.toString(),TreeObject.VIEW_ + "String_Node_Str" + encodedID);
items.add(TreeObject.VIEW_ + "String_Node_Str" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
}
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
StringWriter sw=new StringWriter();
try {
Marshaller.marshal(eps,sw);
writeString(sw.toString(),"String_Node_Str");
}
 catch (Exception e) {
}
monitor.done();
}
 catch (Exception e) {
}
}