Esempio n. 1
0
 /** {@inheritDoc} */
 public Property<?> readProperty(String name) {
   if (name == null || name.isEmpty()) {
     throw new IllegalArgumentException("Property name cannot be null nor empty");
   }
   Response cRes = getStore().path(name).request(MediaType.APPLICATION_JSON_TYPE).get();
   if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
     throw new PropertyNotFoundException(name);
   }
   String resEntity = (String) cRes.readEntity(String.class);
   return PropertyJsonParser.parseProperty(resEntity);
 }
Esempio n. 2
0
 /** {@inheritDoc} */
 public Map<String, Property<?>> readAllProperties() {
   Response cRes = getStore().request(MediaType.APPLICATION_JSON_TYPE).get();
   if (Status.OK.getStatusCode() != cRes.getStatus()) {
     throw new PropertyAccessException(
         "Cannot read properties, an HTTP error " + cRes.getStatus() + " occured.");
   }
   String resEntity = cRes.readEntity(String.class);
   Property<?>[] pArray = PropertyJsonParser.parsePropertyArray(resEntity);
   Map<String, Property<?>> properties = new HashMap<String, Property<?>>();
   for (Property<?> pName : pArray) {
     properties.put(pName.getName(), pName);
   }
   return properties;
 }