Search in sources :

Example 6 with UrlDto

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);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Example 7 with UrlDto

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);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Example 8 with UrlDto

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;
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkStoreRequestUrlsEntity(org.openkilda.store.linkstore.dao.entity.LinkStoreRequestUrlsEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with UrlDto

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;
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SwitchStoreRequestUrlsEntity(org.openkilda.store.switchstore.dao.entity.SwitchStoreRequestUrlsEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with UrlDto

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;
}
Also used : UrlDto(org.openkilda.store.model.UrlDto)

Aggregations

UrlDto (org.openkilda.store.model.UrlDto)17 HashMap (java.util.HashMap)11 IAuthService (org.openkilda.integration.auth.service.IAuthService)9 StoreIntegrationException (org.openkilda.integration.exception.StoreIntegrationException)9 AuthConfigDto (org.openkilda.store.model.AuthConfigDto)9 Transactional (org.springframework.transaction.annotation.Transactional)5 LinkStoreRequestUrlsEntity (org.openkilda.store.linkstore.dao.entity.LinkStoreRequestUrlsEntity)3 SwitchStoreRequestUrlsEntity (org.openkilda.store.switchstore.dao.entity.SwitchStoreRequestUrlsEntity)3 ArrayList (java.util.ArrayList)2 OauthConfigEntity (org.openkilda.store.auth.dao.entity.OauthConfigEntity)2 RequestValidationException (org.usermanagement.exception.RequestValidationException)2 LinkStoreConfigDto (org.openkilda.store.model.LinkStoreConfigDto)1 SwitchStoreConfigDto (org.openkilda.store.model.SwitchStoreConfigDto)1