Search in sources :

Example 1 with DataNotFoundException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException in project carbon-apimgt by wso2.

the class FaultyRequestDataCollector method getFaultyEvent.

private Event getFaultyEvent() throws DataNotFoundException {
    long requestInTime = provider.getRequestTime();
    String offsetDateTime = getTimeInISO(requestInTime);
    Event event = new Event();
    API api = provider.getApi();
    Target target = new Target();
    target.setTargetResponseCode(Constants.UNKNOWN_INT_VALUE);
    MetaInfo metaInfo = provider.getMetaInfo();
    event.setApi(api);
    event.setTarget(target);
    event.setProxyResponseCode(provider.getProxyResponseCode());
    event.setRequestTimestamp(offsetDateTime);
    event.setMetaInfo(metaInfo);
    return event;
}
Also used : Target(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Target) MetaInfo(org.wso2.carbon.apimgt.common.analytics.publishers.dto.MetaInfo) Event(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Event) API(org.wso2.carbon.apimgt.common.analytics.publishers.dto.API)

Example 2 with DataNotFoundException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException in project carbon-apimgt by wso2.

the class WebSocketAnalyticsDataProvider method getApplication.

@Override
public Application getApplication() throws DataNotFoundException {
    AuthenticationContext authContext = getAuthenticationContext();
    if (authContext == null) {
        throw new DataNotFoundException("Error occurred when getting Application information");
    }
    Application application = new Application();
    application.setApplicationId(authContext.getApplicationUUID());
    application.setApplicationName(authContext.getApplicationName());
    application.setApplicationOwner(authContext.getSubscriber());
    application.setKeyType(authContext.getKeyType());
    return application;
}
Also used : DataNotFoundException(org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException) AuthenticationContext(org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext) Application(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Application)

Example 3 with DataNotFoundException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException in project carbon-apimgt by wso2.

the class SynapseAnalyticsDataProvider method getOperation.

@Override
public Operation getOperation() throws DataNotFoundException {
    String httpMethod = (String) messageContext.getProperty(APIMgtGatewayConstants.HTTP_METHOD);
    String apiResourceTemplate = (String) messageContext.getProperty(APIConstants.API_ELECTED_RESOURCE);
    Operation operation = new Operation();
    operation.setApiMethod(httpMethod);
    if (APIConstants.GRAPHQL_API.equalsIgnoreCase(getApi().getApiType())) {
        String orderedOperations = sortGraphQLOperations(apiResourceTemplate);
        operation.setApiResourceTemplate(orderedOperations);
    } else {
        operation.setApiResourceTemplate(apiResourceTemplate);
    }
    return operation;
}
Also used : Operation(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Operation)

Example 4 with DataNotFoundException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException in project carbon-apimgt by wso2.

the class SynapseAnalyticsDataProvider method getApi.

@Override
public API getApi() throws DataNotFoundException {
    String apiContext = (String) messageContext.getProperty(RESTConstants.REST_API_CONTEXT);
    String apiVersion = (String) messageContext.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION);
    String tenantDomain = MultitenantUtils.getTenantDomainFromRequestURL(apiContext);
    if (tenantDomain == null) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }
    SubscriptionDataStore store = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain);
    org.wso2.carbon.apimgt.keymgt.model.entity.API apiObj = store.getApiByContextAndVersion(apiContext, apiVersion);
    API api = new API();
    if (apiObj == null) {
        try {
            apiObj = new SubscriptionDataLoaderImpl().getApi(apiContext, apiVersion);
        } catch (DataLoadingException e) {
            log.error("Error occurred when getting api.", e);
            throw new DataNotFoundException("Error occurred when getting API information", e);
        }
    }
    if (apiObj != null) {
        api.setApiId(apiObj.getUuid());
        api.setApiType(apiObj.getApiType());
        api.setApiName(apiObj.getApiName());
        api.setApiVersion(apiObj.getApiVersion());
        api.setApiCreator(apiObj.getApiProvider());
        api.setApiCreatorTenantDomain(MultitenantUtils.getTenantDomain(api.getApiCreator()));
    }
    return api;
}
Also used : SubscriptionDataLoaderImpl(org.wso2.carbon.apimgt.keymgt.model.impl.SubscriptionDataLoaderImpl) DataLoadingException(org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException) DataNotFoundException(org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException) API(org.wso2.carbon.apimgt.common.analytics.publishers.dto.API) SubscriptionDataStore(org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore)

Example 5 with DataNotFoundException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException in project carbon-apimgt by wso2.

the class AsyncAnalyticsDataProvider method getOperation.

@Override
public Operation getOperation() throws DataNotFoundException {
    Operation operation = super.getOperation();
    Object eventPrefix = messageContext.getProperty(ASYNC_MESSAGE_TYPE);
    if (eventPrefix != null) {
        operation.setApiResourceTemplate(eventPrefix.toString() + operation.getApiResourceTemplate());
    }
    return operation;
}
Also used : Operation(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Operation)

Aggregations

DataNotFoundException (org.wso2.carbon.apimgt.common.analytics.exceptions.DataNotFoundException)3 API (org.wso2.carbon.apimgt.common.analytics.publishers.dto.API)2 Application (org.wso2.carbon.apimgt.common.analytics.publishers.dto.Application)2 Operation (org.wso2.carbon.apimgt.common.analytics.publishers.dto.Operation)2 AuthenticationContext (org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext)2 Event (org.wso2.carbon.apimgt.common.analytics.publishers.dto.Event)1 MetaInfo (org.wso2.carbon.apimgt.common.analytics.publishers.dto.MetaInfo)1 Target (org.wso2.carbon.apimgt.common.analytics.publishers.dto.Target)1 SubscriptionDataStore (org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore)1 DataLoadingException (org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException)1 SubscriptionDataLoaderImpl (org.wso2.carbon.apimgt.keymgt.model.impl.SubscriptionDataLoaderImpl)1