3821c.4384k.patch
src/com/goldencode/p2j/oo/core/LegacyString.java 2021-05-21 12:43:12 +0000 | ||
---|---|---|
13 | 13 |
** CA 20210113 Renamed trim() to trim_(), to follow NameConverter's rules. |
14 | 14 |
** 006 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
15 | 15 |
** signature. |
16 |
** 007 ME 20210520 Set hashCode to return the actual string hashCode. |
|
16 | 17 |
*/ |
17 | 18 | |
18 | 19 |
/* |
... | ... | |
680 | 681 |
})); |
681 | 682 |
} |
682 | 683 |
|
684 |
@Override |
|
683 | 685 |
public int hashCode() |
684 | 686 |
{ |
685 |
return this.value.hashCode(); |
|
687 |
return this.value.toStringMessage().hashCode();
|
|
686 | 688 |
} |
687 | 689 |
|
688 | 690 |
} |
src/com/goldencode/p2j/oo/core/collections/LegacyMap.java 2021-05-24 05:27:05 +0000 | ||
---|---|---|
12 | 12 |
** 003 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 | 14 |
** 004 ME 20210325 Increment/decrement object references (key/value) when added/removed. |
15 |
** ME 20210521 Use a 'key' object with hashCode/equals overrides. |
|
15 | 16 |
*/ |
16 | 17 | |
17 | 18 |
/* |
... | ... | |
79 | 80 |
import static com.goldencode.p2j.util.BlockManager.*; |
80 | 81 |
import static com.goldencode.p2j.util.InternalEntry.Type; |
81 | 82 | |
83 |
import java.lang.reflect.InvocationHandler; |
|
84 |
import java.lang.reflect.Method; |
|
85 |
import java.lang.reflect.Proxy; |
|
82 | 86 |
import java.util.HashMap; |
83 | 87 |
import java.util.LinkedHashMap; |
84 | 88 |
import java.util.Map; |
... | ... | |
93 | 97 |
public class LegacyMap extends BaseObject implements com.goldencode.p2j.oo.core.collections.Imap |
94 | 98 |
{ |
95 | 99 |
private HashMap<object, object> map = new LinkedHashMap<object, object>(); |
100 |
|
|
96 | 101 |
// 4GL BUG, size not reset on clear |
97 | 102 |
private int size = 0; |
98 | 103 | |
... | ... | |
214 | 219 | |
215 | 220 |
return function(LegacyMap.class, this, "ContainsKey", logical.class, new Block((Body) () -> |
216 | 221 |
{ |
217 |
returnNormal(new logical(map.containsKey(poKey)));
|
|
218 |
}));
|
|
222 |
returnNormal(new logical(map.containsKey(new keyobject(poKey))));
|
|
223 |
})); |
|
219 | 224 |
} |
220 | 225 | |
221 | 226 |
@LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "ContainsAllKeys", parameters = { |
... | ... | |
314 | 319 | |
315 | 320 |
return function(LegacyMap.class, this, "Get", object.class, new Block((Body) () -> |
316 | 321 |
{ |
317 | ||
318 |
if (map.containsKey(poKey)) |
|
319 |
returnNormal(map.get(poKey)); |
|
322 |
keyobject key = new keyobject(poKey); |
|
323 |
|
|
324 |
if (map.containsKey(key)) |
|
325 |
returnNormal(map.get(key)); |
|
320 | 326 | |
321 | 327 |
returnNormal(new object()); |
322 | 328 |
})); |
... | ... | |
340 | 346 |
if (poKey.ref().equals(this)) |
341 | 347 |
undoThrow(AppError.newInstance(new character("A Map cannot have itself as key."))); |
342 | 348 | |
343 |
ObjectOps.increment(poKey.ref()); |
|
344 | 349 |
if (poValue._isValid()) |
345 | 350 |
{ |
346 | 351 |
ObjectOps.increment(poValue.ref()); |
347 | 352 |
} |
348 | 353 |
|
349 |
object obj = map.put(poKey, poValue);
|
|
354 |
object obj = map.put(new keyobject(poKey), poValue);
|
|
350 | 355 | |
351 |
if (obj == null) |
|
356 |
if (obj == null) |
|
357 |
{ |
|
358 |
ObjectOps.increment(poKey.ref()); |
|
352 | 359 |
size++; |
360 |
} |
|
353 | 361 |
|
354 | 362 |
returnNormal(obj != null ? obj : new object()); |
355 | 363 |
})); |
... | ... | |
468 | 476 |
{ |
469 | 477 |
return map; |
470 | 478 |
} |
479 |
|
|
480 |
class keyobject extends object { |
|
481 |
|
|
482 |
public keyobject(object other) |
|
483 |
{ |
|
484 |
super(other); |
|
485 |
} |
|
486 | ||
487 |
@Override |
|
488 |
public int hashCode() |
|
489 |
{ |
|
490 |
return _isValid() ? ref.hashCode() : 0; |
|
491 |
} |
|
492 | ||
493 |
@Override |
|
494 |
public boolean equals(Object obj) |
|
495 |
{ |
|
496 |
if (obj instanceof object) |
|
497 |
{ |
|
498 |
object other = (object) obj; |
|
499 |
return _isValid() ? ref.legacyEquals(other).booleanValue() : !other._isValid(); |
|
500 |
} |
|
501 |
|
|
502 |
return false; |
|
503 |
} |
|
504 |
} |
|
471 | 505 |
} |
src/com/goldencode/p2j/oo/lang/ParameterList.java 2021-05-10 06:17:30 +0000 | ||
---|---|---|
14 | 14 |
** CA 20210216 Methods which have an int parameter must use the BlockManager API for top-level block. |
15 | 15 |
** 004 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
16 | 16 |
** signature. |
17 |
** 005 ME 20210507 Improve parameter validation (call syntax uses '-' as separator instead space). |
|
17 | 18 |
*/ |
18 | 19 | |
19 | 20 |
/* |
... | ... | |
72 | 73 |
package com.goldencode.p2j.oo.lang; |
73 | 74 | |
74 | 75 |
import static com.goldencode.p2j.util.BlockManager.*; |
76 | ||
77 |
import com.goldencode.p2j.persist.DataSetParameter; |
|
78 | ||
75 | 79 |
import static com.goldencode.p2j.report.ReportConstants.*; |
76 | 80 | |
77 | 81 |
import com.goldencode.p2j.util.*; |
... | ... | |
241 | 245 |
ErrorManager.recordOrThrowError(15295, "Unusable datatype for SetParameter method.", false); |
242 | 246 |
} |
243 | 247 |
|
244 |
CallMode cmode = CallMode.buildMode(mode); |
|
245 |
if (cmode == null) |
|
248 |
// space is used as separator instead of '-' for call, trailing spaces are allowed |
|
249 |
CallMode cmode = CallMode.buildMode(TextOps.replaceAll(TextOps.rightTrim(mode), " ", "-")); |
|
250 |
if (!validCallMode(cmode, type.getValue(), val)) |
|
246 | 251 |
{ |
247 | 252 |
String msg = "SetParameter IOmode parameter is required in the overload" |
248 | 253 |
+ " being used, and should be 'INPUT', 'OUTPUT', 'INPUT-OUTPUT'" |
... | ... | |
252 | 257 |
|
253 | 258 |
if (!cmode.input && !Call.validOutputParameter(pos.intValue(), val)) |
254 | 259 |
{ |
255 |
returnNormal(new logical(false)); |
|
260 |
ErrorManager.recordOrThrowError(15311, |
|
261 |
"SetParameter value for OUTPUT parameters may not be a function or any expression unsuitable for output, nor a database field.", |
|
262 |
false); |
|
256 | 263 |
} |
257 | 264 |
|
258 | 265 |
CallParameter param = Call.createParameter(type.getValue(), cmode, val, false, true); |
... | ... | |
268 | 275 |
})); |
269 | 276 |
} |
270 | 277 | |
278 |
private boolean validCallMode(CallMode cmode, String type, Object val) |
|
279 |
{ |
|
280 |
if (cmode != null) |
|
281 |
{ |
|
282 |
if (val instanceof BaseDataTypeVariable) |
|
283 |
{ |
|
284 |
val = ((BaseDataTypeVariable) val).get(); |
|
285 |
} |
|
286 | ||
287 |
boolean needDataStructure = false; |
|
288 |
|
|
289 |
switch (cmode.mode) |
|
290 |
{ |
|
291 |
// by-value is not accepted although it's default |
|
292 |
case BY_VALUE: |
|
293 |
return false; |
|
294 |
case BIND: |
|
295 |
if (cmode.inputOutput) |
|
296 |
return false; |
|
297 |
case BY_REFERENCE: |
|
298 |
if (cmode.append) |
|
299 |
return false; |
|
300 |
needDataStructure = true; |
|
301 | ||
302 |
} |
|
303 |
|
|
304 |
needDataStructure = needDataStructure || cmode.append; |
|
305 |
|
|
306 |
if (needDataStructure) |
|
307 |
return ("TABLE".equalsIgnoreCase(type) || "TABLE-HANDLE".equalsIgnoreCase(type) |
|
308 |
|| "DATASET".equalsIgnoreCase(type) |
|
309 |
|| "DATASET-HANDLE".equalsIgnoreCase(type)) |
|
310 |
&& (val instanceof TableParameter || val instanceof DataSetParameter |
|
311 |
|| val instanceof handle); |
|
312 |
|
|
313 |
return true; |
|
314 |
} |
|
315 | ||
316 |
return false; |
|
317 |
} |
|
318 | ||
271 | 319 |
/** |
272 | 320 |
* Get the argument modes. |
273 | 321 |
* |
src/com/goldencode/p2j/oo/net/FileTypeRegistry.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
9 | 9 |
** 002 CA 20210113 Renamed clear() to clear_(), to follow NameConverter's rules. |
10 | 10 |
** 003 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
11 | 11 |
** signature. |
12 |
** 004 ME 20210519 Fix registry lazy loading. |
|
12 | 13 |
*/ |
13 | 14 | |
14 | 15 |
/* |
... | ... | |
81 | 82 | |
82 | 83 |
import java.util.ArrayList; |
83 | 84 |
import java.util.HashMap; |
84 |
import java.util.HashSet; |
|
85 | 85 |
import java.util.List; |
86 |
import java.util.Map.Entry; |
|
87 | 86 |
import java.util.Set; |
88 | 87 | |
89 | 88 |
/** |
... | ... | |
164 | 163 |
|
165 | 164 |
return function(FileTypeRegistry.class, "Registry", object.class, new Block((Body) () -> |
166 | 165 |
{ |
167 |
if(registry.get().isUnknown())
|
|
166 |
if(!registry.get()._isValid())
|
|
168 | 167 |
{ |
169 |
object<? extends FileTypeRegistry> oFTR = ObjectOps.newInstance(FileTypeRegistry.class); |
|
170 |
initMap(oFTR); |
|
171 |
registry.set(oFTR); |
|
168 |
registry.get().assign(ObjectOps.newInstance(FileTypeRegistry.class)); |
|
169 |
initMap(registry.get()); |
|
172 | 170 |
} |
173 | 171 |
returnNormal(registry.get()); |
174 | 172 |
})); |
src/com/goldencode/p2j/oo/net/http/ClientBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
11 | 11 |
** 004 ME 20200410 Complete implementation as of OE 11.7.4. |
12 | 12 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 |
** 006 ME 20210519 Fix registry lazy loading. |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
247 | 248 |
final object<? extends com.goldencode.p2j.oo.net.http.IhttpClient> p2) |
248 | 249 |
{ |
249 | 250 |
object<? extends com.goldencode.p2j.oo.lang.LegacyClass> _p1 = TypeFactory.initInput(p1); |
251 |
object<? extends _BaseObject_> client = TypeFactory.object(IhttpClient.class); |
|
252 |
|
|
250 | 253 |
return function(ClientBuilder.class, "DecorateClient", object.class, new Block((Body) () -> { |
251 | 254 |
|
252 | 255 |
object<? extends LegacyClass> decoratorType = ObjectOps.newInstance(LegacyClass.class); |
... | ... | |
260 | 263 |
else { |
261 | 264 |
Assert.isType(decoratorType, ObjectOps.getLegacyClass(HttpClientDecorator.class)); |
262 | 265 |
|
263 |
object<? extends _BaseObject_> client = ObjectOps |
|
264 |
.newInstance(decoratorType.ref().getType(), "I", p2); |
|
266 |
client.assign(ObjectOps.newInstance(decoratorType.ref().getType(), "I", p2)); |
|
265 | 267 |
|
266 | 268 |
if (!client.isUnknown() && client.ref() instanceof ISupportInitialize) |
267 | 269 |
((ISupportInitialize) client.ref()).initialize(); |
... | ... | |
303 | 305 |
{ |
304 | 306 |
return function(null, "Registry", object.class, new Block((Body) () -> |
305 | 307 |
{ |
306 |
object<? extends BuilderRegistry> registry = ClientBuilder.registry.get(); |
|
307 |
|
|
308 |
if (!registry.isValid().booleanValue()) { |
|
309 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class)); |
|
310 |
initializeRegistry(registry); |
|
308 |
if (!registry.get().isValid().booleanValue()) { |
|
309 |
registry.get().assign(ObjectOps.newInstance(BuilderRegistry.class)); |
|
310 |
initializeRegistry(registry.get()); |
|
311 | 311 |
} |
312 | 312 |
|
313 |
returnNormal(registry); |
|
313 |
returnNormal(registry.get());
|
|
314 | 314 |
})); |
315 | 315 |
} |
316 | 316 |
src/com/goldencode/p2j/oo/net/http/CookieJarBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
11 | 11 |
** 004 ME 20201028 Implement missing methods as of OE12.2. |
12 | 12 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 |
** 006 ME 20210519 Fix registry lazy loading. |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
124 | 125 |
{ |
125 | 126 |
return function(null, "Registry", object.class, new Block((Body) () -> |
126 | 127 |
{ |
127 |
object<? extends BuilderRegistry> oRegistry = CookieJarBuilder.registry.get(); |
|
128 |
|
|
129 |
if(!oRegistry._isValid()) |
|
128 |
if(!registry.get()._isValid()) |
|
130 | 129 |
{ |
131 |
oRegistry.assign(ObjectOps.newInstance(BuilderRegistry.class));
|
|
130 |
registry.get().assign(ObjectOps.newInstance(BuilderRegistry.class));
|
|
132 | 131 |
|
133 |
oRegistry.ref().put(new character(ObjectOps.getLegacyName(CookieJarBuilder.class)),
|
|
132 |
registry.get().ref().put(new character(ObjectOps.getLegacyName(CookieJarBuilder.class)),
|
|
134 | 133 |
ObjectOps.getLegacyClass(DefaultCookieJarBuilder.class)); |
135 |
oRegistry.ref().put(new character(ObjectOps.getLegacyName(ICookieJar.class)),
|
|
134 |
registry.get().ref().put(new character(ObjectOps.getLegacyName(ICookieJar.class)),
|
|
136 | 135 |
ObjectOps.getLegacyClass(CookieJar.class)); |
137 | 136 |
} |
138 |
returnNormal(oRegistry);
|
|
137 |
returnNormal(registry.get());
|
|
139 | 138 |
})); |
140 | 139 |
} |
141 | 140 | |
... | ... | |
158 | 157 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL) |
159 | 158 |
public static object<? extends com.goldencode.p2j.oo.net.http.CookieJarBuilder> build() |
160 | 159 |
{ |
160 |
object<? extends CookieJarBuilder> oCJB = TypeFactory.object(CookieJarBuilder.class); |
|
161 |
|
|
161 | 162 |
return function(CookieJarBuilder.class, "Build", object.class, new Block((Body)() -> |
162 | 163 |
{ |
163 | 164 | |
... | ... | |
166 | 167 |
|
167 | 168 |
Assert.isType(oBuilderType, ObjectOps.getLegacyClass(CookieJarBuilder.class)); |
168 | 169 |
|
169 |
object<? extends CookieJarBuilder> oCJB = (object<? extends CookieJarBuilder>) |
|
170 |
ObjectOps.newInstance(oBuilderType.ref().getType()); |
|
170 |
oCJB.assign(ObjectOps.newInstance(oBuilderType.ref().getType())); |
|
171 | 171 |
|
172 | 172 |
if (oCJB._isValid() && oCJB.ref() instanceof ISupportInitialize) |
173 | 173 |
((ISupportInitialize) oCJB.ref()).initialize(); |
... | ... | |
240 | 240 |
{ |
241 | 241 |
object<? extends com.goldencode.p2j.oo.lang.LegacyClass> poDecorationType = TypeFactory.initInput(_poDecorationType); |
242 | 242 |
object<? extends com.goldencode.p2j.oo.net.http.ICookieJar> poDecoratedClient = TypeFactory.initInput(_poDecoratedClient); |
243 |
object<? extends com.goldencode.p2j.oo.net.http.ICookieJar> decoratedClient = TypeFactory.object(ICookieJar.class); |
|
243 | 244 |
|
244 | 245 |
return function(CookieJarBuilder.class, "DecorateCookieJar", object.class, new Block((Body)() -> |
245 | 246 |
{ |
... | ... | |
251 | 252 |
|
252 | 253 |
Assert.isType(oType, ObjectOps.getLegacyClass(CookieJarDecorator.class)); |
253 | 254 |
|
254 |
object<? extends _BaseObject_> decoratedClient = ObjectOps.newInstance(oType.ref().getType(), "I", poDecoratedClient);
|
|
255 |
decoratedClient.assign(ObjectOps.newInstance(oType.ref().getType(), "I", poDecoratedClient));
|
|
255 | 256 |
|
256 | 257 |
if (decoratedClient._isValid() && decoratedClient.ref() instanceof ISupportInitialize) |
257 | 258 |
((ISupportInitialize) decoratedClient.ref()).initialize(); |
src/com/goldencode/p2j/oo/net/http/HttpClient.java 2021-05-24 06:39:56 +0000 | ||
---|---|---|
15 | 15 |
** CA 20210221 Fixed parameters at the LegacySignature annotation. |
16 | 16 |
** 007 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
17 | 17 |
** signature. |
18 |
** 008 ME 20210524 Added support for retries, destroy library and fix variable scope on execute. |
|
18 | 19 |
*/ |
19 | 20 | |
20 | 21 |
/* |
... | ... | |
80 | 81 |
import static com.goldencode.p2j.util.BlockManager.returnNormal; |
81 | 82 |
import com.goldencode.p2j.oo.core.*; |
82 | 83 |
import com.goldencode.p2j.oo.logging.*; |
83 |
import com.goldencode.p2j.oo.net.http.filter.status.AuthorizationStatusFilter; |
|
84 |
import com.goldencode.p2j.oo.net.http.filter.status.RedirectStatusFilter; |
|
85 | 84 |
import com.goldencode.p2j.oo.net.http.filter.writer.*; |
86 | 85 |
import com.goldencode.p2j.ui.LogicalTerminal; |
87 | 86 |
import com.goldencode.p2j.util.*; |
... | ... | |
127 | 126 |
* Destroy. |
128 | 127 |
*/ |
129 | 128 |
@LegacySignature(type = Type.METHOD, name = "Destroy") |
130 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_STUB)
|
|
129 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
|
|
131 | 130 |
@Override |
132 | 131 |
public void destroy() |
133 | 132 |
{ |
134 |
internalProcedure(HttpClient.class, this, "Destroy", new Block()); |
|
133 |
internalProcedure(HttpClient.class, this, "Destroy", new Block((Body) () -> |
|
134 |
{ |
|
135 |
if (ObjectOps.typeOf(library, ISupportInitialize.class).booleanValue()) |
|
136 |
ObjectOps.cast(library, ISupportInitialize.class).ref().destroy(); |
|
137 |
})); |
|
135 | 138 |
} |
136 | 139 | |
137 | 140 |
/** |
... | ... | |
272 | 275 |
* |
273 | 276 |
* @return HTTP Response. |
274 | 277 |
*/ |
275 |
@LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "Execute", qualified = IHTTPRESPONSE, parameters = |
|
276 |
{ |
|
277 |
@LegacyParameter(name = "poRequest", type = "OBJECT", qualified = IHTTPREQUEST, mode = "INPUT") |
|
278 |
}) |
|
279 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL) |
|
278 |
@LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "Execute", qualified = IHTTPRESPONSE, parameters = { |
|
279 |
@LegacyParameter(name = "poRequest", type = "OBJECT", qualified = IHTTPREQUEST, mode = "INPUT") }) |
|
280 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL) |
|
280 | 281 |
@Override |
281 | 282 |
public object<? extends IhttpResponse> execute(object<? extends IhttpRequest> _poRequest) |
282 | 283 |
{ |
283 | 284 |
object<? extends IhttpRequest> poRequest = TypeFactory.initInput(_poRequest); |
284 |
return function(this, "execute", object.class, new Block((Body) () -> |
|
285 |
{ |
|
286 |
object<? extends IhttpResponse> poResponse = ResponseBuilder.build().ref().getResponse(); |
|
285 |
object<? extends IhttpResponse> poResponse = TypeFactory.object(IhttpResponse.class); |
|
286 | ||
287 |
return function(this, "execute", object.class, new Block((Init) () -> { |
|
288 |
ObjectOps.register(poResponse); |
|
289 |
}, (Body) () -> { |
|
290 |
poResponse.assign(ResponseBuilder.build().ref().getResponse()); |
|
287 | 291 |
execute(poRequest, poResponse); |
288 | 292 |
returnNormal(poResponse); |
289 | 293 |
})); |
... | ... | |
322 | 326 |
{ |
323 | 327 |
object<? extends IhttpRequest> poRequest = TypeFactory.initInput(_poRequest); |
324 | 328 |
object<? extends IhttpResponse> poResponse = TypeFactory.initInput(_poResponse); |
325 |
internalProcedure(this, "__net_http_FwdHttpClientLibrary_constructor__", new Block((Body) () -> |
|
329 |
|
|
330 |
internalProcedure(this, "execute", new Block((Body) () -> |
|
326 | 331 |
{ |
327 |
int retry = Math.max(options.ref().getNumRetries().intValue(), 0); |
|
328 |
double retryPause = retry > 0 ? Math.max(options.ref().getPauseBetweenRetry().doubleValue(), 0) : 0; |
|
332 |
|
|
333 |
Assert.notNull(poRequest, new character("Http request")); |
|
334 |
Assert.notNull(poResponse, new character("Http response")); |
|
335 |
|
|
336 |
int retries = Math.max(options.ref().getNumRetries().intValue(), 0); |
|
337 |
int retry = 0; |
|
338 |
double retryPause = retries > 0 ? Math.max(options.ref().getPauseBetweenRetry().doubleValue(), 0) : 0; |
|
339 |
|
|
340 |
raw reqHash = TypeFactory.raw(); |
|
341 |
|
|
342 |
if (retries > 0) |
|
343 |
getLogger().ref().debug(TextOps.substitute("Initial request for &1 &2; max retries=&3", |
|
344 |
poRequest.ref().getMethod(), |
|
345 |
poRequest.ref().getUri().ref().toLegacyString(), |
|
346 |
retries)); |
|
329 | 347 |
|
330 | 348 |
do |
331 | 349 |
{ |
350 |
if (retry > 0) |
|
351 |
getLogger().ref().debug(TextOps.substitute("Retry attempt &1 of &2 for &3 &4", |
|
352 |
retry, |
|
353 |
retries, |
|
354 |
poRequest.ref().getMethod(), |
|
355 |
poRequest.ref().getUri().ref().toLegacyString())); |
|
356 |
|
|
357 |
addUserAgent(poRequest); |
|
358 |
|
|
359 |
_addAuthentication(poRequest); |
|
360 |
|
|
361 |
reqHash.assign(poRequest.ref().getContentMd5()); |
|
362 |
|
|
332 | 363 |
library.ref().execute(poRequest, poResponse); |
333 | 364 |
|
334 |
if (retry > 0 && retryPause > 0) |
|
335 |
LogicalTerminal.pause(retryPause, (String) null); |
|
365 |
if (processStatusAction(poRequest, poResponse).booleanValue()) |
|
366 |
break; |
|
367 |
|
|
368 |
if (retries == 0 || (retries > 0 && CompareOps._isEqual(reqHash, poRequest.ref().getContentMd5()))) |
|
369 |
{ |
|
370 |
retry++; |
|
371 |
|
|
372 |
if (retryPause > 0) |
|
373 |
LogicalTerminal.pause(retryPause, (String) null); |
|
374 |
} |
|
336 | 375 |
} |
337 |
while(retry >= 0 && !processStatusAction(poRequest, poResponse).booleanValue());
|
|
376 |
while(retry <= retries);
|
|
338 | 377 |
})); |
339 | 378 |
} |
340 | 379 | |
380 |
private void _addAuthentication(object<? extends IhttpRequest> _poRequest) |
|
381 |
{ |
|
382 |
object<? extends IAuthenticatedRequest> authRequest = TypeFactory |
|
383 |
.object(IAuthenticatedRequest.class); |
|
384 | ||
385 |
if (ObjectOps.typeOf(_poRequest, IAdaptable.class).booleanValue()) |
|
386 |
{ |
|
387 |
authRequest.assign(ObjectOps.cast(_poRequest, IAdaptable.class).ref() |
|
388 |
.getAdapter(ObjectOps.getLegacyClass(IAuthenticatedRequest.class))); |
|
389 |
} |
|
390 |
|
|
391 |
if (!authRequest._isValid() && ObjectOps.typeOf(_poRequest, IAuthenticatedRequest.class).booleanValue()) |
|
392 |
{ |
|
393 |
authRequest.assign(ObjectOps.cast(_poRequest, IAuthenticatedRequest.class)); |
|
394 |
} |
|
395 |
|
|
396 |
if (authRequest._isValid()) |
|
397 |
authRequest.ref().addAuthentication(); |
|
398 |
|
|
399 |
} |
|
400 |
|
|
341 | 401 |
/** |
342 | 402 |
* Process HttpResponse status code. |
343 | 403 |
* |
... | ... | |
361 | 421 | |
362 | 422 |
if (statusCodeWriter._isValid()) |
363 | 423 |
{ |
364 |
// really no point to retry if authorization is required but not an authenticated request |
|
365 |
if (ObjectOps.typeOf(statusCodeWriter, AuthorizationStatusFilter.class).booleanValue() && |
|
366 |
ObjectOps.typeOf(poRequest, AuthenticatedRequest.class).booleanValue()) |
|
367 |
returnNormal(true); |
|
424 |
// maybe there is no point to retry if authorization is required but |
|
425 |
// not an authenticated request, still seems not to be the case in 4GL |
|
426 |
// if (ObjectOps.typeOf(statusCodeWriter, AuthorizationStatusFilter.class).booleanValue() && |
|
427 |
// ObjectOps.typeOf(poRequest, AuthenticatedRequest.class).booleanValue()) |
|
428 |
// returnNormal(true); |
|
368 | 429 |
|
369 | 430 |
// copy session management info from initial response, if any |
370 | 431 |
_copyCookies(poResponse.ref(), poRequest.ref()); |
src/com/goldencode/p2j/oo/net/http/HttpClientDecorator.java 2021-05-24 05:32:17 +0000 | ||
---|---|---|
13 | 13 |
** - TypeFactory.initInput will take care of this. |
14 | 14 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
15 | 15 |
** signature. |
16 |
** 006 ME 20210520 Fixed local variable scope for return parameter. |
|
16 | 17 |
*/ |
17 | 18 | |
18 | 19 |
/* |
... | ... | |
183 | 184 |
public object<? extends com.goldencode.p2j.oo.net.http.IhttpResponse> execute( |
184 | 185 |
final object<? extends com.goldencode.p2j.oo.net.http.IhttpRequest> _poRequest) |
185 | 186 |
{ |
187 |
object<? extends IhttpResponse> poResponse = TypeFactory.object(IhttpResponse.class); |
|
188 |
|
|
186 | 189 |
return function(HttpClientDecorator.class, this, "Execute", object.class, new Block((Body) () -> |
187 | 190 |
{ |
188 |
object<? extends IhttpResponse> poResponse = ResponseBuilder.build().ref().getResponse();
|
|
191 |
poResponse.assign(ResponseBuilder.build().ref().getResponse());
|
|
189 | 192 |
|
190 | 193 |
execute(_poRequest, poResponse); |
191 | 194 |
|
src/com/goldencode/p2j/oo/net/http/HttpHeader.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
13 | 13 |
** ME 20210111 Fix toString (null header). |
14 | 14 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
15 | 15 |
** signature. |
16 |
** 006 ME 20210519 Fix NULL header lazy loading. |
|
16 | 17 |
*/ |
17 | 18 | |
18 | 19 |
/* |
... | ... | |
317 | 318 |
{ |
318 | 319 |
return function(null, "NullHeader", object.class, new Block((Body) () -> |
319 | 320 |
{ |
320 |
object<? extends NullHeader> nullHeader = NULL.get(); |
|
321 |
|
|
322 |
if (!nullHeader._isValid()) |
|
321 |
if (!NULL.get()._isValid()) |
|
323 | 322 |
{ |
324 |
nullHeader = ObjectOps.newInstance(NullHeader.class); |
|
325 |
NULL.set(nullHeader); |
|
323 |
NULL.get().assign(ObjectOps.newInstance(NullHeader.class)); |
|
326 | 324 |
} |
327 | 325 |
|
328 |
returnNormal(nullHeader);
|
|
326 |
returnNormal(NULL.get());
|
|
329 | 327 |
})); |
330 | 328 |
} |
331 | 329 |
|
src/com/goldencode/p2j/oo/net/http/HttpHeaderBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
11 | 11 |
** 004 CA 20210216 Fixed getRegistry() - the static var must be assigned, and not re-initialized. |
12 | 12 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 |
** 006 ME 20210519 Fix registry lazy loading. |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
203 | 204 |
{ |
204 | 205 |
return function(HttpHeaderBuilder.class, "Registry", object.class, new Block((Body) () -> |
205 | 206 |
{ |
206 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
207 |
|
|
208 |
if (!registry._isValid()) |
|
207 |
if (!REGISTRY.get()._isValid()) |
|
209 | 208 |
{ |
210 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
209 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
211 | 210 |
ObjectOps.getLegacyClass(HttpHeaderBuilder.class))); |
212 |
initializeRegistry(registry);
|
|
211 |
initializeRegistry(REGISTRY.get());
|
|
213 | 212 |
} |
214 |
returnNormal(registry);
|
|
213 |
returnNormal(REGISTRY.get());
|
|
215 | 214 |
})); |
216 | 215 |
} |
217 | 216 | |
... | ... | |
253 | 252 |
public static object<? extends HttpHeaderBuilder> build(final character _hName) |
254 | 253 |
{ |
255 | 254 |
character hName = TypeFactory.initInput(_hName); |
256 | ||
255 |
object<? extends HttpHeaderBuilder> builder = TypeFactory.object(HttpHeaderBuilder.class); |
|
256 |
|
|
257 | 257 |
return function(HttpHeaderBuilder.class, "Build", object.class, new Block((Body) () -> |
258 | 258 |
{ |
259 | 259 |
Assert.notNullOrEmpty(hName, new character("Header name")); |
... | ... | |
263 | 263 |
builderType.assign(getRegistry().ref().get(new character("*"))); |
264 | 264 |
} |
265 | 265 |
Assert.isType(builderType, ObjectOps.getLegacyClass(HttpHeaderBuilder.class)); |
266 |
object<? extends HttpHeaderBuilder> builder = (object<? extends HttpHeaderBuilder>) ObjectOps |
|
267 |
.newInstance(builderType.ref().getType(), "I", hName); |
|
266 |
builder.assign(ObjectOps.newInstance(builderType.ref().getType(), "I", hName)); |
|
268 | 267 |
if (ObjectOps.typeOf(builder, ISupportInitialize.class).booleanValue()) |
269 | 268 |
{ |
270 | 269 |
ObjectOps.cast(builder, ISupportInitialize.class).ref().initialize(); |
src/com/goldencode/p2j/oo/net/http/RequestBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
16 | 16 |
** 007 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
17 | 17 |
** signature. |
18 | 18 |
** ME 20210310 Add block 'referent' for static methods. |
19 |
** 008 ME 20210519 Fix registry lazy loading. |
|
19 | 20 |
*/ |
20 | 21 | |
21 | 22 |
/* |
... | ... | |
172 | 173 |
{ |
173 | 174 |
object<? extends LegacyClass> poDecorationType = TypeFactory.initInput(_poDecorationType); |
174 | 175 |
object<? extends IhttpRequest> poDecoratedRequest = TypeFactory.initInput(_poDecoratedRequest); |
176 |
object<? extends IhttpRequest> oRequest = TypeFactory.object(IhttpRequest.class); |
|
177 |
|
|
175 | 178 |
return function(RequestBuilder.class, "DecorateRequest", object.class, |
176 | 179 |
new Block((Body) () -> { |
177 | 180 |
|
... | ... | |
193 | 196 |
|
194 | 197 |
Assert.isType(oDecorator, ObjectOps.getLegacyClass(HttpRequestDecorator.class)); |
195 | 198 |
|
196 |
object<? extends _BaseObject_> oRequest = ObjectOps.newInstance(oDecorator.ref().getType(), "I", poDecoratedRequest);
|
|
199 |
oRequest.assign(ObjectOps.newInstance(oDecorator.ref().getType(), "I", poDecoratedRequest));
|
|
197 | 200 |
|
198 | 201 |
if (oRequest._isValid() && oRequest.ref() instanceof ISupportInitialize) |
199 | 202 |
((ISupportInitialize) oRequest.ref()).initialize(); |
... | ... | |
236 | 239 |
{ |
237 | 240 |
return function(RequestBuilder.class, "Registry", object.class, new Block((Body) () -> |
238 | 241 |
{ |
239 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
240 |
|
|
241 |
if (!registry._isValid()) { |
|
242 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class)); |
|
243 |
initializeRegistry(registry); |
|
242 |
if (!REGISTRY.get()._isValid()) { |
|
243 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class)); |
|
244 |
initializeRegistry(REGISTRY.get()); |
|
244 | 245 |
} |
245 | 246 |
|
246 |
returnNormal(registry);
|
|
247 |
returnNormal(REGISTRY.get());
|
|
247 | 248 |
})); |
248 | 249 |
} |
249 | 250 | |
... | ... | |
264 | 265 |
{ |
265 | 266 |
character pcMethod = TypeFactory.initInput(_pcMethod); |
266 | 267 |
object<? extends Uri> poURI = TypeFactory.initInput(_poURI); |
267 | ||
268 |
object<? extends RequestBuilder> builder = TypeFactory.object(RequestBuilder.class); |
|
269 |
|
|
268 | 270 |
return function(RequestBuilder.class, "Build", object.class, new Block((Body) () -> { |
269 | 271 |
object<? extends LegacyClass> builderCls = ObjectOps |
270 | 272 |
.getLegacyClass(RequestBuilder.class); |
... | ... | |
273 | 275 |
|
274 | 276 |
Assert.isType(builderType, builderCls); |
275 | 277 | |
276 |
object<? extends _BaseObject_> builder = ObjectOps |
|
277 |
.newInstance(builderType.ref().getType(), "II", pcMethod, poURI); |
|
278 |
builder.assign(ObjectOps.newInstance(builderType.ref().getType(), "II", pcMethod, poURI)); |
|
278 | 279 | |
279 | 280 |
if (builder._isValid() && builder.ref() instanceof ISupportInitialize) |
280 | 281 |
((ISupportInitialize) builder.ref()).initialize(); |
src/com/goldencode/p2j/oo/net/http/ResponseBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
12 | 12 |
** 004 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 | 14 |
** ME 20210310 Add block 'referent' for static methods. |
15 |
** 005 ME 20210519 Fix registry lazy loading. |
|
15 | 16 |
*/ |
16 | 17 | |
17 | 18 |
/* |
... | ... | |
136 | 137 |
{ |
137 | 138 |
return function(ResponseBuilder.class, "Registry", object.class, new Block((Body) () -> |
138 | 139 |
{ |
139 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
140 |
|
|
141 |
if (!registry._isValid()) { |
|
142 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class)); |
|
140 |
if (!REGISTRY.get()._isValid()) { |
|
141 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class)); |
|
143 | 142 |
|
144 |
registry.ref()._put(ObjectOps.getLegacyName(IhttpResponse.class),
|
|
143 |
REGISTRY.get().ref()._put(ObjectOps.getLegacyName(IhttpResponse.class),
|
|
145 | 144 |
ObjectOps.getLegacyClass(HttpResponse.class)); |
146 |
registry.ref()._put(ObjectOps.getLegacyName(ResponseBuilder.class),
|
|
145 |
REGISTRY.get().ref()._put(ObjectOps.getLegacyName(ResponseBuilder.class),
|
|
147 | 146 |
ObjectOps.getLegacyClass(DefaultResponseBuilder.class)); |
148 | 147 |
} |
149 | 148 |
|
150 |
returnNormal(registry);
|
|
149 |
returnNormal(REGISTRY.get());
|
|
151 | 150 |
})); |
152 | 151 |
} |
153 | 152 |
|
src/com/goldencode/p2j/oo/net/http/filter/auth/AuthenticationRequestFilter.java 2021-06-22 06:15:37 +0000 | ||
---|---|---|
245 | 245 |
final character _pcRealm) |
246 | 246 |
{ |
247 | 247 |
character pcRealm = TypeFactory.initInput(_pcRealm); |
248 | ||
248 |
object<? extends AuthenticationRequestEventArgs> oAuthReqArgs = TypeFactory.object(AuthenticationRequestEventArgs.class); |
|
249 |
|
|
249 | 250 |
return function(AuthenticationRequestFilter.class, this, "GetCredentials", object.class, |
250 | 251 |
new Block((Body) () -> |
251 | 252 |
{ |
... | ... | |
254 | 255 |
if (authenticatedRequest.ref().getCredentials()._isValid()) |
255 | 256 |
returnNormal(authenticatedRequest.ref().getCredentials()); |
256 | 257 |
|
257 |
object<? extends AuthenticationRequestEventArgs> oAuthReqArgs = ObjectOps.newInstance(AuthenticationRequestEventArgs.class,
|
|
258 |
"II", message, pcRealm); |
|
258 |
oAuthReqArgs.assign(ObjectOps.newInstance(AuthenticationRequestEventArgs.class,
|
|
259 |
"II", message, pcRealm));
|
|
259 | 260 | |
260 | 261 |
onHttpCredentialRequest(oAuthReqArgs); |
261 | 262 |
src/com/goldencode/p2j/oo/net/http/filter/writer/AuthenticationRequestWriterBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
13 | 13 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
14 | 14 |
** signature. |
15 | 15 |
** ME 20210310 Add block 'referent' for static methods. |
16 |
** 006 ME 20210519 Fix registry lazy loading. |
|
16 | 17 |
*/ |
17 | 18 | |
18 | 19 |
/* |
... | ... | |
213 | 214 |
public static object<? extends BuilderRegistry> getRegistry() |
214 | 215 |
{ |
215 | 216 |
return function(AuthenticationRequestWriterBuilder.class, "Registry", object.class, new Block((Body) () -> { |
216 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
217 | 217 | |
218 |
if (!registry._isValid())
|
|
218 |
if (!REGISTRY.get()._isValid())
|
|
219 | 219 |
{ |
220 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class));
|
|
220 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class));
|
|
221 | 221 | |
222 |
registry.ref()._put("Basic",
|
|
222 |
REGISTRY.get().ref()._put("Basic",
|
|
223 | 223 |
ObjectOps.getLegacyClass(BasicAuthenticationFilter.class)); |
224 |
registry.ref()._put("Digest",
|
|
224 |
REGISTRY.get().ref()._put("Digest",
|
|
225 | 225 |
ObjectOps.getLegacyClass(DigestAuthenticationFilter.class)); |
226 |
registry.ref()._put("None", ObjectOps.getLegacyClass(NoAuthenticationFilter.class));
|
|
226 |
REGISTRY.get().ref()._put("None", ObjectOps.getLegacyClass(NoAuthenticationFilter.class));
|
|
227 | 227 |
} |
228 | 228 | |
229 |
returnNormal(registry);
|
|
229 |
returnNormal(REGISTRY.get());
|
|
230 | 230 |
})); |
231 | 231 |
} |
232 | 232 |
} |
src/com/goldencode/p2j/oo/net/http/filter/writer/BodyWriterRegistry.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
12 | 12 |
** 004 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 | 14 |
** ME 20210310 Add block 'referent' for static methods. |
15 |
** 005 ME 20210519 Fix registry lazy loading. |
|
15 | 16 |
*/ |
16 | 17 | |
17 | 18 |
/* |
... | ... | |
70 | 71 |
package com.goldencode.p2j.oo.net.http.filter.writer; |
71 | 72 | |
72 | 73 |
import com.goldencode.p2j.util.*; |
74 |
import com.goldencode.p2j.util.BlockManager.Action; |
|
75 |
import com.goldencode.p2j.util.BlockManager.Condition; |
|
73 | 76 |
import com.goldencode.p2j.oo.lang.*; |
74 | 77 |
import com.goldencode.p2j.oo.net.http.*; |
75 | 78 |
import com.goldencode.p2j.oo.net.http.filter.payload.*; |
... | ... | |
114 | 117 |
{ |
115 | 118 |
return function(BodyWriterRegistry.class, "Registry", object.class, new Block((Body) () -> |
116 | 119 |
{ |
117 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
118 | ||
119 |
if (!registry._isValid()) |
|
120 |
if (!REGISTRY.get()._isValid()) |
|
120 | 121 |
{ |
121 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
122 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
122 | 123 |
ObjectOps.getLegacyClass(MessageWriter.class))); |
123 | 124 | |
124 |
initializeRegistry(registry);
|
|
125 |
initializeRegistry(REGISTRY.get());
|
|
125 | 126 |
} |
126 | 127 | |
127 |
returnNormal(registry);
|
|
128 |
returnNormal(REGISTRY.get());
|
|
128 | 129 |
})); |
129 | 130 |
} |
130 | 131 | |
... | ... | |
172 | 173 |
_poRegistry.ref()._put("text/html", ObjectOps.getLegacyClass(HtmlBodyWriter.class)); |
173 | 174 |
})); |
174 | 175 |
} |
176 |
|
|
177 |
@LegacySignature(type = Type.CONSTRUCTOR) |
|
178 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL) |
|
179 |
public static void __net_http_filter_writer_BodyWriterRegistry_constructor__static__() |
|
180 |
{ |
|
181 |
externalProcedure(BodyWriterRegistry.class, new Block((Body) () -> { |
|
182 |
onBlockLevel(Condition.ERROR, Action.THROW); |
|
183 |
})); |
|
184 |
} |
|
175 | 185 |
} |
src/com/goldencode/p2j/oo/net/http/filter/writer/DefaultMessageWriterBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
13 | 13 |
** ME 20210204 Cleanup/fix errors on getWritter method. |
14 | 14 |
** 005 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
15 | 15 |
** signature. |
16 |
** 006 ME 20210519 Fix variable scope for method return value. |
|
16 | 17 |
*/ |
17 | 18 | |
18 | 19 |
/* |
... | ... | |
136 | 137 |
); |
137 | 138 |
})); |
138 | 139 |
} |
139 | ||
140 |
|
|
140 | 141 |
/** |
141 | 142 |
* Get message writer |
142 | 143 |
* |
... | ... | |
147 | 148 |
@Override |
148 | 149 |
public object<? extends MessageWriter> getWriter() |
149 | 150 |
{ |
150 |
return function(this, "Writer", object.class, new Block((Body)() -> { |
|
151 |
object<? extends MessageWriter> writer = TypeFactory.object(MessageWriter.class); |
|
152 |
|
|
153 |
return function(this, "Writer", object.class, new Block((Init) () -> |
|
154 |
{ |
|
155 |
ObjectOps.register(writer); |
|
156 |
}, (Body)() -> { |
|
151 | 157 |
|
152 |
object<? extends MessageWriter> writer = TypeFactory.object(MessageWriter.class); |
|
153 | 158 |
object<? extends LegacyClass> writerType = TypeFactory.object(LegacyClass.class); |
154 | 159 |
object<? extends BaseObject> entity = TypeFactory.object(BaseObject.class); |
155 | 160 |
|
src/com/goldencode/p2j/oo/net/http/filter/writer/EntityWriterRegistry.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
11 | 11 |
** ME 20210208 Fix static registry property initialization. |
12 | 12 |
** 004 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 |
** 005 ME 20210519 Fix registry lazy loading, added static ctor. |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
68 | 69 | |
69 | 70 |
package com.goldencode.p2j.oo.net.http.filter.writer; |
70 | 71 | |
72 |
import static com.goldencode.p2j.util.BlockManager.externalProcedure; |
|
71 | 73 |
import static com.goldencode.p2j.util.BlockManager.function; |
72 | 74 |
import static com.goldencode.p2j.report.ReportConstants.*; |
73 | 75 |
import static com.goldencode.p2j.util.BlockManager.internalProcedure; |
76 |
import static com.goldencode.p2j.util.BlockManager.onBlockLevel; |
|
74 | 77 |
import static com.goldencode.p2j.util.BlockManager.returnNormal; |
75 | 78 | |
76 | 79 |
import com.goldencode.p2j.oo.lang.*; |
... | ... | |
78 | 81 |
import com.goldencode.p2j.oo.net.http.filter.payload.*; |
79 | 82 |
import com.goldencode.p2j.security.*; |
80 | 83 |
import com.goldencode.p2j.util.*; |
84 |
import com.goldencode.p2j.util.BlockManager.Action; |
|
85 |
import com.goldencode.p2j.util.BlockManager.Condition; |
|
81 | 86 |
import com.goldencode.p2j.util.InternalEntry.*; |
82 | 87 | |
83 | 88 |
/** |
... | ... | |
105 | 110 |
} |
106 | 111 |
}; |
107 | 112 | |
113 |
@LegacySignature(type = Type.CONSTRUCTOR) |
|
114 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL) |
|
115 |
public static void __net_http_filter_writer_EntityWriterRegistry_constructor__static__() |
|
116 |
{ |
|
117 |
externalProcedure(EntityWriterRegistry.class, new Block((Body) () -> { |
|
118 |
onBlockLevel(Condition.ERROR, Action.THROW); |
|
119 |
})); |
|
120 |
} |
|
121 |
|
|
108 | 122 |
/** |
109 | 123 |
* Get registry. |
110 | 124 |
* |
... | ... | |
116 | 130 |
{ |
117 | 131 |
return function(EntityWriterRegistry.class, "Registry", object.class, new Block((Body) () -> |
118 | 132 |
{ |
119 |
object<? extends BuilderRegistry> registry = EntityWriterRegistry.REGISTRY.get(); |
|
120 |
|
|
121 |
if (!registry._isValid()) |
|
133 |
if (!REGISTRY.get()._isValid()) |
|
122 | 134 |
{ |
123 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
135 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
124 | 136 |
ObjectOps.getLegacyClass(MessageWriter.class))); |
125 |
initializeRegistry(registry);
|
|
137 |
initializeRegistry(REGISTRY.get());
|
|
126 | 138 |
} |
127 | 139 |
|
128 |
returnNormal(registry);
|
|
140 |
returnNormal(REGISTRY.get());
|
|
129 | 141 |
})); |
130 | 142 |
} |
131 | 143 |
src/com/goldencode/p2j/oo/net/http/filter/writer/MessageWriterBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
14 | 14 |
** signature. |
15 | 15 |
** ME 20210310 Add block 'referent' for static methods, use initInput for object params. |
16 | 16 |
** ME 20210330 Fix registry class type. |
17 |
** 005 ME 20210519 Fix registry lazy loading. |
|
17 | 18 |
*/ |
18 | 19 | |
19 | 20 |
/* |
... | ... | |
185 | 186 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL) |
186 | 187 |
public static object<? extends BuilderRegistry> getRegistry() |
187 | 188 |
{ |
188 |
object<? extends BuilderRegistry> registry = TypeFactory.object(BuilderRegistry.class); |
|
189 | 189 |
|
190 | 190 |
return function(BodyWriterRegistry.class, "Registry", object.class, new Block((Body) () -> { |
191 | 191 |
|
192 |
registry.assign(REGISTRY.get()); |
|
193 |
|
|
194 |
if (!registry._isValid()) |
|
192 |
if (!REGISTRY.get()._isValid()) |
|
195 | 193 |
{ |
196 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
194 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
197 | 195 |
ObjectOps.getLegacyClass(MessageWriterBuilder.class))); |
198 |
initializeRegistry(registry);
|
|
196 |
initializeRegistry(REGISTRY.get());
|
|
199 | 197 |
} |
200 | 198 |
|
201 |
returnNormal(registry);
|
|
199 |
returnNormal(REGISTRY.get());
|
|
202 | 200 |
})); |
203 | 201 |
} |
204 | 202 |
src/com/goldencode/p2j/oo/net/http/filter/writer/RequestWriterBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
14 | 14 |
** signature. |
15 | 15 |
** ME 20210301 Added class 'referent' for static methods, always use registry getter. |
16 | 16 |
** 20210310 Added missing implementation (OE12.2). |
17 |
** 004 ME 20210519 Fix registry lazy loading. |
|
17 | 18 |
*/ |
18 | 19 | |
19 | 20 |
/* |
... | ... | |
183 | 184 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL) |
184 | 185 |
public static object<? extends BuilderRegistry> getRegistry() |
185 | 186 |
{ |
186 |
object<? extends BuilderRegistry> registry = TypeFactory.object(BuilderRegistry.class); |
|
187 |
|
|
188 | 187 |
return function(RequestWriterBuilder.class, "Registry", object.class, new Block((Body) () -> |
189 | 188 |
{ |
190 |
registry.assign(REGISTRY.get()); |
|
191 |
|
|
192 |
if (!registry._isValid()) |
|
189 |
if (!REGISTRY.get()._isValid()) |
|
193 | 190 |
{ |
194 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
191 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
195 | 192 |
ObjectOps.getLegacyClass(MessageWriter.class))); |
196 |
initializeRegistry(registry);
|
|
193 |
initializeRegistry(REGISTRY.get());
|
|
197 | 194 |
} |
198 | 195 |
|
199 |
returnNormal(registry);
|
|
196 |
returnNormal(REGISTRY.get());
|
|
200 | 197 |
})); |
201 | 198 |
} |
202 | 199 |
|
... | ... | |
337 | 334 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL) |
338 | 335 |
protected object<? extends MessageWriter> newRequestWriter() |
339 | 336 |
{ |
337 |
object<? extends MessageWriter> wObj = TypeFactory.object(MessageWriter.class); |
|
338 |
|
|
340 | 339 |
return function(RequestWriterBuilder.class, this, "NewRequestWriter", object.class, new Block((Body) () -> |
341 | 340 |
{ |
342 | 341 |
object<? extends LegacyClass> wCls = getWriter(request, getRegistry()); |
343 |
object<? extends MessageWriter> wObj = TypeFactory.object(MessageWriter.class); |
|
344 | 342 |
|
345 | 343 |
if (wCls._isValid()) |
346 | 344 |
{ |
... | ... | |
386 | 384 |
{ |
387 | 385 |
object<? extends IhttpRequest> pRequest = TypeFactory.initInput(_pRequest); |
388 | 386 |
object<? extends BuilderRegistry> pRegistry = TypeFactory.initInput(_pRegistry); |
387 |
object<? extends LegacyClass> oCls = TypeFactory.object(LegacyClass.class); |
|
389 | 388 |
|
390 | 389 |
return function(RequestWriterBuilder.class, this, "GetWriter", object.class, new Block((Body) () -> |
391 | 390 |
{ |
392 | 391 |
Assert.notNull(pRegistry, new character("Request writer registry")); |
393 | 392 |
|
394 |
object<? extends LegacyClass> oCls = TypeFactory.object(LegacyClass.class); |
|
395 |
|
|
396 | 393 |
if (pRequest._isValid()) |
397 | 394 |
{ |
398 | 395 |
oCls.assign(pRegistry.ref().get(TextOps.trim(TextOps.substitute("&1+&2", pRequest.ref().getVersion(), pRequest.ref().getMethod())))); |
src/com/goldencode/p2j/oo/net/http/filter/writer/SetHeaderMessageWriterBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
11 | 11 |
** 20210208 Fix static registry property initialization, add static ctor. |
12 | 12 |
** 004 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
13 | 13 |
** signature. |
14 |
** 005 ME 20210519 Fix registry lazy loading. |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
131 | 132 |
{ |
132 | 133 |
return function(SetHeaderMessageWriterBuilder.class, "Registry", object.class, new Block((Body) () -> |
133 | 134 |
{ |
134 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
135 |
|
|
136 |
if (!registry._isValid()) |
|
135 |
if (!REGISTRY.get()._isValid()) |
|
137 | 136 |
{ |
138 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
137 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
139 | 138 |
ObjectOps.getLegacyClass(IHttpMessageWriter.class))); |
140 |
initializeRegistry(registry);
|
|
139 |
initializeRegistry(REGISTRY.get());
|
|
141 | 140 |
} |
142 | 141 |
|
143 |
returnNormal(registry);
|
|
142 |
returnNormal(REGISTRY.get());
|
|
144 | 143 |
})); |
145 | 144 |
} |
146 | 145 |
src/com/goldencode/p2j/oo/net/http/filter/writer/StatusCodeWriterBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
10 | 10 |
** 003 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
11 | 11 |
** signature. |
12 | 12 |
** ME 20210301 Added class 'referent' for static methods, always use registry getter. |
13 |
** 004 ME 20210519 Fix registry lazy loading. |
|
13 | 14 |
*/ |
14 | 15 | |
15 | 16 |
/* |
... | ... | |
67 | 68 | |
68 | 69 |
package com.goldencode.p2j.oo.net.http.filter.writer; |
69 | 70 | |
71 |
import static com.goldencode.p2j.util.BlockManager.externalProcedure; |
|
70 | 72 |
import static com.goldencode.p2j.util.BlockManager.function; |
71 | 73 |
import static com.goldencode.p2j.report.ReportConstants.*; |
72 | 74 |
import static com.goldencode.p2j.util.BlockManager.internalProcedure; |
73 |
import static com.goldencode.p2j.report.ReportConstants.*;
|
|
75 |
import static com.goldencode.p2j.util.BlockManager.onBlockLevel;
|
|
74 | 76 |
import static com.goldencode.p2j.util.BlockManager.returnNormal; |
75 |
import static com.goldencode.p2j.report.ReportConstants.*; |
|
76 | 77 | |
77 | 78 |
import com.goldencode.p2j.oo.core.*; |
78 | 79 |
import com.goldencode.p2j.oo.lang.*; |
... | ... | |
80 | 81 |
import com.goldencode.p2j.oo.net.http.filter.status.*; |
81 | 82 |
import com.goldencode.p2j.security.*; |
82 | 83 |
import com.goldencode.p2j.util.*; |
84 |
import com.goldencode.p2j.util.BlockManager.Action; |
|
85 |
import com.goldencode.p2j.util.BlockManager.Condition; |
|
83 | 86 |
import com.goldencode.p2j.util.InternalEntry.*; |
84 | 87 | |
85 | 88 |
/** |
... | ... | |
106 | 109 |
return TypeFactory.object(BuilderRegistry.class); |
107 | 110 |
} |
108 | 111 |
}; |
112 |
|
|
113 |
@LegacySignature(type = Type.CONSTRUCTOR) |
|
114 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL) |
|
115 |
public static void __net_http_filter_writer_StatusCodeWriterBuilder_constructor__static__() |
|
116 |
{ |
|
117 |
externalProcedure(StatusCodeWriterBuilder.class, new Block((Body) () -> { |
|
118 |
onBlockLevel(Condition.ERROR, Action.THROW); |
|
119 |
})); |
|
120 |
} |
|
109 | 121 | |
110 | 122 |
/** |
111 | 123 |
* Get registry. |
... | ... | |
118 | 130 |
{ |
119 | 131 |
return function(StatusCodeWriterBuilder.class, "Registry", object.class, new Block((Body) () -> |
120 | 132 |
{ |
121 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
122 |
|
|
123 |
if (!registry._isValid()) |
|
133 |
if (!REGISTRY.get()._isValid()) |
|
124 | 134 |
{ |
125 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
135 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class, "I",
|
|
126 | 136 |
ObjectOps.getLegacyClass(IHttpMessageWriter.class))); |
127 |
initializeRegistry(registry);
|
|
137 |
initializeRegistry(REGISTRY.get());
|
|
128 | 138 |
} |
129 | 139 |
|
130 |
returnNormal(registry);
|
|
140 |
returnNormal(REGISTRY.get());
|
|
131 | 141 |
|
132 | 142 |
})); |
133 | 143 |
} |
... | ... | |
175 | 185 |
object<? extends IhttpRequest> poRequest, |
176 | 186 |
object<? extends IhttpResponse> poResponse) |
177 | 187 |
{ |
188 |
object<? extends IHttpMessageWriter> writer = TypeFactory.object(IHttpMessageWriter.class); |
|
189 |
|
|
178 | 190 |
return function(StatusCodeWriterBuilder.class, "Build", object.class, new Block((Body)() -> { |
179 |
object<? extends IHttpMessageWriter> writer = |
|
180 |
TypeFactory.object(IHttpMessageWriter.class); |
|
191 |
|
|
181 | 192 |
object<? extends LegacyClass> writerType = TypeFactory.object(LegacyClass.class); |
182 | 193 | |
183 | 194 |
Assert.notNull(poResponse, new character("Response")); |
src/com/goldencode/p2j/oo/net/http/lib/ClientLibraryBuilder.java 2021-05-24 06:41:34 +0000 | ||
---|---|---|
16 | 16 |
** 007 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
17 | 17 |
** signature. |
18 | 18 |
** ME 20210301 Added class 'referent' for static methods. |
19 |
** 008 ME 20210519 Fix registry lazy loading. |
|
19 | 20 |
*/ |
20 | 21 | |
21 | 22 |
/* |
... | ... | |
191 | 192 |
{ |
192 | 193 |
return function(ClientLibraryBuilder.class, "Registry", object.class, new Block((Body) () -> |
193 | 194 |
{ |
194 |
object<? extends BuilderRegistry> registry = REGISTRY.get(); |
|
195 |
|
|
196 |
if (!registry._isValid()) |
|
195 |
if (!REGISTRY.get()._isValid()) |
|
197 | 196 |
{ |
198 |
registry.assign(ObjectOps.newInstance(BuilderRegistry.class));
|
|
199 |
initializeRegistry(registry);
|
|
197 |
REGISTRY.get().assign(ObjectOps.newInstance(BuilderRegistry.class));
|
|
198 |
initializeRegistry(REGISTRY.get());
|
|
200 | 199 |
} |
201 |
returnNormal(registry);
|
|
200 |
returnNormal(REGISTRY.get());
|
|
202 | 201 |
})); |
203 | 202 |
} |
204 | 203 |
src/com/goldencode/p2j/oo/net/http/lib/sockets/LegacySocketLibrary.java 2021-05-24 06:22:49 +0000 | ||
---|---|---|
18 | 18 |
** - TypeFactory.initInput will take care of this. |
19 | 19 |
** 007 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy |
20 | 20 |
** signature. |
21 |
** 008 ME 20210426 Removed default ctor, add destructor to clean-up client socket and connect params. |
|
22 |
** 009 ME 20210524 Added request timeout, improve error handling (4GL style). |
|
21 | 23 |
*/ |
22 | 24 | |
23 | 25 |
/* |
... | ... | |
81 | 83 |
import static com.goldencode.p2j.util.BlockManager.internalProcedure; |
82 | 84 |
import static com.goldencode.p2j.util.BlockManager.onBlockLevel; |
83 | 85 |
import static com.goldencode.p2j.util.BlockManager.returnNormal; |
86 |
import static com.goldencode.p2j.util.BlockManager.undoThrow; |
|
84 | 87 | |
85 | 88 |
import java.io.*; |
86 | 89 |
import java.net.*; |
... | ... | |
131 | 134 |
import com.goldencode.p2j.util.*; |
132 | 135 |
import com.goldencode.p2j.util.BlockManager.Action; |
133 | 136 |
import com.goldencode.p2j.util.BlockManager.Condition; |
137 |
import com.goldencode.p2j.util.ErrorManager; |
|
134 | 138 |
import com.goldencode.p2j.util.InternalEntry.*; |
135 | 139 |
import com.goldencode.p2j.xml.*; |
136 | 140 | |
... | ... | |
393 | 397 |
object<? extends IhttpResponse> _poResponse) |
394 | 398 |
{ |
395 | 399 |
object<? extends IhttpRequest> poRequest = TypeFactory.initInput(_poRequest); |
396 |
internalProcedure(this, "__net_http_lib_ablsockets_ABLSocketLibrary_constructor__", new Block((Body) () -> |
|
400 |
object<? extends IhttpResponse> poResponse = TypeFactory.initInput(_poResponse); |
|
401 | ||
402 |
internalProcedure(this, "execute", new Block((Body) () -> |
|
397 | 403 |
{ |
398 |
_execute(poRequest, _poResponse); |
|
404 | ||
405 |
Assert.notNull(poRequest, new character("HTTP request")); |
|
406 |
Assert.notNull(poResponse, new character("HTTP response")); |
|
407 | ||
408 |
integer port = poRequest.ref().getUri().ref().getPort(); |
|
409 |
|
|
410 |
// too high port number checked by client socket probably, comes before host check |
|
411 |
if (!port.isUnknown() && port.intValue() > 65535) |
|
412 |
{ |
|
413 |
undoThrow(AppError.newInstance(String.format("Port is too large: %d", port.intValue()), 0)); |
|
414 |
} |
|
415 |
|
|
416 |
character host = poRequest.ref().getUri().ref().getHost(); |
|
417 | ||
418 |
// spaces in host name is breaking the connection params (-H xxxx yyyy) |
|
419 |
if (TextOps.numEntries(host, " ").intValue() > 1) |
|
420 |
{ |
|
421 |
ErrorManager.recordOrThrowError(new int[] { 301, 5509, 5510 }, |
|
422 |
new String[] { |
|
423 |
String.format("** Could not recognize argument: %s", |
|
424 |
TextOps.entry(2, host, " ").toStringMessage()), |
|
425 |
"Unable to process parameters", "Invalid parameter string" }, |
|
426 |
false); |
|
427 |
} |
|
428 | ||
429 |
// negative port is breaking the connection params (-S -xxxx) |
|
430 |
if (port.intValue() < 0) |
|
431 |
{ |
|
432 |
ErrorManager.recordOrThrowError(new int[] { 1403, 5509, 5510 }, |
|
433 |
new String[] { "You have not supplied a parameter for argument -S", |
|
434 |
"Unable to process parameters", "Invalid parameter string" }, |
|
435 |
false); |
|
436 |
} |
|
437 | ||
438 |
try |
|
439 |
{ |
|
440 |
_execute(poRequest, poResponse); |
|
441 |
} |
|
442 |
catch (UnknownHostException e) |
|
443 |
{ |
|
444 |
undoThrow(SysError.newInstance(String.format("Unknown hostname %s", |
|
445 |
poRequest.ref().getUri().ref().getHost()), 5482, false, true)); |
|
446 |
} |
|
447 |
catch (HttpHostConnectException e) |
|
448 |
{ |
|
449 |
undoThrow(SysError.newInstance( |
|
450 |
String.format("Connection failure for host %s port %d transport TCP", |
|
451 |
e.getHost().getHostName(), e.getHost().getPort()), |
|
452 |
9407, false, true)); |
|
453 |
} |
|
454 |
catch (IOException e) |
|
455 |
{ |
|
456 |
// request terminated |
|
457 |
readTerminatedHandler(null, null); |
|
458 |
} |
|
459 |
catch (Exception e) |
|
460 |
{ |
|
461 |
// TODO: there might be other cases |
|
462 |
undoThrow(AppError.newInstance(String.format("Unknown exception: %s", e.getMessage()), 0)); |
|
463 |
} |
|
464 | ||
399 | 465 |
})); |
400 | 466 |
} |
401 | 467 | |
402 | 468 |
/** |
403 |
* Constructor
|
|
469 |
* Destructor
|
|
404 | 470 |
*/ |
405 |
@LegacySignature(type = Type.CONSTRUCTOR)
|
|
406 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL_RESTR)
|
|
407 |
public void __net_http_lib_sockets_LegacySocketLibrary_constructor__()
|
|
471 |
@LegacySignature(type = Type.DESTRUCTOR)
|
|
472 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL) |
|
473 |
public void __net_http_lib_sockets_LegacySocketLibrary_destructor__()
|
|
408 | 474 |
{ |
409 |
internalProcedure(this, "__net_http_lib_ablsockets_ABLSocketLibrary_constructor__", new Block((Body) () ->
|
|
475 |
internalProcedure(this, "__net_http_lib_ablsockets_ABLSocketLibrary_destructor__", new Block((Body) () ->
|
|
410 | 476 |
{ |
411 |
__lang_BaseObject_constructor__(); |
|
477 |
moSocketLib.setUnknown(); |
|
478 |
moSocketConnectionParam.setUnknown(); |
|
412 | 479 |
})); |
413 | 480 |
} |
414 | 481 |
|
... | ... | |
543 | 610 |
@LegacyParameter(name = "poSender", type = "OBJECT", qualified = "openedge.net.serverconnection.clientsocket", mode = "INPUT"), |
544 | 611 |
@LegacyParameter(name = "poEventArgs", type = "OBJECT", qualified = "openedge.net.serverconnection.socketreadeventargs", mode = "INPUT") |
545 | 612 |
}) |
546 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_STUB)
|
|
613 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
|
|
547 | 614 |
public void readTerminatedHandler(final object<? extends com.goldencode.p2j.oo.net.serverconnection.ClientSocket> _poSender, final object<? extends com.goldencode.p2j.oo.net.serverconnection.SocketReadEventArgs> _poEventArgs) |
548 | 615 |
{ |
549 | 616 |
object<? extends com.goldencode.p2j.oo.net.serverconnection.ClientSocket> poSender = TypeFactory.initInput(_poSender); |
... | ... | |
551 | 618 |
|
552 | 619 |
internalProcedure(LegacySocketLibrary.class, this, "ReadTerminatedHandler", new Block((Body) () -> |
553 | 620 |
{ |
554 |
UnimplementedFeature.missing("ABLSocketLibrary:ReadTerminatedHandler METHOD"); |
|
621 |
undoThrow(AppError.newInstance(TextOps.substitute("Read terminated for &1", |
|
622 |
moSocketConnectionParam.ref().getUri().ref().toLegacyString()), new integer(105))); |
|
555 | 623 |
})); |
556 | 624 |
} |
557 | 625 |
|
... | ... | |
560 | 628 |
@LegacyParameter(name = "poSender", type = "OBJECT", qualified = "openedge.net.serverconnection.clientsocket", mode = "INPUT"), |
561 | 629 |
@LegacyParameter(name = "poEventArgs", type = "OBJECT", qualified = "openedge.net.serverconnection.socketreadeventargs", mode = "INPUT") |
562 | 630 |
}) |
563 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_STUB)
|
|
631 |
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
|
|
564 | 632 |
public void readTimeoutHandler(final object<? extends com.goldencode.p2j.oo.net.serverconnection.ClientSocket> _poSender, final object<? extends com.goldencode.p2j.oo.net.serverconnection.SocketReadEventArgs> _poEventArgs) |
565 | 633 |
{ |
566 | 634 |
object<? extends com.goldencode.p2j.oo.net.serverconnection.ClientSocket> poSender = TypeFactory.initInput(_poSender); |
... | ... | |
568 | 636 |
|
569 | 637 |
internalProcedure(LegacySocketLibrary.class, this, "ReadTimeoutHandler", new Block((Body) () -> |
570 | 638 |
{ |
571 |
UnimplementedFeature.missing("ABLSocketLibrary:ReadTimeoutHandler METHOD"); |
|
639 |
undoThrow(ObjectOps.newInstance(HttpRequestError.class, "III", |
|
640 |
new character(StatusCodeEnum.requestTimeOut), |
|
641 |
new character("read"), |
|
642 |
moSocketConnectionParam.ref().getUri().ref().toLegacyString())); |
|
572 | 643 |
})); |
573 | 644 |
} |
574 | 645 |
|
... | ... | |
579 | 650 |
* request |
580 | 651 |
* @param rsp |
581 | 652 |
* response |
653 |
* @throws Exception |
|
582 | 654 |
*/ |
583 |
private void _execute(object<? extends IhttpRequest> req, object<? extends IhttpResponse> rsp) |
|
655 |
private void _execute(object<? extends IhttpRequest> req, object<? extends IhttpResponse> rsp) |
|
656 |
throws Exception |
|
584 | 657 |
{ |
585 | 658 |
Uri uri = req.ref().getUri().ref(); |
586 | 659 |
String method = req.ref().getMethod().getValue(); |
... | ... | |
598 | 671 |
} |
599 | 672 |
|
600 | 673 |
java.net.URI _uri; |
601 |
try |
|
674 |
URIBuilder builder = new URIBuilder().setScheme(scheme).setHost(host).setPort(port) |
|
675 |
.setPath(path); |
|
676 | ||
677 |
String encoding = I18nOps.getJavaCharset(req.ref().getCharacterEncoding()); |
|
678 | ||
679 |
if (encoding != null && Charset.isSupported(encoding)) |
|
680 |
builder.setCharset(Charset.forName(encoding)); |
|
681 | ||
682 |
object<? extends IStringStringMap> qryMap = uri.getQueryMap_1(); |
|
683 | ||
684 |
if (qryMap._isValid() && qryMap.ref().getSize().intValue() > 0) |
|
602 | 685 |
{ |
603 |
URIBuilder builder = new URIBuilder(). |
|
604 |
setScheme(scheme). |
|
605 |
setHost(host). |
|
606 |
setPort(port). |
|
607 |
setPath(path); |
|
608 |
|
|
609 |
String encoding = I18nOps.getJavaCharset(req.ref().getCharacterEncoding()); |
|
610 |
|
|
611 |
if (encoding != null && Charset.isSupported(encoding)) |
|
612 |
builder.setCharset(Charset.forName(encoding)); |
|
613 |
|
|
614 |
object<? extends IStringStringMap> qryMap = uri.getQueryMap_1(); |
|
615 |
|
|
616 |
if (qryMap._isValid() && qryMap.ref().getSize().intValue() > 0) { |
|
617 |
object<? extends Iiterator> iterator = qryMap.ref().getKeySet().ref().iterator(); |
|
618 |
while (iterator.ref().hasNext().booleanValue()) |
|
619 |
{ |
|
620 |
object<? extends _BaseObject_> key = iterator.ref().next_(); |
|
621 |
object<? extends _BaseObject_> value = qryMap.ref().get(key); |
|
622 |
|
|
623 |
builder.addParameter(key.ref().toLegacyString().getValue(), |
|
624 |
value.ref().toLegacyString().getValue()); |
|
625 |
} |
|
686 |
object<? extends Iiterator> iterator = qryMap.ref().getKeySet().ref().iterator(); |
|
687 |
while (iterator.ref().hasNext().booleanValue()) |
|
688 |
{ |
|
689 |
object<? extends _BaseObject_> key = iterator.ref().next_(); |
|
690 |
object<? extends _BaseObject_> value = qryMap.ref().get(key); |
|
691 | ||
692 |
builder.addParameter(key.ref().toLegacyString().getValue(), |
|
693 |
value.ref().toLegacyString().getValue()); |
|
626 | 694 |
} |
627 |
|
|
628 |
String fragment = uri.getFragment().getValue(); |
|
629 |
|
|
630 |
if (!TextOps.isEmpty(fragment)) |
|
631 |
builder.setFragment(fragment); |
|
632 |
|
|
633 |
_uri = builder.build(); |
|
634 |
} |
|
635 |
catch (URISyntaxException e) |
|
636 |
{ |
|
637 |
LOG.log(Level.WARNING, "Invalid URI", e); |
|
638 |
rsp.ref().setStatusCode(new integer(500)); |
|
639 |
rsp.ref().setStatusReason(new character("Invalid URI")); |
|
640 |
return; |
|
641 | 695 |
} |
642 |
org.apache.http.client.methods.RequestBuilder requestBuilder = |
|
643 |
org.apache.http.client.methods.RequestBuilder.create(method).setUri(_uri); |
|
696 | ||
697 |
String fragment = uri.getFragment().getValue(); |
|
698 | ||
699 |
if (!TextOps.isEmpty(fragment)) |
|
700 |
builder.setFragment(fragment); |
|
701 | ||
702 |
_uri = builder.build(); |