File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
main/java/in/erail/amazon/lambda
test/java/in/erail/service Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1616import java .io .OutputStream ;
1717import java .io .OutputStreamWriter ;
1818import in .erail .model .RequestEvent ;
19+ import in .erail .model .ResponseEvent ;
1920import java .util .ArrayList ;
2021import java .util .HashSet ;
2122import java .util .List ;
@@ -69,7 +70,8 @@ public Single<String> handleMessage(JsonObject pRequest) {
6970 .subscribeOn (Schedulers .computation ())
7071 .map (this ::convertBodyToBase64 )
7172 .map (reqJson -> reqJson .mapTo (RequestEvent .class ))
72- .map (req -> getService ().process (req ))
73+ .flatMapMaybe (req -> getService ().process (req ))
74+ .toSingle (new ResponseEvent ())
7375 .map (resp -> JsonObject .mapFrom (resp ))
7476 .map (this ::sanatizeResponse )
7577 .map (respJson -> respJson .toString ());
@@ -78,7 +80,7 @@ public Single<String> handleMessage(JsonObject pRequest) {
7880 protected JsonObject sanatizeResponse (JsonObject pResp ) {
7981 Preconditions .checkNotNull (pResp );
8082
81- Set <String > keys = new HashSet (pResp .fieldNames ());
83+ Set <String > keys = new HashSet <> (pResp .fieldNames ());
8284
8385 keys
8486 .stream ()
Original file line number Diff line number Diff line change 33import com .google .common .net .MediaType ;
44import in .erail .model .RequestEvent ;
55import in .erail .model .ResponseEvent ;
6+ import io .reactivex .Maybe ;
67import io .vertx .core .json .JsonArray ;
78
89public class SessionGetService extends RESTServiceImpl {
@@ -18,10 +19,10 @@ public SessionGetService() {
1819 }
1920
2021 @ Override
21- public ResponseEvent process (RequestEvent pRequest ) {
22- return new ResponseEvent ()
22+ public Maybe < ResponseEvent > process (RequestEvent pRequest ) {
23+ return Maybe . just ( new ResponseEvent ()
2324 .setBody (getSessions ().toString ().getBytes ())
24- .setContentType (MediaType .JSON_UTF_8 );
25+ .setContentType (MediaType .JSON_UTF_8 )) ;
2526 }
2627
2728 public JsonArray getSessions () {
You can’t perform that action at this time.
0 commit comments