use of org.gluu.oxtrust.model.scim2.User in project oxTrust by GluuFederation.
the class Scim2UserService method updateUser.
public UserResource updateUser(String id, UserResource user, String url) throws InvalidAttributeValueException {
// This is never null (see decorator involved)
GluuCustomPerson gluuPerson = personService.getPersonByInum(id);
UserResource tmpUser = new UserResource();
transferAttributesToUserResource(gluuPerson, tmpUser, url);
long now = System.currentTimeMillis();
tmpUser.getMeta().setLastModified(ISODateTimeFormat.dateTime().withZoneUTC().print(now));
tmpUser = (UserResource) ScimResourceUtil.transferToResourceReplace(user, tmpUser, extService.getResourceExtensions(user.getClass()));
replacePersonInfo(gluuPerson, tmpUser, url);
return tmpUser;
}
use of org.gluu.oxtrust.model.scim2.User in project oxTrust by GluuFederation.
the class Scim2UserService method transferExtendedAttributesToPerson.
/**
* Takes all extended attributes found in the SCIM resource and copies them to a GluuCustomPerson
* This method is called after validations take place (see associated decorator for User Service), so all inputs are
* OK and can go straight to LDAP with no runtime surprises
* @param resource A SCIM resource used as origin of data
* @param person a GluuCustomPerson used as destination
*/
private void transferExtendedAttributesToPerson(BaseScimResource resource, GluuCustomPerson person) {
try {
// Gets all the extended attributes for this resource
Map<String, Object> extendedAttrs = resource.getCustomAttributes();
// Iterates over all extensions this type of resource might have
for (Extension extension : extService.getResourceExtensions(resource.getClass())) {
Object val = extendedAttrs.get(extension.getUrn());
if (val != null) {
// Obtains the attribute/value(s) pairs in the current extension
Map<String, Object> attrsMap = IntrospectUtil.strObjMap(val);
for (String attribute : attrsMap.keySet()) {
Object value = attrsMap.get(attribute);
// Ignore if the attribute is unassigned in this resource: destination will not be changed in this regard
if (value != null) {
// Get properly formatted string representations for the value(s) associated to the attribute
List<String> values = extService.getStringAttributeValues(extension.getFields().get(attribute), value);
log.debug("transferExtendedAttributesToPerson. Setting attribute '{}' with values {}", attribute, values.toString());
person.setAttribute(attribute, values.toArray(new String[] {}));
}
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.gluu.oxtrust.model.scim2.User in project Douya by DreaminginCodeZH.
the class NavigationHeaderLayout method bindRecentUser.
private void bindRecentUser(ImageView avatarImage, final Account account) {
if (account == null) {
avatarImage.setVisibility(GONE);
return;
}
avatarImage.setVisibility(VISIBLE);
User user = mAdapter.getUser(account);
if (user != null) {
bindAvatarImage(avatarImage, user.getLargeAvatarOrAvatar());
} else {
bindAvatarImage(avatarImage, null);
}
avatarImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
switchToAccountWithTransitionIfNotRunning(account);
}
});
}
use of org.gluu.oxtrust.model.scim2.User in project Douya by DreaminginCodeZH.
the class NavigationHeaderLayout method bindActiveUser.
private void bindActiveUser() {
mActiveAccount = AccountUtils.getActiveAccount();
User user = mAdapter.getUser(mActiveAccount);
if (user != null) {
bindAvatarImage(mAvatarImage, user.getLargeAvatarOrAvatar());
mNameText.setText(user.name);
if (!TextUtils.isEmpty(user.signature)) {
mDescriptionText.setText(user.signature);
} else {
//noinspection deprecation
mDescriptionText.setText(user.uid);
}
} else {
SimpleUser partialUser = mAdapter.getPartialUser(mActiveAccount);
bindAvatarImage(mAvatarImage, null);
mNameText.setText(partialUser.name);
//noinspection deprecation
mDescriptionText.setText(partialUser.uid);
}
mAvatarImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mAccountTransitionRunning) {
return;
}
if (mListener != null) {
mListener.openProfile(mActiveAccount);
}
}
});
//mBackdropImage.setImageResource();
}
use of org.gluu.oxtrust.model.scim2.User in project Douya by DreaminginCodeZH.
the class UserResource method get.
@Override
public User get() {
User user = super.get();
if (user == null) {
// Can be called before onCreate() is called.
ensureArguments();
user = mExtraUser;
}
return user;
}
Aggregations