Search in sources :

Example 6 with DatabaseException

use of password.pwm.util.db.DatabaseException in project pwm by pwm-project.

the class PwNotifyDbStorageService method writeStoredState.

public void writeStoredState(final UserIdentity userIdentity, final SessionLabel sessionLabel, final StoredNotificationState storedNotificationState) throws PwmUnrecoverableException {
    final String guid;
    try {
        guid = LdapOperationsHelper.readLdapGuidValue(pwmApplication, sessionLabel, userIdentity, true);
    } catch (ChaiUnavailableException e) {
        throw new PwmUnrecoverableException(PwmUnrecoverableException.fromChaiException(e).getErrorInformation());
    }
    if (StringUtil.isEmpty(guid)) {
        throw new PwmUnrecoverableException(PwmError.ERROR_MISSING_GUID);
    }
    final String rawDbValue = JsonUtil.serialize(storedNotificationState);
    try {
        pwmApplication.getDatabaseAccessor().put(TABLE, guid, rawDbValue);
    } catch (DatabaseException e) {
        throw new PwmUnrecoverableException(new ErrorInformation(PwmError.ERROR_DB_UNAVAILABLE, e.getMessage()));
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) DatabaseException(password.pwm.util.db.DatabaseException)

Aggregations

ErrorInformation (password.pwm.error.ErrorInformation)6 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)6 DatabaseException (password.pwm.util.db.DatabaseException)6 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)3 DatabaseAccessor (password.pwm.util.db.DatabaseAccessor)3 ChaiResponseSet (com.novell.ldapchai.cr.ChaiResponseSet)1 ChaiException (com.novell.ldapchai.exception.ChaiException)1 UserIdentity (password.pwm.bean.UserIdentity)1