Search in sources :

Example 31 with Preferences

use of org.orcid.jaxb.model.record_rc2.Preferences in project k-9 by k9mail.

the class MailService method saveLastCheckEnd.

public static void saveLastCheckEnd(Context context) {
    long lastCheckEnd = System.currentTimeMillis();
    Timber.i("Saving lastCheckEnd = %tc", lastCheckEnd);
    Preferences prefs = Preferences.getPreferences(context);
    Storage storage = prefs.getStorage();
    StorageEditor editor = storage.edit();
    editor.putLong(LAST_CHECK_END, lastCheckEnd);
    editor.commit();
}
Also used : Storage(com.fsck.k9.preferences.Storage) Preferences(com.fsck.k9.Preferences) StorageEditor(com.fsck.k9.preferences.StorageEditor)

Example 32 with Preferences

use of org.orcid.jaxb.model.record_rc2.Preferences in project k-9 by k9mail.

the class DatabaseUpgradeService method upgradeDatabases.

/**
     * Upgrade the accounts' databases.
     */
private void upgradeDatabases() {
    Preferences preferences = Preferences.getPreferences(this);
    List<Account> accounts = preferences.getAccounts();
    mProgressEnd = accounts.size();
    mProgress = 0;
    for (Account account : accounts) {
        mAccountUuid = account.getUuid();
        sendProgressBroadcast(mAccountUuid, mProgress, mProgressEnd);
        try {
            // Account.getLocalStore() is blocking and will upgrade the database if necessary
            account.getLocalStore();
        } catch (UnavailableStorageException e) {
            Timber.e("Database unavailable");
        } catch (Exception e) {
            Timber.e(e, "Error while upgrading database");
        }
        mProgress++;
    }
    K9.setDatabasesUpToDate(true);
    sendUpgradeCompleteBroadcast();
}
Also used : Account(com.fsck.k9.Account) UnavailableStorageException(com.fsck.k9.mailstore.UnavailableStorageException) Preferences(com.fsck.k9.Preferences) UnavailableStorageException(com.fsck.k9.mailstore.UnavailableStorageException)

Example 33 with Preferences

use of org.orcid.jaxb.model.record_rc2.Preferences in project uPortal by Jasig.

the class PreferencesService method parsePreferences.

public Preferences parsePreferences(String preferencesToken) {
    final Jws<Claims> claims = parseEncrypteToken(preferencesToken, Preferences.class);
    final String username = claims.getBody().getSubject();
    final Map<String, List<String>> preferencesMap = new HashMap<>();
    for (Map.Entry<String, Object> y : claims.getBody().entrySet()) {
        final String key = y.getKey();
        if (JwtClaims.forName(key) != null) {
            // Skip these;  we handle these differently
            continue;
        }
        if (y.getValue() instanceof List) {
            @SuppressWarnings("unchecked") final List<String> values = (List<String>) y.getValue();
            preferencesMap.put(key, values);
        } else {
            logger.warn("Unexpected claim '{}' was not a List;  skipping", key);
        }
    }
    Preferences rslt = new Preferences(preferencesToken, preferencesMap);
    logger.debug("Produced the following Preferences for user '{}':  {}", username, rslt);
    return rslt;
}
Also used : Claims(io.jsonwebtoken.Claims) HashMap(java.util.HashMap) List(java.util.List) Preferences(org.apereo.portal.soffit.model.v1_0.Preferences) Map(java.util.Map) HashMap(java.util.HashMap)

Example 34 with Preferences

use of org.orcid.jaxb.model.record_rc2.Preferences in project uPortal by Jasig.

the class ModelAttributeServiceTest method testPrepareMethodParameters.

@Test
public void testPrepareMethodParameters() {
    final ModelAttributeService modelAttributeService = new ModelAttributeService();
    final Class[] parameterClasses = new Class[] { HttpServletRequest.class, PortalRequest.class, Bearer.class };
    final Method method;
    try {
        method = getClass().getMethod("soffitModelAttributeMethod", parameterClasses);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
    // Object Model
    final HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
    final HttpServletResponse res = Mockito.mock(HttpServletResponse.class);
    final PortalRequest portalRequest = Mockito.mock(PortalRequest.class);
    final Bearer bearer = Mockito.mock(Bearer.class);
    final Preferences preferences = Mockito.mock(Preferences.class);
    final Definition definition = Mockito.mock(Definition.class);
    final Object[] parameters = modelAttributeService.prepareMethodParameters(method, req, res, portalRequest, bearer, preferences, definition);
    assertEquals("parameterClasses and parameters arrays must be the same length", parameterClasses.length, parameters.length);
    for (int i = 0; i < parameters.length; i++) {
        assertTrue("Mismatched parameter type", parameterClasses[i].isInstance(parameters[i]));
    }
}
Also used : Definition(org.apereo.portal.soffit.model.v1_0.Definition) HttpServletResponse(javax.servlet.http.HttpServletResponse) Method(java.lang.reflect.Method) PortalRequest(org.apereo.portal.soffit.model.v1_0.PortalRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Preferences(org.apereo.portal.soffit.model.v1_0.Preferences) Bearer(org.apereo.portal.soffit.model.v1_0.Bearer) Test(org.junit.Test)

Aggregations

Preferences (com.fsck.k9.Preferences)17 Account (com.fsck.k9.Account)13 Test (org.junit.Test)12 Preferences (org.apereo.portal.soffit.model.v1_0.Preferences)5 Preferences (org.orcid.jaxb.model.record_v2.Preferences)5 StorageEditor (com.fsck.k9.preferences.StorageEditor)4 SearchAccount (com.fsck.k9.search.SearchAccount)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 InvalidSettingValueException (com.fsck.k9.preferences.Settings.InvalidSettingValueException)3 Storage (com.fsck.k9.preferences.Storage)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Bearer (org.apereo.portal.soffit.model.v1_0.Bearer)3 Definition (org.apereo.portal.soffit.model.v1_0.Definition)3 PortalRequest (org.apereo.portal.soffit.model.v1_0.PortalRequest)3 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 Uri (android.net.Uri)2 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)2