20
20
package com .cognifide .apm .checks .utils ;
21
21
22
22
import com .cognifide .apm .api .actions .ActionResult ;
23
- import com .cognifide .apm .api .exceptions .ActionExecutionException ;
24
- import java .util .Iterator ;
25
23
import java .util .List ;
26
- import javax .jcr .RepositoryException ;
27
- import org .apache .jackrabbit .api .security .user .Authorizable ;
28
- import org .apache .jackrabbit .api .security .user .Group ;
29
24
30
25
public final class ActionUtils {
31
26
@@ -35,43 +30,6 @@ private ActionUtils() {
35
30
// intentionally empty
36
31
}
37
32
38
- /**
39
- * Adding group to another group may result in cyclic relation. Let current group be the group where we
40
- * want to add current authorizable to. If current authorizable contains group such that current group
41
- * belongs to, then we prevent such operation.
42
- *
43
- * @param currentGroup The group where we want to add current authorizable
44
- * @param groupToBeAdded Authorizable we want to add
45
- * @throws ActionExecutionException Throw exception, if adding operation results in cyclic relation
46
- */
47
- public static void checkCyclicRelations (Group currentGroup , Group groupToBeAdded )
48
- throws ActionExecutionException {
49
- try {
50
- if (groupToBeAdded .getID ().equals (currentGroup .getID ())) {
51
- throw new ActionExecutionException (MessagingUtils .addingGroupToItself (currentGroup .getID ()));
52
- }
53
- Iterator <Group > parents = currentGroup .memberOf ();
54
- while (parents .hasNext ()) {
55
- Group currentParent = parents .next ();
56
- // Is added group among my parents?
57
- if (currentParent .getID ().equals (groupToBeAdded .getID ())) {
58
- throw new ActionExecutionException (MessagingUtils .cyclicRelationsForbidden (
59
- currentGroup .getID (), groupToBeAdded .getID ()));
60
- }
61
- // ... and are its children among my parents?
62
- for (Iterator <Authorizable > children = groupToBeAdded .getMembers (); children .hasNext (); ) {
63
- Authorizable currentChild = children .next ();
64
- if (currentParent .getID ().equals (currentChild .getID ())) {
65
- throw new ActionExecutionException (MessagingUtils .cyclicRelationsForbidden (
66
- currentChild .getID (), groupToBeAdded .getID ()));
67
- }
68
- }
69
- }
70
- } catch (RepositoryException e ) {
71
- throw new ActionExecutionException (MessagingUtils .createMessage (e ));
72
- }
73
- }
74
-
75
33
public static void logErrors (List <String > errors , ActionResult actionResult ) {
76
34
for (String error : errors ) {
77
35
actionResult .logError (error );
0 commit comments