Esempio n. 1
0
  /** {@inheritDoc} */
  public <T> void createProperty(Property<T> value) {
    Util.assertNotNull(value);
    Util.assertHasLength(value.getName());
    if (existProperty(value.getName())) {
      throw new PropertyAlreadyExistException("Property already exist");
    }
    // Now can process upsert through PUT HTTP method
    Response cRes =
        getStore()
            .path(value.getName()) //
            .request(MediaType.APPLICATION_JSON)
            .put(Entity.entity(new PropertyApiBean(value), MediaType.APPLICATION_JSON));

    // Check response code CREATED or raised error
    if (Status.CREATED.getStatusCode() != cRes.getStatus()) {
      throw new FeatureAccessException(
          "Cannot create properties, an HTTP error " + cRes.getStatus() + " occured.");
    }
  }