@Override
 protected boolean shouldHandleEvent(final OrderCancelledEvent event) {
   final OrderModel order = event.getProcess().getOrder();
   ServicesUtil.validateParameterNotNullStandardMessage("event.order", order);
   final BaseSiteModel site = order.getSite();
   ServicesUtil.validateParameterNotNullStandardMessage("event.order.site", site);
   return SiteChannel.B2C.equals(site.getChannel());
 }
 @Override
 protected boolean shouldHandleEvent(final SendReadyForPickupMessageEvent event) {
   final AbstractOrderModel order = event.getProcess().getConsignment().getOrder();
   ServicesUtil.validateParameterNotNullStandardMessage("event.order", order);
   final BaseSiteModel site = order.getSite();
   ServicesUtil.validateParameterNotNullStandardMessage("event.order.site", site);
   return SiteChannel.TELCO.equals(site.getChannel());
 }
  @Override
  public void populate(final SOURCE productModel, final TARGET productData)
      throws ConversionException {
    final BaseSiteModel baseSiteModel = getBaseSiteService().getCurrentBaseSite();
    if (baseSiteModel != null) {
      final PromotionGroupModel defaultPromotionGroup = baseSiteModel.getDefaultPromotionGroup();
      final Date currentTimeRoundedToMinute =
          DateUtils.round(getTimeService().getCurrentTime(), Calendar.MINUTE);

      if (defaultPromotionGroup != null) {
        final List<ProductPromotionModel> promotions =
            getPromotionsService()
                .getProductPromotions(
                    Collections.singletonList(defaultPromotionGroup),
                    productModel,
                    true,
                    currentTimeRoundedToMinute);

        productData.setPotentialPromotions(
            Converters.convertAll(promotions, getPromotionsConverter()));
      }
    }
  }
  protected void executeSiteImport(
      final AddOnDataImportEventContext context,
      final ImportData importData,
      final ImpexMacroParameterData parameterData) {
    final CatalogModel productCatalog =
        getCatalogService().getCatalogForId(importData.getProductCatalogName() + "ProductCatalog");
    context.setProductCatalog(productCatalog);
    populate(context, parameterData, getSelectedProductCatalogImpexMacroParametersPopulators());
    final boolean productFilesImported =
        getAddonConfigDataImportService()
            .executeImport(
                parameterData.getConfigExtensionName(),
                AddonConfigDataImportType.PRODUCT,
                parameterData);
    if (productFilesImported
        && getAddonSystemSetupSupport()
            .getBooleanSystemSetupParameter(
                context.getSourceEvent().getContext(),
                AddOnSystemSetupSupport.IMPORT_SYNC_CATALOGS)) {
      getAddonSystemSetupSupport()
          .synchronizeProductCatalog(context.getSourceEvent().getContext(), productCatalog.getId());
    }

    for (final String store : importData.getStoreNames()) {

      final BaseSiteModel baseSite = getBaseSiteService().getBaseSiteForUID(store);
      if (getSupportedChannels().contains(baseSite.getChannel())) {
        if (LOG.isInfoEnabled()) {
          LOG.info(
              "importing addon ["
                  + parameterData.getConfigExtensionName()
                  + "] configuration for ["
                  + store
                  + "]");
        }

        context.setBaseSite(baseSite);
        populate(context, parameterData, getSelectedBaseSiteImpexMacroParametersPopulators());

        if (baseSite instanceof CMSSiteModel) {
          final CMSSiteModel cmsSite = (CMSSiteModel) baseSite;
          for (final String contentCatalogName : importData.getContentCatalogNames()) {
            final CatalogModel contentCatalog =
                getCatalogService().getCatalogForId(contentCatalogName + "ContentCatalog");
            if (cmsSite.getContentCatalogs().contains(contentCatalog)) {
              context.setContentCatalog((ContentCatalogModel) contentCatalog);
              populate(
                  context,
                  parameterData,
                  getSelectedContentCatalogImpexMacroParametersPopulators());
              final boolean contentFilesImported =
                  getAddonConfigDataImportService()
                      .executeImport(
                          parameterData.getConfigExtensionName(),
                          AddonConfigDataImportType.CONTENT,
                          parameterData);
              if (contentFilesImported
                  && getAddonSystemSetupSupport()
                      .getBooleanSystemSetupParameter(
                          context.getSourceEvent().getContext(),
                          AddOnSystemSetupSupport.IMPORT_SYNC_CATALOGS)) {
                getAddonSystemSetupSupport()
                    .synchronizeContentCatalog(
                        context.getSourceEvent().getContext(), contentCatalog.getId());
              }
              // import stores
              getAddonConfigDataImportService()
                  .executeImport(
                      parameterData.getConfigExtensionName(),
                      AddonConfigDataImportType.STORE,
                      parameterData);
            }
          }
        }

        final boolean solrFilesImported =
            getAddonConfigDataImportService()
                .executeImport(
                    parameterData.getConfigExtensionName(),
                    AddonConfigDataImportType.SOLR,
                    parameterData);
        if ((solrFilesImported || productFilesImported)
            && getAddonSystemSetupSupport()
                .getBooleanSystemSetupParameter(
                    context.getSourceEvent().getContext(),
                    AddOnSystemSetupSupport.ACTIVATE_SOLR_CRON_JOBS)) {
          getAddonSystemSetupSupport()
              .executeSolrIndexerCronJob(parameterData.getSiteUid() + "Index", true);
        }
      }
    }
  }