public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
   String path = deploymentFileData.getAbsolutePath();
   try {
     if (deploymentFileData.getName().contains(EventSimulatorConstant.CONFIGURATION_XML_SUFFIX)) {
       processDeployStreamConfig(deploymentFileData);
     } else if (deploymentFileData
         .getName()
         .contains(EventSimulatorConstant.DATA_SOURCE_CONFIGURATION_XML_SUFFIX)) {
       processDeployDatasourceConfig(deploymentFileData);
     } else {
       log.warn(
           "XML file : "
               + deploymentFileData.getName()
               + " not deployed. Name should contain either "
               + EventSimulatorConstant.CONFIGURATION_XML_SUFFIX
               + " or "
               + EventSimulatorConstant.DATA_SOURCE_CONFIGURATION_XML_SUFFIX);
     }
   } catch (Throwable t) {
     File file = new File(path);
     log.error("Could not deploy XML file : " + file.getName(), t);
     throw new DeploymentException(
         "XML file not deployed and in inactive state :  " + new File(path).getName(), t);
   }
 }
 public void run() {
   try {
     AnalyticsEventStoreDeployer deployer =
         (AnalyticsEventStoreDeployer)
             CarbonUtils.getDeployer(AnalyticsEventStoreDeployer.class.getName());
     if (AnalyticsEventStoreDeployer.getPausedDeployments() != null) {
       List<DeploymentFileData> pausedDeployment =
           AnalyticsEventStoreDeployer.getPausedDeployments();
       started.set(true);
       PrivilegedCarbonContext.startTenantFlow();
       PrivilegedCarbonContext.getThreadLocalCarbonContext()
           .setTenantId(MultitenantConstants.SUPER_TENANT_ID);
       for (DeploymentFileData deploymentFileData : pausedDeployment) {
         try {
           deployer.deploy(deploymentFileData);
         } catch (DeploymentException e) {
           log.error(
               "Error while  deploying analytics event store the file : "
                   + deploymentFileData.getName(),
               e);
         }
       }
       AnalyticsEventStoreDeployer.clearPausedDeployments();
       PrivilegedCarbonContext.endTenantFlow();
     }
   } catch (CarbonException e) {
     log.error(
         "Error when getting the deployer for evn store to proceed the initialization of deployments. ",
         e);
   }
 }
  /**
   * Deploys a .gar archive to the Registry path in REGISTRY_GADGET_STORAGE_PATH
   *
   * @param deploymentFileData - info about the deployed file
   * @throws DeploymentException - error while deploying .gar archive
   */
  public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
    try {

      //            int tenantId;
      //            try {
      //                tenantId =
      // MultitenantUtils.getTenantId(DashboardContext.getConfigContext());
      //            } catch (Exception e) {
      //                throw new DeploymentException(e);
      //            }

      UserRegistry registry = getRegistry(tenantID);

      // Extracting archive
      String extractedArchiveDir = extractGarArchive(deploymentFileData.getAbsolutePath());

      // Set permission for anonymous read. We do it here because it should happen always in order
      // to support mounting a remote registry.

      if (registry != null) {
        AuthorizationManager accessControlAdmin = registry.getUserRealm().getAuthorizationManager();

        if (!accessControlAdmin.isRoleAuthorized(
            CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME,
            RegistryConstants.CONFIG_REGISTRY_BASE_PATH + REGISTRY_GADGET_STORAGE_PATH,
            ActionConstants.GET)) {
          accessControlAdmin.authorizeRole(
              CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME,
              RegistryConstants.CONFIG_REGISTRY_BASE_PATH + REGISTRY_GADGET_STORAGE_PATH,
              ActionConstants.GET);
        }

        File gadgetsDir = new File(extractedArchiveDir);
        if (gadgetsDir.exists()) {
          beginFileTansfer(gadgetsDir, tenantID);

          log.info(
              "Successfully populated gadgets from archive ."
                  + deploymentFileData.getAbsolutePath()
                  + " to the registry.");
        } else {
          log.info("Couldn't find contents at '" + extractedArchiveDir + "'. Giving up.");
        }
      }

    } catch (RegistryException e) {
      throw new DeploymentException("An error occured while deploying gadget archive", e);
    } catch (CarbonException e) {
      throw new DeploymentException("An error occured while deploying gadget archive", e);
    } catch (UserStoreException e) {
      throw new DeploymentException("An error occured while deploying gadget archive", e);
    }
  }
 /*
 Deploying CSV configuration
  */
 public void processDeployStreamConfig(DeploymentFileData deploymentFileData)
     throws DeploymentException {
   CSVFileInfo csvFileInfo =
       DeploymentHelper.getCSVFileInfo(
           deploymentFileData.getFile(), configurationContext.getAxisConfiguration());
   CarbonEventSimulator eventSimulator = EventSimulatorValueHolder.getEventSimulator();
   eventSimulator.addCSVFileInfo(csvFileInfo);
 }
  /*
  Deploying datasource configuration
   */
  public void processDeployDatasourceConfig(DeploymentFileData deploymentFileData)
      throws DeploymentException {
    File xmlFile = deploymentFileData.getFile();
    DataSourceTableAndStreamInfo dataSourceTableAndStreamInfo =
        DeploymentHelper.getEventMappingConfiguration(xmlFile);
    dataSourceTableAndStreamInfo.setFileName(xmlFile.getName());
    dataSourceTableAndStreamInfo.setFilePath(xmlFile.getAbsolutePath());
    dataSourceTableAndStreamInfo.setStatus(DataSourceTableAndStreamInfo.Status.STOPPED);

    CarbonEventSimulator eventSimulator = EventSimulatorValueHolder.getEventSimulator();
    if (dataSourceTableAndStreamInfo != null) {
      eventSimulator.addDataSourceTableAndStreamInfo(dataSourceTableAndStreamInfo);
    }
  }
 @Override
 public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
   log.info("Deploying JAX-WS/JAX-RS Web Application : " + deploymentFileData.getAbsolutePath());
   super.deploy(deploymentFileData);
 }