Package fr.becpg.repo.helper
Class UserPreferenceWriter
java.lang.Object
fr.becpg.repo.helper.UserPreferenceWriter
Saves best-effort user preferences, such as UI history, without putting the calling request at risk.
Every preference write rewrites the whole cm:preferenceValues content of the person node.
When another transaction holds a lock on that node or on alf_content_url, the write fails
with a ConcurrencyFailureException that the content service wraps into a
ContentIOException. Run inside the caller's transaction, that failure either aborts the
whole transaction or makes the web script container replay the request, each attempt waiting for the
database lock timeout again. The write therefore runs in a transaction of its own and is skipped when
the cause chain reveals a lock conflict.
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Logprivate final org.alfresco.service.cmr.preference.PreferenceServiceprivate final org.alfresco.service.transaction.TransactionService -
Constructor Summary
ConstructorsConstructorDescriptionUserPreferenceWriter(org.alfresco.service.cmr.preference.PreferenceService preferenceService, org.alfresco.service.transaction.TransactionService transactionService) Constructor for UserPreferenceWriter. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprivate voidrollbackQuietly(jakarta.transaction.UserTransaction transaction) voidsavePreferencesUnlessLocked(String userName, Map<String, Serializable> preferences) Saves the preferences in a dedicated transaction, and skips the write when it loses a lock conflict.
-
Field Details
-
logger
private static final org.apache.commons.logging.Log logger -
preferenceService
private final org.alfresco.service.cmr.preference.PreferenceService preferenceService -
transactionService
private final org.alfresco.service.transaction.TransactionService transactionService
-
-
Constructor Details
-
UserPreferenceWriter
@Autowired public UserPreferenceWriter(@Qualifier("PreferenceService") org.alfresco.service.cmr.preference.PreferenceService preferenceService, @Qualifier("TransactionService") org.alfresco.service.transaction.TransactionService transactionService) Constructor for UserPreferenceWriter.
- Parameters:
preferenceService- the service storing the user preferencestransactionService- the service providing the dedicated write transaction
-
-
Method Details
-
savePreferencesUnlessLocked
Saves the preferences in a dedicated transaction, and skips the write when it loses a lock conflict.- Parameters:
userName- the user owning the preferencespreferences- the preferences to add or replace- Throws:
BeCPGException- if the write fails for any reason other than a lock conflict
-
isLockConflict
-
rollbackQuietly
private void rollbackQuietly(jakarta.transaction.UserTransaction transaction)
-