Class IdMapper
- java.lang.Object
-
- com.atlassian.confluence.impl.backuprestore.restore.idmapping.IdMapper
-
public class IdMapper extends Object
Responsible for keeping all required id mappings between the old ids and the new ones. Note that it does keep id mappings only for entities that can be referenced. For example, it will keep mappings for Content objects but will not keep references for content properties.- Since:
- 7.20.0
-
-
Constructor Summary
Constructors Constructor Description IdMapper(PersistedObjectsRegister persistedObjectsRegister, RestoreDao restoreDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
createFakeObjectForIdGeneration(Class<?> supportedClass)
Create an empty object for id generation Some classes do not have public constructorsMap<String,Object>
createMapOfNewIds(ImportedObjectV2 importedObject, Collection<HibernateField> references)
For all references, it find the new id for each old id.Object
generateNewId(ExportableEntityInfo entityInfo, Object fakeObject, Object oldId)
Generates and returns new id.Collection<HibernateField>
getAllNotSatisfiedDependencies(ImportedObjectV2 importedObject)
Object
getNewId(Class<?> clazz, Object oldId)
Returns the new id related to the old id or null if the new id was not generated before.boolean
isPersistedOldId(Class<?> clazz, Object oldId)
Check if the records with id from XML (oldId) has been persisted.void
markObjectsAsPersisted(ExportableEntityInfo entityInfo, List<Object> newObjectIds)
Marks all ids as persisted.
-
-
-
Constructor Detail
-
IdMapper
public IdMapper(PersistedObjectsRegister persistedObjectsRegister, RestoreDao restoreDao)
-
-
Method Detail
-
generateNewId
public Object generateNewId(ExportableEntityInfo entityInfo, Object fakeObject, Object oldId)
Generates and returns new id. This method could be changed in the future to support generating ids in batches.
-
getNewId
public Object getNewId(Class<?> clazz, Object oldId)
Returns the new id related to the old id or null if the new id was not generated before.- Throws:
BackupRestoreException
- if the new id is not found
-
isPersistedOldId
public boolean isPersistedOldId(Class<?> clazz, Object oldId)
Check if the records with id from XML (oldId) has been persisted.
-
createMapOfNewIds
public Map<String,Object> createMapOfNewIds(ImportedObjectV2 importedObject, Collection<HibernateField> references)
For all references, it find the new id for each old id. Then it returns the map where the key is the property name and the value is the new id.
-
markObjectsAsPersisted
public void markObjectsAsPersisted(ExportableEntityInfo entityInfo, List<Object> newObjectIds)
Marks all ids as persisted. This method is usually called when the transaction commit.- Parameters:
entityInfo
- entity infonewObjectIds
- new objects ids
-
getAllNotSatisfiedDependencies
public Collection<HibernateField> getAllNotSatisfiedDependencies(ImportedObjectV2 importedObject)
- Returns:
- all fields which referenced records are not persisted yet.
-
createFakeObjectForIdGeneration
public Object createFakeObjectForIdGeneration(Class<?> supportedClass) throws BackupRestoreException
Create an empty object for id generation Some classes do not have public constructors- Throws:
BackupRestoreException
-
-