use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.TopicDTO in project carbon-apimgt by wso2.
the class AsyncAPIMappingUtil method fromTopicToDTO.
/**
* Converts Topic object to DTO.
*
* @param topic Topic object
* @return TopicDTO
*/
public static TopicDTO fromTopicToDTO(Topic topic) {
TopicDTO topicDTO = new TopicDTO();
topicDTO.setApiId(topic.getApiId());
topicDTO.setName(topic.getName());
topicDTO.setType(topic.getType());
return topicDTO;
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.TopicDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method updateTopics.
@Override
public Response updateTopics(String apiId, TopicListDTO topicListDTO, String ifMatch, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
String organization = RestApiUtil.getValidatedOrganization(messageContext);
// validate if api exists
validateAPIExistence(apiId);
API existingAPI = apiProvider.getAPIbyUUID(apiId, organization);
// validate API update operation permitted based on the LC state
validateAPIOperationsPerLC(existingAPI.getStatus());
Set<URITemplate> uriTemplates = existingAPI.getUriTemplates();
uriTemplates.clear();
for (TopicDTO topicDTO : topicListDTO.getList()) {
URITemplate uriTemplate = new URITemplate();
uriTemplate.setUriTemplate(topicDTO.getName());
uriTemplate.setHTTPVerb(topicDTO.getMode().toUpperCase());
// TODO: Get these from proper locations
uriTemplate.setAuthType(APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN);
uriTemplate.setThrottlingTier(APIConstants.UNLIMITED_TIER);
uriTemplates.add(uriTemplate);
}
existingAPI.setUriTemplates(uriTemplates);
// TODO: Add scopes
existingAPI.setOrganization(organization);
try {
apiProvider.updateAPI(existingAPI);
} catch (FaultGatewaysException e) {
String errorMessage = "Error while updating API : " + apiId;
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return Response.ok().build();
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.TopicDTO in project carbon-apimgt by wso2.
the class AsyncAPIMappingUtil method fromTopicListToDTO.
/**
* Converts Set of Topic objects to DTO.
*
* @param topics set of Topic objects
* @return TopicListDTO containing TopicDTOs
*/
public static TopicListDTO fromTopicListToDTO(Set<Topic> topics) {
TopicListDTO topicListDTO = new TopicListDTO();
List<TopicDTO> topicDTOs = topicListDTO.getList();
topicListDTO.setCount(topics.size());
if (topicDTOs == null) {
topicDTOs = new ArrayList<>();
topicListDTO.setList(topicDTOs);
}
for (Topic topic : topics) {
topicDTOs.add(fromTopicToDTO(topic));
}
return topicListDTO;
}
Aggregations