use of org.wso2.carbon.apimgt.core.models.policy.ThreatProtectionPolicy in project carbon-apimgt by wso2.
the class ThreatProtectionPoliciesApiServiceImpl method threatProtectionPoliciesPolicyIdGet.
/**
* Get a specific threat protection policy
*
* @param policyId ID of the policy to be retrieved
* @param request
* @return Threat protection policy
* @throws NotFoundException
*/
@Override
public Response threatProtectionPoliciesPolicyIdGet(String policyId, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
APIPublisher apiPublisher = RestAPIPublisherUtil.getApiPublisher(username);
ThreatProtectionPolicy policy = apiPublisher.getThreatProtectionPolicy(policyId);
if (policy == null) {
return Response.status(404).entity("Requested policy was not found.").build();
}
return Response.ok().entity(MappingUtil.toThreatProtectionPolicyDTO(policy)).build();
} catch (APIManagementException e) {
log.error(e.getMessage(), e);
}
return Response.status(500).entity("Internal Server Error.").build();
}
use of org.wso2.carbon.apimgt.core.models.policy.ThreatProtectionPolicy in project carbon-apimgt by wso2.
the class MappingUtil method toThreatProtectionPolicyDTO.
public static ThreatProtectionPolicyDTO toThreatProtectionPolicyDTO(ThreatProtectionPolicy policy) {
ThreatProtectionPolicyDTO dto = new ThreatProtectionPolicyDTO();
dto.setUuid(policy.getUuid());
dto.setType(policy.getType());
dto.setName(policy.getName());
dto.setPolicy(policy.getPolicy());
return dto;
}
Aggregations