fix put disk

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2026-03-02 17:03:43 +05:30
parent 824b05ff0c
commit eac69435b1
2 changed files with 20 additions and 4 deletions

View File

@ -78,8 +78,9 @@ public class DisksRouteHandler extends ManagerBase implements RouteHandler {
if (CollectionUtils.isNotEmpty(idAndSubPath)) {
String id = idAndSubPath.get(0);
if (idAndSubPath.size() == 1) {
if (!"GET".equalsIgnoreCase(method) && !"DELETE".equalsIgnoreCase(method)) {
io.methodNotAllowed(resp, "GET, DELETE", outFormat);
if (!"GET".equalsIgnoreCase(method) && !"DELETE".equalsIgnoreCase(method) &&
!"PUT".equalsIgnoreCase(method)) {
io.methodNotAllowed(resp, "GET, DELETE, PUT", outFormat);
return;
}
if ("GET".equalsIgnoreCase(method)) {
@ -90,6 +91,10 @@ public class DisksRouteHandler extends ManagerBase implements RouteHandler {
handleDeleteById(id, resp, outFormat, io);
return;
}
if ("PUT".equalsIgnoreCase(method)) {
handlePutById(id, req, resp, outFormat, io);
return;
}
} else if (idAndSubPath.size() == 2) {
String subPath = idAndSubPath.get(1);
if ("copy".equals(subPath)) {
@ -123,7 +128,6 @@ public class DisksRouteHandler extends ManagerBase implements RouteHandler {
protected void handlePost(final HttpServletRequest req, final HttpServletResponse resp,
Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException {
String data = RouteHandler.getRequestData(req, logger);
logger.info("Received POST request on /api/disks endpoint. Request-data: {}", data); // ToDo: remove
try {
Disk request = io.getMapper().jsonMapper().readValue(data, Disk.class);
Disk response = serverAdapter.handleCreateDisk(request);
@ -153,6 +157,19 @@ public class DisksRouteHandler extends ManagerBase implements RouteHandler {
}
}
protected void handlePutById(final String id, final HttpServletRequest req, final HttpServletResponse resp,
final Negotiation.OutFormat outFormat, final VeeamControlServlet io) throws IOException {
String data = RouteHandler.getRequestData(req, logger);
try {
// ToDo: do what?
// serverAdapter.deleteDisk(id);
Disk response = serverAdapter.getDisk(id);
io.getWriter().write(resp, HttpServletResponse.SC_OK, response, outFormat);
} catch (InvalidParameterValueException e) {
io.badRequest(resp, e.getMessage(), outFormat);
}
}
protected void handlePostDiskCopy(final String id, final HttpServletRequest req, final HttpServletResponse resp,
final Negotiation.OutFormat outFormat, final VeeamControlServlet io) throws IOException {
try {

View File

@ -333,7 +333,6 @@ public class VmsRouteHandler extends ManagerBase implements RouteHandler {
protected void handleUpdateById(final String id, final HttpServletRequest req, final HttpServletResponse resp, final Negotiation.OutFormat outFormat,
final VeeamControlServlet io) throws IOException {
String data = RouteHandler.getRequestData(req, logger);
logger.info("Received PUT request. Request-data: {}", data);
try {
Vm request = io.getMapper().jsonMapper().readValue(data, Vm.class);
Vm response = serverAdapter.updateInstance(id, request);