use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImpl method updateAttributes.
@Override
public Profile updateAttributes(String profileId, final Map<String, Object> attributes, String... attributesToReturn) throws ProfileException {
Profile profile = updateProfile(profileId, profileUpdater -> {
String tenantName = profileUpdater.getProfile().getTenant();
rejectAttributesIfActionNotAllowed(tenantName, attributes.keySet(), AttributeAction.WRITE_ATTRIBUTE);
profileUpdater.addAttributes(attributes);
}, attributesToReturn);
if (logger.isDebugEnabled()) {
logger.debug(LOG_KEY_PROFILE_ATTRIBS_UPDATED, attributes.keySet(), profileId);
}
return profile;
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImpl method removeAttributes.
@Override
public Profile removeAttributes(String profileId, final Collection<String> attributeNames, String... attributesToReturn) throws ProfileException {
Profile profile = updateProfile(profileId, profileUpdater -> {
String tenantName = profileUpdater.getProfile().getTenant();
rejectAttributesIfActionNotAllowed(tenantName, attributeNames, AttributeAction.REMOVE_ATTRIBUTE);
profileUpdater.removeAttributes(attributeNames);
}, attributesToReturn);
logger.debug(LOG_KEY_PROFILE_ATTRIBS_REMOVED, attributeNames, profileId);
return profile;
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImpl method enableProfile.
@Override
public Profile enableProfile(String profileId, String... attributesToReturn) throws ProfileException {
Profile profile = updateProfile(profileId, profileUpdater -> profileUpdater.setEnabled(true), attributesToReturn);
logger.debug(LOG_KEY_PROFILE_ENABLED, profileId);
return profile;
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImpl method verifyProfile.
@Override
public Profile verifyProfile(String verificationTokenId, final String... attributesToReturn) throws ProfileException {
VerificationToken token = verificationService.getToken(verificationTokenId);
if (token == null) {
throw new NoSuchVerificationTokenException(verificationTokenId);
}
Profile profile = updateProfile(token.getProfileId(), profileUpdater -> {
profileUpdater.setEnabled(true);
profileUpdater.setVerified(true);
}, attributesToReturn);
verificationService.deleteToken(verificationTokenId);
logger.debug(LOG_KEY_PROFILE_VERIFIED, profile.getId());
return profile;
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImpl method getProfilesByExistingAttribute.
@Override
public List<Profile> getProfilesByExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException {
checkIfManageProfilesIsAllowed(tenantName);
try {
List<Profile> profiles = IterableUtils.toList(profileRepository.findByTenantAndExistingAttribute(tenantName, attributeName, sortBy, sortOrder, attributesToReturn));
filterNonReadableAttributes(profiles);
return profiles;
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_GET_PROFILES_BY_EXISTING_ATTRIB_ERROR, e, attributeName, tenantName);
}
}
Aggregations