Program: 148612
Project: 148612
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]);
    try {
      LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
    }
 catch (    Exception e) {
    }
    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();
  String encodedID=null;
try {
  WSDataCluster cluster=port.getDataCluster(new WSGetDataCluster(pk));
  sw=new StringWriter();
  Marshaller.marshal(cluster,sw);
  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);
}
 catch (Exception e) {
}
monitor.worked(1);
monitor.subTask("String_Node_Str" + pk.getPk() + "String_Node_Str");
try {
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) {
if (item.getWsItemPK().getIds() == null) continue;
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();
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.DATA_MODEL:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.PICTURES_RESOURCE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.ROLE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
}
break;
case TreeObject.ROUTING_RULE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
}
break;
case TreeObject.TRANSFORMER:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
}
break;
case TreeObject.VIEW:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
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();
try {
DefaultHttpClient httpclient=new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(new AuthScope(obj.getEndpointHost(),Integer.valueOf(obj.getEndpointPort())),new UsernamePasswordCredentials("String_Node_Str","String_Node_Str"));
HttpGet httpget=new HttpGet(workflowURL);
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);
}
 catch (Exception e) {
monitor.worked(1);
}
}
}
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
try {
WSAutoIncrement auto=port.getAutoIncrement(null);
if (auto != null && auto.getAutoincrement() != null) {
eps.setAutoIncrement(auto.getAutoincrement());
}
}
 catch (Exception e) {
}
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]);
    try {
      LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
    }
 catch (    Exception e) {
    }
    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();
  String encodedID=null;
try {
  WSDataCluster cluster=port.getDataCluster(new WSGetDataCluster(pk));
  sw=new StringWriter();
  Marshaller.marshal(cluster,sw);
  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);
}
 catch (Exception e) {
}
monitor.worked(1);
monitor.subTask("String_Node_Str" + pk.getPk() + "String_Node_Str");
if ("String_Node_Str".equals(port.getMDMConfiguration().getXdbID())) {
bakcupCluster(obj,port);
}
 else {
exportCluster(exports,pk,port);
}
monitor.worked(1);
break;
case TreeObject.DATA_MODEL:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.PICTURES_RESOURCE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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");
writeInputStream(get.getResponseBodyAsStream(),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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.ROLE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
}
break;
case TreeObject.ROUTING_RULE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
}
break;
case TreeObject.TRANSFORMER:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.UNIVERSE:
if (Util.IsEnterPrise()) {
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
monitor.worked(1);
}
break;
case TreeObject.VIEW:
monitor.subTask("String_Node_Str");
items=new ArrayList<String>();
try {
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);
}
 catch (Exception e) {
}
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();
try {
DefaultHttpClient httpclient=new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(new AuthScope(obj.getEndpointHost(),Integer.valueOf(obj.getEndpointPort())),new UsernamePasswordCredentials("String_Node_Str","String_Node_Str"));
HttpGet httpget=new HttpGet(workflowURL);
HttpResponse response=httpclient.execute(httpget);
HttpEntity entity=response.getEntity();
encodedID=URLEncoder.encode(obj.getDisplayName(),"String_Node_Str");
String filename=TreeObject.BARFILE_PATH + encodedID + "String_Node_Str";
writeInputStream(entity.getContent(),filename);
items.add(filename);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
}
 catch (Exception e) {
monitor.worked(1);
}
}
}
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
try {
WSAutoIncrement auto=port.getAutoIncrement(null);
if (auto != null && auto.getAutoincrement() != null) {
eps.setAutoIncrement(auto.getAutoincrement());
}
}
 catch (Exception e) {
}
StringWriter sw=new StringWriter();
try {
Marshaller.marshal(eps,sw);
writeString(sw.toString(),"String_Node_Str");
}
 catch (Exception e) {
}
monitor.done();
}
 catch (Exception e) {
}
}