/** {@inheritDoc} */ @Override public void enableGroup(String groupName) { Map<String, Feature> featuresInGroup = readGroup(groupName); featuresInGroup.entrySet().forEach(kv -> { Feature f = kv.getValue(); f.setGroup(groupName); f.setEnable(true); update(f); }); }
/** {@inheritDoc} */ @Override public void disableGroup(String groupName) { Map<String, Feature> featuresInGroup = readGroup(groupName); featuresInGroup.entrySet().forEach(kv -> { Feature f = kv.getValue(); f.setGroup(groupName); f.setEnable(false); update(f); }); }
/** {@inheritDoc} */ @Override public Feature mapRow(ResultSet rs, int rowNum) throws SQLException { String featUid = rs.getString(COL_FEAT_UID); Feature f = new Feature(featUid, rs.getInt(COL_FEAT_ENABLE) > 0); f.setDescription(rs.getString(COL_FEAT_DESCRIPTION)); f.setGroup(rs.getString(COL_FEAT_GROUPNAME)); // Build Flipping Strategy From DataBase String strategy = rs.getString(COL_FEAT_STRATEGY); if (strategy != null && !"".equals(strategy)) { Map < String, String > initParams = MappingUtil.toMap(rs.getString(COL_FEAT_EXPRESSION)); FlippingStrategy flipStrategy = MappingUtil.instanceFlippingStrategy(featUid, strategy, initParams); f.setFlippingStrategy(flipStrategy); } return f; }
/** {@inheritDoc} */ @Override public void addToGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); // retrieve Feature f = read(featureId); f.setGroup(groupName); // persist modification update(f); }
/** {@inheritDoc} */ @Override public void addToGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); // retrieve Feature f = read(featureId); f.setGroup(groupName); // persist modification update(f); }
/** {@inheritDoc} */ @Override public void addToGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); // retrieve Feature f = read(featureId); f.setGroup(groupName); // persist modification update(f); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String uid, String groupName) { Util.assertHasLength(groupName); assertFeatureExist(uid); Feature f = readGroup(groupName).get(uid); if (f != null) { f.setGroup(null); update(f); } }
/** {@inheritDoc} */ @Override public void addToGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); // retrieve Feature f = read(featureId); f.setGroup(groupName); // persist modification update(f); }
@SuppressWarnings("unchecked") private static Feature parseFeatureMap(Map<String, Object> fMap) { Feature f = new Feature((String) fMap.get("uid")); f.setEnable((Boolean) fMap.get("enable")); f.setDescription((String) fMap.get("description")); f.setGroup((String) fMap.get("group")); // permissions List<String> perm = (ArrayList<String>) fMap.get("permissions"); f.setPermissions(new HashSet<String>()); if (perm != null) { f.getPermissions().addAll(perm); } // flipping strategy f.setFlippingStrategy(parseFlipStrategy(f.getUid(), (LinkedHashMap<String, Object>) fMap.get("flippingStrategy"))); // custom properties Map <String, Object > propertyMap = (Map < String, Object >) fMap.get("customProperties"); f.setCustomProperties(parseCustomProperties(propertyMap)); return f; }
/** {@inheritDoc} */ public void addToGroup(String uid, String groupName) { assertHasLength(uid); assertHasLength(groupName); Feature feat = read(uid); feat.setGroup(groupName); update(feat); }
/** {@inheritDoc} */ @Override public void addToGroup(String uid, String groupName) { Util.assertHasLength(groupName); assertFeatureExist(uid); Feature f = read(uid); f.setGroup(groupName); update(f); }
/** {@inheritDoc} */ public void removeFromGroup(String uid, String groupName) { assertFeatureExist(uid); assertGroupExist(groupName); Feature feat = read(uid); feat.setGroup(""); update(feat); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } // retrieve Feature f = read(featureId); f.setGroup(null); // persist modification update(f); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } // retrieve Feature f = read(featureId); f.setGroup(null); // persist modification update(f); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } // retrieve Feature f = read(featureId); f.setGroup(null); // persist modification update(f); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } // retrieve Feature f = read(featureId); f.setGroup(null); // persist modification update(f); }
/** * Allow to update feature. * * @param featureId */ private void updateFeature(HttpServletRequest req, String featureId) { Feature old = ff4j.getFeatureStore().read(featureId); // Core Feature fp = new Feature(featureId, old.isEnable()); fp.setPermissions(old.getPermissions()); fp.setCustomProperties(old.getCustomProperties()); fp.setFlippingStrategy(buildFlippingStrategy(req, fp.getUid())); // Description final String featureDesc = req.getParameter(DESCRIPTION); if (Util.hasLength(featureDesc)) { fp.setDescription(featureDesc); } // GroupName final String groupName = req.getParameter(GROUPNAME); if (Util.hasLength(groupName)) { fp.setGroup(groupName); } // Creation ff4j.getFeatureStore().update(fp); }
/** {@inheritDoc} */ @Override public Feature fromStore(Document document) { String featUid = document.getString(FEATURE_UUID); boolean status = document.getBoolean(FEATURE_ENABLE); Feature f = new Feature(featUid, status); f.setDescription(document.getString(FEATURE_DESCRIPTION)); f.setGroup(document.getString(FEATURE_GROUPNAME)); f.setPermissions(mapAuthorization(document)); f.setFlippingStrategy(mapStrategy(featUid, document)); f.setCustomProperties(mapCustomProperties(document)); return f; }
/** * Convert {@link DBObject} to {@link Feature}. * * @param dbObject * document in mongodb. * @return */ public Feature mapFeature(DBObject dbObject) { String featUid = (String) dbObject.get(UUID); boolean status = (Boolean) dbObject.get(ENABLE); Feature f = new Feature(featUid, status); f.setDescription((String) dbObject.get(DESCRIPTION)); f.setGroup((String) dbObject.get(GROUPNAME)); f.setPermissions(mapAuthorization(dbObject)); f.setFlippingStrategy(mapStrategy(featUid, dbObject)); f.setCustomProperties(mapCustomProperties(dbObject)); return f; }
public FeatureActions createOrUpdateFeature(String featureUID, FeatureApiBean featureApiBean) { featureValidator.assertFeatureUIDIsNotBlank(featureApiBean.getUid()); featureValidator.assertFeatureIdsMatch(featureUID, featureApiBean.getUid()); Feature feature = new Feature(featureUID); feature.setDescription(featureApiBean.getDescription()); feature.setEnable(featureApiBean.isEnable()); feature.setGroup(featureApiBean.getGroup()); feature.setPermissions(new HashSet<String>(featureApiBean.getPermissions())); initFlippingStrategy(featureApiBean, feature); initProperties(featureApiBean, feature); if (ff4j.getFeatureStore().exist(featureUID)) { ff4j.getFeatureStore().update(feature); return FeatureActions.UPDATED; } else { ff4j.getFeatureStore().create(feature); return FeatureActions.CREATED; } }