public void addHostDescriptor(HostDescription descriptor) throws RegistryException {
if (descriptorRegistry != null){
descriptorRegistry.addHostDescriptor(descriptor);
} else {
GatewayResource gateway = jpa.getGateway();
WorkerResource workerResource = jpa.getWorker();
String hostName = descriptor.getType().getHostName();
if (isHostDescriptorExists(hostName)){
throw new DescriptorAlreadyExistsException(hostName);
}
HostDescriptorResource hostDescriptorResource = gateway.createHostDescriptorResource(hostName);
hostDescriptorResource.setUserName(workerResource.getUser());
hostDescriptorResource.setContent(descriptor.toXML());
hostDescriptorResource.save();
}
}