diff --git a/config/alfresco/model/solrFacetModel.xml b/config/alfresco/model/solrFacetModel.xml
index 0fb5a02fc9..a4f3d5ec9d 100644
--- a/config/alfresco/model/solrFacetModel.xml
+++ b/config/alfresco/model/solrFacetModel.xml
@@ -170,6 +170,7 @@
Additional Facet Information
d:any
+ false
true
diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetConfig.java b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetConfig.java
index 3b50d18fd9..8eb6390adf 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetConfig.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetConfig.java
@@ -326,7 +326,7 @@ public class SolrFacetConfig extends AbstractLifecycleBean
{
if (additionalProps == null)
{
- return Collections.emptySet();
+ return null;
}
Set customProps = new HashSet<>();
diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetProperties.java b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetProperties.java
index a0918eac12..c9408ad1d9 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetProperties.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetProperties.java
@@ -69,7 +69,7 @@ public class SolrFacetProperties implements Serializable
this.isEnabled = builder.isEnabled;
this.isDefault = builder.isDefault;
this.scopedSites = Collections.unmodifiableSet(new HashSet(builder.scopedSites));
- this.customProperties = Collections.unmodifiableSet(new HashSet(builder.customProperties));
+ this.customProperties = (builder.customProperties == null) ? null : Collections.unmodifiableSet(new HashSet(builder.customProperties));
}
/**
@@ -173,13 +173,13 @@ public class SolrFacetProperties implements Serializable
}
/**
- * Returns an unmodifiable view of the custom properties set. Never null.
+ * Returns an unmodifiable view of the custom properties set or null.
*
* @return the customProperties
*/
public Set getCustomProperties()
{
- return Collections.unmodifiableSet(new HashSet(this.customProperties));
+ return (this.customProperties == null) ? null : Collections.unmodifiableSet(new HashSet(this.customProperties));
}
/*
@@ -260,7 +260,7 @@ public class SolrFacetProperties implements Serializable
private Set scopedSites = Collections.emptySet();
private Boolean isEnabled;
private boolean isDefault;
- private Set customProperties = Collections.emptySet();
+ private Set customProperties;
public Builder()
{
@@ -365,10 +365,7 @@ public class SolrFacetProperties implements Serializable
public Builder customProperties(Set customProperties)
{
- if (customProperties != null)
- {
- this.customProperties = customProperties;
- }
+ this.customProperties = customProperties;
return this;
}
diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java
index f17c0b32e1..47867549b3 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java
@@ -313,7 +313,8 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
Set extraProps = null;
Map customProperties = getFacetCustomProperties(properties);
- if (customProperties.isEmpty())
+ boolean hasAspect = nodeService.hasAspect(nodeRef, SolrFacetModel.ASPECT_CUSTOM_PROPERTIES);
+ if (!hasAspect && customProperties.isEmpty())
{
extraProps = defaultFacet.getCustomProperties();
}
@@ -433,7 +434,10 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
{
Map properties = createNodeProperties(facetProperties);
// Set the updated properties back onto the facet node reference
- this.nodeService.setProperties(facetNodeRef, properties);
+ for (Entry prop : properties.entrySet())
+ {
+ this.nodeService.setProperty(facetNodeRef, prop.getKey(), prop.getValue());
+ }
}
if (logger.isDebugEnabled())
{
@@ -441,51 +445,6 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
}
}
- private SolrFacetProperties makeValidFacetPropObj(SolrFacetProperties newFP)
- {
-
- SolrFacetProperties bootstraptedFP = defaultFacetsMap.get(newFP.getFilterID());
- // null means there is no default facet
- if(bootstraptedFP == null)
- {
- return new SolrFacetProperties.Builder(newFP).isDefault(false).build();
- }
-
- QName fieldQName = getValue(bootstraptedFP.getFacetQName(), newFP.getFacetQName(), null);
- String displayName = getValue(bootstraptedFP.getDisplayName(), newFP.getDisplayName(), null);
- String displayControl = getValue(bootstraptedFP.getDisplayControl(), newFP.getDisplayControl(), null);
- int maxFilters = getValue(bootstraptedFP.getMaxFilters(), newFP.getMaxFilters(), -1);
- int hitThreshold = getValue(bootstraptedFP.getHitThreshold(), newFP.getHitThreshold(), -1);
- int minFilterValueLength = getValue(bootstraptedFP.getMinFilterValueLength(), newFP.getMinFilterValueLength(), -1);
- String sortBy = getValue(bootstraptedFP.getSortBy(), newFP.getSortBy(), null);
- String scope = getValue(bootstraptedFP.getScope(), newFP.getScope(), null);
- Boolean isEnabled = getValue(bootstraptedFP.isEnabled(), newFP.isEnabled(), null);
- Set scopedSites = getValue(bootstraptedFP.getScopedSites(), newFP.getScopedSites(), null);
- Set extraProps = getValue(bootstraptedFP.getCustomProperties(), newFP.getCustomProperties(), null);
- // Construct the FacetProperty object
- SolrFacetProperties fp = new SolrFacetProperties.Builder()
- .filterID(newFP.getFilterID())
- .facetQName(fieldQName)
- .displayName(displayName)
- .displayControl(displayControl)
- .maxFilters(maxFilters)
- .hitThreshold(hitThreshold)
- .minFilterValueLength(minFilterValueLength)
- .sortBy(sortBy)
- .scope(scope)
- .isEnabled(isEnabled)
- .isDefault(true)
- .scopedSites(scopedSites)
- .customProperties(extraProps).build();
-
- return fp;
- }
-
- private T getValue(T originalValue, T newValue, T defaultValueIfEquals)
- {
- return (originalValue.equals(newValue) ? defaultValueIfEquals : newValue);
- }
-
@Override
public void deleteFacet(String filterID)
{
@@ -514,12 +473,11 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
throw new SolrFacetConfigException("Filter Id cannot be null.");
}
- // construct a valid facet property object
- facetProperties = makeValidFacetPropObj(facetProperties);
+ boolean isDefaultFP = defaultFacetsMap.containsKey(facetProperties.getFilterID());
Map properties = new HashMap(15);
properties.put(ContentModel.PROP_NAME, facetProperties.getFilterID());
- properties.put(SolrFacetModel.PROP_IS_DEFAULT, facetProperties.isDefault());
+ properties.put(SolrFacetModel.PROP_IS_DEFAULT, isDefaultFP);
addNodeProperty(properties, SolrFacetModel.PROP_FIELD_TYPE, facetProperties.getFacetQName());
addNodeProperty(properties, SolrFacetModel.PROP_FIELD_LABEL, facetProperties.getDisplayName());
@@ -533,7 +491,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
addNodeProperty(properties, SolrFacetModel.PROP_IS_ENABLED, facetProperties.isEnabled());
Set customProperties = facetProperties.getCustomProperties();
- if(customProperties.size() > 0)
+ if (customProperties != null)
{
properties.put(SolrFacetModel.PROP_EXTRA_INFORMATION, new ArrayList<>(customProperties));
}