i = groupList.iterator(); i.hasNext();)
- {
- AuthorityInfo authorityInfo = i.next();
- if (!isRootParam.equals(isRootAuthority(rootAuthorities, authorityInfo.getAuthorityName())))
- {
- i.remove();
- }
- }
+ groupList = groupList
+ .stream()
+ .filter(auth -> isRootPredicate(isRootParam, rootAuthorities, auth.getAuthorityName()))
+ .filter(auth -> displayNamePredicate(auth.getAuthorityDisplayName(), displayNameFilter))
+ .collect(Collectors.toList());
}
}
@@ -463,6 +484,25 @@ public class GroupsImpl implements Groups
return true;
}
+ /**
+ * Checks to see if the named group authority should be included in results
+ * when filtered by displayName.
+ *
+ * If the requiredDisplayName parameter is null, then the filter will not be applied (returns true.)
+ *
+ * @param groupDisplayName
+ * @param requiredDisplayName
+ * @return true if result should be included.
+ */
+ private boolean displayNamePredicate(String groupDisplayName, String requiredDisplayName)
+ {
+ if (requiredDisplayName != null)
+ {
+ return groupDisplayName != null && groupDisplayName.equalsIgnoreCase(requiredDisplayName);
+ }
+ return true;
+ }
+
private Set getAllRootAuthorities(AuthorityType authorityType)
{
Set authorities;
@@ -1026,6 +1066,7 @@ public class GroupsImpl implements Groups
private static class GroupsQueryWalker extends MapBasedQueryWalker
{
private List zones;
+ private List displayNames;
public GroupsQueryWalker()
{
@@ -1045,6 +1086,10 @@ public class GroupsImpl implements Groups
{
zones = Arrays.asList(propertyValues);
}
+ if (propertyName.equalsIgnoreCase(DISPLAY_NAME))
+ {
+ displayNames = Arrays.asList(propertyValues);
+ }
}
/**
@@ -1066,5 +1111,81 @@ public class GroupsImpl implements Groups
{
return getProperty(PARAM_IS_ROOT, WhereClauseParser.EQUALS, Boolean.class);
}
+
+ /**
+ * The list of displayName specified in the where clause.
+ *
+ * @return The displayNames list if specified, or null if not.
+ */
+ public List getDisplayNames()
+ {
+ return displayNames;
+ }
}
}
+
+class GroupsFilter
+{
+ private Boolean isRoot;
+ private String zoneFilter;
+ private String displayNameFilter;
+
+ private GroupsFilter()
+ {
+ }
+
+ public static GroupsFilterBuilder builder()
+ {
+ return new GroupsFilterBuilder();
+ }
+
+ public Boolean getIsRoot()
+ {
+ return isRoot;
+ }
+
+ public String getZoneFilter()
+ {
+ return zoneFilter;
+ }
+
+ public String getDisplayNameFilter()
+ {
+ return displayNameFilter;
+ }
+
+ public static class GroupsFilterBuilder
+ {
+ private Boolean isRoot;
+ private String zoneFilter;
+ private String displayNameFilter;
+
+ public GroupsFilterBuilder withIsRoot(Boolean isRoot)
+ {
+ this.isRoot = isRoot;
+ return this;
+ }
+
+ public GroupsFilterBuilder withZoneFilter(String zoneFilter)
+ {
+ this.zoneFilter = zoneFilter;
+ return this;
+ }
+
+ public GroupsFilterBuilder withDisplayNameFilter(String displayNameFilter)
+ {
+ this.displayNameFilter = displayNameFilter;
+ return this;
+ }
+
+ public GroupsFilter build()
+ {
+ GroupsFilter groupsFilter = new GroupsFilter();
+ groupsFilter.isRoot = this.isRoot;
+ groupsFilter.zoneFilter = this.zoneFilter;
+ groupsFilter.displayNameFilter = this.displayNameFilter;
+ return groupsFilter;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/remote-api/src/test/java/org/alfresco/rest/api/tests/GroupsTest.java b/remote-api/src/test/java/org/alfresco/rest/api/tests/GroupsTest.java
index e28de0e99d..e84ee463e1 100644
--- a/remote-api/src/test/java/org/alfresco/rest/api/tests/GroupsTest.java
+++ b/remote-api/src/test/java/org/alfresco/rest/api/tests/GroupsTest.java
@@ -115,6 +115,7 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
testGetGroupsByIsRoot(true);
testGetGroupsByIsRoot(false);
testGetGroupsWithZoneFilter();
+ testGetGroupsWithDisplayNameFilter();
}
finally
{
@@ -1856,4 +1857,193 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
return subGroup;
}
+
+ private void testGetGroupsWithDisplayNameFilter() throws Exception
+ {
+ shouldFilterGroupByDisplayName();
+ shouldFilterGroupByDisplayNameWhenNameNotExist();
+ shouldFilterGroupByDisplayNameAndZone();
+ shouldFilterGroupByDisplayNameWhenGroupIsRoot();
+ shouldFilterGroupByDisplayNameWhenIsRootIsFalse();
+ shouldFilterGroupByDisplayNameAndZoneWhenGroupIsRoot();
+ shouldReturnBadRequestErrorWhenTooManyDisplayNames();
+ shouldReturnBadRequestErrorWhenDisplayNameIsEmpty();
+ shouldNotAllowWildcards();
+ }
+
+ private void shouldFilterGroupByDisplayName() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("where", "(displayName in ('A Group'))");
+
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertEquals(1, groups.size());
+ assertEquals("A Group", groups.get(0).getDisplayName());
+
+ otherParams.put("where", "(displayName in ('a group'))");
+ response = getGroups(paging, otherParams);
+ response.getList();
+
+ assertEquals(1, groups.size());
+ assertEquals("A Group", groups.get(0).getDisplayName());
+ }
+
+ private void shouldFilterGroupByDisplayNameWhenNameNotExist() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("where", "(displayName in ('AGroupName'))");
+
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertTrue(groups.isEmpty());
+ }
+
+ private void shouldFilterGroupByDisplayNameAndZone() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ addOrderBy(otherParams, org.alfresco.rest.api.Groups.PARAM_DISPLAY_NAME, true);
+ otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_ZONES);
+ otherParams.put("where", "(zones in ('APITEST.MYZONE') AND displayName in ('A Group'))");
+
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertEquals(1, groups.size());
+ assertTrue(groups.get(0).getZones().contains("APITEST.MYZONE"));
+ assertEquals("A Group", groups.get(0).getDisplayName());
+ }
+
+ private void shouldFilterGroupByDisplayNameWhenGroupIsRoot() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("where", "(isRoot=true AND displayName in ('Root Group'))");
+
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertEquals(1, groups.size());
+ assertEquals("Root Group", groups.get(0).getDisplayName());
+ }
+
+ private void shouldFilterGroupByDisplayNameWhenIsRootIsFalse() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("where", "(isRoot=False AND displayName in ('A Group'))");
+
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertEquals(1, groups.size());
+ assertEquals("A Group", groups.get(0).getDisplayName());
+ }
+
+ private void shouldFilterGroupByDisplayNameAndZoneWhenGroupIsRoot() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_ZONES);
+ otherParams.put("where", "(isRoot=true AND zones in ('APITEST.MYZONE') AND displayName in ('Root Group'))");
+
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertEquals(1, groups.size());
+ assertTrue(groups.get(0).getZones().contains("APP.DEFAULT"));
+ assertEquals("Root Group", groups.get(0).getDisplayName());
+ }
+
+ private void shouldReturnBadRequestErrorWhenTooManyDisplayNames() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("where", "(displayName in ('Group A', 'Group B'))");
+
+ getGroups(paging, otherParams, "Incorrect response", 400);
+ }
+
+ private void shouldReturnBadRequestErrorWhenDisplayNameIsEmpty() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+ otherParams.put("where","(displayName in ())");
+
+ getGroups(paging, otherParams, "Incorrect response",400);
+
+ otherParams.put("where","(displayName in (''))");
+ getGroups(paging, otherParams, "Incorrect response",400);
+ }
+
+ private void shouldNotAllowWildcards() throws Exception
+ {
+ Paging paging = getPaging(0, Integer.MAX_VALUE);
+ Map otherParams = new HashMap<>();
+
+ otherParams.put("where", "(displayName in ('*'))");
+ ListResponse response = getGroups(paging, otherParams);
+ List groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(isRoot=true AND displayName in ('*'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(displayName in ('A*'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(isRoot=true AND displayName in ('A*'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(displayName in ('*roup'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(isRoot=true AND displayName in ('*roup'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(displayName in ('Root ?ROUP'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(isRoot=true AND displayName in ('Root ?ROUP'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(displayName in ('Group'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+
+ otherParams.put("where", "(isRoot=true AND displayName in ('Group'))");
+ response = getGroups(paging, otherParams);
+ groups = response.getList();
+
+ assertEquals(0, groups.size());
+ }
}
diff --git a/repository/pom.xml b/repository/pom.xml
index 7d766198c6..e08404ad7b 100644
--- a/repository/pom.xml
+++ b/repository/pom.xml
@@ -705,7 +705,7 @@
org.gytheio
gytheio-messaging-camel
- 0.11.3
+ ${dependency.gytheio.version}
commons-logging
@@ -1027,18 +1027,18 @@
org.aspectj
aspectjrt
- 1.9.5
+ 1.9.6
commons-net
commons-net
- 3.6
+ 3.7
test
org.codehaus.groovy
groovy-all
- 2.4.19
+ 2.4.20
indy
test
diff --git a/repository/src/main/java/org/alfresco/repo/rule/ruletrigger/OnPropertyUpdateRuleTrigger.java b/repository/src/main/java/org/alfresco/repo/rule/ruletrigger/OnPropertyUpdateRuleTrigger.java
index 75407a717a..0122b60b2a 100644
--- a/repository/src/main/java/org/alfresco/repo/rule/ruletrigger/OnPropertyUpdateRuleTrigger.java
+++ b/repository/src/main/java/org/alfresco/repo/rule/ruletrigger/OnPropertyUpdateRuleTrigger.java
@@ -1,28 +1,28 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
package org.alfresco.repo.rule.ruletrigger;
import java.io.Serializable;
@@ -141,7 +141,7 @@ public class OnPropertyUpdateRuleTrigger extends RuleTriggerAbstractBase
for (QName name : keys)
{
// Skip rule firing on this content property for performance reasons
- if (name.equals(ContentModel.PROP_PREFERENCE_VALUES))
+ if (name.equals(ContentModel.PROP_PREFERENCE_VALUES) || name.equals(ContentModel.PROP_CASCADE_CRC))
{
continue;
}
diff --git a/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSet.java b/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSet.java
index aef0e99ac1..bc55077c99 100644
--- a/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSet.java
+++ b/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSet.java
@@ -240,6 +240,11 @@ public class DBResultSet extends AbstractResultSet
nodeRefs[n+1] = nodeRef == null ? null : tenantService.getBaseName(nodeRef);
}
}
- }
+ }
+
+ public NodeService getNodeService()
+ {
+ return nodeService;
+ }
}
diff --git a/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSetRow.java b/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSetRow.java
index 9ee6f6c8c4..40de48db15 100644
--- a/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSetRow.java
+++ b/repository/src/main/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBResultSetRow.java
@@ -25,11 +25,13 @@
*/
package org.alfresco.repo.search.impl.querymodel.impl.db;
+import java.io.Serializable;
import java.util.Map;
import org.alfresco.repo.search.AbstractResultSetRow;
import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.search.ResultSet;
+import org.alfresco.service.cmr.search.ResultSet;
+import org.alfresco.service.namespace.QName;
/**
* @author Andy
@@ -82,6 +84,13 @@ public class DBResultSetRow extends AbstractResultSetRow
public float getScore(String selectorName)
{
throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected Map getDirectProperties()
+ {
+ DBResultSet rs = (DBResultSet) getResultSet();
+ return rs.getNodeService().getProperties(rs.getNodeRef(getIndex()));
}
diff --git a/repository/src/main/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java b/repository/src/main/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java
index c85f6af5cc..d72512d726 100644
--- a/repository/src/main/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java
+++ b/repository/src/main/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java
@@ -54,6 +54,7 @@ import javax.naming.InvalidNameException;
import javax.naming.Name;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ServiceUnavailableException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
@@ -882,6 +883,16 @@ public class LDAPUserRegistry implements UserRegistry, LDAPNameResolver, Initial
continue;
}
}
+ catch (ServiceUnavailableException | CommunicationException e)
+ {
+ // MNT-21614: Check & fail if communication breaks due to ServiceUnavailableException or CommunicationException
+ if (e.getMessage() != null)
+ {
+ Object[] params = {e.getLocalizedMessage() };
+ throw new AlfrescoRuntimeException("synchronization.err.ldap.search", params, e);
+ }
+ continue;
+ }
catch (NamingException e)
{
// Check if it is a timeout and fail
diff --git a/repository/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java b/repository/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java
index 84701bef66..95a240a523 100644
--- a/repository/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java
+++ b/repository/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java
@@ -865,7 +865,22 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
}
else
{
- throw new AlfrescoRuntimeException("Nodes with no type are ignored by SOLR");
+ QName typeQName = null;
+ TypeDefinition typeDefinition = null;
+
+ String errorMessage = "NodeId " + nodeId + " with nodeRef " + nodeRef;
+
+ typeQName = nodeDAO.getNodeType(nodeId);
+ if (typeQName != null)
+ {
+ errorMessage += " has type " + typeQName + ", but this type is not registered in DictionaryService.";
+ }
+ else
+ {
+ errorMessage += " has no type.";
+ }
+
+ throw new AlfrescoRuntimeException(errorMessage + " It will be ignored by SOLR.");
}
}
diff --git a/repository/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java b/repository/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java
index 5412b6adc6..055c30daf8 100644
--- a/repository/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java
+++ b/repository/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java
@@ -25,6 +25,7 @@
*/
package org.alfresco.repo.rule.ruletrigger;
+import java.util.Random;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.repo.content.MimetypeMap;
@@ -426,7 +427,33 @@ public class RuleTriggerTest extends BaseSpringTest
// Check to see if the rule type has been triggered
assertTrue(ruleType.rulesTriggered);
assertEquals(3, ruleType.triggerCount);
- }
+ }
+ @Test
+ public void testOnPropertyUpdateRuleTrigger()
+ {
+ NodeRef nodeRef1 = this.nodeService.createNode(this.rootNodeRef,
+ ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN,
+ ContentModel.TYPE_CONTAINER).getChildRef();
+
+ ContentWriter contentWriter = this.contentService.getWriter(nodeRef1, ContentModel.PROP_CONTENT, true);
+ contentWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
+ contentWriter.setEncoding("UTF-8");
+ contentWriter.putContent("some content");
+
+ Random rand=new Random();
+ this.nodeService.setProperty(nodeRef1, ContentModel.PROP_CASCADE_CRC, rand.nextLong());
+ // Terminate the transaction
+ TestTransaction.flagForCommit();
+ TestTransaction.end();
+ TestTransaction.start();
+
+ TestRuleType contentUpdate = createTestRuleType(ON_PROPERTY_UPDATE_TRIGGER);
+ this.nodeService.setProperty(nodeRef1, ContentModel.PROP_CASCADE_CRC, rand.nextLong());
+
+ assertFalse(contentUpdate.rulesTriggered);
+ assertEquals("trigger count not matching",0,contentUpdate.triggerCount);
+
+ }
private TestRuleType createTestRuleType(String ruleTriggerName)
{
diff --git a/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java b/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java
index f0165212c0..e9c6ae0117 100644
--- a/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java
+++ b/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java
@@ -994,6 +994,30 @@ public class DBQueryTest implements DictionaryListener
results.getResultSetMetaData();
results.close();
}
+
+ @Test
+ public void testGetValueForTransactionalQuery()
+ {
+ String query = "=TYPE:\"cm:folder\" ";
+ queryUsingGetValue(SearchService.LANGUAGE_FTS_ALFRESCO, query);
+ }
+
+ public void queryUsingGetValue(String ql, String query)
+ {
+ SearchParameters sp = new SearchParameters();
+ sp.setLanguage(ql);
+ sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
+ sp.setQuery(query);
+ sp.addStore(rootNodeRef.getStoreRef());
+ ResultSet results = serviceRegistry.getSearchService().query(sp);
+
+ for (int i = 0; i < results.length(); i++) {
+ ResultSetRow row = results.getRow(i);
+ assertNotNull(row.getValue(ContentModel.PROP_NODE_UUID));
+ }
+ results.getResultSetMetaData();
+ results.close();
+ }
private static class UnknownDataType implements Serializable
{
diff --git a/repository/src/test/java/org/alfresco/repo/security/sync/LDAPUserRegistryTest.java b/repository/src/test/java/org/alfresco/repo/security/sync/LDAPUserRegistryTest.java
index 96b192246c..1cade12eae 100644
--- a/repository/src/test/java/org/alfresco/repo/security/sync/LDAPUserRegistryTest.java
+++ b/repository/src/test/java/org/alfresco/repo/security/sync/LDAPUserRegistryTest.java
@@ -34,10 +34,10 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import javax.naming.CompositeName;
-import javax.naming.Name;
+import javax.naming.CommunicationException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ServiceUnavailableException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.InitialDirContext;
@@ -144,4 +144,52 @@ public class LDAPUserRegistryTest
are.getCause().getMessage().contains(LDAPUserRegistry.NAMING_TIMEOUT_EXCEPTION_MESSAGE));
}
}
+
+ /**
+ * Test for MNT-21614: Check & fail if communication breaks due to javax.naming.ServiceUnavailableException
+ */
+ @Test
+ public void testTimeoutDuringSyncForServiceUnavailableException() throws Exception
+ {
+ LDAPUserRegistry userRegistry = createRegistry();
+
+ when(initialDirContext.getAttributes(eq(LDAPUserRegistry.jndiName(MEMBER_ATTRIBUTE_VALUE)), any()))
+ .thenThrow(new ServiceUnavailableException(" test."));
+ try
+ {
+ userRegistry.getGroups(new Date());
+ fail("The process should fail with an exception");
+ }
+ catch (AlfrescoRuntimeException are)
+ {
+ assertEquals("The error message is not of the right format.",
+ "synchronization.err.ldap.search", are.getMsgId());
+ assertTrue("The error message was not caused by timeout.",
+ are.getCause().getMessage().contains(" test."));
+ }
+ }
+
+ /**
+ * Test for MNT-21614: Check & fail if communication breaks due to javax.naming.CommunicationException
+ */
+ @Test
+ public void testTimeoutDuringSyncForCommunicationException() throws Exception
+ {
+ LDAPUserRegistry userRegistry = createRegistry();
+
+ when(initialDirContext.getAttributes(eq(LDAPUserRegistry.jndiName(MEMBER_ATTRIBUTE_VALUE)), any()))
+ .thenThrow(new CommunicationException(" test."));
+ try
+ {
+ userRegistry.getGroups(new Date());
+ fail("The process should fail with an exception");
+ }
+ catch (AlfrescoRuntimeException are)
+ {
+ assertEquals("The error message is not of the right format.",
+ "synchronization.err.ldap.search", are.getMsgId());
+ assertTrue("The error message was not caused by timeout.",
+ are.getCause().getMessage().contains(" test."));
+ }
+ }
}
diff --git a/repository/src/test/java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java b/repository/src/test/java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java
index abab9c9eb7..1b5ac2058f 100644
--- a/repository/src/test/java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java
+++ b/repository/src/test/java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java
@@ -35,6 +35,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model;
@@ -68,6 +69,7 @@ import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.springframework.extensions.surf.util.I18NUtil;
/**
* Tests tracking component
@@ -1491,4 +1493,99 @@ public class SOLRTrackingComponentTest extends BaseSpringTest
return txs;
}
}
+
+ @Test
+ public void testGetNodeMetaDataWithNoType()
+ {
+ long startTime = System.currentTimeMillis();
+
+ SOLRTest st = new SOLRTestWithNoType(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, "testNodeMetaDataNullPropertyValue", true, true);
+ List createdTransactions = st.buildTransactions();
+
+ List txns = getTransactions(null, startTime-1000, null, null, 100);
+
+ int[] updates = new int[] {2};
+ int[] deletes = new int[] {0};
+ List checkedTransactions = checkTransactions(txns, createdTransactions, updates, deletes);
+
+ NodeParameters nodeParameters = new NodeParameters();
+ nodeParameters.setTransactionIds(getTransactionIds(checkedTransactions));
+ getNodes(nodeParameters, st);
+
+
+ NodeMetaDataParameters nodeMetaDataParams = new NodeMetaDataParameters();
+ nodeMetaDataParams.setNodeIds(st.getNodeIds());
+ try
+ {
+ getNodeMetaData(nodeMetaDataParams, null, st);
+ }
+ catch (AlfrescoRuntimeException are)
+ {
+ if (!are.getMessage().contains("It will be ignored by SOLR"))
+ {
+ throw are;
+ }
+ }
+
+ }
+
+ private static class SOLRTestWithNoType extends SOLRTest
+ {
+ private NodeRef container;
+ private NodeRef content;
+
+ SOLRTestWithNoType(
+ RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
+ NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
+ NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
+ {
+ super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService,rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
+ }
+
+ public int getExpectedNumNodes()
+ {
+ return 2;
+ }
+
+ protected List buildTransactionsInternal()
+ {
+ ArrayList txs = new ArrayList(2);
+
+ txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback()
+ {
+ public Long execute() throws Throwable
+ {
+ PropertyMap props = new PropertyMap();
+ props.put(ContentModel.PROP_NAME, "ContainerWithNoType");
+ container = nodeService.createNode(
+ rootNodeRef,
+ ContentModel.ASSOC_CHILDREN,
+ ContentModel.ASSOC_CHILDREN,
+ ContentModel.TYPE_FOLDER,
+ props).getChildRef();
+
+ Long containerId = nodeDAO.getNodePair(container).getFirst();
+
+ content = nodeDAO.newNode(
+ containerId,
+ ContentModel.ASSOC_CHILDREN,
+ ContentModel.ASSOC_CHILDREN,
+ new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"),
+ null,
+ QName.createQName("{nonExisting}nonExisting"),
+ I18NUtil.getLocale(),
+ null,
+ null).getChildNode().getNodeRef();
+
+ return nodeDAO.getNodeRefStatus(container).getDbTxnId();
+ }
+ }));
+
+ setExpectedNodeStatus(container, NodeStatus.UPDATED);
+ setExpectedNodeStatus(content, NodeStatus.UPDATED);
+
+ return txs;
+ }
+ }
+
}
\ No newline at end of file