use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class FlowStoreService method getAllStatus.
/**
* Gets the all status list.
*
* @return the all status list
*/
public List<String> getAllStatus() {
try {
UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.GET_STATUS_LIST);
AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
IAuthService authService = IAuthService.getService(authDto.getAuthType());
return authService.getResponseList(urlDto, authDto, String.class);
} catch (Exception e) {
LOGGER.error("Error occurred while retriving status list", e);
throw new StoreIntegrationException(e);
}
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class FlowStoreService method getFlowsWithParams.
/**
* Gets the flows with params.
*
* @param status the status
* @return the flows with params
*/
public List<InventoryFlow> getFlowsWithParams(final String status) {
try {
UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.GET_LINKS_WITH_PARAMS);
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParams.STATUS.getName(), status);
urlDto.setParams(params);
AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
IAuthService authService = IAuthService.getService(authDto.getAuthType());
return authService.getResponseList(urlDto, authDto, InventoryFlow.class);
} catch (Exception e) {
LOGGER.error("Error occurred while retriving flows with status: " + status, e);
throw new StoreIntegrationException(e);
}
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class StoreService method saveOrUpdateLinkStoreConfig.
/**
* Save or update link store config.
*
* @param linkStoreConfigDto the link store config dto
*
* @return the link store config dto
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public LinkStoreConfigDto saveOrUpdateLinkStoreConfig(final LinkStoreConfigDto linkStoreConfigDto) {
LOGGER.info("Save or update link store configuration");
saveOrUpdateStoreTypeEntity(StoreType.LINK_STORE.getCode());
List<LinkStoreRequestUrlsEntity> linkStoreRequestUrlsEntitiesList = new ArrayList<LinkStoreRequestUrlsEntity>();
List<LinkStoreRequestUrlsEntity> linkStoreRequestUrlsEntities = linkStoreRequestUrlsRepository.findAll();
for (Entry<String, UrlDto> urlEntrySet : linkStoreConfigDto.getUrls().entrySet()) {
if (linkStoreRequestUrlsEntities != null) {
LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntity = null;
for (LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntityObj : linkStoreRequestUrlsEntities) {
if (linkStoreRequestUrlsEntityObj.getUrlEntity().getName().equalsIgnoreCase(urlEntrySet.getValue().getName())) {
linkStoreRequestUrlsEntity = linkStoreRequestUrlsEntityObj;
break;
}
}
if (linkStoreRequestUrlsEntity == null) {
linkStoreRequestUrlsEntity = new LinkStoreRequestUrlsEntity();
}
linkStoreRequestUrlsEntity.setUrlEntity(UrlConverter.toUrlEntity(urlEntrySet.getKey(), urlEntrySet.getValue(), linkStoreRequestUrlsEntity.getUrlEntity()));
linkStoreRequestUrlsEntitiesList.add(linkStoreRequestUrlsEntity);
}
}
linkStoreRequestUrlsEntitiesList = linkStoreRequestUrlsRepository.save(linkStoreRequestUrlsEntitiesList);
Map<String, UrlDto> urls = new HashMap<String, UrlDto>();
for (LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntity : linkStoreRequestUrlsEntitiesList) {
urls.put(linkStoreRequestUrlsEntity.getUrlEntity().getName(), UrlConverter.toUrlDto(linkStoreRequestUrlsEntity.getUrlEntity()));
}
linkStoreConfigDto.setUrls(urls);
return linkStoreConfigDto;
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class StoreService method saveOrUpdateSwitchStoreConfig.
/**
* Save or update switch store config.
*
* @param switchStoreConfigDto he link store config dto
*
* @return the switch store config dto
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public SwitchStoreConfigDto saveOrUpdateSwitchStoreConfig(final SwitchStoreConfigDto switchStoreConfigDto) {
LOGGER.info("Save or update switch store configuration");
saveOrUpdateStoreTypeEntity(StoreType.SWITCH_STORE.getCode());
List<SwitchStoreRequestUrlsEntity> switchStoreRequestUrlsEntitiesList = new ArrayList<SwitchStoreRequestUrlsEntity>();
List<SwitchStoreRequestUrlsEntity> switchStoreRequestUrlsEntities = switchStoreRequestUrlsRepository.findAll();
for (Entry<String, UrlDto> urlEntrySet : switchStoreConfigDto.getUrls().entrySet()) {
if (switchStoreRequestUrlsEntities != null) {
SwitchStoreRequestUrlsEntity switchStoreRequestUrlsEntity = null;
for (SwitchStoreRequestUrlsEntity switchStoreRequestUrlsEntityObj : switchStoreRequestUrlsEntities) {
if (switchStoreRequestUrlsEntityObj.getUrlEntity().getName().equalsIgnoreCase(urlEntrySet.getValue().getName())) {
switchStoreRequestUrlsEntity = switchStoreRequestUrlsEntityObj;
break;
}
}
if (switchStoreRequestUrlsEntity == null) {
switchStoreRequestUrlsEntity = new SwitchStoreRequestUrlsEntity();
}
switchStoreRequestUrlsEntity.setUrlEntity(UrlConverter.toUrlEntity(urlEntrySet.getKey(), urlEntrySet.getValue(), switchStoreRequestUrlsEntity.getUrlEntity()));
switchStoreRequestUrlsEntitiesList.add(switchStoreRequestUrlsEntity);
}
}
switchStoreRequestUrlsEntitiesList = switchStoreRequestUrlsRepository.save(switchStoreRequestUrlsEntitiesList);
Map<String, UrlDto> urls = new HashMap<String, UrlDto>();
for (SwitchStoreRequestUrlsEntity switchStoreRequestUrlsEntity : switchStoreRequestUrlsEntitiesList) {
urls.put(switchStoreRequestUrlsEntity.getUrlEntity().getName(), UrlConverter.toUrlDto(switchStoreRequestUrlsEntity.getUrlEntity()));
}
switchStoreConfigDto.setUrls(urls);
return switchStoreConfigDto;
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class UrlConverter method toUrlDto.
/**
* To url dto.
*
* @param urlEntity the url entity
* @return the url dto
*/
public static UrlDto toUrlDto(final UrlEntity urlEntity) {
UrlDto urlDto = new UrlDto();
urlDto.setName(urlEntity.getName());
urlDto.setUrl(StringUtil.isNullOrEmpty(urlEntity.getUrl()) ? urlEntity.getUrl() : urlEntity.getUrl().trim());
urlDto.setMethodType(urlEntity.getMethodType());
urlDto.setHeader(urlEntity.getHeader());
urlDto.setBody(urlEntity.getBody());
return urlDto;
}
Aggregations