Example #1
0
  public ServiceResults updateApplicationEntity(ServicePayload payload) throws Exception {

    Map<String, Object> properties = payload.getProperties();
    Object m = properties.get("metadata");
    if (m instanceof Map) {
      @SuppressWarnings("unchecked")
      Map<String, Object> metadata = (Map<String, Object>) m;
      Object c = metadata.get("collections");
      if (c instanceof Map) {
        @SuppressWarnings("unchecked")
        Map<String, Object> collections = (Map<String, Object>) c;
        for (String collection : collections.keySet()) {
          em.createApplicationCollection(collection);
          logger.info(
              "Created collection " + collection + " for application " + sm.getApplicationId());
        }
      }
    }

    Entity entity = em.get(em.getApplicationRef());
    em.updateProperties(entity, properties);
    entity.addProperties(properties);
    Results r = Results.fromEntity(entity);

    Set<String> collections = em.getApplicationCollections();
    if (collections.size() > 0) {
      r.setMetadata(em.getApplicationRef().getUuid(), "collections", collections);
    }

    return genericServiceResults(r);
  }
Example #2
0
  public ServiceResults getApplicationEntity() throws Exception {

    Entity entity = em.get(em.getApplicationRef());
    Results r = Results.fromEntity(entity);

    Map<String, Object> collections = em.getApplicationCollectionMetadata();
    // Set<String> collections = em.getApplicationCollections();
    if (collections.size() > 0) {
      r.setMetadata(em.getApplicationRef().getUuid(), "collections", collections);
    }

    return genericServiceResults(r);
  }