if (areas.isEmpty()) {
sb.append(area + " not found");
} else {
for (Filearea earea : areas) {
sb.append(earea.getName());
FileSubscription sub = ORMManager.get(FileSubscription.class)
.getFirstAnd("filearea_id", "=", earea.getId(),
"link_id", "=", link.getId());
if (sub != null) {
sb.append(" already subscribed");
} else {
boolean denied = true;
if (!"".equals(earea.getGroup())) {
for (String group : grps) {
if (earea.getGroup().equals(group)) {
denied = false;
break;
}
}
} else {
denied = false;
}
if (denied) {
sb.append(" access denied");
} else {
sub = new FileSubscription();
sub.setArea(earea);
sub.setLink(link);
ORMManager.get(FileSubscription.class).save(sub);
sb.append(" subscribed");
}
}
sb.append('\n');