@Test public void testGetUniqueIdByMemberPatternWhenPatternIsEmpty() { Configuration configuration = createNiceMock(Configuration.class); Users users = createNiceMock(Users.class); String memberAttribute = "<SID=...>;<GUID=...>;cn=member,dc=apache,dc=org"; AmbariLdapDataPopulatorTestInstance populator = new AmbariLdapDataPopulatorTestInstance(configuration, users); String result = populator.getUniqueIdByMemberPattern(memberAttribute, ""); assertEquals(memberAttribute, result); }
protected String getUniqueIdByMemberPattern(String memberAttributeValue, String pattern) { if (StringUtils.isNotEmpty(memberAttributeValue) && StringUtils.isNotEmpty(pattern)) { try { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(memberAttributeValue); LOG.debug("Apply replace pattern '{}' on '{}' membership attribbute value.", memberAttributeValue, pattern); if (m.matches()) { memberAttributeValue = m.replaceAll(MEMBER_ATTRIBUTE_REPLACE_STRING); LOG.debug("Membership attribute value after replace pattern applied: '{}'", memberAttributeValue); } else { LOG.warn("Membership attribute value pattern is not matched ({}) on '{}'", pattern, memberAttributeValue); } } catch (Exception e) { LOG.error("Error during replace memberAttribute '{}' with pattern '{}'", memberAttributeValue, pattern); } } return memberAttributeValue; }
AmbariLdapDataPopulator { protected String getUniqueIdByMemberPattern(String memberAttributeValue, String pattern) { if (StringUtils.isNotEmpty(memberAttributeValue) && StringUtils.isNotEmpty(pattern)) { try { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(memberAttributeValue); LOG.debug("Apply replace pattern '{}' on '{}' membership attribbute value.", memberAttributeValue, pattern); if (m.matches()) { memberAttributeValue = m.replaceAll(MEMBER_ATTRIBUTE_REPLACE_STRING); LOG.debug("Membership attribute value after replace pattern applied: '{}'", memberAttributeValue); } else { LOG.warn("Membership attribute value pattern is not matched ({}) on '{}'", pattern, memberAttributeValue); } } catch (Exception e) { LOG.error("Error during replace memberAttribute '{}' with pattern '{}'", memberAttributeValue, pattern); } } return memberAttributeValue; } }
AmbariLdapDataPopulator { protected String getUniqueIdByMemberPattern(String memberAttributeValue, String pattern) { if (StringUtils.isNotEmpty(memberAttributeValue) && StringUtils.isNotEmpty(pattern)) { try { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(memberAttributeValue); LOG.debug("Apply replace pattern '{}' on '{}' membership attribbute value.", memberAttributeValue, pattern); if (m.matches()) { memberAttributeValue = m.replaceAll(MEMBER_ATTRIBUTE_REPLACE_STRING); LOG.debug("Membership attribute value after replace pattern applied: '{}'", memberAttributeValue); } else { LOG.warn("Membership attribute value pattern is not matched ({}) on '{}'", pattern, memberAttributeValue); } } catch (Exception e) { LOG.error("Error during replace memberAttribute '{}' with pattern '{}'", memberAttributeValue, pattern); } } return memberAttributeValue; } @Inject  AmbariLdapDataPopulator(Configuration configuration, Users users); }
AmbariLdapDataPopulator { protected String getUniqueIdByMemberPattern(String memberAttributeValue, String pattern) { if (StringUtils.isNotEmpty(memberAttributeValue) && StringUtils.isNotEmpty(pattern)) { try { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(memberAttributeValue); LOG.debug("Apply replace pattern '{}' on '{}' membership attribbute value.", memberAttributeValue, pattern); if (m.matches()) { memberAttributeValue = m.replaceAll(MEMBER_ATTRIBUTE_REPLACE_STRING); LOG.debug("Membership attribute value after replace pattern applied: '{}'", memberAttributeValue); } else { LOG.warn("Membership attribute value pattern is not matched ({}) on '{}'", pattern, memberAttributeValue); } } catch (Exception e) { LOG.error("Error during replace memberAttribute '{}' with pattern '{}'", memberAttributeValue, pattern); } } return memberAttributeValue; } @Inject  AmbariLdapDataPopulator(Configuration configuration, Users users); boolean isLdapEnabled(); LdapSyncDto getLdapSyncInfo(); LdapBatchDto synchronizeAllLdapGroups(LdapBatchDto batchInfo); LdapBatchDto synchronizeAllLdapUsers(LdapBatchDto batchInfo); LdapBatchDto synchronizeLdapGroups(Set<String> groups, LdapBatchDto batchInfo); LdapBatchDto synchronizeLdapUsers(Set<String> users, LdapBatchDto batchInfo); LdapBatchDto synchronizeExistingLdapGroups(LdapBatchDto batchInfo); LdapBatchDto synchronizeExistingLdapUsers(LdapBatchDto batchInfo); }
AmbariLdapDataPopulator { protected String getUniqueIdByMemberPattern(String memberAttributeValue, String pattern) { if (StringUtils.isNotEmpty(memberAttributeValue) && StringUtils.isNotEmpty(pattern)) { try { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(memberAttributeValue); LOG.debug("Apply replace pattern '{}' on '{}' membership attribbute value.", memberAttributeValue, pattern); if (m.matches()) { memberAttributeValue = m.replaceAll(MEMBER_ATTRIBUTE_REPLACE_STRING); LOG.debug("Membership attribute value after replace pattern applied: '{}'", memberAttributeValue); } else { LOG.warn("Membership attribute value pattern is not matched ({}) on '{}'", pattern, memberAttributeValue); } } catch (Exception e) { LOG.error("Error during replace memberAttribute '{}' with pattern '{}'", memberAttributeValue, pattern); } } return memberAttributeValue; } @Inject  AmbariLdapDataPopulator(Configuration configuration, Users users); boolean isLdapEnabled(); LdapSyncDto getLdapSyncInfo(); LdapBatchDto synchronizeAllLdapGroups(LdapBatchDto batchInfo); LdapBatchDto synchronizeAllLdapUsers(LdapBatchDto batchInfo); LdapBatchDto synchronizeLdapGroups(Set<String> groups, LdapBatchDto batchInfo); LdapBatchDto synchronizeLdapUsers(Set<String> users, LdapBatchDto batchInfo); LdapBatchDto synchronizeExistingLdapGroups(LdapBatchDto batchInfo); LdapBatchDto synchronizeExistingLdapUsers(LdapBatchDto batchInfo);  }