From 7968213a8da21157c1ccd9e824547fb5a0da6b20 Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Sat, 20 Sep 2014 09:59:08 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 84974: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 83853: As part of ACE-2639, this adds an optional locale query parameter to the facetableproperties.get webscript. We may revisit the use of a URL query parameter to get the requester's locale and consider e.g. an accept-languages HTTP header, but for now, ?locale=fr, will receive french titles and descriptions for property definitions. ?locale=rubbish or "" will result in the use of the server's default locale. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85289 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../facet/facetable-properties.get.desc.xml | 4 +-- .../web-scripts-application-context.xml | 1 - .../scripts/facet/FacetablePropertiesGet.java | 26 +++++++++++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/facet/facetable-properties.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/facet/facetable-properties.get.desc.xml index 2d1c20dffc..db9c2e804b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/facet/facetable-properties.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/facet/facetable-properties.get.desc.xml @@ -34,8 +34,8 @@ } ]]> - /api/facet/classes/{classname}/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?} - /api/facet/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?} + /api/facet/classes/{classname}/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?}&locale={locale?} + /api/facet/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?}&locale={locale?} argument user required diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 19358905b8..5d75a1ff3d 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -1825,7 +1825,6 @@ id="webscript.org.alfresco.repository.facet.facetable-properties.get" class="org.alfresco.repo.web.scripts.facet.FacetablePropertiesGet" parent="baseSolrFacetConfigAdminWebscript"> - executeImpl(final WebScriptRequest req, final Status status, final Cache cache) @@ -73,6 +80,9 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip @Override protected Map unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache) { + final String userLocaleString = req.getParameter(QUERY_PARAM_LOCALE); + final Locale userLocale = (userLocaleString == null) ? Locale.getDefault() : new Locale(userLocaleString); + // There are multiple defined URIs for this REST endpoint. Some define a "classname" template var. Map templateVars = req.getServiceMatch().getTemplateVars(); final String contentClassName = templateVars.get(TEMPLATE_VAR_CLASSNAME); @@ -91,11 +101,11 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip final SortedSet facetableProperties; if (contentClassQName == null) { - facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties()); + facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(), userLocale); } else { - facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(contentClassQName)); + facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(contentClassQName), userLocale); } // The webscript allows for some further filtering of results: @@ -162,18 +172,18 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip } /** This method returns a {@link FacetablePropertyData} for the specified {@link PropertyDefinition}. */ - private FacetablePropertyData toFacetablePropertyData(PropertyDefinition propDef) + private FacetablePropertyData toFacetablePropertyData(PropertyDefinition propDef, Locale locale) { - String title = propDef.getTitle(dictionaryService); + String title = propDef.getTitle(messageLookup, locale); return new FacetablePropertyData(propDef, title); } - private SortedSet toFacetablePropertyDataSet(Collection propDefs) + private SortedSet toFacetablePropertyDataSet(Collection propDefs, Locale locale) { SortedSet result = new TreeSet<>(); for (PropertyDefinition propDef : propDefs) { - result.add(toFacetablePropertyData(propDef)); + result.add(toFacetablePropertyData(propDef, locale)); } return result; }