use of org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeyManagersApiServiceImpl method keyManagersKeyManagerIdDelete.
public Response keyManagersKeyManagerIdDelete(String keyManagerId, MessageContext messageContext) throws APIManagementException {
String organization = RestApiUtil.getOrganization(messageContext);
APIAdmin apiAdmin = new APIAdminImpl();
KeyManagerConfigurationDTO keyManagerConfigurationDTO = apiAdmin.getKeyManagerConfigurationById(organization, keyManagerId);
if (keyManagerConfigurationDTO != null) {
apiAdmin.deleteKeyManagerConfigurationById(organization, keyManagerConfigurationDTO);
APIUtil.logAuditMessage(APIConstants.AuditLogConstants.KEY_MANAGER, new Gson().toJson(keyManagerConfigurationDTO), APIConstants.AuditLogConstants.DELETED, RestApiCommonUtil.getLoggedInUsername());
return Response.ok().build();
} else {
throw new APIManagementException("Requested KeyManager not found", ExceptionCodes.KEY_MANAGER_NOT_FOUND);
}
}
use of org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeyManagersApiServiceImpl method keyManagersPost.
public Response keyManagersPost(KeyManagerDTO body, MessageContext messageContext) throws APIManagementException {
String organization = RestApiUtil.getOrganization(messageContext);
APIAdmin apiAdmin = new APIAdminImpl();
try {
KeyManagerConfigurationDTO keyManagerConfigurationDTO = KeyManagerMappingUtil.toKeyManagerConfigurationDTO(organization, body);
KeyManagerConfigurationDTO createdKeyManagerConfiguration = apiAdmin.addKeyManagerConfiguration(keyManagerConfigurationDTO);
APIUtil.logAuditMessage(APIConstants.AuditLogConstants.KEY_MANAGER, new Gson().toJson(keyManagerConfigurationDTO), APIConstants.AuditLogConstants.CREATED, RestApiCommonUtil.getLoggedInUsername());
URI location = new URI(RestApiConstants.KEY_MANAGERS + "/" + createdKeyManagerConfiguration.getUuid());
return Response.created(location).entity(KeyManagerMappingUtil.toKeyManagerDTO(createdKeyManagerConfiguration)).build();
} catch (URISyntaxException e) {
String error = "Error while Creating Key Manager configuration in organization " + organization;
throw new APIManagementException(error, e, ExceptionCodes.INTERNAL_ERROR);
}
}
Aggregations