mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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
This commit is contained in:
@@ -34,8 +34,8 @@
|
|||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/facet/classes/{classname}/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?}</url>
|
<url>/api/facet/classes/{classname}/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?}&locale={locale?}</url>
|
||||||
<url>/api/facet/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?}</url>
|
<url>/api/facet/facetable-properties?nsp={namespacePrefix?}&skipCount={skipCount?}&maxItems={maxItems?}&locale={locale?}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
|
@@ -1825,7 +1825,6 @@
|
|||||||
id="webscript.org.alfresco.repository.facet.facetable-properties.get"
|
id="webscript.org.alfresco.repository.facet.facetable-properties.get"
|
||||||
class="org.alfresco.repo.web.scripts.facet.FacetablePropertiesGet"
|
class="org.alfresco.repo.web.scripts.facet.FacetablePropertiesGet"
|
||||||
parent="baseSolrFacetConfigAdminWebscript">
|
parent="baseSolrFacetConfigAdminWebscript">
|
||||||
<property name="dictionaryService" ref="dictionaryService" />
|
|
||||||
<property name="namespaceService" ref="namespaceService" />
|
<property name="namespaceService" ref="namespaceService" />
|
||||||
</bean>
|
</bean>
|
||||||
<bean
|
<bean
|
||||||
|
@@ -23,12 +23,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.cmr.i18n.MessageLookup;
|
||||||
import org.alfresco.service.namespace.NamespaceException;
|
import org.alfresco.service.namespace.NamespaceException;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -58,11 +61,15 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip
|
|||||||
|
|
||||||
private static final String TEMPLATE_VAR_CLASSNAME = "classname";
|
private static final String TEMPLATE_VAR_CLASSNAME = "classname";
|
||||||
private static final String QUERY_PARAM_NAMESPACE = "nsp";
|
private static final String QUERY_PARAM_NAMESPACE = "nsp";
|
||||||
|
private static final String QUERY_PARAM_LOCALE = "locale";
|
||||||
|
|
||||||
private DictionaryService dictionaryService;
|
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
|
private MessageLookup messageLookup;
|
||||||
|
|
||||||
public void setDictionaryService(DictionaryService service) { this.dictionaryService = service; }
|
public FacetablePropertiesGet()
|
||||||
|
{
|
||||||
|
messageLookup = new StaticMessageLookup();
|
||||||
|
}
|
||||||
public void setNamespaceService (NamespaceService service) { this.namespaceService = service; }
|
public void setNamespaceService (NamespaceService service) { this.namespaceService = service; }
|
||||||
|
|
||||||
@Override protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status, final Cache cache)
|
@Override protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status, final Cache cache)
|
||||||
@@ -73,6 +80,9 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip
|
|||||||
|
|
||||||
@Override protected Map<String, Object> unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache)
|
@Override protected Map<String, Object> 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.
|
// There are multiple defined URIs for this REST endpoint. Some define a "classname" template var.
|
||||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||||
final String contentClassName = templateVars.get(TEMPLATE_VAR_CLASSNAME);
|
final String contentClassName = templateVars.get(TEMPLATE_VAR_CLASSNAME);
|
||||||
@@ -91,11 +101,11 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip
|
|||||||
final SortedSet<FacetablePropertyData> facetableProperties;
|
final SortedSet<FacetablePropertyData> facetableProperties;
|
||||||
if (contentClassQName == null)
|
if (contentClassQName == null)
|
||||||
{
|
{
|
||||||
facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties());
|
facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(), userLocale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(contentClassQName));
|
facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(contentClassQName), userLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The webscript allows for some further filtering of results:
|
// 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}. */
|
/** 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);
|
return new FacetablePropertyData(propDef, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedSet<FacetablePropertyData> toFacetablePropertyDataSet(Collection<PropertyDefinition> propDefs)
|
private SortedSet<FacetablePropertyData> toFacetablePropertyDataSet(Collection<PropertyDefinition> propDefs, Locale locale)
|
||||||
{
|
{
|
||||||
SortedSet<FacetablePropertyData> result = new TreeSet<>();
|
SortedSet<FacetablePropertyData> result = new TreeSet<>();
|
||||||
for (PropertyDefinition propDef : propDefs)
|
for (PropertyDefinition propDef : propDefs)
|
||||||
{
|
{
|
||||||
result.add(toFacetablePropertyData(propDef));
|
result.add(toFacetablePropertyData(propDef, locale));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user