log.info("Inside ApiKeysRestService.getAllApiKeys");
try {
- apiKeyService.getAllApiKeys(getDmaapContext());
+ apiKeyService.getAllApiKeys(ServiceUtil.getDMaaPContext(configReader, request, response));
log.info("Fetching all API keys is Successful");
} catch (ConfigDbException | IOException e) {
log.error("Error while retrieving API keys: " + e);
log.info("Fetching details of api key: " + apiKeyName);
try {
- apiKeyService.getApiKey(getDmaapContext(), apiKeyName);
+ apiKeyService.getApiKey(ServiceUtil.getDMaaPContext(configReader, request, response), apiKeyName);
log.info("Fetching specific API key is Successful");
} catch (ConfigDbException | IOException e) {
log.error("Error while retrieving API key details: " + e);
log.info("Creating Api Key.");
try {
- apiKeyService.createApiKey(getDmaapContext(), nsaApiKey);
+ apiKeyService.createApiKey(ServiceUtil.getDMaaPContext(configReader, request, response), nsaApiKey);
log.info("Creating API key is Successful");
} catch (KeyExistsException | ConfigDbException | IOException e) {
log.error("Error while Creating API key : " + e.getMessage(), e);
try {
apiKeyService
- .updateApiKey(getDmaapContext(), apiKeyName, nsaApiKey);
+ .updateApiKey(ServiceUtil.getDMaaPContext(configReader, request, response), apiKeyName, nsaApiKey);
log.error("API key updated sucessfully");
} catch (ConfigDbException | IOException | AccessDeniedException e) {
log.error("Error while Updating API key : " + apiKeyName, e);
public void deleteApiKey(@PathParam("apiKey") String apiKeyName) throws CambriaApiException {
log.info("Deleting Api Key: " + apiKeyName);
try {
- apiKeyService.deleteApiKey(getDmaapContext(), apiKeyName);
+ apiKeyService.deleteApiKey(ServiceUtil.getDMaaPContext(configReader, request, response), apiKeyName);
log.info("Api Key deleted successfully: " + apiKeyName);
} catch (ConfigDbException | IOException | AccessDeniedException e) {
log.error("Error while deleting API key : " + apiKeyName, e);
}
}
- /**
- * Create a dmaap context
- * @return DMaaPContext
- */
- private DMaaPContext getDmaapContext() {
- DMaaPContext dmaapContext = new DMaaPContext();
- dmaapContext.setConfigReader(configReader);
- dmaapContext.setRequest(request);
- dmaapContext.setResponse(response);
- return dmaapContext;
- }
}
\ No newline at end of file