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;
}
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;
}
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;
}
Aggregations