use of com.hortonworks.streamline.common.exception.SchemaValidationFailedException in project streamline by hortonworks.
the class TopologyTestRunResource method validateTestRunCaseSource.
@POST
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources/{id}/validate")
@Timed
public Response validateTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("id") Long id, @Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologyTestRunCaseSource testCaseSource = catalogService.getTopologyTestRunCaseSource(testCaseId, id);
if (testCaseSource == null) {
throw EntityNotFoundException.byId(Long.toString(id));
}
try {
doValidationForTestRunCaseSource(topologyId, testCaseId, testCaseSource);
return WSUtils.respondEntity(Collections.singletonMap("status", "valid"), OK);
} catch (SchemaValidationFailedException e) {
throw handleSchemaValidationFailedException(topologyId, testCaseSource, e);
}
}
use of com.hortonworks.streamline.common.exception.SchemaValidationFailedException in project streamline by hortonworks.
the class TopologyTestRunResource method testRunTopology.
@POST
@Path("/topologies/{topologyId}/actions/testrun")
@Timed
public Response testRunTopology(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, TopologyTestRunParam topologyTestRunParam, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, EXECUTE);
Topology result = catalogService.getTopology(topologyId);
if (result != null) {
Long testCaseId = topologyTestRunParam.getTestCaseId();
Long durationSecs = topologyTestRunParam.getDurationSecs();
if (testCaseId == null) {
throw BadRequestException.missingParameter("testCaseId");
}
TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId);
if (testCase == null) {
throw EntityNotFoundException.byName("topology " + topologyId + " / topology test case " + testCaseId);
}
Collection<TopologyTestRunCaseSource> testCaseSources = catalogService.listTopologyTestRunCaseSource(testCaseId);
if (testCaseSources != null) {
for (TopologyTestRunCaseSource source : testCaseSources) {
try {
doValidationForTestRunCaseSource(topologyId, testCaseId, source);
} catch (SchemaValidationFailedException e) {
throw handleSchemaValidationFailedException(topologyId, source, e);
}
}
}
TopologyTestRunHistory history = actionsService.testRunTopology(result, testCase, durationSecs);
return WSUtils.respondEntity(history, OK);
}
throw EntityNotFoundException.byName("topology " + topologyId.toString());
}
Aggregations