descriptorRegistry.addApplicationDescriptor(serviceName, hostName, descriptor);
} else {
if (serviceName==null || hostName==null){
throw new InsufficientDataException("Service name or Host name cannot be null");
}
GatewayResource gateway = jpa.getGateway();
WorkerResource workerResource = jpa.getWorker();
String applicationName = descriptor.getType().getApplicationName().getStringValue();
applicationName = createAppName(serviceName, hostName, applicationName);
if (isApplicationDescriptorExists(serviceName,hostName,descriptor.getType().getApplicationName().getStringValue())){
throw new DescriptorAlreadyExistsException(applicationName);
}
ApplicationDescriptorResource applicationDescriptorResource = gateway.createApplicationDescriptorResource(applicationName);
applicationDescriptorResource.setUpdatedUser(workerResource.getUser());
applicationDescriptorResource.setServiceDescName(serviceName);
applicationDescriptorResource.setHostDescName(hostName);
applicationDescriptorResource.setContent(descriptor.toXML());
applicationDescriptorResource.save();