use of org.springframework.web.bind.annotation.ResponseStatus in project spring-framework by spring-projects.
the class ServletInvocableHandlerMethod method initResponseStatus.
private void initResponseStatus() {
ResponseStatus annotation = getMethodAnnotation(ResponseStatus.class);
if (annotation == null) {
annotation = AnnotatedElementUtils.findMergedAnnotation(getBeanType(), ResponseStatus.class);
}
if (annotation != null) {
this.responseStatus = annotation.code();
this.responseReason = annotation.reason();
}
}
use of org.springframework.web.bind.annotation.ResponseStatus in project symmetric-ds by JumpMind.
the class RestService method getSnapshot.
/**
* Takes a snapshot for the specified engine and streams it to the client.
*/
@ApiOperation(value = "Take a diagnostic snapshot for the specified engine")
@RequestMapping(value = "engine/{engine}/snapshot", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final void getSnapshot(@PathVariable("engine") String engineName, HttpServletResponse resp) {
BufferedInputStream bis = null;
try {
ISymmetricEngine engine = getSymmetricEngine(engineName);
File file = engine.snapshot();
resp.setHeader("Content-Disposition", String.format("attachment; filename=%s", file.getName()));
bis = new BufferedInputStream(new FileInputStream(file));
IOUtils.copy(bis, resp.getOutputStream());
} catch (IOException e) {
throw new IoException(e);
} finally {
IOUtils.closeQuietly(bis);
}
}
use of org.springframework.web.bind.annotation.ResponseStatus in project symmetric-ds by JumpMind.
the class RestService method getOutgoingBatchSummary.
@ApiOperation(value = "Outgoing summary of batches and data counts waiting for a node")
@RequestMapping(value = "/engine/{engine}/outgoingBatchSummary", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final BatchSummaries getOutgoingBatchSummary(@PathVariable("engine") String engineName, @RequestParam(value = WebConstants.NODE_ID) String nodeId, @ApiParam(value = "This the password for the nodeId being passed in. The password is stored in the node_security table.") @RequestParam(value = WebConstants.SECURITY_TOKEN) String securityToken) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
if (securityVerified(nodeId, engine, securityToken)) {
BatchSummaries summaries = new BatchSummaries();
summaries.setNodeId(nodeId);
IOutgoingBatchService outgoingBatchService = engine.getOutgoingBatchService();
List<OutgoingBatchSummary> list = outgoingBatchService.findOutgoingBatchSummary(OutgoingBatch.Status.RQ, OutgoingBatch.Status.QY, OutgoingBatch.Status.NE, OutgoingBatch.Status.SE, OutgoingBatch.Status.LD, OutgoingBatch.Status.ER);
for (OutgoingBatchSummary sum : list) {
if (sum.getNodeId().equals(nodeId)) {
BatchSummary summary = new BatchSummary();
summary.setBatchCount(sum.getBatchCount());
summary.setDataCount(sum.getDataCount());
summary.setOldestBatchCreateTime(sum.getOldestBatchCreateTime());
summary.setStatus(sum.getStatus().name());
summaries.getBatchSummaries().add(summary);
}
}
return summaries;
} else {
throw new NotAllowedException();
}
}
use of org.springframework.web.bind.annotation.ResponseStatus in project symmetric-ds by JumpMind.
the class RestService method postInstall.
/**
* Installs and starts a new node
*
* @param file
* A file stream that contains the node's properties.
*/
@ApiOperation(value = "Load a configuration file to the single engine")
@RequestMapping(value = "engine/install", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public final void postInstall(@RequestParam MultipartFile file) {
try {
Properties properties = new Properties();
properties.load(file.getInputStream());
getSymmetricEngineHolder().install(properties);
} catch (RuntimeException ex) {
throw ex;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.springframework.web.bind.annotation.ResponseStatus in project symmetric-ds by JumpMind.
the class RestService method postRequestInitialLoad.
/**
* Requests an initial load from the server for the node id provided. The
* initial load requst directs the server to queue up initial load data for
* the client node. Data is obtained for the initial load by the client
* calling the pull method.
*
* @param nodeID
*/
@ApiOperation(value = "Request an initial load for the specified node for the specified engine")
@RequestMapping(value = "/engine/{engine}/requestinitialload", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public final void postRequestInitialLoad(@PathVariable("engine") String engineName, @RequestParam(value = "nodeId") String nodeId) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
INodeService nodeService = engine.getNodeService();
nodeService.setInitialLoadEnabled(nodeId, true, false, -1, "restapi");
}
Aggregations