Skip to content

Commit 0258c89

Browse files
committed
1 parent 10bc1da commit 0258c89

File tree

1 file changed

+70
-12
lines changed

1 file changed

+70
-12
lines changed

framework/service/src/com/ilscipio/scipio/service/test/ServiceTestServices.java

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
import com.ilscipio.scipio.service.def.Attribute;
44
import com.ilscipio.scipio.service.def.EntityAttributes;
55
import com.ilscipio.scipio.service.def.Implements;
6+
import com.ilscipio.scipio.service.def.OverrideAttribute;
7+
import com.ilscipio.scipio.service.def.Permission;
8+
import com.ilscipio.scipio.service.def.PermissionService;
9+
import com.ilscipio.scipio.service.def.Permissions;
610
import com.ilscipio.scipio.service.def.Service;
711
import org.ofbiz.base.util.Debug;
12+
import org.ofbiz.base.util.GeneralException;
813
import org.ofbiz.service.ServiceContext;
14+
import org.ofbiz.service.ServiceHandler;
915
import org.ofbiz.service.ServiceUtil;
1016

1117
import java.util.Map;
@@ -21,11 +27,12 @@ public abstract class ServiceTestServices {
2127

2228
@Service(
2329
attributes = {
24-
@Attribute(name = "param1", type = "String", mode = "IN", defaultValue = "test value 1", optional = "true")
30+
@Attribute(name = "param1", type = "String", mode = "IN", defaultValue = "test value 1", optional = "true"),
31+
@Attribute(name = "result1", type = "String", mode = "OUT", optional = "true")
2532
}
2633
)
27-
public static Map<String, Object> adminTestAnnotations1(ServiceContext ctx) {
28-
Debug.logInfo("adminTestAnnotations1: input: " + ctx.context(), module);
34+
public static Map<String, Object> serviceAnnotationsTest1(ServiceContext ctx) {
35+
Debug.logInfo("serviceAnnotationsTest1: input: " + ctx.context(), module);
2936
Map<String, Object> result = ServiceUtil.returnSuccess();
3037
result.put("result1", "test result value 1");
3138
return result;
@@ -38,22 +45,45 @@ public static Map<String, Object> adminTestAnnotations1(ServiceContext ctx) {
3845
@Attribute(name = "result1", type = "String", mode = "OUT", optional = "true")
3946
}
4047
)
41-
public static Map<String, Object> adminTestAnnotations2(ServiceContext ctx) {
42-
Debug.logInfo("adminTestAnnotations2: input: " + ctx.context(), module);
48+
public static class ServiceAnnotationsTest2 extends ServiceHandler.Local implements ServiceHandler.Exec {
49+
public ServiceAnnotationsTest2(ServiceContext ctx) { // NOTE: If omitted, init(ServiceContext) is called instead
50+
super(ctx);
51+
}
52+
53+
@Override
54+
public Map<String, Object> exec() {
55+
Debug.logInfo("serviceAnnotationsTest2: input: " + ctx.context(), module);
56+
Map<String, Object> result = ServiceUtil.returnSuccess();
57+
result.put("result1", "test result value 1");
58+
return result;
59+
}
60+
}
61+
62+
@Service(
63+
implemented = {
64+
@Implements(service = "serviceAnnotationsTest1")
65+
},
66+
auth = "true",
67+
permissionService = {
68+
@PermissionService(service = "commonGenericPermission", mainAction = "UPDATE")
69+
}
70+
)
71+
public static Map<String, Object> serviceAnnotationsTest3(ServiceContext ctx) {
72+
Debug.logInfo("serviceAnnotationsTest3: input: " + ctx.context(), module);
4373
Map<String, Object> result = ServiceUtil.returnSuccess();
4474
result.put("result1", "test result value 1");
4575
return result;
4676
}
4777

4878
@Service(
49-
name = "adminTestAnnotations2Extended",
79+
name = "serviceAnnotationsTest4Extended",
5080
description = "Extended @Service annotations test service (2)",
5181
deprecated = "Test deprecation message",
5282
deprecatedSince = "2023-02-10",
53-
deprecatedBy = "adminTestAnnotations1",
83+
deprecatedBy = "serviceAnnotationsTest3",
5484
implemented = {
55-
@Implements(service = "adminTestAnnotations1"),
56-
@Implements(service = "adminTestAnnotations2")
85+
@Implements(service = "serviceAnnotationsTest1"),
86+
@Implements(service = "serviceAnnotationsTest2")
5787
},
5888
defaultEntityName = "Person",
5989
entityAttributes = {
@@ -65,12 +95,40 @@ public static Map<String, Object> adminTestAnnotations2(ServiceContext ctx) {
6595
@Attribute(name = "param4", type = "String", mode = "IN", defaultValue = "test value 4", optional = "true"),
6696
@Attribute(name = "result2", type = "String", mode = "OUT", optional = "true")
6797
},
68-
auth = "true"
98+
auth = "true",
99+
permissions = {
100+
@Permissions(
101+
joinType = "AND",
102+
permissions = {
103+
@Permission(permission = "OFBTOOLS", action = "_VIEW")
104+
},
105+
services = {
106+
@PermissionService(service = "commonGenericPermission", mainAction = "UPDATE")
107+
}
108+
)
109+
},
110+
log = "debug",
111+
overrideAttributes = {
112+
@OverrideAttribute(name = "param1", defaultValue = "test value 1 override"),
113+
@OverrideAttribute(name = "param2", defaultValue = "test value 2 override"),
114+
},
115+
logEca = "debug",
116+
maxRetry = "3",
117+
priority = "25",
118+
jobPoolPersist = "pool",
119+
requireNewTransaction = "true",
120+
validate = "true",
121+
semaphore = "fail",
122+
semaphoreSleep = "1000",
123+
semaphoreWaitSeconds = "800",
124+
startDelay = "200",
125+
hideResultInLog = "false"
69126
)
70-
public static Map<String, Object> adminTestAnnotations2Ext(ServiceContext ctx) {
71-
Debug.logInfo("adminTestAnnotations2Ext: input: " + ctx.context(), module);
127+
public static Map<String, Object> serviceAnnotationsTest4Ext(ServiceContext ctx) {
128+
Debug.logInfo("serviceAnnotationsTest4Extended: input: " + ctx.context(), module);
72129
Map<String, Object> result = ServiceUtil.returnSuccess();
73130
result.put("result1", "test result value 1");
131+
result.put("result2", "test result value 2");
74132
return result;
75133
}
76134

0 commit comments

Comments
 (0)