Class OlapQueryIdPatch
- All Implemented Interfaces:
org.alfresco.repo.admin.patch.Patch,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationEventPublisherAware
#24931: before this patch a resource was identified by its file name, which beCPG shipped translated. Renaming the files therefore had to come with a migration, or every reference would break at once and without a trace: a dashboard would point at a query that no longer exists, and the Share dashlet would find nothing behind the query id stored in each user's preferences.
The three are migrated together and in that order, since the mapping from the old identity to the new one is built while walking the folder:
- every installed resource receives
bcpg:olapQueryIdand acm:titlein every language shipped, its name being left untouched; - the dashboards and applications have their query references rewritten to those ids;
- the OLAP dashlet preference of every user is rewritten to the same ids.
A query a user saved from Saiku carries no id: it is left exactly as it is, its name remaining its identity.
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.alfresco.service.cmr.repository.ContentServiceprivate static final StringBundle holding the shipped labels, keyed by technical id.private static final Stringprivate static final org.apache.commons.logging.Logprivate static final Stringprivate org.alfresco.service.cmr.security.PersonServiceprivate static final Stringprivate static final StringPreference holding the query selected in an OLAP dashlet, one per dashlet region.private org.alfresco.service.cmr.preference.PreferenceServiceprivate static final StringFields inherited from class fr.becpg.repo.admin.patch.AbstractBeCPGPatch
BATCH_SIZE, BATCH_THREADS, contentHelper, entitySystemService, INC, nodeDAO, patchDAO, qnameDAO, repoService, repositoryFields inherited from class org.alfresco.repo.admin.patch.AbstractPatch
applicationEventPublisher, authenticationContext, ERR_PROPERTY_NOT_SET, namespaceService, nodeService, patchService, searchService, tenantAdminService, transactionHelper, transactionService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringprivate static ResourceBundleLoads the label bundle of a locale, or null when no module on the classpath ships one, which is the case of a repository installed without the PLM module.Indexes the technical id of every shipped resource by the label it carries, in every language shipped: an instance installed in French must be recognised from its French names.private voidrecordOldIdentities(org.alfresco.service.cmr.repository.NodeRef nodeRef, String label, String olapQueryId, Map<String, String> idByOldIdentity) Records the identities a resource used to answer to: its translated name, and the query id its content declares, which the Share dashlet stored in the user preferences.private booleanrewriteDocumentReferences(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String, String> idByOldIdentity) private intrewritePreferences(String userName, Map<String, String> idByOldIdentity) private intrewritePreferences(Map<String, String> idByOldIdentity) Rewrites the OLAP dashlet preference of every user, which holds the query id it must select.private intrewriteReferences(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, Map<String, String> idByOldIdentity) Rewrites the query references a dashboard or an application holds, which used to be the translated file name of the query.voidsetContentService(org.alfresco.service.cmr.repository.ContentService contentService) Setter for the fieldcontentService.voidsetPersonService(org.alfresco.service.cmr.security.PersonService personService) Setter for the fieldpersonService.voidsetPreferenceService(org.alfresco.service.cmr.preference.PreferenceService preferenceService) Setter for the fieldpreferenceService.private voidWrites the multilingual title of a migrated resource.private intstampTechnicalIds(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, Map<String, String> idByLabel, Map<String, String> idByOldIdentity) Stamps every installed resource that beCPG ships with its technical id and its translated title, and records what that resource used to be identified by.private static StringstripExtension(String name) Methods inherited from class fr.becpg.repo.admin.patch.AbstractBeCPGPatch
createBatchAspectProcessor, createBatchTypeProcessor, createBatchTypeProcessor, formatTenantNodeRef, getBaseName, getCharactDataList, getFolder, getNodeDAO, getPatchDAO, getQnameDAO, getSystemCharactsEntity, getSystemHierachiesEntity, getSystemListValuesEntity, searchFolder, setContentHelper, setEntitySystemService, setNodeDAO, setPatchDAO, setQnameDAO, setRepoService, setRepository, updateResourceMethods inherited from class org.alfresco.repo.admin.patch.AbstractPatch
applies, apply, applyAsync, checkProperties, checkPropertyNotNull, getAlternatives, getDependsOn, getDescription, getFixesFromSchema, getFixesToSchema, getId, getTargetSchema, init, isDeferred, isForce, isIgnored, reportProgress, requiresTransaction, setAlternatives, setApplicationEventPublisher, setApplyToTenants, setAuthenticationContext, setDeferred, setDependsOn, setDescription, setFixesFromSchema, setFixesToSchema, setForce, setId, setIgnored, setNamespaceService, setNodeService, setPatchService, setRequiresTransaction, setSearchService, setTargetSchema, setTenantAdminService, setTransactionService, toString
-
Field Details
-
logger
private static final org.apache.commons.logging.Log logger -
MSG_SUCCESS
- See Also:
-
LABEL_BUNDLE
Bundle holding the shipped labels, keyed by technical id.- See Also:
-
LABEL_KEY_PREFIX
- See Also:
-
PREFERENCE_ROOT
Preference holding the query selected in an OLAP dashlet, one per dashlet region.- See Also:
-
PREFERENCE_QUERY_SUFFIX
- See Also:
-
REFERENCE_PREFIX
- See Also:
-
contentService
private org.alfresco.service.cmr.repository.ContentService contentService -
preferenceService
private org.alfresco.service.cmr.preference.PreferenceService preferenceService -
personService
private org.alfresco.service.cmr.security.PersonService personService
-
-
Constructor Details
-
OlapQueryIdPatch
public OlapQueryIdPatch()
-
-
Method Details
-
setContentService
public void setContentService(org.alfresco.service.cmr.repository.ContentService contentService) Setter for the field
contentService.- Parameters:
contentService- aContentServiceobject
-
setPreferenceService
public void setPreferenceService(org.alfresco.service.cmr.preference.PreferenceService preferenceService) Setter for the field
preferenceService.- Parameters:
preferenceService- aPreferenceServiceobject
-
setPersonService
public void setPersonService(org.alfresco.service.cmr.security.PersonService personService) Setter for the field
personService.- Parameters:
personService- aPersonServiceobject
-
applyInternal
- Specified by:
applyInternalin classorg.alfresco.repo.admin.patch.AbstractPatch- Throws:
Exception
-
stampTechnicalIds
private int stampTechnicalIds(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, Map<String, String> idByLabel, Map<String, String> idByOldIdentity) Stamps every installed resource that beCPG ships with its technical id and its translated title, and records what that resource used to be identified by.- Parameters:
folderNodeRef- the shared OLAP query folderidByLabel- the technical id of every shipped label, in every language shippedidByOldIdentity- filled with the old identities the resource answered to- Returns:
- the number of resources stamped
-
recordOldIdentities
private void recordOldIdentities(org.alfresco.service.cmr.repository.NodeRef nodeRef, String label, String olapQueryId, Map<String, String> idByOldIdentity) Records the identities a resource used to answer to: its translated name, and the query id its content declares, which the Share dashlet stored in the user preferences.- Parameters:
nodeRef- the resource being migratedlabel- its name, extension strippedolapQueryId- the technical id it now carriesidByOldIdentity- the mapping to fill
-
rewriteReferences
private int rewriteReferences(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, Map<String, String> idByOldIdentity) Rewrites the query references a dashboard or an application holds, which used to be the translated file name of the query.- Parameters:
folderNodeRef- the shared OLAP query folderidByOldIdentity- the mapping from the old identity to the technical id- Returns:
- the number of documents rewritten
-
rewriteDocumentReferences
-
rewritePreferences
Rewrites the OLAP dashlet preference of every user, which holds the query id it must select.A preference pointing at something no longer shipped is left untouched: the dashlet falls back to its first query, which is a better outcome than silently choosing another one. When nothing was migrated there is nothing to rewrite either, and the users are not walked at all.
- Parameters:
idByOldIdentity- the mapping from the old identity to the technical id- Returns:
- the number of preferences rewritten
-
rewritePreferences
-
indexIdByLabel
Indexes the technical id of every shipped resource by the label it carries, in every language shipped: an instance installed in French must be recognised from its French names.- Returns:
- the technical id of every known label
-
setTitles
Writes the multilingual title of a migrated resource.Without the ML-aware flag the interceptor keeps only the value of the current locale, and every other language is lost on the way in.
- Parameters:
nodeRef- the resource being migratedolapQueryId- its technical id
-
bundleFor
Loads the label bundle of a locale, or null when no module on the classpath ships one, which is the case of a repository installed without the PLM module.- Parameters:
locale- the locale to load- Returns:
- the bundle, or null
-
stripExtension
-