@ApiOperation(
value = "Update a script of a VNF Package",
notes = "The updated script has to be passed in the Request Body")
@RequestMapping(
value = "{id}/scripts/{scriptId}",
method = RequestMethod.PUT,
produces = MediaType.TEXT_PLAIN_VALUE,
consumes = MediaType.TEXT_PLAIN_VALUE)
public String updateScript(
@PathVariable("id") String vnfPackageId,
@PathVariable("scriptId") String scriptId,
@RequestBody String scriptNew,
@RequestHeader(value = "project-id") String projectId)
throws NotFoundException, BadFormatException, ExecutionException, InterruptedException {
VNFPackage vnfPackage = vnfPackageManagement.query(vnfPackageId, projectId);
if (vnfPackage == null)
throw new NotFoundException("No VNFPackage found with ID " + vnfPackageId);
for (Script script : vnfPackage.getScripts()) {
if (script.getId().equals(scriptId)) {
script.setPayload(scriptNew.getBytes());
script = vnfPackageManagement.updateScript(script, vnfPackageId);
return new String(script.getPayload());
}
}
throw new NotFoundException(
"Script with id " + scriptId + " was not found into package with id " + vnfPackageId);
}