@GET @Path("/" + RESOURCE_PROPERTIES) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value= "Display information regarding <b>Properties</b>", response=PropertyApiBean.class) @ApiResponses(@ApiResponse(code = 200, message= "get all Properties")) public List < PropertyApiBean> readProperties() { List < PropertyApiBean > apiBean = new ArrayList<PropertyApiBean>(); getPropertyStore().readAllProperties(); for (Property<?> prop : getPropertyStore().readAllProperties().values()) { apiBean.add(new PropertyApiBean(prop)); } return apiBean; }
public Response upsertProperty(@Context HttpHeaders headers, @PathParam("name") String name, PropertyApiBean pApiBean) { if ("".equals(name) || !name.equals(pApiBean.getName())) { String errMsg = "Invalid identifier expected " + name; return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); Property<?> property = pApiBean.asProperty();
if (mapProperties != null) { for(PropertyApiBean propertyBean : mapProperties.values()) { feat.addProperty(propertyBean.asProperty());
/** * 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} */ 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));*/ Response cRes = ClientHttpUtils .createRequest(getStore().path(value.getName()), authorization, null) .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); } }
/** * Copy constructor. * * @param f * * target feature */ public FeatureApiBean(Feature f) { this.uid = f.getUid(); this.enable = f.isEnable(); this.description = f.getDescription(); this.group = f.getGroup(); this.permissions = new ArrayList<String>(f.getPermissions()); if (f.getFlippingStrategy() != null) { this.flippingStrategy = new FlippingStrategyApiBean(f.getFlippingStrategy()); } if (f.getCustomProperties() != null) { for (Property<?> ap1 : f.getCustomProperties().values()) { customProperties.put(ap1.getName(), new PropertyApiBean(ap1)); } } }
/** {@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"); } ClientResponse cRes = getStore().path(value.getName())// .type(MediaType.APPLICATION_JSON) // .put(ClientResponse.class, new PropertyApiBean(value)); // 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); } }