/** {@inheritDoc} */ @Override public Map<String, Feature> readGroup(String groupName) { Util.assertParamHasLength(groupName, "groupName"); Map < String, Feature > features = readAll(); Map < String, Feature > group = new HashMap<String, Feature>(); for (Map.Entry<String,Feature> uid : features.entrySet()) { if (groupName.equals(uid.getValue().getGroup())) { group.put(uid.getKey(), uid.getValue()); } } if (group.isEmpty()) { throw new GroupNotFoundException(groupName); } return group; }
/** {@inheritDoc} */ @Override public Map<String, Feature> readGroup(String groupName) { Util.assertParamHasLength(groupName, "groupName"); Map < String, Feature > features = readAll(); Map < String, Feature > group = new HashMap< String, Feature >(); for (Map.Entry<String,Feature> uid : features.entrySet()) { if (groupName.equals(uid.getValue().getGroup())) { group.put(uid.getKey(), uid.getValue()); } } if (group.isEmpty()) { throw new GroupNotFoundException(groupName); } return group; }
/** {@inheritDoc} */ @Override public void enableGroup(String groupName) { Util.assertHasLength(groupName); Response cRes = ClientHttpUtils.invokePostMethod(getGroups() .path(groupName) .path(OPERATION_ENABLE), authorizationHeaderValue); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new GroupNotFoundException(groupName); } if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) { throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED); } }
/** {@inheritDoc} */ @Override public void disableGroup(String groupName) { Util.assertHasLength(groupName); Response cRes = ClientHttpUtils.invokePostMethod(getGroups() .path(groupName) .path(OPERATION_DISABLE), authorizationHeaderValue); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new GroupNotFoundException(groupName); } if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) { throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED); } }
/** {@inheritDoc} */ @Transactional public void enableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } getJdbcTemplate().update(getQueryBuilder().enableGroup(), groupName); }
/** * Validate feature uid. * * @param uid * target uid */ protected void assertGroupExist(String groupName) { Util.assertHasLength(groupName); if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } }
/** {@inheritDoc} */ @Transactional public void disableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } getJdbcTemplate().update(getQueryBuilder().disableGroup(), groupName); }
/** {@inheritDoc} */ public Map<String, Feature> readGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>(); List<Feature> lFp = getJdbcTemplate().query(getQueryBuilder().getFeatureOfGroup(), FMAPPER, groupName); for (Feature flipPoint : lFp) { mapFP.put(flipPoint.getUid(), flipPoint); } return mapFP; }
/** {@inheritDoc} */ @Transactional public void removeFromGroup(String uid, String groupName) { if (uid == null || uid.isEmpty()) { throw new IllegalArgumentException(FEATURE_IDENTIFIER_CANNOT_BE_NULL_NOR_EMPTY); } if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!exist(uid)) { throw new FeatureNotFoundException(uid); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } getJdbcTemplate().update(getQueryBuilder().addFeatureToGroup(), "", uid); }
/** {@inheritDoc} */ @Override public Map<String, Feature> readGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>(); for (DBObject dbObject : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) { Feature feature = MAPPER.mapFeature(dbObject); mapFP.put(feature.getUid(), feature); } return mapFP; }
/** {@inheritDoc} */ @Override public void disableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } ClientResponse cRes = getGroups().path(groupName).path(OPERATION_DISABLE).post(ClientResponse.class); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new GroupNotFoundException(groupName); } if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) { throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED); } }
/** {@inheritDoc} */ @Override public void disableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } for (Document document: getFeaturesCollection().find(BUILDER.getGroupName(groupName))) { Object enabled = BUILDER.getEnable(false); getFeaturesCollection().updateOne(document, new Document(MONGO_SET, enabled)); } }
/** {@inheritDoc} */ @Override public void enableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } for (Document document : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) { Object enabled = BUILDER.getEnable(true); getFeaturesCollection().updateOne(document, new Document(MONGO_SET, enabled)); } }
/** {@inheritDoc} */ @Override public void enableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } ClientResponse cRes = getGroups().path(groupName).path(OPERATION_ENABLE).post(ClientResponse.class); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new GroupNotFoundException(groupName); } if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) { throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED); } }
/** {@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 enableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } for (DBObject dbObject : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) { Object enabledd = BUILDER.getEnable(true); getFeaturesCollection().update(dbObject, BasicDBObjectBuilder.start(MONGO_SET, enabledd).get()); } }
/** {@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 disableGroup(String groupName) { if (groupName == null || groupName.isEmpty()) { throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY); } if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } for (DBObject dbObject : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) { Object enabledd = BUILDER.getEnable(false); getFeaturesCollection().update(dbObject, BasicDBObjectBuilder.start(MONGO_SET, enabledd).get()); } }