Package org.apache.airavata.persistance.registry.jpa.resources

Examples of org.apache.airavata.persistance.registry.jpa.resources.GatewayResource


  private ResourceUtils resourceUtils = new ResourceUtils();
  private WorkerResource workerResource;

  public JPAResourceAccessor(AiravataRegistry2 registry) {
    this.registry=registry;
    gatewayResource = new GatewayResource();
    gatewayResource.setGatewayName(this.registry.getGateway().getGatewayName());
    workerResource = new WorkerResource(registry.getUser().getUserName(), getGateway());
  }
View Full Code Here


                logger.error(e.getMessage(), e);
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
        }

        GatewayResource gatewayResource = new GatewayResource();
        gatewayResource.setGatewayName((String) properties.get(GATEWAY_ID));
        gatewayResource.setOwner((String) properties.get(GATEWAY_ID));
        gatewayResource.save();

        UserResource userResource1 = (UserResource) gatewayResource.create(ResourceType.USER);
        userResource1.setUserName((String) properties.get(REGISTRY_USER));
        userResource1.setPassword((String) properties.get(REGISTRY_PASSWORD));
        userResource1.save();

        UserResource userResource2 = (UserResource) gatewayResource.create(ResourceType.USER);
        userResource2.setUserName("testUser");
        userResource2.setPassword("testPassword");
        userResource2.save();

        WorkerResource workerResource1 = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
        workerResource1.setUser(userResource1.getUserName());
        workerResource1.save();

        WorkerResource workerResource2 = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
        workerResource2.setUser(userResource2.getUserName());
        workerResource2.save();

    }
View Full Code Here

                logger.error(e.getMessage(), e);
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
        }

        GatewayResource gatewayResource = new GatewayResource();
        gatewayResource.setGatewayName((String) properties.get(GATEWAY_ID));
        gatewayResource.setOwner((String) properties.get(GATEWAY_ID));
        gatewayResource.save();

        UserResource userResource = (UserResource) gatewayResource.create(ResourceType.USER);
        userResource.setUserName((String) properties.get(REGISTRY_USER));
        userResource.setPassword((String) properties.get(REGISTRY_PASSWORD));
        userResource.save();

        WorkerResource workerResource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
        workerResource.setUser(userResource.getUserName());
        workerResource.save();

    }
View Full Code Here

            } catch (SQLException e) {
                logger.error(e.getMessage(), e);
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
        }
        GatewayResource gatewayResource = new GatewayResource();
        gatewayResource.setGatewayName((String) properties.get(GATEWAY_ID));
        gatewayResource.setOwner((String) properties.get(GATEWAY_ID));
        gatewayResource.save();
        UserResource userResource = (UserResource) gatewayResource.create(ResourceType.USER);
        userResource.setUserName((String) properties.get(REGISTRY_USER));
        userResource.setPassword((String) properties.get(REGISTRY_PASSWORD));
        userResource.save();
        WorkerResource workerResource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
        workerResource.setUser(userResource.getUserName());
        workerResource.save();
    }
View Full Code Here

    }
    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();
        }
    }
View Full Code Here

    public void updateHostDescriptor(HostDescription descriptor) throws RegistryException {
        if (descriptorRegistry != null){
            descriptorRegistry.updateHostDescriptor(descriptor);
        } else {
            GatewayResource gateway = jpa.getGateway();
            String hostName = descriptor.getType().getHostName();
            if (!isHostDescriptorExists(hostName)){
                throw new DescriptorDoesNotExistsException(hostName);
            }
            HostDescriptorResource hostDescriptorResource = gateway.getHostDescriptorResource(hostName);
            hostDescriptorResource.setContent(descriptor.toXML());
            hostDescriptorResource.save();
        }
    }
View Full Code Here

    public HostDescription getHostDescriptor(String hostName) throws RegistryException {
        if (descriptorRegistry != null){
            return descriptorRegistry.getHostDescriptor(hostName);
        } else {
            GatewayResource gateway = jpa.getGateway();
            if (!isHostDescriptorExists(hostName)){
                return null;
            }
            HostDescriptorResource hostDescriptorResource = gateway.getHostDescriptorResource(hostName);
            return createHostDescriptor(hostDescriptorResource);
        }
    }
View Full Code Here

    public void removeHostDescriptor(String hostName) throws RegistryException {
        if (descriptorRegistry != null){
            descriptorRegistry.removeHostDescriptor(hostName);
        } else {
            GatewayResource gateway = jpa.getGateway();
            if (!isHostDescriptorExists(hostName)){
                throw new DescriptorDoesNotExistsException(hostName);
            }
            gateway.removeHostDescriptor(hostName);
            try {
                //we need to delete the application descriptors bound to this host
        Map<String, ApplicationDescription> applicationDescriptors = getApplicationDescriptorsFromHostName(hostName);
        for (String serviceName : applicationDescriptors.keySet()) {
          removeApplicationDescriptor(serviceName, hostName, applicationDescriptors.get(serviceName).getType().getApplicationName().getStringValue());
View Full Code Here

  public List<HostDescription> getHostDescriptors()
      throws MalformedDescriptorException, RegistryException {
        if (descriptorRegistry != null){
            return descriptorRegistry.getHostDescriptors();
        }
    GatewayResource gateway = jpa.getGateway();
    List<HostDescription> list=new ArrayList<HostDescription>();
    List<HostDescriptorResource> hostDescriptorResources = gateway.getHostDescriptorResources();
    for (HostDescriptorResource resource : hostDescriptorResources) {
      list.add(createHostDescriptor(resource));
    }
    return list;
  }
View Full Code Here

    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();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.persistance.registry.jpa.resources.GatewayResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.