Package org.platformlayer.ids

Examples of org.platformlayer.ids.ProjectId


    MultitenantConfiguration multitenant = opsSystem.getMultitenantConfiguration();
    if (multitenant != null) {
      runAsProject = multitenant.getMasterProject();
    }

    ProjectId runAsProjectId = new ProjectId(runAsProject.getName());
    return runAsProjectId;
  }
View Full Code Here


    if (multitenant != null) {
      ProjectAuthorization localProject = projectAuthz; // .getProject();
      TypedPlatformLayerClient localClient = buildClient(localProject);

      FederationKey host = FederationKey.LOCAL;
      ProjectId project = localClient.getProject();
      FederationMapping mapKey = new FederationMapping(host, project);

      federationMap.addMapping(mapKey, localClient);

      for (PlatformLayerKey mappedService : multitenant.getMappedItems()) {
        FederationMap.Rule rule = new FederationMap.Rule();
        rule.mappedItems = mappedService;
        rule.targetKey = mapKey;
        federationMap.addRule(rule);
      }
    }

    ProjectId runAsProjectId = new ProjectId(runAsProject.getName());

    PlatformLayerClient platformLayerClient;
    if (federationMap.isEmpty()) {
      platformLayerClient = defaultClient;
    } else {
View Full Code Here

  public Class<?> getJavaClass(PlatformLayerKey key) {
    return opsSystem.getJavaClass(key);
  }

  private TypedPlatformLayerClient buildClient(ProjectAuthorization project) throws OpsException {
    ProjectId projectId = new ProjectId(project.getName());

    DirectAuthenticator directAuthenticator = buildDirectAuthenticator(project);
    // TODO: Introduce a direct client for "loopback" (normal) calls?
    String platformLayerUrl = OpsSystem.getPlatformLayerUrlBase();
    List<String> trustKeys = opsSystem.getServerTrustKeys();
View Full Code Here

    String secret = config.secret;
    List<String> authTrustKeys = config.authTrustKeys;

    Authenticator authenticator = new PlatformlayerAuthenticator(httpStrategy, username, secret, server,
        authTrustKeys);
    ProjectId projectId = new ProjectId(project);

    return build(httpStrategy, config.platformlayerEndpoint, authenticator, projectId,
        config.platformlayerTrustKeys);
  }
View Full Code Here

    ServiceType serviceType = new ServiceType(service.getServiceType());
    ItemType itemType = new ItemType(nodeName);

    FederationKey host = null;
    ProjectId project = null;
    return new PlatformLayerKey(host, project, serviceType, itemType, id);
  }
View Full Code Here

    if (components.size() < 4) {
      throw new IllegalArgumentException();
    }

    String componentProject = components.get(0);
    ProjectId project = !Strings.isNullOrEmpty(componentProject) ? new ProjectId(componentProject) : null;

    String serviceComponent = components.get(1);
    ServiceType serviceType = !Strings.isNullOrEmpty(serviceComponent) ? new ServiceType(serviceComponent) : null;

    ItemType itemType = new ItemType(components.get(2));
View Full Code Here

    return new PlatformLayerKey(null, null, new ServiceType(serviceType), ItemType.wrap(itemType), null);
  }

  public static PlatformLayerKey build(String host, String project, String serviceType, String itemType, String itemId) {
    FederationKey federationKey = host != null ? FederationKey.build(host) : null;
    ProjectId projectKey = project != null ? new ProjectId(project) : null;
    ServiceType serviceKey = serviceType != null ? new ServiceType(serviceType) : null;
    ItemType itemKey = itemType != null ? new ItemType(itemType) : null;
    ManagedItemId idKey = itemId != null ? new ManagedItemId(itemId) : null;

    return new PlatformLayerKey(federationKey, projectKey, serviceKey, itemKey, idKey);
View Full Code Here

    // Note that we have a different notion of project id from the auth system
    // TODO: I think this is not needed for direct authentication? Fix? Cleanup?
    authz = new XaasProjectAuthorization(repository, authz);

    getScope().put(new ProjectId(projectKey));
    getScope().put(ProjectAuthorization.class, authz);

    ServicesCollectionResource resources = objectInjector.getInstance(ServicesCollectionResource.class);
    return resources;
  }
View Full Code Here

    // }
    // }

    // Class<T> javaClass = modelClass.getJavaClass();

    ProjectId project = getProjectId(authentication);

    // ModelKey modelKey = new ModelKey(modelClass.getServiceType(), modelClass.getItemType(), project, null);

    // if (isSystemObject(modelKey)) {
    // checkLoggedInAsAdmin();
View Full Code Here

        // id = UUID.randomUUID().toString();
        // item.setId(id);
      }
    }

    ProjectId project = getProjectId(auth);
    PlatformLayerKey itemKey = new PlatformLayerKey(null, project, modelClass.getServiceType(),
        modelClass.getItemType(), new ManagedItemId(id));
    item.setKey(itemKey);

    item.state = ManagedItemState.CREATION_REQUESTED;

    final OpsContext opsContext = buildTemporaryOpsContext(modelClass.getServiceType(), auth);

    T created = OpsContext.runInContext(opsContext, new CheckedCallable<T, Exception>() {
      @Override
      public T call() throws Exception {
        PlatformLayerKey itemKey = item.getKey();

        T existing;

        SecretProvider secretProvider = SecretProvider.from(auth);

        if (uniqueTagKey != null) {
          boolean fetchTags = true;
          Tag uniqueTag = null;
          for (Tag tag : item.getTags()) {
            if (Objects.equal(tag.getKey(), uniqueTagKey)) {
              uniqueTag = tag;
            }
          }
          if (uniqueTag == null) {
            throw new IllegalArgumentException("Could not find unique tag");
          }
          Filter filter = TagFilter.byTag(uniqueTag);
          filter = StateFilter.excludeDeleted(filter);

          existing = null;
          List<T> existingList = repository.findAll(modelClass, itemKey.getProject(), fetchTags,
              secretProvider, filter);
          if (!existingList.isEmpty()) {
            if (existingList.size() != 1) {
              throw new IllegalArgumentException("Found multiple items with unique tag");
            }
            existing = existingList.get(0);
          }

          if (existing == null) {
            itemKey = findUniqueId(item, itemKey, secretProvider);
          }
        } else {
          if (generateUniqueName) {
            itemKey = findUniqueId(item, itemKey, secretProvider);
          }

          try {
            boolean fetchTags = true;
            existing = Casts.checkedCast(repository.getManagedItem(itemKey, fetchTags, secretProvider),
                javaClass);
          } catch (RepositoryException e) {
            throw new OpsException("Error fetching item from database", e);
          }
        }

        if (!canExist && existing != null) {
          throw new OpsException("Item already exists");
        }

        serviceProvider.beforeCreateItem(item);

        ProjectId project = getProjectId(auth);
        T newItem;
        try {
          if (existing == null) {
            newItem = repository.createManagedItem(project, item);
          } else {
View Full Code Here

TOP

Related Classes of org.platformlayer.ids.ProjectId

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.