Search in sources :

Example 36 with MongoDataException

use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.

the class ProfileServiceImpl method getProfilesByAttributeValue.

@Override
public List<Profile> getProfilesByAttributeValue(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException {
    checkIfManageProfilesIsAllowed(tenantName);
    try {
        List<Profile> profiles = IterableUtils.toList(profileRepository.findByTenantAndAttributeValue(tenantName, attributeName, attributeValue, sortBy, sortOrder, attributesToReturn));
        filterNonReadableAttributes(profiles);
        return profiles;
    } catch (MongoDataException e) {
        throw new I10nProfileException(ERROR_KEY_GET_PROFILES_BY_ATTRIB_VALUE_ERROR, e, attributeName, attributeValue, tenantName);
    }
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) Profile(org.craftercms.profile.api.Profile)

Example 37 with MongoDataException

use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.

the class ProfileServiceImpl method getProfileRange.

@Override
public List<Profile> getProfileRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException {
    checkIfManageProfilesIsAllowed(tenantName);
    try {
        List<Profile> profiles = IterableUtils.toList(profileRepository.findRange(tenantName, sortBy, sortOrder, start, count, attributesToReturn));
        filterNonReadableAttributes(profiles);
        return profiles;
    } catch (MongoDataException e) {
        throw new I10nProfileException(ERROR_KEY_GET_PROFILE_RANGE_ERROR, e, start, count, tenantName);
    }
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) Profile(org.craftercms.profile.api.Profile)

Example 38 with MongoDataException

use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.

the class ProfileServiceImpl method getProfileByUsername.

@Override
public Profile getProfileByUsername(String tenantName, String username, String... attributesToReturn) throws ProfileException {
    checkIfManageProfilesIsAllowed(tenantName);
    try {
        Profile profile = profileRepository.findByTenantAndUsername(tenantName, username, attributesToReturn);
        filterNonReadableAttributes(profile);
        return profile;
    } catch (MongoDataException e) {
        throw new I10nProfileException(ERROR_KEY_GET_PROFILE_BY_USERNAME_ERROR, e, username, tenantName);
    }
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) Profile(org.craftercms.profile.api.Profile)

Example 39 with MongoDataException

use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.

the class ProfileServiceImpl method getProfilesByRole.

@Override
public List<Profile> getProfilesByRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException {
    checkIfManageProfilesIsAllowed(tenantName);
    try {
        List<Profile> profiles = IterableUtils.toList(profileRepository.findByTenantAndRole(tenantName, role, sortBy, sortOrder, attributesToReturn));
        filterNonReadableAttributes(profiles);
        return profiles;
    } catch (MongoDataException e) {
        throw new I10nProfileException(ERROR_KEY_GET_PROFILES_BY_ROLE_ERROR, e, role, tenantName);
    }
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) Profile(org.craftercms.profile.api.Profile)

Aggregations

MongoDataException (org.craftercms.commons.mongo.MongoDataException)39 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)27 Profile (org.craftercms.profile.api.Profile)15 MongoException (com.mongodb.MongoException)12 Date (java.util.Date)7 Find (org.jongo.Find)6 Tenant (org.craftercms.profile.api.Tenant)5 Ticket (org.craftercms.profile.api.Ticket)4 ObjectId (org.bson.types.ObjectId)3 DuplicateKeyException (org.craftercms.commons.mongo.DuplicateKeyException)3 PersistentLogin (org.craftercms.profile.api.PersistentLogin)3 DisabledProfileException (org.craftercms.profile.exceptions.DisabledProfileException)3 FindOne (org.jongo.FindOne)3 Update (org.jongo.Update)3 UpdateHelper (org.craftercms.commons.mongo.UpdateHelper)2 VerificationToken (org.craftercms.profile.api.VerificationToken)2 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 FileExistsException (org.apache.commons.io.FileExistsException)1 FileInfo (org.craftercms.commons.mongo.FileInfo)1