Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PT-40032285: LDAP import - when duplicate alias, concurrent modificat…

…ion exception may be thrown

-check for duplicate aliases and remove all duplicates at once after finishing iterating (not during iteration)
-make sure to catch any runtime exception to make sure import does not stop in the middle
  • Loading branch information...
commit 27ca3b7dd8e55f9582d9fbb27cd7c5c936a5e66d 1 parent ec646cd
Mircea Carasel mirceac authored
14 sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/bulk/ldap/LdapRowInserter.java
View
@@ -14,6 +14,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.TreeSet;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
@@ -48,6 +49,7 @@
private boolean m_preserveMissingUsers;
+ @Override
public void beforeInserting() {
// Make sure m_userMapper's AttrMap is set up.
m_userMapper.setAttrMap(m_attrMap);
@@ -61,6 +63,7 @@ public void beforeInserting() {
}
}
+ @Override
public void afterInserting() {
if (m_preserveMissingUsers) {
return;
@@ -70,6 +73,7 @@ public void afterInserting() {
m_existingUserNames.clear();
}
+ @Override
protected void insertRow(SearchResult searchResult) {
Attributes attrs = searchResult.getAttributes();
LOG.info("Inserting:" + attrs.toString());
@@ -129,10 +133,12 @@ void insertRow(SearchResult searchResult, Attributes attrs) {
/**
* Initial implementation will just print all attributes...
*/
+ @Override
protected String dataToString(SearchResult sr) {
return sr.getName();
}
+ @Override
protected RowStatus checkRowData(SearchResult sr) {
Attributes attrs = sr.getAttributes();
String idAttrName = m_attrMap.getIdentityAttributeName();
@@ -148,15 +154,19 @@ protected RowStatus checkRowData(SearchResult sr) {
}
Set<String> aliases = m_userMapper.getAliasesSet(attrs);
if (aliases != null) {
+ Set<String> aliasesToRemove = new TreeSet<String>();
for (String alias : aliases) {
if (m_coreContext.isAliasInUseForOthers(alias, userName)) {
- aliases.remove(alias);
+ aliasesToRemove.add(alias);
status = RowStatus.WARNING_ALIAS_COLLISION;
}
}
+ if (!aliasesToRemove.isEmpty()) {
+ aliases.removeAll(aliasesToRemove);
+ }
}
m_aliases = aliases;
- } catch (NamingException e) {
+ } catch (Exception e) {
return RowStatus.FAILURE;
}
return status;
Please sign in to comment.
Something went wrong with that request. Please try again.