Skip to content

Commit

Permalink
- Remove API IvyExecutor.executeAsSystem of Portal in Express
Browse files Browse the repository at this point in the history
- Use Sudo.get instead
  • Loading branch information
chnam-axonivy committed Nov 9, 2023
1 parent 3ac344e commit 8062fd2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ch.ivy.gawfs.DynaFormController;
import ch.ivy.gawfs.Formelement;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.security.exec.Sudo;
import ch.ivyteam.ivy.workflow.ICase;
import gawfs.ExecutePredefinedWorkflowData;
import gawfs.TaskDef;
Expand Down Expand Up @@ -40,7 +41,7 @@ public static void storeHistory(long originalTaskId, String content) {
}

public static void attachToBusinessCase(final ICase icase, final Long businessCaseId) {
IvyExecutor.executeAsSystem(() -> {
Sudo.get(() -> {
icase.attachToBusinessCase(businessCaseId);
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ch.ivy.addon.portalkit.service.exception.PortalException;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.persistence.PersistencyException;
import ch.ivyteam.ivy.security.exec.Sudo;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.ITask;
import ch.ivyteam.ivy.workflow.query.CaseQuery;
Expand All @@ -21,7 +22,7 @@ private ExecutingExpressProcessUtils() {}

@SuppressWarnings("unchecked")
public static <T> List<T> getAttributesOfTasks(String groupId, String attribute) {
return IvyExecutor.executeAsSystem(() -> {
return Sudo.get(() -> {
TaskQuery query =
TaskQuery.create().where().caseId().isEqual(Ivy.wfCase().getId()).and().customField().textField(TASK_GROUP_ID_KEY)
.isEqual(groupId).orderBy().endTimestamp();
Expand All @@ -40,7 +41,7 @@ public static <T> List<T> getAttributesOfTasks(String groupId, String attribute)

@SuppressWarnings("unchecked")
public static <T> List<T> getExpressTaskEndProcessData(Long caseId, String parentCategoryName) {
return IvyExecutor.executeAsSystem(() -> {
return Sudo.get(() -> {
TaskQuery query = buildExpressTaskQuery(caseId, parentCategoryName);
query.orderBy().endTimestamp();
List<ITask> tasks = Ivy.wf().getTaskQueryExecutor().getResults(query);
Expand All @@ -66,7 +67,7 @@ private static TaskQuery buildExpressTaskQuery(Long caseId, String parentCategor
}

public static ICase getExpressCase(long caseId) {
return IvyExecutor.executeAsSystem(() -> {
return Sudo.get(() -> {
CaseQuery query = CaseQuery.businessCases().where().caseId().isEqual(caseId)
.and().customField().stringField(CustomFields.IS_EXPRESS_PROCESS).isEqual("true");
List<ICase> result = Ivy.wf().getCaseQueryExecutor().getResults(query);
Expand Down
4 changes: 2 additions & 2 deletions axonivy-express/src/ch/ivy/gawfs/mail/ExpressMailClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import ch.ivy.addon.portalkit.bo.ExpressUserEmail;
import ch.ivy.addon.portalkit.dto.ExpressAttachment;
import ch.ivy.addon.portalkit.util.IvyExecutor;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.mail.Attachment;
import ch.ivyteam.ivy.mail.MailClient;
Expand All @@ -19,11 +18,12 @@
import ch.ivyteam.ivy.mail.MailMessage;
import ch.ivyteam.ivy.mail.MailMessage.Builder;
import ch.ivyteam.ivy.scripting.objects.File;
import ch.ivyteam.ivy.security.exec.Sudo;

public class ExpressMailClient {

public static void send(ExpressUserEmail mail) {
IvyExecutor.executeAsSystem(() -> {
Sudo.get(() -> {
MailMessage message = mapMailMessage(mail);
MailClientConfig mailSetupConfig = getMailClientConfig();

Expand Down

0 comments on commit 8062fd2

Please sign in to comment.