MCPcopy Create free account
hub / github.com/annmuor/jnode / add

Method add

jnode-core/src/jnode/robot/FileFix.java:195–239  ·  view source on GitHub ↗
(Link link, String area)

Source from the content-addressed store, hash-verified

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();

Callers 1

executeMethod · 0.95

Calls 14

getOptionStringArrayMethod · 0.95
getMethod · 0.95
setAreaMethod · 0.95
setLinkMethod · 0.95
getAndMethod · 0.80
isEmptyMethod · 0.80
appendMethod · 0.80
getFirstAndMethod · 0.80
saveMethod · 0.80
getIdMethod · 0.65
getNameMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected