use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class LinkStoreConfigValidator method validate.
/**
* Validate.
*
* @param linkStoreConfigDto the link store config dto
*/
public void validate(final LinkStoreConfigDto linkStoreConfigDto) {
List<OauthConfigEntity> oauthConfigEntityList = oauthConfigRepository.findByAuthType_authTypeId(AuthType.OAUTH_TWO.getAuthTypeEntity().getAuthTypeId());
if (CollectionUtil.isEmpty(oauthConfigEntityList)) {
LOGGER.warn(messageUtil.getStoreMustConfigured());
throw new RequestValidationException(messageUtil.getStoreMustConfigured());
}
List<String> urls = StoreUrl.getUrlName(StoreType.LINK_STORE.getCode());
for (Entry<String, UrlDto> urlEntrySet : linkStoreConfigDto.getUrls().entrySet()) {
if (!urls.contains(urlEntrySet.getKey())) {
LOGGER.warn("Validation fail for link store configuration. Error: " + messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getUrl())) {
LOGGER.warn("Validation fail for link store configuration. Error: " + messageUtil.getAttributeNotNull("url of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getMethodType())) {
LOGGER.warn("Validation fail for link store configuration. Error: " + messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
}
}
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class SwitchStoreConfigValidator method validate.
/**
* Validate.
*
* @param switchStoreConfigDto the link store config dto
*/
public void validate(final SwitchStoreConfigDto switchStoreConfigDto) {
List<OauthConfigEntity> oauthConfigEntityList = oauthConfigRepository.findByAuthType_authTypeId(AuthType.OAUTH_TWO.getAuthTypeEntity().getAuthTypeId());
if (CollectionUtil.isEmpty(oauthConfigEntityList)) {
LOGGER.warn(messageUtil.getStoreMustConfigured());
throw new RequestValidationException(messageUtil.getStoreMustConfigured());
}
List<String> urls = StoreUrl.getUrlName(StoreType.SWITCH_STORE.getCode());
for (Entry<String, UrlDto> urlEntrySet : switchStoreConfigDto.getUrls().entrySet()) {
if (!urls.contains(urlEntrySet.getKey())) {
LOGGER.warn("Validation fail for switch store configuration. Error: " + messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getUrl())) {
LOGGER.warn("Validation fail for switch store configuration. Error: " + messageUtil.getAttributeNotNull("url of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getMethodType())) {
LOGGER.warn("Validation fail for switch store configuration. Error: " + messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
}
}
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class FlowStoreService method getFlowById.
/**
* Gets the flow by id.
*
* @param flowId the flow id
* @return the flow by id
*/
public InventoryFlow getFlowById(final String flowId) {
try {
UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.GET_LINK);
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParams.LINK_ID.getName(), flowId);
urlDto.setParams(params);
AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
IAuthService authService = IAuthService.getService(authDto.getAuthType());
return authService.getResponse(urlDto, authDto, InventoryFlow.class);
} catch (Exception e) {
LOGGER.error("Error occurred while retriving flow by id: " + flowId, e);
throw new StoreIntegrationException(e);
}
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class SwitchStoreService method getPortFlows.
/**
* Gets the customer flows.
*
* @return the customer with flows
*/
public List<Customer> getPortFlows(String switchId, String port) {
try {
UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_SWITCH_PORT_FLOWS);
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParams.SWITCH_ID.getName(), switchId);
params.put(RequestParams.PORT_NUMBER.getName(), port);
urlDto.setParams(params);
AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
IAuthService authService = IAuthService.getService(authDto.getAuthType());
return authService.getResponseList(urlDto, authDto, Customer.class);
} catch (Exception e) {
LOGGER.error("Error occurred while retriving switch port flows. Switch Id: " + switchId + ", Port: " + port, e);
throw new StoreIntegrationException(e);
}
}
use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.
the class StoreService method getLinkStoreConfig.
/**
* Gets the link store config.
*
* @return the link store config
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public LinkStoreConfigDto getLinkStoreConfig() {
LOGGER.info("Get link store configuration");
LinkStoreConfigDto linkStoreConfigDto = new LinkStoreConfigDto();
List<LinkStoreRequestUrlsEntity> linkStoreRequestUrlsEntitiesList = linkStoreRequestUrlsRepository.findAll();
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;
}
Aggregations