Search in sources :

Example 1 with ApplicationAttributeListDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeListDTO in project carbon-apimgt by wso2.

the class ApplicationMappingUtil method fromApplicationAttributeListToDTO.

/**
 * Converts an Application Attribute List object into corresponding REST API DTO
 *
 * @param attributeList List of attribute objects
 * @return ApplicationAttributeListDTO object
 */
public static ApplicationAttributeListDTO fromApplicationAttributeListToDTO(List<ApplicationAttributeDTO> attributeList) {
    ApplicationAttributeListDTO applicationAttributeListDTO = new ApplicationAttributeListDTO();
    applicationAttributeListDTO.setList(attributeList);
    applicationAttributeListDTO.setCount(attributeList.size());
    return applicationAttributeListDTO;
}
Also used : ApplicationAttributeListDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeListDTO)

Example 2 with ApplicationAttributeListDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeListDTO in project carbon-apimgt by wso2.

the class SettingsApiServiceImpl method settingsApplicationAttributesGet.

@Override
public Response settingsApplicationAttributesGet(String ifNoneMatch, MessageContext messageContext) {
    String username = RestApiCommonUtil.getLoggedInUsername();
    try {
        APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username);
        List<ApplicationAttributeDTO> applicationAttributeDTOList = new ArrayList<>();
        JSONArray attributeArray = apiConsumer.getAppAttributesFromConfig(username);
        for (int i = 0; i < attributeArray.size(); i++) {
            JSONObject obj = (JSONObject) attributeArray.get(i);
            ApplicationAttributeDTO applicationAttributeDTO = ApplicationMappingUtil.fromApplicationAttributeJsonToDTO(obj);
            applicationAttributeDTOList.add(applicationAttributeDTO);
        }
        ApplicationAttributeListDTO applicationAttributeListDTO = ApplicationMappingUtil.fromApplicationAttributeListToDTO(applicationAttributeDTOList);
        return Response.ok().entity(applicationAttributeListDTO).build();
    } catch (APIManagementException e) {
        RestApiUtil.handleInternalServerError("Error occurred in reading application attributes from config", e, log);
    }
    return null;
}
Also used : JSONObject(org.json.simple.JSONObject) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) ApplicationAttributeDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeDTO) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) APIConsumer(org.wso2.carbon.apimgt.api.APIConsumer) ApplicationAttributeListDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeListDTO)

Aggregations

ApplicationAttributeListDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeListDTO)2 ArrayList (java.util.ArrayList)1 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 ApplicationAttributeDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeDTO)1