nvazquez commented on code in PR #7915:
URL: https://github.com/apache/cloudstack/pull/7915#discussion_r1307535660
##########
plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java:
##########
@@ -115,7 +124,7 @@ public void onPublishMessage(String senderAddress, String
subject, Object args)
long domainId = account.getDomainId();
LdapTrustMapVO ldapTrustMapVO =
_ldapTrustMapDao.findByAccount(domainId, account.getAccountId());
if (ldapTrustMapVO != null) {
- String msg = String.format("Removing link between
LDAP: %s - type: %s and account: %s on domain: %s",
+ String msg =
String.format(REMOVING_LDAP_LINK_ON_DOMAIN,
ldapTrustMapVO.getName(),
ldapTrustMapVO.getType().name(), account.getAccountId(), domainId);
Review Comment:
And here we could invoke that method, something like: `String msg =
generateRemoveMessage(ldapTrustMapVO, ...)`
##########
plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java:
##########
@@ -65,6 +66,7 @@
@Component
public class LdapManagerImpl extends ComponentLifecycleBase implements
LdapManager, LdapValidator {
private static final Logger LOGGER =
Logger.getLogger(LdapManagerImpl.class.getName());
+ public static final String REMOVING_LDAP_LINK_ON_DOMAIN = "Removing link
between LDAP: %s - type: %s and account: %s on domain: %s";
Review Comment:
I think its better to define a method that generates the resulting string
message with the parameters already set instead of this
##########
plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java:
##########
@@ -125,10 +134,27 @@ public void onPublishMessage(String senderAddress, String
subject, Object args)
}
}
});
-
- return true;
}
+ private void addDomainRemovalListener() {
+ messageBus.subscribe(DomainManager.MESSAGE_REMOVE_DOMAIN_EVENT, new
MessageSubscriber() {
+ @Override
+ public void onPublishMessage(String senderAddress, String subject,
Object args) {
+ try {
+ long domainId = ((DomainVO) args).getId();
+ List<LdapTrustMapVO> ldapTrustMapVOs =
_ldapTrustMapDao.searchByDomainId(domainId);
+ for (LdapTrustMapVO ldapTrustMapVO : ldapTrustMapVOs) {
+ String msg =
String.format(REMOVING_LDAP_LINK_ON_DOMAIN,
Review Comment:
Same here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]