/*
 * Copyright 2017 JBoss Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.apicurio.studio.fe.servlet.config;

import javax.enterprise.context.ApplicationScoped;

import io.apicurio.studio.fe.servlet.servlets.DownloadServlet;
import io.apicurio.studio.shared.config.Configuration;

/**
 * @author eric.wittmann@gmail.com
 */
@ApplicationScoped
public class StudioUiConfiguration extends Configuration {

    private static final String HUB_API_URL_ENV = "APICURIO_UI_HUB_API_URL";
    private static final String HUB_API_URL_SYSPROP = "apicurio-ui.hub-api.url";

    private static final String HUB_API_DISABLE_API_TRUST_ENV = "APICURIO_UI_HUB_API_DISABLE_TRUST_MANAGER";
    private static final String HUB_API_DISABLE_API_TRUST_SYSPROP = "apicurio-ui.hub-api.disable-trust-manager";

    private static final String LOGOUT_REDIRECT_URI_ENV = "APICURIO_UI_LOGOUT_REDIRECT_URI";
    private static final String LOGOUT_REDIRECT_URI_SYSPROP = "apicurio-ui.logout-redirect-uri";

    private static final String EDITING_URL_ENV = "APICURIO_UI_EDITING_URL";
    private static final String EDITING_URL_SYSPROP = "apicurio-ui.editing.url";

    private static final String FEATURE_MICROCKS_ENV = "APICURIO_UI_FEATURE_MICROCKS";
    private static final String FEATURE_MICROCKS_SYSPROP = "apicurio-ui.feature.microcks";

    /**
     * Returns the URL of the Apicurio Hub API.
     */
    public String getHubApiUrl() {
        return getConfigurationProperty(HUB_API_URL_ENV, HUB_API_URL_SYSPROP, null);
    }

    /**
     * Returns the URL of the Apicurio Editing API.
     */
    public String getEditingUrl() {
        return getConfigurationProperty(EDITING_URL_ENV, EDITING_URL_SYSPROP, null);
    }

    /**
     * Returns the URI of where to redirect after the user logs out of the application.
     */
    public String getLogoutRedirectUri() {
        return getConfigurationProperty(LOGOUT_REDIRECT_URI_ENV, LOGOUT_REDIRECT_URI_SYSPROP, "/studio");
    }

    /**
     * Returns true if the trust manager should be disabled when making server-server API calls
     * to the Hub API.  This happens, for example, in the {@link DownloadServlet}.
     */
    public boolean isDisableHubApiTrustManager() {
        return "true".equals(getConfigurationProperty(HUB_API_DISABLE_API_TRUST_ENV, HUB_API_DISABLE_API_TRUST_SYSPROP, "true"));
    }
    
    /**
     * Returns true if the integration with Microcks should be enabled in the UI.
     */
    public boolean isMicrocksEnabled() {
        return "true".equals(getConfigurationProperty(FEATURE_MICROCKS_ENV, FEATURE_MICROCKS_SYSPROP, "true"));
    }
}

@@ -3107,33 +3107,34 @@
 ROCKS_SYSPROP, %22
-tru
+fals
 e%22));%0A    %7D%0A%7D%0A

disable microcks support by default