use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class ProfileServiceRestClient method getProfilesByQuery.
@Override
public List<Profile> getProfilesByQuery(String tenantName, String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_QUERY, query, params);
HttpUtils.addValue(PARAM_SORT_BY, sortBy, params);
HttpUtils.addValue(PARAM_SORT_ORDER, sortOrder, params);
HttpUtils.addValue(PARAM_START, start, params);
HttpUtils.addValue(PARAM_COUNT, count, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_BY_QUERY);
url = addQueryParams(url, params, true);
try {
return doGetForObject(new URI(url), profileListTypeRef);
} catch (URISyntaxException e) {
throw new I10nProfileException(ERROR_KEY_INVALID_URI_ERROR, url);
}
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class AccessTokenServiceImpl method createToken.
@Override
public AccessToken createToken(AccessToken token) throws ProfileException {
checkIfTokenActionIsAllowed(null, Action.CREATE_TOKEN);
if (token.getId() == null) {
token.setId(UUID.randomUUID().toString());
}
try {
accessTokenRepository.insert(token);
} catch (DuplicateKeyException e) {
throw new AccessTokenExistsException(token.getId());
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_CREATE_ACCESS_TOKEN_ERROR, e, token);
}
logger.debug(LOG_KEY_ACCESS_TOKEN_CREATED, token);
return token;
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class ProfileServiceImpl method getProfileByQuery.
@Override
public Profile getProfileByQuery(String tenantName, String query, String... attributesToReturn) throws ProfileException {
checkIfManageProfilesIsAllowed(tenantName);
Tenant tenant = getTenant(tenantName);
try {
Profile profile = profileRepository.findOneByQuery(getFinalQuery(tenant, query), attributesToReturn);
filterNonReadableAttributes(tenant, profile);
return profile;
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_GET_PROFILE_BY_QUERY_ERROR, e, query);
}
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class ProfileServiceImpl method getProfilesByIds.
@Override
public List<Profile> getProfilesByIds(List<String> profileIds, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException {
try {
List<Profile> profiles = IterableUtils.toList(profileRepository.findByIds(profileIds, sortBy, sortOrder, attributesToReturn));
if (profiles != null) {
for (Profile profile : profiles) {
checkIfManageProfilesIsAllowed(profile.getTenant());
filterNonReadableAttributes(profile);
}
}
return profiles;
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_GET_PROFILES_ERROR, e, profileIds);
}
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class ProfileServiceImpl method deleteProfile.
@Override
public void deleteProfile(String profileId) throws ProfileException {
try {
Profile profile = getProfile(profileId);
if (profile != null) {
profileRepository.removeById(profileId);
}
logger.debug(LOG_KEY_PROFILE_DELETED, profileId);
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_DELETE_PROFILE_ERROR, e, profileId);
}
}
Aggregations