Ignore:
Timestamp:
2017-10-06T15:17:51+02:00 (7 years ago)
Author:
bastiK
Message:

see #15229 - do not copy the entire preferences list, just to set a custom server API in OAuth wizard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java

    r10294 r12928  
    77import org.openstreetmap.josm.data.Preferences;
    88import org.openstreetmap.josm.io.OsmApi;
     9import org.openstreetmap.josm.spi.preferences.Config;
    910import org.openstreetmap.josm.tools.CheckParameterUtil;
    1011import org.openstreetmap.josm.tools.Utils;
     
    7980     * Replies a set of parameters as defined in the preferences.
    8081     *
     82     * @param apiUrl the API URL. Must not be null.
     83     * @return the parameters
     84     */
     85    public static OAuthParameters createFromApiUrl(String apiUrl) {
     86        OAuthParameters parameters = createDefault(apiUrl);
     87        return new OAuthParameters(
     88                Config.getPref().get("oauth.settings.consumer-key", parameters.getConsumerKey()),
     89                Config.getPref().get("oauth.settings.consumer-secret", parameters.getConsumerSecret()),
     90                Config.getPref().get("oauth.settings.request-token-url", parameters.getRequestTokenUrl()),
     91                Config.getPref().get("oauth.settings.access-token-url", parameters.getAccessTokenUrl()),
     92                Config.getPref().get("oauth.settings.authorise-url", parameters.getAuthoriseUrl()),
     93                Config.getPref().get("oauth.settings.osm-login-url", parameters.getOsmLoginUrl()),
     94                Config.getPref().get("oauth.settings.osm-logout-url", parameters.getOsmLogoutUrl()));
     95    }
     96
     97    /**
     98     * Replies a set of parameters as defined in the preferences.
     99     *
    81100     * @param pref the preferences
    82101     * @return the parameters
    83      */
     102     * @deprecated (since 12928) replaced by {@link #createFromApiUrl(java.lang.String)}
     103     */
     104    @Deprecated
    84105    public static OAuthParameters createFromPreferences(Preferences pref) {
    85106        OAuthParameters parameters = createDefault(pref.get("osm-server.url"));
     
    95116
    96117    /**
     118     * Remembers the current values in the preferences.
     119     */
     120    public void rememberPreferences() {
     121        Config.getPref().put("oauth.settings.consumer-key", getConsumerKey());
     122        Config.getPref().put("oauth.settings.consumer-secret", getConsumerSecret());
     123        Config.getPref().put("oauth.settings.request-token-url", getRequestTokenUrl());
     124        Config.getPref().put("oauth.settings.access-token-url", getAccessTokenUrl());
     125        Config.getPref().put("oauth.settings.authorise-url", getAuthoriseUrl());
     126        Config.getPref().put("oauth.settings.osm-login-url", getOsmLoginUrl());
     127        Config.getPref().put("oauth.settings.osm-logout-url", getOsmLogoutUrl());
     128    }
     129
     130    /**
    97131     * Remembers the current values in the preferences <code>pref</code>.
    98132     *
    99133     * @param pref the preferences. Must not be null.
    100134     * @throws IllegalArgumentException if pref is null.
    101      */
     135     * @deprecated (since 12928) replaced by {@link #rememberPreferences()}
     136     */
     137    @Deprecated
    102138    public void rememberPreferences(Preferences pref) {
    103139        CheckParameterUtil.ensureParameterNotNull(pref, "pref");
     
    129165     * @param osmLogoutUrl the OSM logout URL (for automatic mode)
    130166     * @see #createDefault
    131      * @see #createFromPreferences
     167     * @see #createFromApiUrl
    132168     * @since 9220
    133169     */
Note: See TracChangeset for help on using the changeset viewer.