Skip to content

Commit

Permalink
more retries
Browse files Browse the repository at this point in the history
  • Loading branch information
kcibul committed Oct 28, 2019
1 parent 66c5fab commit 52ed22a
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,19 @@ class LdapDirectoryDAO(
override def listAncestorGroups(groupId: WorkbenchGroupIdentity): IO[Set[WorkbenchGroupIdentity]] = listMemberOfGroups(groupId)

override def enableIdentity(subject: WorkbenchSubject): IO[Unit] =
executeLdap(
IO(ldapConnectionPool.modify(directoryConfig.enabledUsersGroupDn, new Modification(ModificationType.ADD, Attr.member, subjectDn(subject)))).void
).recoverWith {
case ldape: LDAPException if ldape.getResultCode == ResultCode.NO_SUCH_OBJECT =>
executeLdap(
IO(
ldapConnectionPool.add(
directoryConfig.enabledUsersGroupDn,
new Attribute("objectclass", Seq("top", "groupofnames").asJava),
new Attribute(Attr.member, subjectDn(subject))))).void
case ldape: LDAPException if ldape.getResultCode == ResultCode.ATTRIBUTE_OR_VALUE_EXISTS => IO.unit
retryLdapBusyWithBackoff(100.millisecond, 4) {
executeLdap(
IO(ldapConnectionPool.modify(directoryConfig.enabledUsersGroupDn, new Modification(ModificationType.ADD, Attr.member, subjectDn(subject)))).void
).recoverWith {
case ldape: LDAPException if ldape.getResultCode == ResultCode.NO_SUCH_OBJECT =>
executeLdap(
IO(
ldapConnectionPool.add(
directoryConfig.enabledUsersGroupDn,
new Attribute("objectclass", Seq("top", "groupofnames").asJava),
new Attribute(Attr.member, subjectDn(subject))))).void
case ldape: LDAPException if ldape.getResultCode == ResultCode.ATTRIBUTE_OR_VALUE_EXISTS => IO.unit
}
}

override def disableIdentity(subject: WorkbenchSubject): IO[Unit] = {
Expand Down

0 comments on commit 52ed22a

Please sign in to comment.