Program: 148757
Project: 148757
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>();
  List<String> schemas=new ArrayList<String>();
  XtentisPort port;
  try {
    port=Util.getPort(objs[0]);
    LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
    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.PICTURES_RESOURCE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
String picUrl=obj.getEndpointIpAddress() + ResourcesUtil.getResourcesMapFromURI(obj.getEndpointIpAddress() + TreeObject.PICTURES_URI).get(obj.getDisplayName());
HttpClient client=new HttpClient();
GetMethod get=new GetMethod(picUrl);
client.executeMethod(get);
sw=new StringWriter();
Marshaller.marshal(get.getResponseBody(),sw);
encodedID=URLEncoder.encode(obj.getDisplayName(),"String_Node_Str");
writeByte(get.getResponseBody(),TreeObject.PICTURES_ + "String_Node_Str" + encodedID);
items.add(TreeObject.PICTURES_ + "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()]));
eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
StringWriter sw=new StringWriter();
try {
Marshaller.marshal(eps,sw);
writeString(sw.toString(),"String_Node_Str");
}
 catch (Exception e) {
}
monitor.done();
}
 catch (Exception e) {
e.printStackTrace();
}
}

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>();
  List<String> schemas=new ArrayList<String>();
  XtentisPort port;
  try {
    port=Util.getPort(objs[0]);
    LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
    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.PICTURES_RESOURCE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
String picUrl=obj.getEndpointIpAddress() + ResourcesUtil.getResourcesMapFromURI(obj.getEndpointIpAddress() + TreeObject.PICTURES_URI).get(obj.getDisplayName());
HttpClient client=new HttpClient();
GetMethod get=new GetMethod(picUrl);
client.executeMethod(get);
sw=new StringWriter();
Marshaller.marshal(get.getResponseBody(),sw);
encodedID=URLEncoder.encode(obj.getDisplayName(),"String_Node_Str");
writeByte(get.getResponseBody(),TreeObject.PICTURES_ + "String_Node_Str" + encodedID);
items.add(TreeObject.PICTURES_ + "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);
break;
case TreeObject.WORKFLOW_PROCESS:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
String workflowURL=obj.getEndpointIpAddress() + TreeObject.BARFILE_URI + obj.getDisplayName();
DefaultHttpClient httpclient=new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(new AuthScope("String_Node_Str",8080),new UsernamePasswordCredentials("String_Node_Str","String_Node_Str"));
HttpGet httpget=new HttpGet(workflowURL);
System.out.println("String_Node_Str" + httpget.getRequestLine());
HttpResponse response=httpclient.execute(httpget);
HttpEntity entity=response.getEntity();
encodedID=URLEncoder.encode(obj.getDisplayName(),"String_Node_Str");
writeInputStream(entity.getContent(),TreeObject.BARFILE_PATH + encodedID + "String_Node_Str");
items.add(TreeObject.BARFILE_PATH + encodedID + "String_Node_Str");
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
monitor.worked(1);
}
}
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
StringWriter sw=new StringWriter();
try {
Marshaller.marshal(eps,sw);
writeString(sw.toString(),"String_Node_Str");
}
 catch (Exception e) {
}
monitor.done();
}
 catch (Exception e) {
e.printStackTrace();
}
}