use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.
the class AuthenticationServiceImpl method createTicket.
@Override
public Ticket createTicket(String profileId) throws ProfileException {
Profile profile = profileService.getProfile(profileId, ProfileConstants.NO_ATTRIBUTE);
if (profile != null) {
String tenantName = profile.getTenant();
checkIfManageTicketsIsAllowed(tenantName);
if (!profile.isEnabled()) {
throw new DisabledProfileException(profile.getId().toString(), tenantName);
}
try {
Ticket ticket = new Ticket();
ticket.setId(UUID.randomUUID().toString());
ticket.setTenant(tenantName);
ticket.setProfileId(profile.getId().toString());
ticket.setLastRequestTime(new Date());
ticketRepository.insert(ticket);
logger.debug(LOG_KEY_TICKET_CREATED, profile.getId(), ticket);
return ticket;
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_CREATE_TICKET_ERROR, profile.getId());
}
} else {
throw new NoSuchProfileException.ById(profileId);
}
}
use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.
the class TenantServiceImpl method deleteTenant.
@Override
public void deleteTenant(String name) throws ProfileException {
checkIfTenantActionIsAllowed(name, TenantAction.DELETE_TENANT);
try {
profileRepository.removeAll(name);
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_DELETE_ALL_PROFILES_ERROR, e, name);
}
try {
tenantRepository.removeByName(name);
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_DELETE_TENANT_ERROR, e, name);
}
logger.debug(LOG_KEY_TENANT_DELETED, name);
}
use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.
the class ProfileRepositoryImpl method updateAllWithDefaultValue.
@Override
public void updateAllWithDefaultValue(String tenantName, String attributeName, Object defaultValue) throws MongoDataException {
try {
String query = getQueryFor(KEY_FIND_BY_TENANT_AND_NON_EXISTING_ATTRIB_QUERY);
Update update = getCollection().update(query, tenantName, attributeName).multi();
update.with(MODIFIER_UPDATE_ATTRIBUTE, attributeName, defaultValue);
} catch (MongoException ex) {
String msg = "Unable to add attribute with name '" + attributeName + "' to profiles of tenant '" + tenantName + "'";
logger.error(msg, ex);
throw new MongoDataException(msg, ex);
}
}
use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.
the class ProfileRepositoryImpl method removeAttributeFromAll.
@Override
public void removeAttributeFromAll(String tenantName, String attributeName) throws MongoDataException {
try {
String query = getQueryFor(KEY_FIND_BY_TENANT_AND_EXISTING_ATTRIB_QUERY);
Update update = getCollection().update(query, tenantName, attributeName).multi();
update.with(MODIFIER_REMOVE_ATTRIBUTE, attributeName);
} catch (MongoException ex) {
String msg = "Unable to remove attribute with name '" + attributeName + "' from profiles of tenant '" + tenantName + "'";
logger.error(msg, ex);
throw new MongoDataException(msg, ex);
}
}
use of org.craftercms.commons.mongo.MongoDataException in project profile by craftercms.
the class ProfileRepositoryImpl method removeRoleFromAll.
@Override
public void removeRoleFromAll(String tenantName, String role) throws MongoDataException {
try {
String query = getQueryFor(KEY_FIND_BY_TENANT_AND_ROLE_QUERY);
Update update = getCollection().update(query, tenantName, role).multi();
update.with(MODIFIER_REMOVE_ROLE, role);
} catch (MongoException ex) {
String msg = "Unable to remove role '" + role + "' from profiles of tenant '" + tenantName + "'";
logger.error(msg, ex);
throw new MongoDataException(msg, ex);
}
}
Aggregations