diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java index e591406dbc..0223a16cd5 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java @@ -42,8 +42,11 @@ import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilHttp; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntity; +import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.security.Security; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; @@ -107,7 +110,7 @@ public class CoreEvents { Security security = (Security) request.getAttribute("security"); GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - //Delegator delegator = (Delegator) request.getAttribute("delegator"); + Delegator delegator = (Delegator) request.getAttribute("delegator"); Locale locale = UtilHttp.getLocale(request); TimeZone timeZone = UtilHttp.getTimeZone(request); @@ -122,6 +125,7 @@ public class CoreEvents { String serviceIntr = (String) params.remove("SERVICE_INTERVAL"); String serviceCnt = (String) params.remove("SERVICE_COUNT"); String retryCnt = (String) params.remove("SERVICE_MAXRETRY"); + String runAsSystemUser = (String) params.remove("SERVICE_RUN_AS_SYSTEM"); // the frequency map Map freqMap = new HashMap(); @@ -206,6 +210,17 @@ public class CoreEvents { serviceContext.put("userLogin", userLogin); } + // Override the userLogin with system when runAsSystem is Y + if ("Y".equals(runAsSystemUser)) { + try { + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); + serviceContext.put("userLogin", userLogin); + } catch (GenericEntityException e) { + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } + } + if (locale != null) { serviceContext.put("locale", locale); } diff --git a/framework/webtools/config/WebtoolsUiLabels.xml b/framework/webtools/config/WebtoolsUiLabels.xml index b29c3ef384..048ff06bbd 100644 --- a/framework/webtools/config/WebtoolsUiLabels.xml +++ b/framework/webtools/config/WebtoolsUiLabels.xml @@ -4535,6 +4535,9 @@ 结果 結果 + + Run As System + GC starten Run GC diff --git a/framework/webtools/data/WebtoolsSecurityGroupDemoData.xml b/framework/webtools/data/WebtoolsSecurityGroupDemoData.xml index 7a246f0f47..894f5f2239 100644 --- a/framework/webtools/data/WebtoolsSecurityGroupDemoData.xml +++ b/framework/webtools/data/WebtoolsSecurityGroupDemoData.xml @@ -45,6 +45,7 @@ under the License. + diff --git a/framework/webtools/data/WebtoolsSecurityPermissionSeedData.xml b/framework/webtools/data/WebtoolsSecurityPermissionSeedData.xml index 70cd28b8b6..196acc8d0f 100644 --- a/framework/webtools/data/WebtoolsSecurityPermissionSeedData.xml +++ b/framework/webtools/data/WebtoolsSecurityPermissionSeedData.xml @@ -36,6 +36,7 @@ under the License. + @@ -60,6 +61,7 @@ under the License. + @@ -75,4 +77,5 @@ under the License. + diff --git a/framework/webtools/widget/ServiceForms.xml b/framework/webtools/widget/ServiceForms.xml index f9bf6ca86c..252eabad26 100644 --- a/framework/webtools/widget/ServiceForms.xml +++ b/framework/webtools/widget/ServiceForms.xml @@ -23,6 +23,9 @@ under the License.
+ + + @@ -43,6 +46,7 @@ under the License. +