@Override
  public void undeployInactiveExecutionPlanConfiguration(
      String filename, AxisConfiguration axisConfiguration)
      throws ExecutionPlanConfigurationException {

    EventProcessorConfigurationFilesystemInvoker.delete(filename, axisConfiguration);
  }
 @Override
 public void undeployActiveExecutionPlanConfiguration(
     String name, AxisConfiguration axisConfiguration) throws ExecutionPlanConfigurationException {
   int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
   EventProcessorConfigurationFilesystemInvoker.delete(
       getExecutionPlanConfigurationFileByPlanName(name, tenantId).getFileName(),
       axisConfiguration);
 }
 public void editInactiveExecutionPlanConfiguration(
     String executionPlanConfiguration, String filename, AxisConfiguration axisConfiguration)
     throws ExecutionPlanConfigurationException, ExecutionPlanDependencyValidationException {
   try {
     int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
     OMElement omElement = AXIOMUtil.stringToOM(executionPlanConfiguration);
     EventProcessorConfigurationHelper.validateExecutionPlanConfiguration(omElement, tenantId);
     ExecutionPlanConfiguration config = EventProcessorConfigurationHelper.fromOM(omElement);
     EventProcessorConfigurationFilesystemInvoker.delete(filename, axisConfiguration);
     EventProcessorConfigurationFilesystemInvoker.save(
         executionPlanConfiguration, config.getName(), filename, axisConfiguration);
   } catch (XMLStreamException e) {
     log.error("Error while creating the xml object");
     throw new ExecutionPlanConfigurationException("Not a valid xml object ", e);
   }
 }
  private void editExecutionPlanConfiguration(
      ExecutionPlanConfiguration executionPlanConfiguration,
      String executionPlanName,
      int tenantId,
      AxisConfiguration axisConfiguration)
      throws ExecutionPlanConfigurationException {

    ExecutionPlanConfigurationFile configFile =
        getExecutionPlanConfigurationFileByPlanName(executionPlanName, tenantId);
    String fileName = configFile.getFileName();
    EventProcessorConfigurationFilesystemInvoker.delete(
        configFile.getFileName(), axisConfiguration);
    OMElement omElement = EventProcessorConfigurationHelper.toOM(executionPlanConfiguration);
    EventProcessorConfigurationFilesystemInvoker.save(
        omElement, executionPlanName, fileName, axisConfiguration);
  }
 public void editActiveExecutionPlanConfiguration(
     String executionPlanConfiguration,
     String executionPlanName,
     AxisConfiguration axisConfiguration)
     throws ExecutionPlanConfigurationException, ExecutionPlanDependencyValidationException {
   int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
   try {
     OMElement omElement = AXIOMUtil.stringToOM(executionPlanConfiguration);
     EventProcessorConfigurationHelper.validateExecutionPlanConfiguration(omElement, tenantId);
     ExecutionPlanConfiguration executionPlanConfigurationObject =
         EventProcessorConfigurationHelper.fromOM(omElement);
     if (!(executionPlanConfigurationObject.getName().equals(executionPlanName))) {
       if (!(checkExecutionPlanValidity(executionPlanConfigurationObject.getName(), tenantId))) {
         throw new ExecutionPlanConfigurationException(
             executionPlanConfigurationObject.getName()
                 + " already registered as an execution in this tenant");
       }
     }
     if (executionPlanName != null && executionPlanName.length() > 0) {
       String fileName;
       ExecutionPlanConfigurationFile file =
           getExecutionPlanConfigurationFileByPlanName(executionPlanName, tenantId);
       if (file == null) {
         fileName = executionPlanName + EventProcessorConstants.EP_CONFIG_FILE_EXTENSION_WITH_DOT;
       } else {
         fileName = file.getFileName();
       }
       EventProcessorConfigurationFilesystemInvoker.delete(fileName, axisConfiguration);
       EventProcessorConfigurationFilesystemInvoker.save(
           executionPlanConfiguration, executionPlanName, fileName, axisConfiguration);
     } else {
       throw new ExecutionPlanConfigurationException(
           "Invalid configuration provided, No execution plan name.");
     }
   } catch (XMLStreamException e) {
     log.error("Error while creating the xml object");
     throw new ExecutionPlanConfigurationException("Not a valid xml object, ", e);
   }
 }
  private void validateToRemoveInactiveExecutionPlanConfiguration(
      String executionPlanName, AxisConfiguration axisConfiguration)
      throws ExecutionPlanConfigurationException {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();

    String fileName = executionPlanName + EventProcessorConstants.EP_CONFIG_FILE_EXTENSION_WITH_DOT;
    List<ExecutionPlanConfigurationFile> executionPlanConfigurationFiles =
        tenantSpecificExecutionPlanFiles.get(tenantId);
    if (executionPlanConfigurationFiles != null) {
      for (ExecutionPlanConfigurationFile executionPlanConfigurationFile :
          executionPlanConfigurationFiles) {
        if ((executionPlanConfigurationFile.getFileName().equals(fileName))) {
          if (!(executionPlanConfigurationFile
              .getStatus()
              .equals(ExecutionPlanConfigurationFile.Status.DEPLOYED))) {
            EventProcessorConfigurationFilesystemInvoker.delete(fileName, axisConfiguration);
            break;
          }
        }
      }
    }
  }