/** * Accessor to read a custom property from Feature. * * @param propId * property * @return * property value (if exist) */ @SuppressWarnings("unchecked") public <T> Property<T> getProperty(String propId) { Util.assertNotNull(propId); if (customProperties != null && customProperties.containsKey(propId)) { return (Property<T>) customProperties.get(propId); } throw new PropertyNotFoundException(propId); }
/** * Allows to retrieve feature by its id. * * @param featId * target feature identifier * @return feature is exist */ @GET @RolesAllowed({ROLE_READ}) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value= "Read information about a Property", response=PropertyApiBean.class) @ApiResponses({ @ApiResponse(code = 200, message= "Information about features"), @ApiResponse(code = 404, message= "Property not found") }) public Response read(@PathParam("name") String name) { if (!ff4j.getPropertiesStore().existProperty(name)) { String errMsg = new PropertyNotFoundException(name).getMessage(); return Response.status(Response.Status.NOT_FOUND).entity(errMsg).build(); } return Response.ok(new PropertyApiBean(ff4j.getPropertiesStore().readProperty(name))).build(); }
/** {@inheritDoc} */ @Override public Property<?> readProperty(String name) { if (!existProperty(name)) { throw new PropertyNotFoundException(name); } return (Property<?>) wrapper.getCacheProperties().get(name).getObjectValue(); }
/** {@inheritDoc} */ public Property<?> readProperty(String name) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Property name cannot be null nor empty"); } Response cRes = ClientHttpUtils.invokeGetMethod(getStore().path(name), authorization); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new PropertyNotFoundException(name); } String resEntity = (String) cRes.readEntity(String.class); return PropertyJsonParser.parseProperty(resEntity); }
/** {@inheritDoc} */ public void deleteProperty(String name) { Util.assertHasLength(name); Response cRes = ClientHttpUtils.invokeDeleteMethod(getStore().path(name), authorization); 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); } }
/** * Validate property name and existence * * @param uid * target uid */ protected void assertPropertyExist(String name) { Util.assertHasLength(name); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } }
/** {@inheritDoc} */ @Override public Property<?> readProperty(String name) { Util.assertHasLength(name); String value = conf().getString(name); if (value == null) { throw new PropertyNotFoundException(name); } return new PropertyString(name, value); }
/** {@inheritDoc} */ @Override public Property<?> readProperty(String name) { if (!existProperty(name)) { throw new PropertyNotFoundException(name); } return getCacheManager().getProperty(name); }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { if (!existProperty(name)) { throw new PropertyNotFoundException(name); } getCacheManager().evictProperty(name); }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { if (!existProperty(name)) { throw new PropertyNotFoundException(name); } wrapper.getCacheProperties().remove(name); }
/** {@inheritDoc} */ public Property<?> readProperty(String name) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Property name cannot be null nor empty"); } ClientResponse cRes = getStore().path(name).get(ClientResponse.class); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new PropertyNotFoundException(name); } return PropertyJsonParser.parseProperty(cRes.getEntity(String.class)); }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { if (!existProperty(name)) { throw new PropertyNotFoundException(name); } conf().clearProperty(name); }
throw new PropertyNotFoundException( PLACEHOLDER_PROPERTY_PREFIX + ": Cannot perform placeholding on " + placeholder);
/** {@inheritDoc} */ @Override public <T> void updateProperty(Property<T> property) { if (property == null) { throw new IllegalArgumentException("Property cannot be null"); } if (!existProperty(property.getName())) { throw new PropertyNotFoundException(property.getName()); } wrapper.getCacheProperties().put(new Element(property.getName(), property)); }
/** {@inheritDoc} */ public Property<?> readProperty(String name) { Util.assertNotNull(name); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } return getJdbcTemplate(). queryForObject(getQueryBuilder().getProperty(), PMAPPER, name); }
/** {@inheritDoc} */ public void deleteProperty(String name) { Util.assertHasLength(name); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } getJdbcTemplate().update(getQueryBuilder().deleteProperty(), name); }
/** {@inheritDoc} */ @Override public <T> void updateProperty(Property<T> property) { if (property == null) { throw new IllegalArgumentException("Property cannot be null"); } if (!existProperty(property.getName())) { throw new PropertyNotFoundException(property.getName()); } getCacheManager().putProperty(property); }
/** {@inheritDoc} */ public void deleteProperty(String name) { Util.assertHasLength(name); ClientResponse cRes = getStore().path(name).delete(ClientResponse.class); 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); } }
/** {@inheritDoc} */ public void updateProperty(String name, String newValue) { Util.assertHasLength(name); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } // Check new value validity readProperty(name).fromString(newValue); getJdbcTemplate().update(getQueryBuilder().updateProperty(), newValue, name); }
/** {@inheritDoc} */ public void deleteProperty(String name) { Util.assertHasLength(name); Connection sqlConn = null; PreparedStatement ps = null; try { sqlConn = getDataSource().getConnection(); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } ps = buildStatement(sqlConn, getQueryBuilder().deleteProperty(), name); ps.executeUpdate(); } catch (SQLException sqlEX) { throw new PropertyAccessException("Cannot delete property database, SQL ERROR", sqlEX); } finally { closeStatement(ps); closeConnection(sqlConn); } }