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 ElementaddExportDataRootElement(PortletDataContext portletDataContext) protected ElementaddImportDataRootElement(PortletDataContext portletDataContext, String data) protected voidaddUncheckedModelAdditionCount(PortletDataContext portletDataContext, PortletDataHandlerControl portletDataHandlerControl) deleteData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) Deletes the data created by the portlet.protected PortletPreferencesdoAddDefaultData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) protected PortletPreferencesdoDeleteData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) protected StringdoExportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) protected PortletPreferencesdoImportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences, String data) protected voiddoPrepareManifestSummary(PortletDataContext portletDataContext, PortletPreferences portletPreferences) protected booleandoValidateSchemaVersion(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 StringgetExportDataRootElementString(Element rootElement) Returns an array of the metadata controls defined for this data handler.longgetExportModelCount(ManifestSummary manifestSummary) Returns the number of entities defined for this data handler that are available for export according to the provided manifest summary, or-1if no entities are included in the manifest summary.protected longgetExportModelCount(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.intgetRank()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.booleanbooleanbooleanbooleanbooleanbooleanbooleanReturns whether the data exported by this handler should be included by default when publishing to live.booleanReturnstrueif the data handler stops operations and rolls back their transactions on operations throwing exceptions.voidprepareManifestSummary(PortletDataContext portletDataContext) voidprepareManifestSummary(PortletDataContext portletDataContext, PortletPreferences portletPreferences) protected voidsetDataAlwaysStaged(boolean dataAlwaysStaged) protected voidsetDataLevel(DataLevel dataLevel) protected voidsetDataLocalized(boolean dataLocalized) protected voidsetDataPortletPreferences(String... dataPortletPreferences) protected voidsetDeletionSystemEventStagedModelTypes(StagedModelType... deletionSystemEventStagedModelTypes) protected voidsetExportControls(PortletDataHandlerControl... exportControls) protected voidsetExportMetadataControls(PortletDataHandlerControl... exportMetadataControls) protected voidsetImportControls(PortletDataHandlerControl... importControls) protected voidsetImportMetadataControls(PortletDataHandlerControl... importMetadataControls) voidsetPortletId(String portletId) protected voidsetPublishToLiveByDefault(boolean publishToLiveByDefault) voidsetRank(int rank) protected voidsetStagingControls(PortletDataHandlerControl... stagingControls) booleanvalidateSchemaVersion(String schemaVersion) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:PortletDataHandlerReturns the portlet's preferences with default data added.- Specified by:
addDefaultDatain 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
nullif 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:PortletDataHandlerDeletes 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:
deleteDatain 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
nullif 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:PortletDataHandlerReturns a string of data to be placed in the <portlet-data> section of the LAR file. This data will be passed as thedataparameter ofimportData().- Specified by:
exportDatain 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
nullif no portlet data is to be written out - Throws:
PortletDataException- if a portlet data exception occurred
-
getDataLevel
- Specified by:
getDataLevelin interfacePortletDataHandler
-
getDataPortletPreferences
Description copied from interface:PortletDataHandlerReturns an array of the portlet preferences that reference data. These preferences should only be updated if the referenced data is imported.- Specified by:
getDataPortletPreferencesin interfacePortletDataHandler- Returns:
- an array of the portlet preferences that reference data
-
getDeletionSystemEventStagedModelTypes
- Specified by:
getDeletionSystemEventStagedModelTypesin interfacePortletDataHandler
-
getExportConfigurationControls
public PortletDataHandlerControl[] getExportConfigurationControls(long companyId, long groupId, Portlet portlet, boolean privateLayout) throws Exception - Specified by:
getExportConfigurationControlsin interfacePortletDataHandler- Throws:
Exception
-
getExportConfigurationControls
public PortletDataHandlerControl[] getExportConfigurationControls(long companyId, long groupId, Portlet portlet, long plid, boolean privateLayout) throws Exception - Specified by:
getExportConfigurationControlsin interfacePortletDataHandler- Throws:
Exception
-
getExportControls
Description copied from interface:PortletDataHandlerReturns 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:
getExportControlsin interfacePortletDataHandler- Returns:
- an array of the controls defined for this data handler
-
getExportMetadataControls
Description copied from interface:PortletDataHandlerReturns 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:
getExportMetadataControlsin interfacePortletDataHandler- Returns:
- an array of the metadata controls defined for this data handler
-
getExportModelCount
Description copied from interface:PortletDataHandlerReturns the number of entities defined for this data handler that are available for export according to the provided manifest summary, or-1if no entities are included in the manifest summary.- Specified by:
getExportModelCountin 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
-1if no entities are included in the manifest summary
-
getImportConfigurationControls
public PortletDataHandlerControl[] getImportConfigurationControls(Portlet portlet, ManifestSummary manifestSummary) - Specified by:
getImportConfigurationControlsin interfacePortletDataHandler
-
getImportConfigurationControls
public PortletDataHandlerControl[] getImportConfigurationControls(String[] configurationPortletOptions) - Specified by:
getImportConfigurationControlsin interfacePortletDataHandler
-
getImportControls
Description copied from interface:PortletDataHandlerReturns 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:
getImportControlsin interfacePortletDataHandler- Returns:
- an array of the controls defined for this data handler
-
getImportMetadataControls
Description copied from interface:PortletDataHandlerReturns 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:
getImportMetadataControlsin interfacePortletDataHandler- Returns:
- an array of the metadata controls defined for this data handler
-
getPortletId
- Specified by:
getPortletIdin interfacePortletDataHandler
-
getRank
public int getRank()- Specified by:
getRankin interfacePortletDataHandler
-
getResourceName
- Specified by:
getResourceNamein interfacePortletDataHandler
-
getSchemaVersion
Description copied from interface:PortletDataHandlerReturns 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:
getSchemaVersionin interfacePortletDataHandler- Returns:
- the portlet data handler's schema version
-
getServiceName
- Specified by:
getServiceNamein interfacePortletDataHandler
-
getStagingControls
Description copied from interface:PortletDataHandlerReturns 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:
getStagingControlsin 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:PortletDataHandlerHandles any special processing of the data when the portlet is imported into a new layout. Can optionally return a modified version ofpreferencesto be saved in the new portlet.- Specified by:
importDatain 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
nullif the data handler made no changes to the portlet preferences - Throws:
PortletDataException- if a portlet data exception occurred
-
isDataAlwaysStaged
public boolean isDataAlwaysStaged()- Specified by:
isDataAlwaysStagedin interfacePortletDataHandler
-
isDataLocalized
public boolean isDataLocalized()- Specified by:
isDataLocalizedin interfacePortletDataHandler
-
isDataPortalLevel
public boolean isDataPortalLevel()- Specified by:
isDataPortalLevelin interfacePortletDataHandler
-
isDataPortletInstanceLevel
public boolean isDataPortletInstanceLevel()- Specified by:
isDataPortletInstanceLevelin interfacePortletDataHandler
-
isDataSiteLevel
public boolean isDataSiteLevel()- Specified by:
isDataSiteLevelin interfacePortletDataHandler
-
isDisplayPortlet
public boolean isDisplayPortlet()- Specified by:
isDisplayPortletin interfacePortletDataHandler
-
isPublishToLiveByDefault
public boolean isPublishToLiveByDefault()Description copied from interface:PortletDataHandlerReturns whether the data exported by this handler should be included by default when publishing to live. This should only betruefor 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:
isPublishToLiveByDefaultin interfacePortletDataHandler- Returns:
trueif the data exported by this handler should be included by default when publishing to live;falseotherwise
-
isRollbackOnException
public boolean isRollbackOnException()Description copied from interface:PortletDataHandlerReturnstrueif the data handler stops operations and rolls back their transactions on operations throwing exceptions.- Specified by:
isRollbackOnExceptionin interfacePortletDataHandler- Returns:
trueif the data handler stops operations and rolls back their transactions on operations throwing exceptions;falseotherwise
-
prepareManifestSummary
public void prepareManifestSummary(PortletDataContext portletDataContext) throws PortletDataException - Specified by:
prepareManifestSummaryin interfacePortletDataHandler- Throws:
PortletDataException
-
prepareManifestSummary
public void prepareManifestSummary(PortletDataContext portletDataContext, PortletPreferences portletPreferences) throws PortletDataException - Specified by:
prepareManifestSummaryin interfacePortletDataHandler- Throws:
PortletDataException
-
setPortletId
- Specified by:
setPortletIdin interfacePortletDataHandler
-
setRank
public void setRank(int rank) - Specified by:
setRankin interfacePortletDataHandler
-
validateSchemaVersion
- Specified by:
validateSchemaVersionin 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
-