/** {@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 Map<String, Feature> readGroup(String groupName) { Util.assertParamHasLength(groupName, "groupName"); Map < String, Feature > features = readAll(); Map < String, Feature > group = new HashMap<>(); 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 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 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} */ @Override public void removeFromGroup(String uid, String groupName) { Util.assertHasLength(uid, groupName); Response cRes = ClientHttpUtils.invokePostMethod(getStore() .path(uid) .path(OPERATION_REMOVEGROUP) .path(groupName), authorizationHeaderValue); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new FeatureNotFoundException(uid); } if (Status.BAD_REQUEST.getStatusCode() == cRes.getStatus()) { throw new GroupNotFoundException(groupName); } if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) { throw new FeatureAccessException("Cannot remove feature from group, an HTTP error " + cRes.getStatus() + OCCURED); } }
/** {@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} */ public Map<String, Feature> readGroup(String groupName) { Util.assertHasLength(groupName); Response cRes = ClientHttpUtils.invokeGetMethod(getGroups().path(groupName), authorizationHeaderValue); if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) { throw new GroupNotFoundException(groupName); } if (Status.OK.getStatusCode() != cRes.getStatus()) { throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED); } String resEntity = cRes.readEntity(String.class); Feature[] fArray = parseFeatureArray(resEntity); Map<String, Feature> features = new HashMap<String, Feature>(); for (Feature feature : fArray) { features.put(feature.getUid(), feature); } return features; }
/** {@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 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 (Document document : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) { Feature feature = FMAPPER.fromStore(document); 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 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); } Document target = BUILDER.getFeatUid(uid); Document nGroupName = BUILDER.getGroupName(""); getFeaturesCollection().updateOne(target, new Document(MONGO_SET, nGroupName)); }
/** {@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); } }