Package org.platformlayer.xaas.services

Examples of org.platformlayer.xaas.services.ServiceProvider


  private JaxbHelper getJaxbHelper(DbHelper db, ServiceType serviceType, ItemType itemType) throws SQLException {
    if (serviceType == null || itemType == null) {
      throw new IllegalStateException();
    }

    ServiceProvider serviceProvider = serviceProviderDirectory.getServiceProvider(serviceType);
    if (serviceProvider == null) {
      throw new IllegalStateException("Cannot find service provider: " + serviceType);
    }

    ModelClass<?> modelClass = serviceProvider.getModelClass(itemType);
    if (modelClass == null) {
      throw new IllegalStateException();
    }

    JaxbHelper jaxbHelper = JaxbHelper.get(modelClass.getJavaClass());
View Full Code Here


  public ItemBase getManagedItem(PlatformLayerKey key, boolean fetchTags, SecretProvider secretProvider)
      throws RepositoryException {
    DbHelper db = new DbHelper(key);

    try {
      ServiceProvider serviceProvider = serviceProviderDirectory.getServiceProvider(key.getServiceType());
      if (serviceProvider == null) {
        throw new IllegalStateException();
      }

      ModelClass<?> modelClass = serviceProvider.getModelClass(key.getItemType());

      ServiceType serviceType = key.getServiceType();
      ItemType itemType = key.getItemType();
      ProjectId project = key.getProject();
      ManagedItemId itemId = key.getItemId();
View Full Code Here

      javaClasses.add(DeleteAction.class);
      javaClasses.add(BackupAction.class);

      for (ServiceInfo serviceInfo : serviceProviderDictionary.getAllServices()) {
        ServiceType serviceType = new ServiceType(serviceInfo.serviceType);
        ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProvider(serviceType);

        for (ModelClass<?> modelClass : serviceProvider.getModels().all()) {
          javaClasses.add(modelClass.getJavaClass());
          // String modelNamespace = modelClass.getJaxbHelper().getPrimaryNamespace();
          // if (namespace == null) {
          // namespace = modelNamespace;
          // } else if (!namespace.equals(modelNamespace)) {
          // throw new IllegalStateException();
          // }
        }

        for (Class<?> clazz : serviceProvider.getActions()) {
          javaClasses.add(clazz);
        }
      }

      try {
View Full Code Here

  public ManagedItemRepository getManagedItemRepository() {
    return managedItemRepository;
  }

  public Class<?> getJavaClass(PlatformLayerKey key) {
    ServiceProvider serviceProvider = getServiceProvider(key.getServiceType());
    return serviceProvider.getJavaClass(key.getItemType());
  }
View Full Code Here

    ServiceProvider serviceProvider = getServiceProvider(key.getServiceType());
    return serviceProvider.getJavaClass(key.getItemType());
  }

  public Class<?> getJavaClass(ModelKey key) {
    ServiceProvider serviceProvider = getServiceProvider(key.getServiceType());
    return serviceProvider.getJavaClass(key.getItemType());
  }
View Full Code Here

    }
  }

  protected ModelClass<?> getModelClass(ServiceType serviceType, ItemType itemType)
      throws PlatformLayerClientException {
    ServiceProvider serviceProvider = getServiceProvider(serviceType);
    if (serviceProvider == null) {
      log.warn("Unknown serviceType: " + serviceType);
      throw new PlatformLayerClientException("Service type not recognized: " + serviceType.getKey());
    }
    ModelClass<?> modelClass = serviceProvider.getModels().find(itemType);
    if (modelClass == null) {
      log.warn("Unknown itemtype: " + itemType);
      throw new PlatformLayerClientException("Item type not recognized: " + itemType.getKey());
    }
View Full Code Here

  private List<ModelClass<?>> findModelsProviding(Class<?> serviceClass) throws OpsException {
    List<ModelClass<?>> models = Lists.newArrayList();

    for (ServiceInfo service : serviceProviderDictionary.getAllServices()) {
      ServiceType serviceType = new ServiceType(service.getServiceType());
      ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProvider(serviceType);
      for (ModelClass<?> model : serviceProvider.getModels().all()) {
        Class<?> controllerClass = serviceProvider.getControllerClass(model.getJavaClass());
        if (serviceClass.isAssignableFrom(controllerClass)) {
          models.add(model);
        }
      }
    }
View Full Code Here

      final ProjectAuthorization project = activeJob.getProjectAuthorization();

      final OpsContext opsContext = opsContextBuilder.buildOpsContext(activeJob);

      final ServiceType serviceType = activeJob.getServiceType();
      final ServiceProvider serviceProvider = opsSystem.getServiceProvider(serviceType);

      try {
        return OpsContext.runInContext(opsContext, new CheckedCallable<Object, Exception>() {
          @Override
          public Object call() throws Exception {
            log.info("Starting job");
            activeJob.setState(JobState.RUNNING);

            ItemBase item;
            ManagedItemRepository repository = opsSystem.getManagedItemRepository();
            try {
              boolean fetchTags = true;
              item = repository.getManagedItem(targetItemKey, fetchTags, SecretProvider.from(project));
            } catch (RepositoryException e) {
              throw new OpsException("Error reading item from repository", e);
            }

            if (item == null) {
              throw new WebApplicationException(404);
            }

            List<Object> scopeItems = Lists.newArrayList();

            addActionScopeItems(action, item, scopeItems);

            Object controller = serviceProvider.getController(item);

            scopeItems.add(item);
            scopeItems.add(action);

            BindingScope scope = BindingScope.push(scopeItems);
View Full Code Here

  public <T extends ItemBase> List<ModelClass<? extends T>> getModelSubclasses(Class<T> parent) {
    List<ModelClass<? extends T>> modelClasses = Lists.newArrayList();

    for (ServiceInfo serviceInfo : serviceProviderDictionary.getAllServices()) {
      ServiceType serviceType = new ServiceType(serviceInfo.serviceType);
      ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProvider(serviceType);

      for (ModelClass<?> modelClass : serviceProvider.getModels().all()) {
        Class<?> javaClass = modelClass.getJavaClass();
        if (parent.isAssignableFrom(javaClass)) {
          modelClasses.add((ModelClass<? extends T>) modelClass);
        }
      }
View Full Code Here

    ModelClass<?> modelClass = serviceProviderDictionary.getModelClass(itemType);
    return modelClass.getServiceType();
  }

  public ModelClass<?> getModelClass(String namespaceUri, String nodeName) {
    ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProviderForNamespace(namespaceUri);

    if (serviceProvider == null) {
      throw new IllegalArgumentException("Unknown namespace: " + namespaceUri);
    }

    ModelClass<?> modelClass = null;
    for (ModelClass<?> modelClassCandidate : serviceProvider.getModels().all()) {
      if (nodeName.equals(modelClassCandidate.getXmlElementName())) {
        modelClass = modelClassCandidate;
        break;
      }
    }
View Full Code Here

TOP

Related Classes of org.platformlayer.xaas.services.ServiceProvider

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.