Class BasePortletDataHandler

java.lang.Object
com.liferay.exportimport.kernel.lar.BasePortletDataHandler
All Implemented Interfaces:
PortletDataHandler
Direct Known Subclasses:
DefaultConfigurationPortletDataHandler

public abstract class BasePortletDataHandler extends Object implements PortletDataHandler
Author:
Brian Wing Shun Chan
  • Constructor Details

    • BasePortletDataHandler

      public BasePortletDataHandler()
  • Method Details

    • addDefaultData

      public jakarta.portlet.PortletPreferences addDefaultData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences) throws PortletDataException
      Description copied from interface: PortletDataHandler
      Returns the portlet's preferences with default data added.
      Specified by:
      addDefaultData in interface PortletDataHandler
      Parameters:
      portletDataContext - the context of the data addition
      portletId - the portlet ID of the portlet
      portletPreferences - the portlet preferences of the portlet
      Returns:
      a modified version of the portlet preferences that should be saved, or null if the data handler made no changes to the portlet preferences
      Throws:
      PortletDataException - if a portlet data exception occurred
    • deleteData

      public jakarta.portlet.PortletPreferences deleteData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences) throws PortletDataException
      Description copied from interface: PortletDataHandler
      Deletes the data created by the portlet. It can optionally return a modified version of the portlet preferences if it contains references to data that no longer exists.
      Specified by:
      deleteData in interface PortletDataHandler
      Parameters:
      portletDataContext - the context of the data deletion
      portletId - the portlet ID of the portlet
      portletPreferences - the portlet preferences of the portlet
      Returns:
      a modified version of the portlet preferences that should be saved, or null if the data handler made no changes to the portlet preferences
      Throws:
      PortletDataException - if a portlet data exception occurred
    • exportData

      public String exportData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences) throws PortletDataException
      Description copied from interface: PortletDataHandler
      Returns a string of data to be placed in the <portlet-data> section of the LAR file. This data will be passed as the data parameter of importData().
      Specified by:
      exportData in interface PortletDataHandler
      Parameters:
      portletDataContext - the context of the data export
      portletId - the portlet ID of the portlet
      portletPreferences - the portlet preferences of the portlet
      Returns:
      a string of data to be placed in the LAR, which can be, but not limited to XML, or null if no portlet data is to be written out
      Throws:
      PortletDataException - if a portlet data exception occurred
    • getDataLevel

      public DataLevel getDataLevel()
      Specified by:
      getDataLevel in interface PortletDataHandler
    • getDataPortletPreferences

      public String[] getDataPortletPreferences()
      Description copied from interface: PortletDataHandler
      Returns an array of the portlet preferences that reference data. These preferences should only be updated if the referenced data is imported.
      Specified by:
      getDataPortletPreferences in interface PortletDataHandler
      Returns:
      an array of the portlet preferences that reference data
    • getDeletionSystemEventStagedModelTypes

      public StagedModelType[] getDeletionSystemEventStagedModelTypes()
      Specified by:
      getDeletionSystemEventStagedModelTypes in interface PortletDataHandler
    • getExportConfigurationPortletDataHandlerControls

      public PortletDataHandlerControl[] getExportConfigurationPortletDataHandlerControls(long companyId, long groupId, Portlet portlet, boolean privateLayout) throws Exception
      Specified by:
      getExportConfigurationPortletDataHandlerControls in interface PortletDataHandler
      Throws:
      Exception
    • getExportConfigurationPortletDataHandlerControls

      public PortletDataHandlerControl[] getExportConfigurationPortletDataHandlerControls(long companyId, long groupId, Portlet portlet, long plid, boolean privateLayout) throws Exception
      Specified by:
      getExportConfigurationPortletDataHandlerControls in interface PortletDataHandler
      Throws:
      Exception
    • getExportMetadataPortletDataHandlerControls

      public PortletDataHandlerControl[] getExportMetadataPortletDataHandlerControls()
      Description copied from interface: PortletDataHandler
      Returns an array of the metadata controls defined for this data handler. These controls enable the developer to create fine grained controls over export behavior of metadata such as tags, categories, ratings or comments. The controls are rendered in the export UI.
      Specified by:
      getExportMetadataPortletDataHandlerControls in interface PortletDataHandler
      Returns:
      an array of the metadata controls defined for this data handler
    • getExportModelCount

      public long getExportModelCount(ManifestSummary manifestSummary)
      Specified by:
      getExportModelCount in interface PortletDataHandler
    • getExportPortletDataHandlerControls

      public PortletDataHandlerControl[] getExportPortletDataHandlerControls()
      Description copied from interface: PortletDataHandler
      Returns an array of the controls defined for this data handler. These controls enable the developer to create fine grained controls over export behavior. The controls are rendered in the export UI.
      Specified by:
      getExportPortletDataHandlerControls in interface PortletDataHandler
      Returns:
      an array of the controls defined for this data handler
    • getImportConfigurationPortletDataHandlerControls

      public PortletDataHandlerControl[] getImportConfigurationPortletDataHandlerControls(Portlet portlet, ManifestSummary manifestSummary)
      Specified by:
      getImportConfigurationPortletDataHandlerControls in interface PortletDataHandler
    • getImportConfigurationPortletDataHandlerControls

      public PortletDataHandlerControl[] getImportConfigurationPortletDataHandlerControls(String[] configurationPortletOptions)
      Specified by:
      getImportConfigurationPortletDataHandlerControls in interface PortletDataHandler
    • getImportMetadataPortletDataHandlerControls

      public PortletDataHandlerControl[] getImportMetadataPortletDataHandlerControls()
      Description copied from interface: PortletDataHandler
      Returns an array of the metadata controls defined for this data handler. These controls enable the developer to create fine grained controls over import behavior of metadata such as tags, categories, ratings or comments. The controls are rendered in the export UI.
      Specified by:
      getImportMetadataPortletDataHandlerControls in interface PortletDataHandler
      Returns:
      an array of the metadata controls defined for this data handler
    • getImportPortletDataHandlerControls

      public PortletDataHandlerControl[] getImportPortletDataHandlerControls()
      Description copied from interface: PortletDataHandler
      Returns an array of the controls defined for this data handler. These controls enable the developer to create fine grained controls over import behavior. The controls are rendered in the import UI.
      Specified by:
      getImportPortletDataHandlerControls in interface PortletDataHandler
      Returns:
      an array of the controls defined for this data handler
    • getPortletId

      public String getPortletId()
      Specified by:
      getPortletId in interface PortletDataHandler
    • getRank

      public int getRank()
      Specified by:
      getRank in interface PortletDataHandler
    • getResourceName

      public String getResourceName()
      Specified by:
      getResourceName in interface PortletDataHandler
    • getSchemaVersion

      public String getSchemaVersion()
      Description copied from interface: PortletDataHandler
      Returns the schema version for this data handler, which represents the staging and export/import aspect of a component. The schema version is used to perform component related validation before importing data. Validating the schema version avoids broken data when importing, which is typically caused by import failures due to data schema inconsistency.

      Schema versions follow the semantic versioning format major.minor.bugfix. The schema version is added to the LAR file for each application being processed. During import, the current schema version in an environment is compared to the schema version in the LAR file. The generic semantic versioning rules apply during this comparison:

      • The major version has to be an exact match
      • The minor version is backwards compatible for the same major version
      • The bug fix is always compatible in the context of the two other version numbers

      Examples:

      • Importing 2.0.0 into 3.0.0 is not compatible
      • Importing 3.0.0 into 3.0.0 is compatible
      • Importing 4.6.2 into 4.9.0 is compatible
      • Importing 2.1.3 into 2.1.6 is compatible
      Specified by:
      getSchemaVersion in interface PortletDataHandler
      Returns:
      the portlet data handler's schema version
    • getServiceName

      public String getServiceName()
      Specified by:
      getServiceName in interface PortletDataHandler
    • getStagingPortletDataHandlerControls

      public PortletDataHandlerControl[] getStagingPortletDataHandlerControls()
      Specified by:
      getStagingPortletDataHandlerControls in interface PortletDataHandler
    • importData

      public jakarta.portlet.PortletPreferences importData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences, String data) throws PortletDataException
      Description copied from interface: PortletDataHandler
      Handles any special processing of the data when the portlet is imported into a new layout. Can optionally return a modified version of preferences to be saved in the new portlet.
      Specified by:
      importData in interface PortletDataHandler
      Parameters:
      portletDataContext - the context of the data import
      portletId - the portlet ID of the portlet
      portletPreferences - the portlet preferences of the portlet
      data - the string data that was returned by exportData()
      Returns:
      a modified version of the portlet preferences that should be saved, or null if the data handler made no changes to the portlet preferences
      Throws:
      PortletDataException - if a portlet data exception occurred
    • isDataAlwaysStaged

      public boolean isDataAlwaysStaged()
      Specified by:
      isDataAlwaysStaged in interface PortletDataHandler
    • isDataDepotLevel

      public boolean isDataDepotLevel()
      Specified by:
      isDataDepotLevel in interface PortletDataHandler
    • isDataLocalized

      public boolean isDataLocalized()
      Specified by:
      isDataLocalized in interface PortletDataHandler
    • isDataPortalLevel

      public boolean isDataPortalLevel()
      Specified by:
      isDataPortalLevel in interface PortletDataHandler
    • isDataPortletInstanceLevel

      public boolean isDataPortletInstanceLevel()
      Specified by:
      isDataPortletInstanceLevel in interface PortletDataHandler
    • isDataSiteLevel

      public boolean isDataSiteLevel()
      Specified by:
      isDataSiteLevel in interface PortletDataHandler
    • isDisplayPortlet

      public boolean isDisplayPortlet()
      Specified by:
      isDisplayPortlet in interface PortletDataHandler
    • isEmptyControlsAllowed

      public boolean isEmptyControlsAllowed()
      Specified by:
      isEmptyControlsAllowed in interface PortletDataHandler
    • isPublishToLiveByDefault

      public boolean isPublishToLiveByDefault()
      Description copied from interface: PortletDataHandler
      Returns whether the data exported by this handler should be included by default when publishing to live. This should only be true for data that is meant to be managed in an staging environment such as CMS content, but not for data meant to be input by users such as wiki pages or message board posts.
      Specified by:
      isPublishToLiveByDefault in interface PortletDataHandler
      Returns:
      true if the data exported by this handler should be included by default when publishing to live; false otherwise
    • isRollbackOnException

      public boolean isRollbackOnException()
      Description copied from interface: PortletDataHandler
      Returns true if the data handler stops operations and rolls back their transactions on operations throwing exceptions.
      Specified by:
      isRollbackOnException in interface PortletDataHandler
      Returns:
      true if the data handler stops operations and rolls back their transactions on operations throwing exceptions; false otherwise
    • prepareManifestSummary

      public void prepareManifestSummary(PortletDataContext portletDataContext) throws PortletDataException
      Specified by:
      prepareManifestSummary in interface PortletDataHandler
      Throws:
      PortletDataException
    • prepareManifestSummary

      public void prepareManifestSummary(PortletDataContext portletDataContext, jakarta.portlet.PortletPreferences portletPreferences) throws PortletDataException
      Specified by:
      prepareManifestSummary in interface PortletDataHandler
      Throws:
      PortletDataException
    • setPortletId

      public void setPortletId(String portletId)
      Specified by:
      setPortletId in interface PortletDataHandler
    • setRank

      public void setRank(int rank)
      Specified by:
      setRank in interface PortletDataHandler
    • validateSchemaVersion

      public boolean validateSchemaVersion(String schemaVersion)
      Specified by:
      validateSchemaVersion in interface PortletDataHandler
    • addExportDataRootElement

      protected Element addExportDataRootElement(PortletDataContext portletDataContext)
    • addImportDataRootElement

      protected Element addImportDataRootElement(PortletDataContext portletDataContext, String data) throws DocumentException
      Throws:
      DocumentException
    • addUncheckedModelAdditionCount

      protected void addUncheckedModelAdditionCount(PortletDataContext portletDataContext, PortletDataHandlerControl portletDataHandlerControl)
    • doAddDefaultData

      protected jakarta.portlet.PortletPreferences doAddDefaultData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences) throws Exception
      Throws:
      Exception
    • doDeleteData

      protected jakarta.portlet.PortletPreferences doDeleteData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences) throws Exception
      Throws:
      Exception
    • doExportData

      protected String doExportData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences) throws Exception
      Throws:
      Exception
    • doImportData

      protected jakarta.portlet.PortletPreferences doImportData(PortletDataContext portletDataContext, String portletId, jakarta.portlet.PortletPreferences portletPreferences, String data) throws Exception
      Throws:
      Exception
    • doPrepareManifestSummary

      protected void doPrepareManifestSummary(PortletDataContext portletDataContext, jakarta.portlet.PortletPreferences portletPreferences) throws Exception
      Throws:
      Exception
    • doValidateSchemaVersion

      protected boolean doValidateSchemaVersion(String schemaVersion) throws Exception
      Throws:
      Exception
    • getExportDataRootElementString

      protected String getExportDataRootElementString(Element rootElement)
    • getExportModelCount

      protected long getExportModelCount(ManifestSummary manifestSummary, PortletDataHandlerControl[] portletDataHandlerControls)
    • getStagedModelTypes

      protected StagedModelType[] getStagedModelTypes(Supplier<List<StagedModelType>> stagedModelTypesSupplier)
    • setDataAlwaysStaged

      protected void setDataAlwaysStaged(boolean dataAlwaysStaged)
    • setDataLevel

      protected void setDataLevel(DataLevel dataLevel)
    • setDataLocalized

      protected void setDataLocalized(boolean dataLocalized)
    • setDataPortletPreferences

      protected void setDataPortletPreferences(String... dataPortletPreferences)
    • setDeletionSystemEventStagedModelTypes

      protected void setDeletionSystemEventStagedModelTypes(StagedModelType... deletionSystemEventStagedModelTypes)
    • setEmptyControlsAllowed

      protected void setEmptyControlsAllowed(boolean emptyControlsAllowed)
    • setExportMetadataPortletDataHandlerControls

      protected void setExportMetadataPortletDataHandlerControls(PortletDataHandlerControl... exportMetadataPortletDataHandlerControls)
    • setExportPortletDataHandlerControls

      protected void setExportPortletDataHandlerControls(PortletDataHandlerControl... exportPortletDataHandlerControls)
    • setImportMetadataPortletDataHandlerControls

      protected void setImportMetadataPortletDataHandlerControls(PortletDataHandlerControl... importMetadataPortletDataHandlerControls)
    • setImportPortletDataHandlerControls

      protected void setImportPortletDataHandlerControls(PortletDataHandlerControl... importPortletDataHandlerControls)
    • setPublishToLiveByDefault

      protected void setPublishToLiveByDefault(boolean publishToLiveByDefault)
    • setStagingPortletDataHandlerControls

      protected void setStagingPortletDataHandlerControls(PortletDataHandlerControl... stagingPortletDataHandlerControls)