use of org.apache.knox.gateway.services.topology.TopologyService in project knox by apache.
the class TopologiesResource method uploadSimpleDescriptor.
@PUT
@Consumes({ APPLICATION_JSON, TEXT_PLAIN })
@Path(SINGLE_DESCRIPTOR_API_PATH)
public Response uploadSimpleDescriptor(@PathParam("name") String name, @Context HttpHeaders headers, String content) {
Response response = null;
GatewayServices gs = (GatewayServices) request.getServletContext().getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
TopologyService ts = gs.getService(GatewayServices.TOPOLOGY_SERVICE);
File existing = getExistingConfigFile(ts.getDescriptors(), name);
boolean isUpdate = (existing != null);
// If it's an update, then use the matching existing filename; otherwise, use the media type to determine the file
// extension.
String filename = isUpdate ? existing.getName() : getFileNameForResource(name, headers);
if (ts.deployDescriptor(filename, content)) {
try {
if (isUpdate) {
response = Response.noContent().build();
} else {
response = created(new URI(buildHref(request))).build();
}
} catch (URISyntaxException e) {
log.invalidResourceURI(e.getInput(), e.getReason(), e);
response = status(Response.Status.BAD_REQUEST).entity("{ \"error\" : \"Failed to deploy descriptor " + name + "\" }").build();
}
}
return response;
}
use of org.apache.knox.gateway.services.topology.TopologyService in project knox by apache.
the class GatewayServer method redeployTopologies.
public static void redeployTopologies(String topologyName) {
TopologyService ts = getGatewayServices().getService(GatewayServices.TOPOLOGY_SERVICE);
ts.reloadTopologies();
ts.redeployTopologies(topologyName);
}
use of org.apache.knox.gateway.services.topology.TopologyService in project knox by apache.
the class GatewayServer method cleanupTopologyDeployments.
private void cleanupTopologyDeployments() {
File deployDir = new File(config.getGatewayDeploymentDir());
TopologyService ts = getGatewayServices().getService(GatewayServices.TOPOLOGY_SERVICE);
for (Topology topology : ts.getTopologies()) {
cleanupTopologyDeployments(deployDir, topology);
}
}
Aggregations