public void addServiceDescriptor(ServiceDescription descriptor) throws RegistryException {
if (descriptorRegistry != null) {
descriptorRegistry.addServiceDescriptor(descriptor);
}else {
GatewayResource gateway = jpa.getGateway();
WorkerResource workerResource = jpa.getWorker();
String serviceName = descriptor.getType().getName();
if (isServiceDescriptorExists(serviceName)){
throw new DescriptorAlreadyExistsException(serviceName);
}
ServiceDescriptorResource serviceDescriptorResource = gateway.createServiceDescriptorResource(serviceName);
serviceDescriptorResource.setUserName(workerResource.getUser());
serviceDescriptorResource.setContent(descriptor.toXML());
serviceDescriptorResource.save();
}
}