public void removeBPSProfile(String profileName) throws WorkflowImplException {

    try {
      WorkflowImplServiceDataHolder.getInstance()
          .getWorkflowImplService()
          .removeBPSProfile(profileName);
    } catch (WorkflowImplException e) {
      log.error("Error when removing workflow " + profileName, e);
      throw new WorkflowImplException(e.getMessage());
    }
  }
  /**
   * update BPS profile for given data
   *
   * @param bpsProfileDTO
   * @throws WorkflowImplException
   */
  public void updateBPSProfile(BPSProfile bpsProfileDTO) throws WorkflowImplException {

    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    try {
      WorkflowImplServiceDataHolder.getInstance()
          .getWorkflowImplService()
          .updateBPSProfile(bpsProfileDTO, tenantId);
    } catch (WorkflowImplException e) {
      log.error("Server error when updating the BPS profile", e);
      throw new WorkflowImplException("Server error occurred when updating the BPS profile");
    }
  }
  /**
   * Reading BPS profile for given profile name and for current tenant
   *
   * @param bpsProfileName
   * @return
   * @throws WorkflowImplException
   */
  public BPSProfile getBPSProfile(String bpsProfileName) throws WorkflowImplException {

    BPSProfile bpsProfileDTO = null;
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    try {
      bpsProfileDTO =
          WorkflowImplServiceDataHolder.getInstance()
              .getWorkflowImplService()
              .getBPSProfile(bpsProfileName, tenantId);
    } catch (WorkflowImplException e) {
      log.error("Server error when reading a BPS profile", e);
      throw new WorkflowImplException("Server error occurred when reading a BPS profile");
    }
    return bpsProfileDTO;
  }
  public BPSProfile[] listBPSProfiles() throws WorkflowImplException {

    List<BPSProfile> bpsProfiles = null;
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    try {
      bpsProfiles =
          WorkflowImplServiceDataHolder.getInstance()
              .getWorkflowImplService()
              .listBPSProfiles(tenantId);
    } catch (WorkflowImplException e) {
      log.error("Server error when listing BPS profiles", e);
      throw new WorkflowImplException("Server error occurred when listing BPS profiles");
    }
    if (CollectionUtils.isEmpty(bpsProfiles)) {
      return new BPSProfile[0];
    }
    return bpsProfiles.toArray(new BPSProfile[bpsProfiles.size()]);
  }
  /**
   * Removes BPS artifacts of a particular workflow.
   *
   * @param workflow Workflow request to be deleted.
   * @throws WorkflowImplException
   */
  public void removeBPSPackage(Workflow workflow) throws WorkflowImplException {

    try {
      WorkflowImplService workflowImplService =
          WorkflowImplServiceDataHolder.getInstance().getWorkflowImplService();

      if (workflowImplService == null) {
        log.error("Error while initialising WorkflowImplService");
        throw new WorkflowImplException(
            "Error when removing BPS artifacts of: " + workflow.getWorkflowName());
      }

      workflowImplService.removeBPSPackage(workflow);
    } catch (WorkflowImplException e) {
      log.error("Error when removing BPS artifacts of: " + workflow.getWorkflowName(), e);
      throw new WorkflowImplException(e.getMessage());
    }
  }
  @Override
  public void initialize(List<Parameter> parameterList) throws WorkflowImplException {

    if (!validateParams(parameterList)) {
      throw new WorkflowRuntimeException(
          "Workflow initialization failed, required parameter is missing");
    }

    Parameter wfNameParameter =
        WorkflowManagementUtil.getParameter(
            parameterList,
            WFConstant.ParameterName.WORKFLOW_NAME,
            WFConstant.ParameterHolder.WORKFLOW_IMPL);

    if (wfNameParameter != null) {
      processName = StringUtils.deleteWhitespace(wfNameParameter.getParamValue());
      role =
          WorkflowManagementUtil.createWorkflowRoleName(
              StringUtils.deleteWhitespace(wfNameParameter.getParamValue()));
    }

    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
      tenantContext = "t/" + tenantDomain + "/";
    }

    Parameter bpsProfileParameter =
        WorkflowManagementUtil.getParameter(
            parameterList,
            WFImplConstant.ParameterName.BPS_PROFILE,
            WFConstant.ParameterHolder.WORKFLOW_IMPL);
    if (bpsProfileParameter != null) {
      String bpsProfileName = bpsProfileParameter.getParamValue();
      bpsProfile =
          WorkflowImplServiceDataHolder.getInstance()
              .getWorkflowImplService()
              .getBPSProfile(bpsProfileName, tenantId);
    }
    htName = processName + BPELDeployer.Constants.HT_SUFFIX;

    generateAndDeployArtifacts();
  }