Skip to content

Commit cfbdf0a

Browse files
committed
fixed some code smells
1 parent 2016ca9 commit cfbdf0a

File tree

3 files changed

+0
-59
lines changed

3 files changed

+0
-59
lines changed

app/aem/actions.checks/src/main/java/com/cognifide/apm/checks/utils/ActionUtils.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
package com.cognifide.apm.checks.utils;
2121

2222
import com.cognifide.apm.api.actions.ActionResult;
23-
import com.cognifide.apm.api.exceptions.ActionExecutionException;
24-
import java.util.Iterator;
2523
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;
2924

3025
public final class ActionUtils {
3126

@@ -35,43 +30,6 @@ private ActionUtils() {
3530
// intentionally empty
3631
}
3732

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-
7533
public static void logErrors(List<String> errors, ActionResult actionResult) {
7634
for (String error : errors) {
7735
actionResult.logError(error);

app/aem/actions.checks/src/main/java/com/cognifide/apm/checks/utils/MessagingUtils.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,7 @@ public static String createMessage(Exception e) {
3131
return StringUtils.isBlank(e.getMessage()) ? "Internal error: " + e.getClass() : e.getMessage();
3232
}
3333

34-
public static String addingGroupToItself(String groupId) {
35-
return "You can not add group " + groupId + " to itself";
36-
}
37-
3834
public static String authorizableNotExists(String authorizableId) {
3935
return "Authorizable with id: " + authorizableId + " does not exists";
4036
}
41-
42-
public static String cyclicRelationsForbidden(String currentGroup, String groupToBeAdded) {
43-
return "Cannot add group " + groupToBeAdded + " to group " + currentGroup
44-
+ " due to resulting cyclic relation";
45-
}
4637
}

app/aem/actions.main/src/main/java/com/cognifide/apm/main/utils/ActionUtils.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
*/
2020
package com.cognifide.apm.main.utils;
2121

22-
import com.cognifide.apm.api.actions.ActionResult;
2322
import com.cognifide.apm.api.exceptions.ActionExecutionException;
2423
import java.util.Iterator;
25-
import java.util.List;
2624
import javax.jcr.RepositoryException;
2725
import org.apache.jackrabbit.api.security.user.Authorizable;
2826
import org.apache.jackrabbit.api.security.user.Group;
@@ -71,10 +69,4 @@ public static void checkCyclicRelations(Group currentGroup, Group groupToBeAdded
7169
throw new ActionExecutionException(MessagingUtils.createMessage(e));
7270
}
7371
}
74-
75-
public static void logErrors(List<String> errors, ActionResult actionResult) {
76-
for (String error : errors) {
77-
actionResult.logError(error);
78-
}
79-
}
8072
}

0 commit comments

Comments
 (0)