use of org.wso2.msf4j.Request in project carbon-apimgt by wso2.
the class EndpointsApiServiceImplTestCase method getRequest.
private Request getRequest() throws Exception {
HTTPCarbonMessage carbonMessage = Mockito.mock(HTTPCarbonMessage.class);
Request request = new Request(carbonMessage);
PowerMockito.whenNew(Request.class).withArguments(carbonMessage).thenReturn(request);
return request;
}
use of org.wso2.msf4j.Request in project carbon-apimgt by wso2.
the class GatewaysApiServiceImplTestCase method getRequest.
private Request getRequest() throws Exception {
HTTPCarbonMessage carbonMessage = Mockito.mock(HTTPCarbonMessage.class);
Request request = new Request(carbonMessage);
PowerMockito.whenNew(Request.class).withArguments(carbonMessage).thenReturn(request);
return request;
}
use of org.wso2.msf4j.Request in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTestCase method getRequest.
private Request getRequest() throws Exception {
HTTPCarbonMessage carbonMessage = Mockito.mock(HTTPCarbonMessage.class);
Request request = new Request(carbonMessage);
PowerMockito.whenNew(Request.class).withArguments(carbonMessage).thenReturn(request);
return request;
}
use of org.wso2.msf4j.Request in project carbon-apimgt by wso2.
the class ThreatProtectionApiServiceImplTestCase method getRequest.
private Request getRequest() throws Exception {
HTTPCarbonMessage carbonMessage = Mockito.mock(HTTPCarbonMessage.class);
Request request = new Request(carbonMessage);
PowerMockito.whenNew(Request.class).withArguments(carbonMessage).thenReturn(request);
return request;
}
use of org.wso2.msf4j.Request in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method apisApiIdThreatProtectionPoliciesPost.
/**
* Add a threat protection policy to an API
* @param apiId APIID
* @param policyId Threat protection policy id
* @param request MSF4J Request
* @return HTTP status 200 if success, 500 otherwise
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response apisApiIdThreatProtectionPoliciesPost(String apiId, String policyId, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
APIPublisher apiPublisher = RestAPIPublisherUtil.getApiPublisher(username);
if (!apiPublisher.isAPIExists(apiId)) {
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setCode(404l);
errorDTO.setDescription("Specified API was not found");
return Response.status(404).entity(errorDTO).build();
}
apiPublisher.addThreatProtectionPolicy(apiId, policyId);
return Response.ok().build();
} catch (APIManagementException e) {
log.error(e.getMessage(), e);
return Response.status(500).entity("Internal Server Error.").build();
}
}
Aggregations