(Link link, String area)
| 193 | } |
| 194 | |
| 195 | private String add(Link link, String area) throws SQLException { |
| 196 | StringBuilder sb = new StringBuilder(); |
| 197 | String like = area.replace("*", "%"); |
| 198 | String[] grps = FtnTools.getOptionStringArray(link, |
| 199 | LinkOption.SARRAY_LINK_GROUPS); |
| 200 | List<Filearea> areas = ORMManager.get(Filearea.class).getAnd("name", |
| 201 | "~", like); |
| 202 | if (areas.isEmpty()) { |
| 203 | sb.append(area + " not found"); |
| 204 | } else { |
| 205 | for (Filearea earea : areas) { |
| 206 | sb.append(earea.getName()); |
| 207 | FileSubscription sub = ORMManager.get(FileSubscription.class) |
| 208 | .getFirstAnd("filearea_id", "=", earea.getId(), |
| 209 | "link_id", "=", link.getId()); |
| 210 | if (sub != null) { |
| 211 | sb.append(" already subscribed"); |
| 212 | } else { |
| 213 | boolean denied = true; |
| 214 | if (!"".equals(earea.getGroup())) { |
| 215 | for (String group : grps) { |
| 216 | if (earea.getGroup().equals(group)) { |
| 217 | denied = false; |
| 218 | break; |
| 219 | } |
| 220 | } |
| 221 | } else { |
| 222 | denied = false; |
| 223 | } |
| 224 | if (denied) { |
| 225 | sb.append(" access denied"); |
| 226 | } else { |
| 227 | sub = new FileSubscription(); |
| 228 | sub.setArea(earea); |
| 229 | sub.setLink(link); |
| 230 | ORMManager.get(FileSubscription.class).save(sub); |
| 231 | sb.append(" subscribed"); |
| 232 | } |
| 233 | } |
| 234 | sb.append('\n'); |
| 235 | } |
| 236 | } |
| 237 | sb.append('\n'); |
| 238 | return sb.toString(); |
| 239 | } |
| 240 | |
| 241 | private String rem(Link link, String area) throws SQLException { |
| 242 | StringBuilder sb = new StringBuilder(); |
no test coverage detected