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);
   }
 }
  @Override
  public void deployExecutionPlanConfiguration(
      String executionPlanConfigurationXml, AxisConfiguration axisConfiguration)
      throws ExecutionPlanDependencyValidationException, ExecutionPlanConfigurationException {

    OMElement omElement = null;
    try {
      omElement = AXIOMUtil.stringToOM(executionPlanConfigurationXml);
    } catch (XMLStreamException e) {
      throw new ExecutionPlanConfigurationException(
          "Cannot parse execution plan configuration XML:" + e.getMessage(), e);
    }
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    EventProcessorConfigurationHelper.validateExecutionPlanConfiguration(omElement, tenantId);
    String executionPlanName = EventProcessorConfigurationHelper.getExecutionPlanName(omElement);

    File directory = new File(axisConfiguration.getRepository().getPath());
    if (!directory.exists()) {
      if (directory.mkdir()) {
        throw new ExecutionPlanConfigurationException(
            "Cannot create directory to add tenant specific execution plan : " + executionPlanName);
      }
    }
    directory =
        new File(
            directory.getAbsolutePath()
                + File.separator
                + EventProcessorConstants.EP_ELE_DIRECTORY);
    if (!directory.exists()) {
      if (!directory.mkdir()) {
        throw new ExecutionPlanConfigurationException(
            "Cannot create directory "
                + EventProcessorConstants.EP_ELE_DIRECTORY
                + " to add tenant specific  execution plan :"
                + executionPlanName);
      }
    }
    validateToRemoveInactiveExecutionPlanConfiguration(executionPlanName, axisConfiguration);
    EventProcessorConfigurationFilesystemInvoker.save(
        omElement,
        executionPlanName,
        executionPlanName + EventProcessorConstants.XML_EXTENSION,
        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 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);
  }