Program: 30052
Project: 30052
Buggy source:
public void execute(AdminCommandContext context){
  ActionReport report=context.getActionReport();
  boolean sharedServiceFound=false;
  Services services=domain.getExtensionByType(Services.class);
  if (services != null) {
    for (    org.glassfish.paas.orchestrator.config.Service service : services.getServices()) {
      if (service instanceof SharedService) {
        SharedService sharedService=(SharedService)service;
        String serviceType=sharedService.getType();
        if (sharedService.getServiceName().equalsIgnoreCase(serviceName)) {
          sharedServiceFound=true;
          if (sharedService.getState().equalsIgnoreCase(ServiceStatus.STOPPED.toString())) {
            report.setMessage("String_Node_Str" + sharedService.getServiceName() + "String_Node_Str");
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
            return;
          }
 else {
            String appName=null;
            boolean appEnabled=false;
            List<ServiceRef> serviceRefList=services.getServiceRefs();
            for (            ServiceRef serviceRef : serviceRefList) {
              if (serviceName.equalsIgnoreCase(serviceRef.getServiceName())) {
                appName=serviceRef.getApplicationName();
                if (appName != null) {
                  Clusters clusters=domain.getClusters();
                  List<Cluster> clusterList=clusters.getCluster();
                  for (                  Cluster cluster : clusterList) {
                    ApplicationRef applicationRef=cluster.getApplicationRef(appName);
                    if (applicationRef != null) {
                      if ("String_Node_Str".equalsIgnoreCase(applicationRef.getEnabled())) {
                        appEnabled=true;
                        report.setMessage("String_Node_Str" + serviceName + "String_Node_Str"+ "String_Node_Str"+ appName+ "String_Node_Str");
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        return;
                      }
                    }
                  }
                }
              }
            }
            if (!appEnabled) {
              ServiceInfo serviceInfo=serviceUtil.getServiceInfo(serviceName,null,null);
              ServiceDescription serviceDescription=orchestrator.getSharedServiceDescription(serviceName);
              ServicePlugin plugin=serviceDescription.getPlugin();
              boolean serviceStopped=plugin.stopService(serviceDescription,serviceInfo);
              if (serviceStopped) {
                orchestrator.removeSharedService(serviceName);
                try {
                  if (ConfigSupport.apply(new SingleConfigCode<Services>(){
                    public Object run(                    Services param) throws PropertyVetoException, TransactionFailure {
                      for (                      org.glassfish.paas.orchestrator.config.Service service : param.getServices()) {
                        if (service instanceof SharedService) {
                          SharedService sharedSvc=(SharedService)service;
                          if (sharedSvc.getServiceName().equalsIgnoreCase(serviceName)) {
                            Transaction t=Transaction.getTransaction(param);
                            SharedService sharedService_w=t.enroll(sharedSvc);
                            sharedService_w.setState(ServiceStatus.STOPPED.toString());
                          }
                        }
                      }
                      return param;
                    }
                  }
,services) == null) {
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
                  }
 else {
                    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return;
                  }
                }
 catch (                TransactionFailure transactionFailure) {
                  report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                  report.setFailureCause(transactionFailure);
                  return;
                }
              }
 else {
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
                return;
              }
            }
          }
        }
      }
    }
    if (!sharedServiceFound) {
      report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
      report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
      return;
    }
  }
 else {
    report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    return;
  }
}

Fixed version (ground truth):
public void execute(AdminCommandContext context){
  ActionReport report=context.getActionReport();
  boolean sharedServiceFound=false;
  Services services=domain.getExtensionByType(Services.class);
  if (services != null) {
    for (    org.glassfish.paas.orchestrator.config.Service service : services.getServices()) {
      if (service instanceof SharedService) {
        SharedService sharedService=(SharedService)service;
        if (sharedService.getServiceName().equalsIgnoreCase(serviceName)) {
          sharedServiceFound=true;
          if (sharedService.getState().equalsIgnoreCase(ServiceStatus.STOPPED.toString())) {
            report.setMessage("String_Node_Str" + sharedService.getServiceName() + "String_Node_Str");
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
            return;
          }
 else {
            String appName=null;
            boolean appEnabled=false;
            List<ServiceRef> serviceRefList=services.getServiceRefs();
            for (            ServiceRef serviceRef : serviceRefList) {
              if (serviceName.equalsIgnoreCase(serviceRef.getServiceName())) {
                appName=serviceRef.getApplicationName();
                if (appName != null) {
                  Clusters clusters=domain.getClusters();
                  List<Cluster> clusterList=clusters.getCluster();
                  for (                  Cluster cluster : clusterList) {
                    ApplicationRef applicationRef=cluster.getApplicationRef(appName);
                    if (applicationRef != null) {
                      if ("String_Node_Str".equalsIgnoreCase(applicationRef.getEnabled())) {
                        appEnabled=true;
                        report.setMessage("String_Node_Str" + serviceName + "String_Node_Str"+ "String_Node_Str"+ appName+ "String_Node_Str");
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        return;
                      }
                    }
                  }
                }
              }
            }
            if (!appEnabled) {
              ServiceInfo serviceInfo=serviceUtil.getServiceInfo(serviceName,null,null);
              ServiceDescription serviceDescription=orchestrator.getSharedServiceDescription(serviceName);
              ServicePlugin plugin=serviceDescription.getPlugin();
              boolean serviceStopped=plugin.stopService(serviceDescription,serviceInfo);
              if (serviceStopped) {
                orchestrator.removeSharedService(serviceName);
                try {
                  if (ConfigSupport.apply(new SingleConfigCode<Services>(){
                    public Object run(                    Services param) throws PropertyVetoException, TransactionFailure {
                      for (                      org.glassfish.paas.orchestrator.config.Service service : param.getServices()) {
                        if (service instanceof SharedService) {
                          SharedService sharedSvc=(SharedService)service;
                          if (sharedSvc.getServiceName().equalsIgnoreCase(serviceName)) {
                            Transaction t=Transaction.getTransaction(param);
                            SharedService sharedService_w=t.enroll(sharedSvc);
                            sharedService_w.setState(ServiceStatus.STOPPED.toString());
                          }
                        }
                      }
                      return param;
                    }
                  }
,services) == null) {
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
                  }
 else {
                    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return;
                  }
                }
 catch (                TransactionFailure transactionFailure) {
                  report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                  report.setFailureCause(transactionFailure);
                  return;
                }
              }
 else {
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
                return;
              }
            }
          }
        }
      }
    }
    if (!sharedServiceFound) {
      report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
      report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
      return;
    }
  }
 else {
    report.setMessage("String_Node_Str" + serviceName + "String_Node_Str");
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    return;
  }
}