Class BasePortletDataHandler
Object
com.liferay.exportimport.kernel.lar.BasePortletDataHandler
- All Implemented Interfaces:
PortletDataHandler
- Direct Known Subclasses:
DefaultConfigurationPortletDataHandler
- Author:
- Brian Wing Shun Chan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) Returns the portlet's preferences with default data added.protected Element
addExportDataRootElement
(PortletDataContext portletDataContext) protected Element
addImportDataRootElement
(PortletDataContext portletDataContext, String data) protected void
addUncheckedModelAdditionCount
(PortletDataContext portletDataContext, PortletDataHandlerControl portletDataHandlerControl) deleteData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) Deletes the data created by the portlet.protected PortletPreferences
doAddDefaultData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) protected PortletPreferences
doDeleteData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) protected String
doExportData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) protected PortletPreferences
doImportData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences, String data) protected void
doPrepareManifestSummary
(PortletDataContext portletDataContext, PortletPreferences portletPreferences) protected boolean
doValidateSchemaVersion
(String schemaVersion) exportData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) Returns a string of data to be placed in the <portlet-data> section of the LAR file.String[]
Returns an array of the portlet preferences that reference data.getExportConfigurationControls
(long companyId, long groupId, Portlet portlet, boolean privateLayout) getExportConfigurationControls
(long companyId, long groupId, Portlet portlet, long plid, boolean privateLayout) Returns an array of the controls defined for this data handler.protected String
getExportDataRootElementString
(Element rootElement) Returns an array of the metadata controls defined for this data handler.long
getExportModelCount
(ManifestSummary manifestSummary) Returns the number of entities defined for this data handler that are available for export according to the provided manifest summary, or-1
if no entities are included in the manifest summary.protected long
getExportModelCount
(ManifestSummary manifestSummary, PortletDataHandlerControl[] portletDataHandlerControls) getImportConfigurationControls
(Portlet portlet, ManifestSummary manifestSummary) getImportConfigurationControls
(String[] configurationPortletOptions) Returns an array of the controls defined for this data handler.Returns an array of the metadata controls defined for this data handler.int
getRank()
Returns the schema version for this data handler, which represents the staging and export/import aspect of a component.protected StagedModelType[]
getStagedModelTypes
(Supplier<List<StagedModelType>> stagedModelTypesSupplier) Returns an array of the controls defined for this data handler.importData
(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences, String data) Handles any special processing of the data when the portlet is imported into a new layout.boolean
boolean
boolean
boolean
boolean
boolean
boolean
Returns whether the data exported by this handler should be included by default when publishing to live.boolean
Returnstrue
if the data handler stops operations and rolls back their transactions on operations throwing exceptions.void
prepareManifestSummary
(PortletDataContext portletDataContext) void
prepareManifestSummary
(PortletDataContext portletDataContext, PortletPreferences portletPreferences) protected void
setDataAlwaysStaged
(boolean dataAlwaysStaged) protected void
setDataLevel
(DataLevel dataLevel) protected void
setDataLocalized
(boolean dataLocalized) protected void
setDataPortletPreferences
(String... dataPortletPreferences) protected void
setDeletionSystemEventStagedModelTypes
(StagedModelType... deletionSystemEventStagedModelTypes) protected void
setExportControls
(PortletDataHandlerControl... exportControls) protected void
setExportMetadataControls
(PortletDataHandlerControl... exportMetadataControls) protected void
setImportControls
(PortletDataHandlerControl... importControls) protected void
setImportMetadataControls
(PortletDataHandlerControl... importMetadataControls) void
setPortletId
(String portletId) protected void
setPublishToLiveByDefault
(boolean publishToLiveByDefault) void
setRank
(int rank) protected void
setStagingControls
(PortletDataHandlerControl... stagingControls) boolean
validateSchemaVersion
(String schemaVersion) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.liferay.exportimport.kernel.lar.PortletDataHandler
getClassNames, getName, getNamespace, isCompany, isConfigurationEnabled, isEnabled, isStaged, isSupportsDataStrategyCopyAsNew, isSupportsDataStrategyMirrorWithOverwriting
-
Constructor Details
-
BasePortletDataHandler
public BasePortletDataHandler()
-
-
Method Details
-
addDefaultData
public PortletPreferences addDefaultData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws PortletDataException Description copied from interface:PortletDataHandler
Returns the portlet's preferences with default data added.- Specified by:
addDefaultData
in interfacePortletDataHandler
- Parameters:
portletDataContext
- the context of the data additionportletId
- the portlet ID of the portletportletPreferences
- 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 PortletPreferences deleteData(PortletDataContext portletDataContext, String portletId, 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 interfacePortletDataHandler
- Parameters:
portletDataContext
- the context of the data deletionportletId
- the portlet ID of the portletportletPreferences
- 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, 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 thedata
parameter ofimportData()
.- Specified by:
exportData
in interfacePortletDataHandler
- Parameters:
portletDataContext
- the context of the data exportportletId
- the portlet ID of the portletportletPreferences
- 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
- Specified by:
getDataLevel
in interfacePortletDataHandler
-
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 interfacePortletDataHandler
- Returns:
- an array of the portlet preferences that reference data
-
getDeletionSystemEventStagedModelTypes
- Specified by:
getDeletionSystemEventStagedModelTypes
in interfacePortletDataHandler
-
getExportConfigurationControls
public PortletDataHandlerControl[] getExportConfigurationControls(long companyId, long groupId, Portlet portlet, boolean privateLayout) throws Exception - Specified by:
getExportConfigurationControls
in interfacePortletDataHandler
- Throws:
Exception
-
getExportConfigurationControls
public PortletDataHandlerControl[] getExportConfigurationControls(long companyId, long groupId, Portlet portlet, long plid, boolean privateLayout) throws Exception - Specified by:
getExportConfigurationControls
in interfacePortletDataHandler
- Throws:
Exception
-
getExportControls
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:
getExportControls
in interfacePortletDataHandler
- Returns:
- an array of the controls defined for this data handler
-
getExportMetadataControls
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:
getExportMetadataControls
in interfacePortletDataHandler
- Returns:
- an array of the metadata controls defined for this data handler
-
getExportModelCount
Description copied from interface:PortletDataHandler
Returns the number of entities defined for this data handler that are available for export according to the provided manifest summary, or-1
if no entities are included in the manifest summary.- Specified by:
getExportModelCount
in interfacePortletDataHandler
- Parameters:
manifestSummary
- the manifest summary listing the number of exportable entities- Returns:
- the number of entities that are available for export according to
the manifest summary, or
-1
if no entities are included in the manifest summary
-
getImportConfigurationControls
public PortletDataHandlerControl[] getImportConfigurationControls(Portlet portlet, ManifestSummary manifestSummary) - Specified by:
getImportConfigurationControls
in interfacePortletDataHandler
-
getImportConfigurationControls
public PortletDataHandlerControl[] getImportConfigurationControls(String[] configurationPortletOptions) - Specified by:
getImportConfigurationControls
in interfacePortletDataHandler
-
getImportControls
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:
getImportControls
in interfacePortletDataHandler
- Returns:
- an array of the controls defined for this data handler
-
getImportMetadataControls
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:
getImportMetadataControls
in interfacePortletDataHandler
- Returns:
- an array of the metadata controls defined for this data handler
-
getPortletId
- Specified by:
getPortletId
in interfacePortletDataHandler
-
getRank
public int getRank()- Specified by:
getRank
in interfacePortletDataHandler
-
getResourceName
- Specified by:
getResourceName
in interfacePortletDataHandler
-
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 interfacePortletDataHandler
- Returns:
- the portlet data handler's schema version
-
getServiceName
- Specified by:
getServiceName
in interfacePortletDataHandler
-
getStagingControls
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 staging publication behavior. The controls are rendered in the publish UI.- Specified by:
getStagingControls
in interfacePortletDataHandler
- Returns:
- an array of the controls defined for this data handler
-
importData
public PortletPreferences importData(PortletDataContext portletDataContext, String portletId, 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 ofpreferences
to be saved in the new portlet.- Specified by:
importData
in interfacePortletDataHandler
- Parameters:
portletDataContext
- the context of the data importportletId
- the portlet ID of the portletportletPreferences
- the portlet preferences of the portletdata
- the string data that was returned byexportData()
- 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 interfacePortletDataHandler
-
isDataLocalized
public boolean isDataLocalized()- Specified by:
isDataLocalized
in interfacePortletDataHandler
-
isDataPortalLevel
public boolean isDataPortalLevel()- Specified by:
isDataPortalLevel
in interfacePortletDataHandler
-
isDataPortletInstanceLevel
public boolean isDataPortletInstanceLevel()- Specified by:
isDataPortletInstanceLevel
in interfacePortletDataHandler
-
isDataSiteLevel
public boolean isDataSiteLevel()- Specified by:
isDataSiteLevel
in interfacePortletDataHandler
-
isDisplayPortlet
public boolean isDisplayPortlet()- Specified by:
isDisplayPortlet
in interfacePortletDataHandler
-
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 betrue
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 interfacePortletDataHandler
- 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
Returnstrue
if the data handler stops operations and rolls back their transactions on operations throwing exceptions.- Specified by:
isRollbackOnException
in interfacePortletDataHandler
- 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 interfacePortletDataHandler
- Throws:
PortletDataException
-
prepareManifestSummary
public void prepareManifestSummary(PortletDataContext portletDataContext, PortletPreferences portletPreferences) throws PortletDataException - Specified by:
prepareManifestSummary
in interfacePortletDataHandler
- Throws:
PortletDataException
-
setPortletId
- Specified by:
setPortletId
in interfacePortletDataHandler
-
setRank
public void setRank(int rank) - Specified by:
setRank
in interfacePortletDataHandler
-
validateSchemaVersion
- Specified by:
validateSchemaVersion
in interfacePortletDataHandler
-
addExportDataRootElement
-
addImportDataRootElement
protected Element addImportDataRootElement(PortletDataContext portletDataContext, String data) throws DocumentException - Throws:
DocumentException
-
addUncheckedModelAdditionCount
protected void addUncheckedModelAdditionCount(PortletDataContext portletDataContext, PortletDataHandlerControl portletDataHandlerControl) -
doAddDefaultData
protected PortletPreferences doAddDefaultData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception - Throws:
Exception
-
doDeleteData
protected PortletPreferences doDeleteData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception - Throws:
Exception
-
doExportData
protected String doExportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception - Throws:
Exception
-
doImportData
protected PortletPreferences doImportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences, String data) throws Exception - Throws:
Exception
-
doPrepareManifestSummary
protected void doPrepareManifestSummary(PortletDataContext portletDataContext, PortletPreferences portletPreferences) throws Exception - Throws:
Exception
-
doValidateSchemaVersion
- Throws:
Exception
-
getExportDataRootElementString
-
getExportModelCount
protected long getExportModelCount(ManifestSummary manifestSummary, PortletDataHandlerControl[] portletDataHandlerControls) -
getStagedModelTypes
protected StagedModelType[] getStagedModelTypes(Supplier<List<StagedModelType>> stagedModelTypesSupplier) -
setDataAlwaysStaged
protected void setDataAlwaysStaged(boolean dataAlwaysStaged) -
setDataLevel
-
setDataLocalized
protected void setDataLocalized(boolean dataLocalized) -
setDataPortletPreferences
-
setDeletionSystemEventStagedModelTypes
protected void setDeletionSystemEventStagedModelTypes(StagedModelType... deletionSystemEventStagedModelTypes) -
setExportControls
-
setExportMetadataControls
-
setImportControls
-
setImportMetadataControls
-
setPublishToLiveByDefault
protected void setPublishToLiveByDefault(boolean publishToLiveByDefault) -
setStagingControls
-