LDAPProfileXClass ldaXClass = new LDAPProfileXClass(context); needsUpdate |= ldaXClass.updateLDAPObject(userProfile, ldapDN, ldapUid);
LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context);
/** * @param validXWikiUserName the valid XWiki name of the user to get the profile for. Used for fast lookup relying * on the document cache before doing a database search. * @param ldapUid the UID to get the profile for * @param context the XWiki context * @return the XWiki document of the user with the passed UID * @throws XWikiException when a problem occurs while retrieving the user profile */ public XWikiDocument getUserProfileByUid(String validXWikiUserName, String ldapUid, XWikiContext context) throws XWikiException { LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context); // Try default profile name (generally in the cache) XWikiDocument userProfile = context.getWiki().getDocument( new DocumentReference(context.getDatabase(), XWIKI_USER_SPACE, validXWikiUserName), context); if (!ldapUid.equalsIgnoreCase(ldapXClass.getUid(userProfile))) { // Search for existing profile with provided uid userProfile = ldapXClass.searchDocumentByUid(ldapUid); // Resolve default profile patch of an uid if (userProfile == null) { userProfile = getAvailableUserProfile(validXWikiUserName, ldapUid, context); } } return userProfile; }
/** * @param validXWikiUserName the valid XWiki name of the user to get the profile for. Used for fast lookup relying * on the document cache before doing a database search. * @param ldapUid the UID to get the profile for * @param context the XWiki context * @return the XWiki document of the user with the passed UID * @throws XWikiException when a problem occurs while retrieving the user profile */ public XWikiDocument getUserProfileByUid(String validXWikiUserName, String ldapUid, XWikiContext context) throws XWikiException { LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context); // Try default profile name (generally in the cache) XWikiDocument userProfile = context.getWiki() .getDocument(new DocumentReference(context.getWikiId(), XWIKI_USER_SPACE, validXWikiUserName), context); if (!ldapUid.equalsIgnoreCase(ldapXClass.getUid(userProfile))) { // Search for existing profile with provided uid userProfile = ldapXClass.searchDocumentByUid(ldapUid); // Resolve default profile patch of an uid if (userProfile == null) { userProfile = getAvailableUserProfile(validXWikiUserName, ldapUid, context); } } return userProfile; }
LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context);
/** * @param validXWikiUserName a valid XWiki username for which to get a profile document * @param ldapUid ldap UID of the user profile to get * @param context the XWiki context * @return a (new) XWiki document for the passed username * @throws XWikiException when a problem occurs while retrieving the user profile */ private XWikiDocument getAvailableUserProfile(String validXWikiUserName, String ldapUid, XWikiContext context) throws XWikiException { BaseClass userClass = context.getWiki().getUserClass(context); LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context); DocumentReference userReference = new DocumentReference(context.getDatabase(), XWIKI_USER_SPACE, validXWikiUserName); // Check if the default profile document is available for (int i = 0; true; ++i) { if (i > 0) { userReference.setName(validXWikiUserName + "_" + i); } XWikiDocument doc = context.getWiki().getDocument(userReference, context); // Don't use non user existing document if (doc.isNew() || doc.getXObject(userClass.getDocumentReference()) != null) { String ldapUidFromObject = ldapXClass.getUid(doc); // If the user is a LDAP user compare uids if (ldapUidFromObject == null || ldapUid.equalsIgnoreCase(ldapUidFromObject)) { return doc; } } } }
LDAPProfileXClass ldaXClass = new LDAPProfileXClass(context); needsUpdate |= ldaXClass.updateLDAPObject(userProfile, ldapDN, ldapUid);
LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context);