Class CalendarSyncUidUpgradePlugin

java.lang.Object
org.exoplatform.container.component.BaseComponentPlugin
org.exoplatform.commons.upgrade.UpgradeProductPlugin
org.exoplatform.agenda.upgrade.CalendarSyncUidUpgradePlugin
All Implemented Interfaces:
org.exoplatform.container.component.ComponentPlugin

public class CalendarSyncUidUpgradePlugin extends org.exoplatform.commons.upgrade.UpgradeProductPlugin
Gives an anchor to the calendars that predate the column holding it.

EXO-89497 added SYNC_UID together with the guard in CalendarDAO.create that mints one for every new calendar. It did not migrate what was already stored, and nothing since can: the service copies the stored value back over whatever a caller passes, so a null stays null, and the DAO mints only on create. A calendar older than that commit would therefore never carry an anchor.

That matters because the anchor is what an integration binds to — the CalDAV connector deliberately binds by it rather than by id, since an id does not survive a restore that renumbers. A calendar with no anchor is excluded from synchronisation entirely, and the calendar this hits hardest is the user's default one, which holds most of their events.

A fresh database needs none of this. Every deployment upgrading across EXO-89497 does, because every user has a default calendar created long before it.

  • Field Summary

    Fields inherited from class org.exoplatform.commons.upgrade.UpgradeProductPlugin

    asyncUpgradeExecution, executeOnlyOnce, OLD_PRODUCT_GROUP_ID, oldProductGroupId, PRODUCT_GROUP_ID, productGroupId, targetVersion, UPGRADE_COMPLETED_STATUS, UPGRADE_PLUGIN_ASYNC, UPGRADE_PLUGIN_ENABLE, UPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETER, UPGRADE_PLUGIN_EXECUTION_ORDER, UPGRADE_PLUGIN_TARGET_PARAMETER

    Fields inherited from class org.exoplatform.container.component.BaseComponentPlugin

    desc, name
  • Constructor Summary

    Constructors
    Constructor
    Description
    CalendarSyncUidUpgradePlugin(org.exoplatform.commons.persistence.impl.EntityManagerService entityManagerService, org.exoplatform.container.xml.InitParams initParams)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    mintAnchor(long id)
    Writes an anchor onto one calendar.
    One page of calendars still missing an anchor.
    void
    processUpgrade(String oldVersion, String newVersion)
    Mints an anchor for every calendar lacking one.
    boolean
    shouldProceedToUpgrade(String newVersion, String previousVersion)
    Whether this upgrade has anything to do.

    Methods inherited from class org.exoplatform.commons.upgrade.UpgradeProductPlugin

    afterUpgrade, beforeUpgrade, equals, getPluginExecutionOrder, getProductGroupId, getTargetVersion, getValue, hashCode, isAsyncUpgradeExecution, isEnabled, isExecuteOnlyOnce, shouldProceedToUpgrade, storeValueForPlugin

    Methods inherited from class org.exoplatform.container.component.BaseComponentPlugin

    getDescription, getName, setDescription, setName

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CalendarSyncUidUpgradePlugin

      public CalendarSyncUidUpgradePlugin(org.exoplatform.commons.persistence.impl.EntityManagerService entityManagerService, org.exoplatform.container.xml.InitParams initParams)
      Parameters:
      entityManagerService - the shared entity manager
      initParams - the plugin's declared parameters
  • Method Details

    • shouldProceedToUpgrade

      public boolean shouldProceedToUpgrade(String newVersion, String previousVersion)
      Whether this upgrade has anything to do.

      A first installation is skipped: its calendars are all created through the DAO that already mints anchors, so there is nothing older to repair.

      Overrides:
      shouldProceedToUpgrade in class org.exoplatform.commons.upgrade.UpgradeProductPlugin
      Parameters:
      newVersion - the version being upgraded to
      previousVersion - the version being upgraded from, blank on a first installation
      Returns:
      true when this is an upgrade rather than an installation
    • processUpgrade

      public void processUpgrade(String oldVersion, String newVersion)
      Mints an anchor for every calendar lacking one.
      Specified by:
      processUpgrade in class org.exoplatform.commons.upgrade.UpgradeProductPlugin
      Parameters:
      oldVersion - the version being upgraded from
      newVersion - the version being upgraded to
    • nextPage

      public List<Long> nextPage()
      One page of calendars still missing an anchor.
      Returns:
      their identifiers, empty when none are left
    • mintAnchor

      public int mintAnchor(long id)
      Writes an anchor onto one calendar.
      Parameters:
      id - the calendar to repair
      Returns:
      1 when it was given one, 0 when it already had one