本文整理了Java中org.ff4j.core.Feature.setPermissions()
方法的一些代码示例,展示了Feature.setPermissions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature.setPermissions()
方法的具体详情如下:
包路径:org.ff4j.core.Feature
类名称:Feature
方法名:setPermissions
[英]Setter accessor for attribute 'permissions'.
[中]属性“权限”的Setter访问器。
代码示例来源:origin: ff4j/ff4j
f.setPermissions(parseListAuthorizations((Element) securities.item(0)));
代码示例来源:origin: ff4j/ff4j
@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;
}
代码示例来源:origin: ff4j/ff4j
fp.setPermissions(permissions);
代码示例来源:origin: ff4j/ff4j
fp.setPermissions(permissions);
代码示例来源:origin: ff4j/ff4j
fout.setPermissions(FeatureJsonParser.parsePermissions(
Bytes.toString(result.getValue(B_FEATURES_CF_CORE, B_FEAT_ROLES))));
代码示例来源:origin: ff4j/ff4j
/**
* Transform node FF4J_FEATURE into core Feature.
*
* @param nodeFeature
* @return
*/
public static Feature fromNode2Feature(Node nodeFeature) {
Map < String, Object > nodeProperties = nodeFeature.getAllProperties();
String featureID = (String) nodeFeature.getProperty(NODEFEATURE_ATT_UID);
Boolean enable = (Boolean) nodeFeature.getProperty(NODEFEATURE_ATT_ENABLE);
Feature feature = new Feature(featureID, enable);
if (nodeProperties.containsKey(NODEFEATURE_ATT_DESCRIPTION)) {
feature.setDescription((String) nodeFeature.getProperty(NODEFEATURE_ATT_DESCRIPTION));
}
if (nodeProperties.containsKey(NODEFEATURE_ATT_ROLES)) {
String[] roles = (String[]) nodeFeature.getProperty(NODEFEATURE_ATT_ROLES);
feature.setPermissions(new HashSet<>(Arrays.asList(roles)));
}
return feature;
}
代码示例来源:origin: ff4j/ff4j
Set<String> auths = gson.fromJson(permissions, new TypeToken<HashSet<String>>() {
}.getType());
feature.setPermissions(auths);
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
public void testUpdateFeatureMoreAutorisation() {
// Parameters
Set<String> rights2 = new HashSet<String>(Arrays.asList(new String[] { ROLE_USER, ROLE_ADMIN }));
// Given
assertFf4j.assertThatFeatureExist(F1);
assertFf4j.assertThatFeatureHasNotRole(F1, ROLE_ADMIN);
// When
Feature fpBis = testedStore.read(F1);
fpBis.setPermissions(rights2);
testedStore.update(fpBis);
// Then
assertFf4j.assertThatFeatureHasRole(F1, ROLE_USER);
assertFf4j.assertThatFeatureHasRole(F1, ROLE_ADMIN);
}
代码示例来源:origin: ff4j/ff4j
feat.setEnable(fApiBean.isEnable());
feat.setGroup(fApiBean.getGroup());
feat.setPermissions(new HashSet<String>(fApiBean.getPermissions()));
代码示例来源:origin: ff4j/ff4j
f.setEnable(1 == row.getInt(COL_FEAT_ENABLE));
f.setGroup(row.getString(COL_FEAT_GROUPNAME));
f.setPermissions(mapFeaturePermissions(row));
代码示例来源:origin: ff4j/ff4j
/**
* 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);
}
代码示例来源:origin: ff4j/ff4j
/** {@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;
}
代码示例来源:origin: ff4j/ff4j
/**
* 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;
}
代码示例来源:origin: ff4j/ff4j
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;
}
}
内容来源于网络,如有侵权,请联系作者删除!