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.");
    }
  }
Esempio n. 2
0
 /** {@inheritDoc} */
 public void deleteProperty(String name) {
   Util.assertHasLength(name);
   Response cRes = getStore().path(name).request().delete();
   if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
     throw new PropertyNotFoundException(name);
   }
   if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
     throw new PropertyAccessException(
         "Cannot delete property, an HTTP error " + cRes.getStatus() + " occured.");
   }
 }
Esempio n. 3
0
 /** {@inheritDoc} */
 public boolean existProperty(String name) {
   Util.assertHasLength(name);
   Response cRes = getStore().path(name).request(MediaType.APPLICATION_JSON_TYPE).get();
   if (Status.OK.getStatusCode() == cRes.getStatus()) {
     return true;
   }
   if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
     return false;
   }
   throw new PropertyAccessException(
       "Cannot check existence of property, an HTTP error "
           + cRes.getStatus()
           + " occured : "
           + cRes.getEntity());
 }
 /** {@inheritDoc} */
 @Override
 public boolean exist(String featId) {
   Util.assertHasLength(featId);
   return 1 == collection.count(BUILDER.getFeatUid(featId));
 }