Search in sources :

Example 1 with SettingsMappingUtil

use of org.wso2.carbon.apimgt.rest.api.admin.v1.utils.mappings.SettingsMappingUtil in project carbon-apimgt by wso2.

the class SettingsApiServiceImpl method settingsGet.

/**
 * Retrieves admin portal related server settings
 *
 * @param messageContext
 * @return settings list
 * @throws APIManagementException
 */
@Override
public Response settingsGet(MessageContext messageContext) throws APIManagementException {
    String username = RestApiCommonUtil.getLoggedInUsername();
    boolean isUserAvailable = false;
    if (!APIConstants.WSO2_ANONYMOUS_USER.equalsIgnoreCase(username)) {
        isUserAvailable = true;
    }
    SettingsMappingUtil settingsMappingUtil = new SettingsMappingUtil();
    SettingsDTO settingsDTO = settingsMappingUtil.fromSettingsToDTO(isUserAvailable);
    return Response.ok().entity(settingsDTO).build();
}
Also used : SettingsDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.SettingsDTO) SettingsMappingUtil(org.wso2.carbon.apimgt.rest.api.admin.v1.utils.mappings.SettingsMappingUtil)

Example 2 with SettingsMappingUtil

use of org.wso2.carbon.apimgt.rest.api.admin.v1.utils.mappings.SettingsMappingUtil in project carbon-apimgt by wso2.

the class SettingsApiServiceImpl method getSettings.

@Override
public Response getSettings(MessageContext messageContext) {
    try {
        String username = RestApiCommonUtil.getLoggedInUsername();
        boolean isUserAvailable = false;
        if (!APIConstants.WSO2_ANONYMOUS_USER.equalsIgnoreCase(username)) {
            isUserAvailable = true;
        }
        SettingsMappingUtil settingsMappingUtil = new SettingsMappingUtil();
        String organization = RestApiUtil.getValidatedOrganization(messageContext);
        SettingsDTO settingsDTO = settingsMappingUtil.fromSettingstoDTO(isUserAvailable, organization);
        settingsDTO.setScopes(GetScopeList());
        return Response.ok().entity(settingsDTO).build();
    } catch (APIManagementException | IOException e) {
        String errorMessage = "Error while retrieving Publisher Settings";
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}
Also used : SettingsDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SettingsDTO) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) SettingsMappingUtil(org.wso2.carbon.apimgt.rest.api.publisher.v1.common.mappings.SettingsMappingUtil) IOException(java.io.IOException)

Example 3 with SettingsMappingUtil

use of org.wso2.carbon.apimgt.rest.api.admin.v1.utils.mappings.SettingsMappingUtil in project carbon-apimgt by wso2.

the class SettingsApiServiceImpl method settingsGet.

@Override
public Response settingsGet(String xWSO2Tenant, MessageContext messageContext) throws APIManagementException {
    try {
        String username = RestApiCommonUtil.getLoggedInUsername();
        APIConsumer apiConsumer = RestApiCommonUtil.getConsumer(username);
        String requestedTenantDomain = RestApiUtil.getRequestedTenantDomain(xWSO2Tenant);
        boolean monetizationEnabled = apiConsumer.isMonetizationEnabled(requestedTenantDomain);
        boolean recommendationEnabled = apiConsumer.isRecommendationEnabled(requestedTenantDomain);
        boolean anonymousEnabled = RestApiUtil.isDevPortalAnonymousEnabled(requestedTenantDomain);
        boolean isUserAvailable = false;
        if (!APIConstants.WSO2_ANONYMOUS_USER.equalsIgnoreCase(username)) {
            isUserAvailable = true;
        }
        String organization = RestApiUtil.getValidatedOrganization(messageContext);
        SettingsMappingUtil settingsMappingUtil = new SettingsMappingUtil();
        SettingsDTO settingsDTO = settingsMappingUtil.fromSettingstoDTO(isUserAvailable, monetizationEnabled, recommendationEnabled, anonymousEnabled, organization);
        return Response.ok().entity(settingsDTO).build();
    } catch (APIManagementException e) {
        String errorMessage = "Error while retrieving Store Settings";
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}
Also used : SettingsDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.SettingsDTO) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIConsumer(org.wso2.carbon.apimgt.api.APIConsumer) SettingsMappingUtil(org.wso2.carbon.apimgt.rest.api.store.v1.mappings.SettingsMappingUtil)

Example 4 with SettingsMappingUtil

use of org.wso2.carbon.apimgt.rest.api.admin.v1.utils.mappings.SettingsMappingUtil in project carbon-apimgt by wso2.

the class SettingsApiServiceImpl method getSettings.

public Response getSettings(MessageContext messageContext) {
    try {
        SettingsMappingUtil settingsMappingUtil = new SettingsMappingUtil();
        SettingsDTO settingsDTO = settingsMappingUtil.fromSettingsToDTO();
        return Response.ok().entity(settingsDTO).build();
    } catch (APIManagementException e) {
        String errorMessage = "Error while retrieving Service Catalog Settings";
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}
Also used : SettingsDTO(org.wso2.carbon.apimgt.rest.api.service.catalog.dto.SettingsDTO) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) SettingsMappingUtil(org.wso2.carbon.apimgt.rest.api.service.catalog.utils.SettingsMappingUtil)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 IOException (java.io.IOException)1 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)1 SettingsDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.SettingsDTO)1 SettingsMappingUtil (org.wso2.carbon.apimgt.rest.api.admin.v1.utils.mappings.SettingsMappingUtil)1 SettingsMappingUtil (org.wso2.carbon.apimgt.rest.api.publisher.v1.common.mappings.SettingsMappingUtil)1 SettingsDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SettingsDTO)1 SettingsDTO (org.wso2.carbon.apimgt.rest.api.service.catalog.dto.SettingsDTO)1 SettingsMappingUtil (org.wso2.carbon.apimgt.rest.api.service.catalog.utils.SettingsMappingUtil)1 SettingsDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.SettingsDTO)1 SettingsMappingUtil (org.wso2.carbon.apimgt.rest.api.store.v1.mappings.SettingsMappingUtil)1