@POST
@Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE)
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response udpateApplicationDescriptor(ApplicationDescriptor applicationDescriptor) {
AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
try {
String hostdescName = applicationDescriptor.getHostdescName();
if (!airavataRegistry.isHostDescriptorExists(hostdescName)) {
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
builder.entity("Host does not available...");
return builder.build();
}
ApplicationDescription applicationDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
ServiceDescriptor serviceDescriptor = applicationDescriptor.getServiceDescriptor();
String serviceName;
if (serviceDescriptor != null) {
if (serviceDescriptor.getServiceName() == null) {
serviceName = applicationDescriptor.getName();
serviceDescriptor.setServiceName(serviceName);
} else {
serviceName = serviceDescriptor.getServiceName();
}
// ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
// if (airavataRegistry.isServiceDescriptorExists(serviceName)) {
// airavataRegistry.updateServiceDescriptor(serviceDescription);
// } else {
// airavataRegistry.addServiceDescriptor(serviceDescription);
// }
} else {
serviceName = applicationDescriptor.getName();
}
airavataRegistry.updateApplicationDescriptor(serviceName, hostdescName, applicationDescription);
Response.ResponseBuilder builder = Response.status(Response.Status.OK);
builder.entity("Application descriptor updated successfully...");
return builder.build();
} catch (DescriptorAlreadyExistsException e) {
Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);