use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class TenantUpdater method addAttributeDefinitions.
public void addAttributeDefinitions(Collection<AttributeDefinition> attributeDefinitions) {
List<AttributeDefinition> allDefinitions = tenant.getAttributeDefinitions();
List<AttributeDefinition> pushValues = new ArrayList<>();
for (AttributeDefinition definition : attributeDefinitions) {
if (!allDefinitions.contains(definition)) {
allDefinitions.add(definition);
pushValues.add(definition);
}
}
updateHelper.pushAll("attributeDefinitions", pushValues);
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class TenantServiceIT method getGenderAttributeDefinition.
private AttributeDefinition getGenderAttributeDefinition() {
AttributePermission permission = new AttributePermission(AttributePermission.ANY_APPLICATION);
permission.allow(AttributePermission.ANY_ACTION);
AttributeDefinition definition = new AttributeDefinition();
definition.setName(GENDER_ATTRIBUTE_NAME);
definition.addPermission(permission);
return definition;
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class TenantServiceImpl method addAttributeDefinitions.
@Override
public Tenant addAttributeDefinitions(final String tenantName, final Collection<AttributeDefinition> attributeDefinitions) throws ProfileException {
Tenant tenant = updateTenant(tenantName, new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
tenantUpdater.addAttributeDefinitions(attributeDefinitions);
}
});
for (AttributeDefinition definition : tenant.getAttributeDefinitions()) {
addDefaultValue(tenantName, definition.getName(), definition.getDefaultValue());
}
logger.debug(LOG_KEY_ATTRIBUTE_DEFINITIONS_ADDED, attributeDefinitions, tenantName);
return tenant;
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class TenantUpdater method updateAttributeDefinitions.
public void updateAttributeDefinitions(Collection<AttributeDefinition> attributeDefinitions) {
List<AttributeDefinition> allDefinitions = tenant.getAttributeDefinitions();
for (AttributeDefinition definition : attributeDefinitions) {
int idx = indexOfAttributeDefinition(definition.getName(), allDefinitions);
if (idx >= 0) {
allDefinitions.set(idx, definition);
updateHelper.set("attributeDefinitions." + idx, definition);
}
}
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class MellonAutoLoginProcessor method createProfileWithSsoInfo.
protected Profile createProfileWithSsoInfo(String username, Tenant tenant, HttpServletRequest request) throws ProfileException {
Map<String, Object> attributes = null;
List<AttributeDefinition> attributeDefinitions = tenant.getAttributeDefinitions();
String email = request.getHeader(emailHeaderName);
for (AttributeDefinition attributeDefinition : attributeDefinitions) {
String attributeName = attributeDefinition.getName();
String attributeValue = request.getHeader(mellonHeaderPrefix + attributeName);
if (StringUtils.isNotEmpty(attributeValue)) {
if (attributes == null) {
attributes = new HashMap<>();
}
attributes.put(attributeName, attributeValue);
}
}
logger.info("Creating new profile with SSO info: username={}, email={}, tenant={}, attributes={}", username, email, tenant.getName(), attributes);
return profileService.createProfile(tenant.getName(), username, null, email, true, null, attributes, null);
}
Aggregations