use of org.craftercms.profile.api.exceptions.I10nProfileException 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.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class AuthenticationServiceImpl method refreshPersistentLoginToken.
@Override
public PersistentLogin refreshPersistentLoginToken(String loginId) throws ProfileException {
PersistentLogin login = getPersistentLogin(loginId);
if (login != null) {
try {
login.setToken(UUID.randomUUID().toString());
persistentLoginRepository.save(login);
logger.debug(LOG_KEY_PERSISTENT_LOGIN_TOKEN_REFRESHED, loginId, login.getToken());
return login;
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_UPDATE_PERSISTENT_LOGIN_ERROR, loginId);
}
} else {
throw new NoSuchPersistentLoginException(loginId);
}
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class AuthenticationServiceImpl method getTicket.
@Override
public Ticket getTicket(String ticketId) throws ProfileException {
Ticket ticket;
try {
ticket = ticketRepository.findByStringId(ticketId);
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_GET_TICKET_ERROR, e, ticketId);
}
if (ticket != null) {
checkIfManageTicketsIsAllowed(ticket.getTenant());
ticket.setLastRequestTime(new Date());
try {
ticketRepository.save(ticket);
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_UPDATE_TICKET_ERROR, ticketId);
}
logger.debug(LOG_KEY_TICKET_REQUESTED, ticketId);
return ticket;
}
return null;
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class TenantServiceImpl method updateTenant.
protected Tenant updateTenant(String tenantName, UpdateCallback callback) throws ProfileException {
Tenant tenant = getTenant(tenantName);
if (tenant != null) {
checkIfTenantActionIsAllowed(tenantName, TenantAction.UPDATE_TENANT);
UpdateHelper updateHelper = new UpdateHelper();
TenantUpdater tenantUpdater = new TenantUpdater(tenant, updateHelper, tenantRepository);
callback.doWithTenant(tenantUpdater);
try {
tenantUpdater.update();
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_UPDATE_TENANT_ERROR, e, tenant.getName());
}
} else {
throw new NoSuchTenantException(tenantName);
}
return tenant;
}
use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.
the class TenantServiceImpl method createTenant.
@Override
public Tenant createTenant(Tenant tenant) throws ProfileException {
checkIfTenantActionIsAllowed(null, TenantAction.CREATE_TENANT);
// Make sure ID is null, we want it auto-generated
tenant.setId(null);
try {
tenantRepository.insert(tenant);
} catch (DuplicateKeyException e) {
throw new TenantExistsException(tenant.getName());
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_CREATE_TENANT_ERROR, e, tenant.getName());
}
logger.debug(LOG_KEY_TENANT_CREATED, tenant);
return tenant;
}
Aggregations