Search in sources :

Example 6 with SettingsDTO

use of org.wso2.carbon.apimgt.rest.api.service.catalog.dto.SettingsDTO 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 7 with SettingsDTO

use of org.wso2.carbon.apimgt.rest.api.service.catalog.dto.SettingsDTO 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)

Example 8 with SettingsDTO

use of org.wso2.carbon.apimgt.rest.api.service.catalog.dto.SettingsDTO 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)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)4 Map (java.util.Map)2 Environment (org.wso2.carbon.apimgt.api.model.Environment)2 SettingsDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.SettingsDTO)2 SettingsDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SettingsDTO)2 SettingsDTO (org.wso2.carbon.apimgt.rest.api.service.catalog.dto.SettingsDTO)2 SettingsDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.SettingsDTO)2 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)1 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)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 EnvironmentListDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.EnvironmentListDTO)1 SettingsMappingUtil (org.wso2.carbon.apimgt.rest.api.service.catalog.utils.SettingsMappingUtil)1 SettingsIdentityProviderDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.SettingsIdentityProviderDTO)1 SettingsMappingUtil (org.wso2.carbon.apimgt.rest.api.store.v1.mappings.SettingsMappingUtil)1 FrameworkException (org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException)1 Property (org.wso2.carbon.identity.application.common.model.Property)1 RealmConfiguration (org.wso2.carbon.user.api.RealmConfiguration)1