Search in sources :

Example 11 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testUnmarshallPreferences.

@Test
public void testUnmarshallPreferences() throws SAXException, URISyntaxException {
    Preferences preferences = (Preferences) unmarshallFromPath("/record_2.0/samples/read_samples/preferences-2.0.xml", Preferences.class, "/record_2.0/preferences-2.0.xsd");
    assertNotNull(preferences);
    assertNotNull(preferences.getLocale());
    assertEquals(Locale.EN, preferences.getLocale());
}
Also used : Preferences(org.orcid.jaxb.model.record_v2.Preferences) Test(org.junit.Test)

Example 12 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest method testMarshallPreferences.

@Test
public void testMarshallPreferences() throws JAXBException, SAXException, URISyntaxException {
    Preferences object = (Preferences) unmarshallFromPath("/record_2.0_rc4/samples/preferences-2.0_rc4.xml", Preferences.class);
    marshall(object, "/record_2.0_rc4/preferences-2.0_rc4.xsd");
}
Also used : Preferences(org.orcid.jaxb.model.record_rc4.Preferences) Test(org.junit.Test)

Example 13 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testMarshallPreferences.

@Test
public void testMarshallPreferences() throws JAXBException, SAXException, URISyntaxException {
    Preferences object = (Preferences) unmarshallFromPath("/record_2.1/samples/read_samples/preferences-2.1.xml", Preferences.class);
    marshall(object, "/record_2.1/preferences-2.1.xsd");
}
Also used : Preferences(org.orcid.jaxb.model.record_v2.Preferences) Test(org.junit.Test)

Example 14 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) CreditName(org.orcid.jaxb.model.record_v2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_v2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_v2.Deprecated) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 15 with Preferences

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

the class PreferencesHeaderProvider method createHeader.

@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
    // Username
    final String username = getUsername(renderRequest);
    // PreferencesMap
    final Map<String, List<String>> preferencesMap = new HashMap<>();
    final PortletPreferences prefs = renderRequest.getPreferences();
    for (Map.Entry<String, String[]> y : prefs.getMap().entrySet()) {
        final String name = y.getKey();
        /*
             * We ignore (skip) preferences that exist for the benefit of the
             * SoffitConnectorController.
             */
        if (name.startsWith(SoffitConnectorController.CONNECTOR_PREFERENCE_PREFIX)) {
            continue;
        }
        List<String> values = Arrays.asList(prefs.getValues(name, new String[0]));
        if (!values.isEmpty()) {
            preferencesMap.put(name, values);
        }
    }
    // Preferences header
    final Preferences preferences = preferencesService.createPreferences(preferencesMap, username, getExpiration(renderRequest));
    final Header rslt = new BasicHeader(Headers.PREFERECES.getName(), preferences.getEncryptedToken());
    logger.debug("Produced the following Preferences header for username='{}':  {}", username, rslt);
    return rslt;
}
Also used : Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) HashMap(java.util.HashMap) List(java.util.List) PortletPreferences(javax.portlet.PortletPreferences) PortletPreferences(javax.portlet.PortletPreferences) Preferences(org.apereo.portal.soffit.model.v1_0.Preferences) HashMap(java.util.HashMap) Map(java.util.Map) BasicHeader(org.apache.http.message.BasicHeader)

Aggregations

Preferences (com.fsck.k9.Preferences)17 Account (com.fsck.k9.Account)13 Test (org.junit.Test)12 IOException (java.io.IOException)5 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 InvalidSettingValueException (com.fsck.k9.preferences.Settings.InvalidSettingValueException)3 Storage (com.fsck.k9.preferences.Storage)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)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 InputStreamReader (java.io.InputStreamReader)2