Class BaseStagedModelDataHandler<T extends StagedModel>
Object
com.liferay.exportimport.kernel.lar.BaseStagedModelDataHandler<T>
- All Implemented Interfaces:
StagedModelDataHandler<T>
public abstract class BaseStagedModelDataHandler<T extends StagedModel>
extends Object
implements StagedModelDataHandler<T>
- Author:
- Máté Thurzó, Daniel Kocsis, Zsolt Berentey
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
countStagedModel
(PortletDataContext portletDataContext, T stagedModel) abstract void
deleteStagedModel
(String uuid, long groupId, String className, String extraData) Deletes the staged model matching the parameters.abstract void
deleteStagedModel
(T stagedModel) Deletes the staged model.protected abstract void
doExportStagedModel
(PortletDataContext portletDataContext, T stagedModel) protected void
doImportMissingReference
(PortletDataContext portletDataContext, Element referenceElement) protected void
doImportMissingReference
(PortletDataContext portletDataContext, String uuid, long groupId, long classPK) protected abstract void
doImportStagedModel
(PortletDataContext portletDataContext, T stagedModel) protected void
doRestoreStagedModel
(PortletDataContext portletDataContext, T stagedModel) protected void
exportAssetCategories
(PortletDataContext portletDataContext, T stagedModel) protected void
exportAssetTags
(PortletDataContext portletDataContext, T stagedModel) protected void
exportComments
(PortletDataContext portletDataContext, T stagedModel) protected void
exportRatings
(PortletDataContext portletDataContext, T stagedModel) void
exportStagedModel
(PortletDataContext portletDataContext, T stagedModel) Exports the staged model and its references.fetchMissingReference
(String uuid, long groupId) Returns a reference of the staged model.fetchStagedModelByUuidAndGroupId
(String uuid, long groupId) Returns the staged model with the UUID and group.fetchStagedModelsByUuidAndCompanyId
(String uuid, long companyId) Returns the staged models with the UUID and company.abstract String[]
Returns the class names of the models the data handler handles.getDisplayName
(T stagedModel) Returns the staged model's display name.int[]
Returns the workflow statuses that are used as filters during the export process.protected int
getReferenceAttributes
(PortletDataContext portletDataContext, T stagedModel) Returns the attributes that are automatically merged into the XML element of the staged model reference.protected String[]
protected void
importAssetCategories
(PortletDataContext portletDataContext, T stagedModel) protected void
importAssetTags
(PortletDataContext portletDataContext, T stagedModel) protected void
importComments
(PortletDataContext portletDataContext, T stagedModel) protected void
importMissingGroupReference
(PortletDataContext portletDataContext, Element referenceElement) void
importMissingReference
(PortletDataContext portletDataContext, Element referenceElement) Maps the ID of the existing staged model to the old ID in the reference element.void
importMissingReference
(PortletDataContext portletDataContext, String uuid, long groupId, long classPK) Maps the ID of the existing staged model to the old ID in the reference element.protected void
importRatings
(PortletDataContext portletDataContext, T stagedModel) protected void
importReferenceStagedModels
(PortletDataContext portletDataContext, T stagedModel) void
importStagedModel
(PortletDataContext portletDataContext, T stagedModel) Imports the staged model.protected boolean
protected boolean
isStagedModelInTrash
(T stagedModel) void
restoreStagedModel
(PortletDataContext portletDataContext, T stagedModel) Restores the staged model from the trash.protected void
validateExport
(PortletDataContext portletDataContext, T stagedModel) protected boolean
validateMissingGroupReference
(PortletDataContext portletDataContext, Element referenceElement) protected boolean
validateMissingReference
(String uuid, long groupId) boolean
validateReference
(PortletDataContext portletDataContext, Element referenceElement) Returnstrue
if the staged model reference validation is successful.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.StagedModelDataHandler
isEnabled
-
Constructor Details
-
BaseStagedModelDataHandler
public BaseStagedModelDataHandler()
-
-
Method Details
-
deleteStagedModel
public abstract void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException Description copied from interface:StagedModelDataHandler
Deletes the staged model matching the parameters. This method is called when deletions are imported.- Specified by:
deleteStagedModel
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
uuid
- the staged model's UUIDgroupId
- the primary key of the entity's groupclassName
- the staged model's class nameextraData
- the extra data containing useful information about the staged model. This information makes the staged model easier to identify and fetch for deletion. It is populated when a deletion system event is added, usually in the*LocalServiceImpl
class of the model.- Throws:
PortalException
- if a portal exception occurred
-
deleteStagedModel
Description copied from interface:StagedModelDataHandler
Deletes the staged model. This method is called when deletions are imported.- Specified by:
deleteStagedModel
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
stagedModel
- the staged model to delete- Throws:
PortalException
- if a portal exception occurred
-
exportStagedModel
public void exportStagedModel(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException Description copied from interface:StagedModelDataHandler
Exports the staged model and its references. See theStagedModelDataHandler.exportStagedModel(PortletDataContext, T)
method for a reference implementation. Refrain from overriding this method; instead, override theBaseStagedModelDataHandler#doExportStagedModel(PortletDataContext, T)
method.- Specified by:
exportStagedModel
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the portlet data context of the current processstagedModel
- the staged model to export- Throws:
PortletDataException
- if a portlet data exception occurred
-
fetchMissingReference
Description copied from interface:StagedModelDataHandler
Returns a reference of the staged model. This method is typically used in validation and import methods.- Specified by:
fetchMissingReference
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
uuid
- the reference's UUIDgroupId
- the primary key of the group- Returns:
- a reference of the staged model
-
fetchStagedModelByUuidAndGroupId
Description copied from interface:StagedModelDataHandler
Returns the staged model with the UUID and group. This method is used in cases with grouped models.- Specified by:
fetchStagedModelByUuidAndGroupId
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
uuid
- the staged model's UUIDgroupId
- the primary key of the group- Returns:
- the staged model with the UUID and group
-
fetchStagedModelsByUuidAndCompanyId
Description copied from interface:StagedModelDataHandler
Returns the staged models with the UUID and company.- Specified by:
fetchStagedModelsByUuidAndCompanyId
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
uuid
- the staged model's UUIDcompanyId
- the primary key of the company- Returns:
- the staged models with the UUID and company
-
getClassNames
Description copied from interface:StagedModelDataHandler
Returns the class names of the models the data handler handles.- Specified by:
getClassNames
in interfaceStagedModelDataHandler<T extends StagedModel>
- Returns:
- the class names of the models the data handler handles
-
getDisplayName
Description copied from interface:StagedModelDataHandler
Returns the staged model's display name. The display name is presented in the UI so users can follow the export/import process.- Specified by:
getDisplayName
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
stagedModel
- the staged model from which to extract the display name- Returns:
- the staged model's display name
-
getExportableStatuses
public int[] getExportableStatuses()Description copied from interface:StagedModelDataHandler
Returns the workflow statuses that are used as filters during the export process.- Specified by:
getExportableStatuses
in interfaceStagedModelDataHandler<T extends StagedModel>
- Returns:
- the workflow statuses that are used as filters during the export process
-
getReferenceAttributes
public Map<String,String> getReferenceAttributes(PortletDataContext portletDataContext, T stagedModel) Description copied from interface:StagedModelDataHandler
Returns the attributes that are automatically merged into the XML element of the staged model reference. These attributes are available during the import process in, for example, theStagedModelDataHandler.importMissingReference(PortletDataContext, Element)
andStagedModelDataHandler.validateReference(PortletDataContext, Element)
methods.- Specified by:
getReferenceAttributes
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the current process's portlet data contextstagedModel
- the staged model for which to get attributes- Returns:
- the attributes for the staged model
-
importMissingReference
public void importMissingReference(PortletDataContext portletDataContext, Element referenceElement) throws PortletDataException Description copied from interface:StagedModelDataHandler
Maps the ID of the existing staged model to the old ID in the reference element. When a reference is exported as missing, the Data Handler framework calls this method during the import process and updates the new primary key map in the portlet data context.- Specified by:
importMissingReference
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the portlet data context of the current processreferenceElement
- the XML element that contains information about the staged model reference- Throws:
PortletDataException
- if a portlet data exception occurred
-
importMissingReference
public void importMissingReference(PortletDataContext portletDataContext, String uuid, long groupId, long classPK) throws PortletDataException Description copied from interface:StagedModelDataHandler
Maps the ID of the existing staged model to the old ID in the reference element. When the staged model data handler instance extendsBaseStagedModelDataHandler
, this method is called to override theimportMissingReference(PortletDataContext, Element)
anddoImportMissingReference(PortletDataContext, Element)
methods.- Specified by:
importMissingReference
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the portlet data context of the current processuuid
- the staged model's UUID from the reference elementgroupId
- the primary key of the entity's group from the reference elementclassPK
- the class primary key of the staged model from the reference element- Throws:
PortletDataException
- if a portlet data exception occurred- See Also:
-
importStagedModel
public void importStagedModel(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException Description copied from interface:StagedModelDataHandler
Imports the staged model. All the staged model's references must be imported before this method is called. See theimportStagedModel(PortletDataContext, StagedModel)
method for a reference implementation. Refrain from overriding this method; instead, override theBaseStagedModelDataHandler#doImportStagedModel(PortletDataContext, T)
method.- Specified by:
importStagedModel
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the portlet data context of the current processstagedModel
- the staged model to import- Throws:
PortletDataException
- if a portlet data exception occurred
-
restoreStagedModel
public void restoreStagedModel(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException Description copied from interface:StagedModelDataHandler
Restores the staged model from the trash. This method is called during the import process to ensure the imported staged model is not in the trash. See therestoreStagedModel(PortletDataContext, StagedModel)
method for a reference implementation. Refrain from overriding this method; instead, override thedoRestoreStagedModel(PortletDataContext, StagedModel)
method.- Specified by:
restoreStagedModel
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the portlet data context of the current processstagedModel
- the staged model to restore from the trash- Throws:
PortletDataException
- if a portlet data exception occurred
-
validateReference
Description copied from interface:StagedModelDataHandler
Returnstrue
if the staged model reference validation is successful.- Specified by:
validateReference
in interfaceStagedModelDataHandler<T extends StagedModel>
- Parameters:
portletDataContext
- the portlet data context of the current processreferenceElement
- the XML element that contains information about the reference- Returns:
true
if the reference validation is successful;false
otherwise
-
countStagedModel
-
doExportStagedModel
protected abstract void doExportStagedModel(PortletDataContext portletDataContext, T stagedModel) throws Exception - Throws:
Exception
-
doImportMissingReference
protected void doImportMissingReference(PortletDataContext portletDataContext, Element referenceElement) throws PortletDataException - Throws:
PortletDataException
-
doImportMissingReference
protected void doImportMissingReference(PortletDataContext portletDataContext, String uuid, long groupId, long classPK) throws Exception - Throws:
Exception
-
doImportStagedModel
protected abstract void doImportStagedModel(PortletDataContext portletDataContext, T stagedModel) throws Exception - Throws:
Exception
-
doRestoreStagedModel
protected void doRestoreStagedModel(PortletDataContext portletDataContext, T stagedModel) throws Exception - Throws:
Exception
-
exportAssetCategories
protected void exportAssetCategories(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
exportAssetTags
protected void exportAssetTags(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
exportComments
protected void exportComments(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
exportRatings
protected void exportRatings(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
getProcessFlag
protected int getProcessFlag() -
getSkipImportReferenceStagedModelNames
-
importAssetCategories
protected void importAssetCategories(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
importAssetTags
protected void importAssetTags(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
importComments
protected void importComments(PortletDataContext portletDataContext, T stagedModel) throws PortalException - Throws:
PortalException
-
importMissingGroupReference
protected void importMissingGroupReference(PortletDataContext portletDataContext, Element referenceElement) throws PortletDataException - Throws:
PortletDataException
-
importRatings
protected void importRatings(PortletDataContext portletDataContext, T stagedModel) throws PortalException - Throws:
PortalException
-
importReferenceStagedModels
protected void importReferenceStagedModels(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
isSkipImportReferenceStagedModels
protected boolean isSkipImportReferenceStagedModels() -
isStagedModelInTrash
-
validateExport
protected void validateExport(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException - Throws:
PortletDataException
-
validateMissingGroupReference
protected boolean validateMissingGroupReference(PortletDataContext portletDataContext, Element referenceElement) -
validateMissingReference
-