Search in sources :

Example 6 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException 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 StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException 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 StoreIntegrationException

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

the class SwitchService method getSwitch.

/**
 * get All SwitchList.
 *
 * @return SwitchRelationData the switch info
 * @throws IntegrationException the integration exception
 */
public SwitchInfo getSwitch(final String switchId, boolean controller) throws IntegrationException {
    SwitchInfo switchInfo = null;
    try {
        switchInfo = switchIntegrationService.getSwitchesById(switchId);
    } catch (InvalidResponseException ex) {
        LOGGER.error("Error occurred while retrieving switches from controller", ex);
    }
    if (!controller) {
        try {
            UserInfo userInfo = userService.getLoggedInUserInfo();
            if (userInfo.getPermissions().contains(IConstants.Permission.SW_SWITCH_INVENTORY)) {
                if (storeService.getSwitchStoreConfig().getUrls().size() > 0) {
                    InventorySwitch inventorySwitch = switchStoreService.getSwitch(switchId);
                    if (inventorySwitch.getSwitchId() != null) {
                        switchInfo = processInventorySwitch(switchInfo, inventorySwitch);
                    } else {
                        SwitchDiscrepancy discrepancy = new SwitchDiscrepancy();
                        discrepancy.setControllerDiscrepancy(false);
                        discrepancy.setStatus(true);
                        discrepancy.setInventoryDiscrepancy(true);
                        SwitchStatus switchState = new SwitchStatus();
                        switchState.setControllerStatus(switchInfo.getState());
                        discrepancy.setStatusValue(switchState);
                        switchInfo.setDiscrepancy(discrepancy);
                    }
                }
            }
        } catch (Exception ex) {
            LOGGER.error("Error occurred while retrieving switches from store", ex);
            throw new StoreIntegrationException("Error occurred while retrieving switches from store");
        }
    }
    return switchInfo;
}
Also used : InventorySwitch(org.openkilda.integration.source.store.dto.InventorySwitch) SwitchDiscrepancy(org.openkilda.model.SwitchDiscrepancy) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) UserInfo(org.usermanagement.model.UserInfo) SwitchInfo(org.openkilda.model.SwitchInfo) InvalidResponseException(org.openkilda.integration.exception.InvalidResponseException) SwitchStatus(org.openkilda.model.SwitchStatus) InvalidResponseException(org.openkilda.integration.exception.InvalidResponseException) IntegrationException(org.openkilda.integration.exception.IntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) RequestValidationException(org.usermanagement.exception.RequestValidationException) AccessDeniedException(java.nio.file.AccessDeniedException)

Example 9 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException 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);
    }
}
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 10 with StoreIntegrationException

use of org.openkilda.integration.exception.StoreIntegrationException 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);
    }
}
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