Examples of ProjectId


Examples of org.platformlayer.ids.ProjectId

    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

Examples of org.platformlayer.ids.ProjectId

    // 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

Examples of org.platformlayer.ids.ProjectId

    // }
    // }

    // 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

Examples of org.platformlayer.ids.ProjectId

        // 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

Examples of org.platformlayer.ids.ProjectId

  public <T extends ItemBase> T findItem(ProjectAuthorization auth, Class<T> itemClass, String id)
      throws OpsException {
    ModelClass<T> modelClass = serviceProviderDirectory.getModelClass(itemClass);
    // Class<T> javaClass = modelClass.getJavaClass();

    ProjectId project = getProjectId(auth);

    PlatformLayerKey modelKey = new PlatformLayerKey(null, project, modelClass.getServiceType(),
        modelClass.getItemType(), new ManagedItemId(id));

    boolean fetchTags = true;
View Full Code Here

Examples of org.platformlayer.ids.ProjectId

    return managedItem;
  }

  @Override
  public List<ItemBase> findRoots(ProjectAuthorization authentication) throws OpsException {
    ProjectId project = getProjectId(authentication);

    boolean fetchTags = true;
    List<ItemBase> items;
    try {
      items = repository.findRoots(project, fetchTags, SecretProvider.from(authentication));
View Full Code Here

Examples of org.platformlayer.ids.ProjectId

    return items;
  }

  @Override
  public List<ItemBase> listAll(ProjectAuthorization authentication, Filter filter) throws OpsException {
    ProjectId project = getProjectId(authentication);

    List<ItemBase> items;
    try {
      items = repository.listAll(project, filter, SecretProvider.from(authentication));
    } catch (RepositoryException e) {
View Full Code Here

Examples of org.platformlayer.ids.ProjectId

  private ProjectId getProjectId(ProjectAuthorization authentication) {
    String key = authentication.getName();
    if (key == null) {
      throw new IllegalStateException();
    }
    return new ProjectId(key);
  }
View Full Code Here

Examples of org.platformlayer.ids.ProjectId

    ProjectAuthorization project = getScopeParameter(ProjectAuthorization.class, true);
    return project;
  }

  protected ProjectId getProject() {
    ProjectId project = getScopeParameter(ProjectId.class, true);
    return project;
  }
View Full Code Here

Examples of org.platformlayer.ids.ProjectId

    PlatformLayerKey key = item.getKey();

    ManagedItemId itemId = getItemId();
    ServiceType serviceType = getServiceType();
    ItemType itemType = getItemType();
    ProjectId project = getProject();

    if (key != null) {
      if (key.getItemId() != null && !equal(key.getItemId(), itemId)) {
        throw new OpsException("Item id mismatch");
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.