Ejemplo n.º 1
0
 /** {@inheritDoc} */
 @Override
 public boolean existGroup(String groupName) {
   if (groupName == null || groupName.isEmpty()) {
     throw new IllegalArgumentException("Groupname cannot be null nor empty");
   }
   return collection.count(BUILDER.getGroupName(groupName)) > 0;
 }
Ejemplo n.º 2
0
 /** {@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 : collection.find(BUILDER.getGroupName(groupName))) {
     Object enabledd = BUILDER.getEnable(false);
     collection.update(dbObject, BasicDBObjectBuilder.start(MONGO_SET, enabledd).get());
   }
 }
Ejemplo n.º 3
0
 /** {@inheritDoc} */
 @Override
 public void addToGroup(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);
   }
   DBObject target = BUILDER.getFeatUid(uid);
   DBObject nGroupName = BUILDER.getGroupName(groupName);
   collection.update(target, BasicDBObjectBuilder.start(MONGO_SET, nGroupName).get());
 }
Ejemplo n.º 4
0
 /** {@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 : collection.find(BUILDER.getGroupName(groupName))) {
     Feature feature = MAPPER.mapFeature(dbObject);
     mapFP.put(feature.getUid(), feature);
   }
   return mapFP;
 }