List of usage examples for javax.naming.ldap LdapName compareTo
public int compareTo(Object obj)
From source file:org.apache.syncope.core.sync.LDAPDomainSyncActions.java
@Transactional(readOnly = true) @Override// w w w.j ava 2s . c om public <T extends AbstractAttributableTO, K extends AbstractAttributableMod> SyncDelta beforeUpdate( SyncResultsHandler srh, SyncDelta sd, T t, K k) throws JobExecutionException { if (!ObjectClass.ACCOUNT_NAME.equals(sd.getObject().getObjectClass().toString())) { if (t != null) { SyncopeUser user = userDAO.find(t.getId()); if (user != null && !user.isSuspended()) { ConnectorObject conn = sd.getObject(); // Get dn of current user to be updated on Syncope LdapName dnOnSyncope = resolveDnOnSyncope(user, srh); try { LdapName dn = new LdapName(conn.getAttributeByName(Name.NAME).getValue().toString() .replace("[", "").replace("]", "")); // Check if dn on Syncope and dn on Ldap are the same, if so returns if (dnOnSyncope.compareTo(dn) != 0) { String rdn; if (dn.size() == 4) { rdn = dn.getRdn(2).getValue().toString(); } else { rdn = "/"; } //Creation of new attribute to assign to new user in Syncope AttributeMod attr = new AttributeMod(); attr.setSchema("domain"); attr.addValueToBeAdded(rdn); k.addAttributeToBeUpdated(attr); } else { LOG.info("NO CHANGES APPLIED TO DOMAIN ATTRIBUTE"); return sd; } } catch (InvalidNameException ex) { LOG.error("ERROR CONSTRUCTING LDAP DN FROM NAME ATTRIBUTE: ".concat(ex.getMessage())); } } else { LOG.error("USER WITH ID: " + t.getId() + " DOESN'T EXIST OR IS SUSPENDED ON SYNCOPE "); } } else { LOG.error("SUBJECT OF SYNCHRONIZATION IS NULL"); } } return sd; }