Skip to content

Commit

Permalink
Merge pull request #428 from wttech/refactor-execution-interrupted-msg
Browse files Browse the repository at this point in the history
refactor 'Execution interrupted' message
  • Loading branch information
dprzybyl authored Nov 2, 2023
2 parents e572330 + c5f76e4 commit 2611bb3
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private ActionResult process(Context context, boolean execute) {
LOGGER.info("Adding authorizables {} to group with id={}", String.join(", ", authorizableIds), group.getID());
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
return actionResult;
}

Expand Down Expand Up @@ -101,7 +102,7 @@ private ActionResult process(Context context, boolean execute) {
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError("Execution interrupted");
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private ActionResult process(Context context, boolean execute) {
actionResult.setAuthorizable(authorizable.getID());
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
return actionResult;
}

Expand Down Expand Up @@ -101,7 +102,7 @@ private ActionResult process(Context context, boolean execute) {
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError("Execution interrupted");
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.cognifide.apm.main.permissions.PermissionActionHelper;
import com.cognifide.apm.main.permissions.Restrictions;
import com.cognifide.apm.main.permissions.exceptions.PermissionException;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import com.cognifide.apm.main.utils.PathUtils;
import java.util.Collections;
Expand Down Expand Up @@ -103,11 +104,14 @@ private ActionResult process(Context context, boolean simulate) {
actionResult.logWarning("Path " + path + " not found");
} else {
actionResult.logError("Path " + path + " not found");
return actionResult;
}
} catch (RepositoryException | PermissionException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cognifide.apm.api.actions.Message;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import com.cognifide.apm.main.utils.PathUtils;
import java.util.HashSet;
Expand Down Expand Up @@ -87,6 +88,9 @@ private ActionResult process(Context context, boolean execute) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.permissions.utils.JackrabbitAccessControlListUtil;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import com.cognifide.apm.main.utils.PathUtils;
import java.security.Principal;
Expand Down Expand Up @@ -73,6 +74,10 @@ private ActionResult process(final Context context, boolean execute) {
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.actions.forauthorizable.ForAuthorizable;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import javax.jcr.RepositoryException;
import org.apache.jackrabbit.api.security.user.Authorizable;
Expand Down Expand Up @@ -83,6 +84,8 @@ public ActionResult process(Context context, boolean simulate) {
if (actionResult.getStatus() != Status.ERROR) {
ActionResult forAuthorizableActionResult = new ForAuthorizable(id, false, createStrategy == CreateAuthorizableStrategy.GROUP).process(context);
actionResult.changeStatus(forAuthorizableActionResult.getStatus(), forAuthorizableActionResult.getMessages().get(0).getText());
} else {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.exceptions.AuthorizableNotFoundException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import java.util.List;
import javax.jcr.RepositoryException;
Expand Down Expand Up @@ -72,7 +73,7 @@ private ActionResult process(Context context, boolean execute) {
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError("Execution interrupted");
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.exceptions.AuthorizableNotFoundException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.actions.clearpermissions.Purge;
import com.cognifide.apm.main.actions.removeparents.RemoveParents;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -67,6 +69,10 @@ public ActionResult simulate(Context context) {
actionResult = context.createActionResult();
actionResult.logWarning(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand All @@ -91,6 +97,10 @@ public ActionResult execute(Context context) {
actionResult = context.createActionResult();
actionResult.logWarning(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.exceptions.AuthorizableNotFoundException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import java.util.List;
import javax.jcr.RepositoryException;
Expand Down Expand Up @@ -71,7 +72,7 @@ private ActionResult process(Context context, boolean execute) {
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError("Execution interrupted");
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.cognifide.apm.main.permissions.PermissionActionHelper;
import com.cognifide.apm.main.permissions.Restrictions;
import com.cognifide.apm.main.permissions.exceptions.PermissionException;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import com.cognifide.apm.main.utils.PathUtils;
import java.util.ArrayList;
Expand Down Expand Up @@ -108,6 +109,10 @@ private ActionResult process(Context context, boolean simulate) {
} catch (RepositoryException | PermissionException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.exceptions.AuthorizableNotFoundException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import javax.jcr.RepositoryException;
import org.apache.jackrabbit.api.security.user.Group;
Expand Down Expand Up @@ -76,6 +78,10 @@ public ActionResult process(Context context) {
actionResult.logError(MessagingUtils.createMessage(e));
}
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.exceptions.AuthorizableNotFoundException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import java.util.List;
import javax.jcr.RepositoryException;
Expand Down Expand Up @@ -62,6 +63,7 @@ private ActionResult process(Context context, boolean execute) {
LOGGER.info("Removing authorizables {} from group with id={}", String.join(", ", authorizableIds), group.getID());
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
return actionResult;
}

Expand All @@ -82,7 +84,7 @@ private ActionResult process(Context context, boolean execute) {
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError("Execution interrupted");
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import java.util.Iterator;
import javax.jcr.RepositoryException;
Expand Down Expand Up @@ -61,6 +63,10 @@ public ActionResult detachMembersFromGroup() {
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand All @@ -76,6 +82,10 @@ public ActionResult detachAuthorizableFromParents() {
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.exceptions.AuthorizableNotFoundException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import java.util.List;
import javax.jcr.RepositoryException;
Expand Down Expand Up @@ -65,6 +66,7 @@ public ActionResult process(Context context, boolean execute) {
LOGGER.info("Removing authorizable with id={} from groups {}", authorizable.getID(), String.join(", ", groupIds));
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
return actionResult;
}

Expand All @@ -89,7 +91,7 @@ public ActionResult process(Context context, boolean execute) {
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError("Execution interrupted");
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import javax.jcr.RepositoryException;
import org.apache.jackrabbit.api.security.user.Authorizable;
Expand Down Expand Up @@ -64,6 +66,10 @@ private ActionResult process(final Context context, boolean simulate) {
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.actions.SessionSavingMode;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import javax.jcr.RepositoryException;

Expand All @@ -49,6 +51,10 @@ private ActionResult process(final Context context, boolean execute) {
} catch (final RepositoryException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.actions.SessionSavingMode;
import com.cognifide.apm.api.actions.SessionSavingPolicy;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;

public class SessionSave implements Action {
Expand Down Expand Up @@ -56,6 +58,10 @@ private ActionResult process(final Context context, boolean execute) {
actionResult.logError(MessagingUtils.createMessage(e));
}
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import javax.jcr.RepositoryException;
import org.apache.jackrabbit.api.security.user.User;
Expand Down Expand Up @@ -62,6 +64,10 @@ private ActionResult process(final Context context, boolean execute) {
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Context;
import com.cognifide.apm.api.exceptions.ActionExecutionException;
import com.cognifide.apm.api.status.Status;
import com.cognifide.apm.main.utils.ActionUtils;
import com.cognifide.apm.main.utils.MessagingUtils;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
Expand Down Expand Up @@ -72,6 +74,10 @@ private ActionResult process(final Context context, boolean simulate) {
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}

if (actionResult.getStatus() == Status.ERROR) {
actionResult.logError(ActionUtils.EXECUTION_INTERRUPTED_MSG);
}
return actionResult;
}
}
Loading

0 comments on commit 2611bb3

Please sign in to comment.