Search in sources :

Example 1 with ApplicationAttributeDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeDTO 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 ApplicationAttributeDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeDTO 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)

Example 3 with ApplicationAttributeDTO

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

the class ApplicationMappingUtil method fromApplicationAttributeJsonToDTO.

/**
 * Creates a DTO representation of an Application Attribute
 *
 * @param attribute Application Attribute JSON object
 * @return an Application Attribute DTO
 */
public static ApplicationAttributeDTO fromApplicationAttributeJsonToDTO(JSONObject attribute) {
    ApplicationAttributeDTO applicationAttributeDTO = new ApplicationAttributeDTO();
    applicationAttributeDTO.setAttribute((String) attribute.get(APIConstants.ApplicationAttributes.ATTRIBUTE));
    applicationAttributeDTO.setDescription((String) attribute.get(APIConstants.ApplicationAttributes.DESCRIPTION));
    applicationAttributeDTO.setRequired(String.valueOf(attribute.get(APIConstants.ApplicationAttributes.REQUIRED)));
    applicationAttributeDTO.setHidden(String.valueOf(attribute.get(APIConstants.ApplicationAttributes.HIDDEN)));
    applicationAttributeDTO.setType(String.valueOf(attribute.get(APIConstants.ApplicationAttributes.TYPE)));
    applicationAttributeDTO.setTooltip(String.valueOf(attribute.get(APIConstants.ApplicationAttributes.TOOLTIP)));
    return applicationAttributeDTO;
}
Also used : ApplicationAttributeDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeDTO)

Aggregations

ApplicationAttributeDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationAttributeDTO)2 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