/** * Checks the API unique identifier against what this contract expects (org id, id, version). * Returns true if they match. * @param request the request * @return true if the given request matches this contract */ public boolean matches(ApiRequest request) { String apiOrgId = request.getApiOrgId(); String apiId = request.getApiId(); String apiVersion = request.getApiVersion(); return matches(apiOrgId, apiId, apiVersion); }
/** * @see io.apiman.gateway.engine.components.IPolicyFailureFactoryComponent#createFailure(io.apiman.gateway.engine.beans.PolicyFailureType, int, java.lang.String) */ @Override public PolicyFailure createFailure(PolicyFailureType type, int failureCode, String message) { PolicyFailure failure = new PolicyFailure(); // TODO pool failure.setFailureCode(failureCode); failure.setMessage(message); failure.setType(type); return failure; } }
/** * Constructor. * @param failure */ public PolicyFailureError(PolicyFailure failure) { super(failure.getMessage()); this.failure = failure; }
/** * Generates an in-memory key for an api, used to index the client for later quick * retrieval. * @param api an api * @return a api key */ private String getApiIndex(Api api) { return getApiIndex(api.getOrganizationId(), api.getApiId(), api.getVersion()); }
/** * Generates an in-memory key for an application, used to index the app for later quick * retrieval. * @param app an application * @return an application key */ private String getApplicationKey(Application app) { return app.getOrganizationId() + "|" + app.getApplicationId() + "|" + app.getVersion(); //$NON-NLS-1$ //$NON-NLS-2$ } }
/** * Resolve property replacements for list of policies */ private void resolvePropertyReplacements(List<Policy> apiPolicies) { if (apiPolicies != null) { for (Policy policy : apiPolicies) { String config = policy.getPolicyJsonConfig(); config = resolveProperties(config); policy.setPolicyJsonConfig(config); } } }
/** * Generates a valid document ID for the client - used to index the client in ES. * @param client * @return an id */ protected String getClientId(Client client) { return client.getApiKey(); }
public int code() { return response.getCode(); }
/** * @see io.apiman.gateway.engine.components.IPolicyFailureFactoryComponent#createFailure(io.apiman.gateway.engine.beans.PolicyFailureType, int, java.lang.String) */ @Override public PolicyFailure createFailure(PolicyFailureType type, int failureCode, String message) { PolicyFailure failure = new PolicyFailure(type, failureCode, message); return failure; }
public HeaderMap headers() { return response.getHeaders(); }
/** * Constructor. * @param api the api * @param client the client * @param plan the plan * @param policies the list of policies */ public ApiContract(Api api, Client client, String plan, List<Policy> policies) { setApi(api); setClient(client); setPlan(plan); setPolicies(policies); }
/** * @param error */ protected EngineErrorResponse createErrorResponse(Throwable error, String message, int statusCode) { EngineErrorResponse eer = new EngineErrorResponse(); eer.setResponseCode(statusCode); eer.setMessage(message); return eer; }
@SuppressWarnings("nls") @Override public String toString() { final int maxLen = 10; return "Client [organizationId=" + organizationId + ", clientId=" + clientId + ", version=" + version + ", contracts=" + (contracts != null ? toString(contracts, maxLen) : null) + "]"; }
@SuppressWarnings("nls") @Override public String toString() { final int maxLen = 10; return "API [publicAPI=" + publicAPI + ", organizationId=" + organizationId + ", apiId=" + apiId + ", version=" + version + ", endpointType=" + endpointType + ", endpoint=" + endpoint + ", endpointProperties=" + (endpointProperties != null ? toString(endpointProperties.entrySet(), maxLen) : null) + ", apiPolicies=" + (apiPolicies != null ? toString(apiPolicies, maxLen) : null) + ", parsePayload=" + parsePayload + "]"; }
/** * Generates a valid document ID for the client - used to index the client in ES. * @param client * @return an id */ protected String getClientId(Client client) { return client.getApiKey(); }
public int code() { return response.getCode(); }
/** * @see io.apiman.gateway.engine.components.IPolicyFailureFactoryComponent#createFailure(io.apiman.gateway.engine.beans.PolicyFailureType, int, java.lang.String) */ @Override public PolicyFailure createFailure(PolicyFailureType type, int failureCode, String message) { PolicyFailure failure = new PolicyFailure(type, failureCode, message); return failure; }
public HeaderMap headers() { return response.getHeaders(); }
/** * Constructor. * @param failure */ public PolicyFailureError(PolicyFailure failure) { super(failure.getMessage()); this.failure = failure; }
/** * @param error */ protected EngineErrorResponse createErrorResponse(Throwable error, String message, int statusCode) { EngineErrorResponse eer = new EngineErrorResponse(); eer.setResponseCode(statusCode); eer.setMessage(message); return eer; }