Search in sources :

Example 1 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException in project open-kilda by telstra.

the class SwitchStoreService method getSwitch.

/**
 * Gets the switch with params.
 *
 * @return the switch with params
 */
public InventorySwitch getSwitch(String switchId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_SWITCH);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.SWITCH_ID.getName(), switchId);
        urlDto.setParams(params);
        AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponse(urlDto, authDto, InventorySwitch.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving switches. Switch Id: " + switchId, 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 2 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException in project open-kilda by telstra.

the class SwitchStoreService method getSwitchPort.

/**
 * Gets the switch port.
 *
 * @param switchId the switch id
 * @return the switch port
 */
public List<Port> getSwitchPort(final String switchId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_SWITCH_PORTS);
        AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.SWITCH_ID.getName(), switchId);
        urlDto.setParams(params);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponseList(urlDto, authDto, Port.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving switch ports. Switch Id: " + switchId, 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 3 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException in project open-kilda by telstra.

the class SwitchStoreService method getSwitches.

/**
 * Gets the switches with params.
 *
 * @return the switches with params
 */
public List<InventorySwitch> getSwitches() {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_ALL_SWITCHES);
        AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponseList(urlDto, authDto, InventorySwitch.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving switches", 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 4 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException in project open-kilda by telstra.

the class FlowStoreService method getContracts.

/**
 * Gets the all contracts.
 *
 * @param linkId
 *            the link id
 * @return the all contracts
 */
public List<Contract> getContracts(final String linkId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.GET_CONTRACT);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.LINK_ID.getName(), linkId);
        urlDto.setParams(params);
        AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponseList(urlDto, authDto, Contract.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving contracts by link id: " + linkId, 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 5 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException in project open-kilda by telstra.

the class FlowStoreService method deleteContract.

/**
 * Delete contract.
 *
 * @param linkId
 *            the link id
 * @param contractId
 *            the contract id
 */
public void deleteContract(final String linkId, final String contractId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.DELETE_CONTRACT);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.LINK_ID.getName(), linkId);
        params.put(RequestParams.CONTRACT_ID.getName(), contractId);
        urlDto.setParams(params);
        AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        authService.getResponse(urlDto, authDto, null);
    } catch (Exception e) {
        LOGGER.error("Error occurred while deleting contract: " + contractId, 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)

Aggregations

StoreIntegrationException (org.openkilda.integration.exception.StoreIntegrationException)10 IAuthService (org.openkilda.integration.auth.service.IAuthService)9 AuthConfigDto (org.openkilda.store.model.AuthConfigDto)9 UrlDto (org.openkilda.store.model.UrlDto)9 HashMap (java.util.HashMap)7 AccessDeniedException (java.nio.file.AccessDeniedException)1 IntegrationException (org.openkilda.integration.exception.IntegrationException)1 InvalidResponseException (org.openkilda.integration.exception.InvalidResponseException)1 InventorySwitch (org.openkilda.integration.source.store.dto.InventorySwitch)1 SwitchDiscrepancy (org.openkilda.model.SwitchDiscrepancy)1 SwitchInfo (org.openkilda.model.SwitchInfo)1 SwitchStatus (org.openkilda.model.SwitchStatus)1 RequestValidationException (org.usermanagement.exception.RequestValidationException)1 UserInfo (org.usermanagement.model.UserInfo)1