Beispiel #1
0
 @SuppressWarnings("deprecation")
 public static void synchronizeCatVersions(
     final CatalogVersionSyncJobModel catalogVersionSyncJob, final ModelService modelService) {
   final SyncItemJob job = setupStoreTemplateSyncJobs(catalogVersionSyncJob, modelService);
   try {
     performSynchronization(job);
     LOG.info("\t" + job.getCode() + " - OK");
   } catch (final Exception e) {
     LOG.warn("\t" + job.getCode() + " - FAILED (Reason: " + e.getMessage() + ")");
   }
 }
Beispiel #2
0
 @SuppressWarnings("deprecation")
 protected static void performSynchronization(final SyncItemJob job) {
   final SyncItemCronJob cronJob = job.newExecution();
   cronJob.setLogToDatabase(false);
   cronJob.setLogToFile(false);
   cronJob.setForceUpdate(false);
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         "Generating cronjob "
             + cronJob.getCode()
             + " to synchronize staged to online version, configuring ...");
   }
   job.configureFullVersionSync(cronJob);
   if (LOG.isDebugEnabled()) {
     LOG.debug("Starting synchronization, this may take a while ...");
   }
   job.perform(cronJob, true);
 }
Beispiel #3
0
  @SuppressWarnings("deprecation")
  protected static SyncItemJob setupStoreTemplateSyncJobs(
      final CatalogVersionSyncJobModel syncJobModel, final ModelService modelService) {
    // configure root types
    final SyncItemJob syncJob = modelService.getSource(syncJobModel);
    if (syncJob == null) {
      LOG.warn(
          "Could not setup catalog version synchronization job. Reason: Synchronization job not found.");

    } else {
      final List<ComposedType> rootTypes = new ArrayList<ComposedType>(2);
      final ComposedType cmsItemType =
          TypeManager.getInstance().getComposedType(Cms2Constants.TC.CMSITEM);
      rootTypes.add(cmsItemType);
      rootTypes.add(TypeManager.getInstance().getComposedType(Cms2Constants.TC.CMSRELATION));
      rootTypes.add(TypeManager.getInstance().getComposedType(Media.class));
      syncJob.setRootTypes(JaloSession.getCurrentSession().getSessionContext(), rootTypes);
      syncJob.setSyncLanguages(
          JaloSession.getCurrentSession().getSessionContext(),
          C2LManager.getInstance().getAllLanguages());

      final Collection<SyncAttributeDescriptorConfig> syncAttributeConfigs =
          syncJob.getSyncAttributeConfigurations();
      for (final SyncAttributeDescriptorConfig syncAttributeDescriptorConfig :
          syncAttributeConfigs) {
        final Type attributeType =
            syncAttributeDescriptorConfig.getAttributeDescriptor().getAttributeType();
        if ((syncAttributeDescriptorConfig
                    .getAttributeDescriptor()
                    .getEnclosingType()
                    .isAssignableFrom(cmsItemType)
                && cmsItemType.isAssignableFrom(attributeType))
            || ((attributeType instanceof CollectionType)
                && cmsItemType.isAssignableFrom(
                    ((CollectionType) attributeType).getElementType()))) {
          syncAttributeDescriptorConfig.setCopyByValue(true);
        }
      }
    }
    return syncJob;
  }