1- package com .contentstack .sdk ;import com .contentstack .sdk .utility .CSAppConstants ;import org .json .JSONObject ;import java .util .HashMap ;import java .util .LinkedHashMap ;class CSBackgroundTask { public CSBackgroundTask (Query queryInstance , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , LinkedHashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , CSAppConstants .RequestMethod method , ResultCallBack callback ) { if (headers != null && headers .size () > 0 ) { String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ; CSConnectionRequest csConnectionRequest = new CSConnectionRequest (queryInstance ); csConnectionRequest .setQueryInstance (queryInstance ); csConnectionRequest .setURLQueries (urlQueries ); csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback ); } else { sendErrorForHeader (callback ); } } public CSBackgroundTask (Entry entryInstance , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , HashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , boolean isOffline , CSAppConstants .RequestMethod method , ResultCallBack callBack ) { if (headers != null && headers .size () > 0 ) { String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ; CSConnectionRequest csConnectionRequest = new CSConnectionRequest (entryInstance ); csConnectionRequest .setURLQueries (urlQueries ); csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callBack ); } else { sendErrorForHeader (callBack ); } } public CSBackgroundTask (AssetLibrary assetLibrary , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , HashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , boolean isOffline , CSAppConstants .RequestMethod method , ResultCallBack callback ) { if (headers != null && headers .size () > 0 ) { String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ; CSConnectionRequest csConnectionRequest = new CSConnectionRequest (assetLibrary ); csConnectionRequest .setURLQueries (urlQueries ); csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback ); } else { sendErrorForHeader (callback ); } } public CSBackgroundTask (Asset asset , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , HashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , boolean isOffline , CSAppConstants .RequestMethod method , ResultCallBack callback ) { if (headers != null && headers .size () > 0 ) { String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ; CSConnectionRequest csConnectionRequest = new CSConnectionRequest (asset ); csConnectionRequest .setURLQueries (urlQueries ); csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback ); } else { sendErrorForHeader (callback ); } } public CSBackgroundTask (Stack stackInstance , String controller , String url , HashMap <String , Object > headers , HashMap <String , Object > urlParams , JSONObject jsonMain , String requestInfo , boolean b , CSAppConstants .RequestMethod method , ResultCallBack callback ) { if (headers != null && headers .size () > 0 ) { String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ; CSConnectionRequest csConnectionRequest = new CSConnectionRequest (stackInstance ); csConnectionRequest .setStackInstance (stackInstance ); csConnectionRequest .setURLQueries (urlParams ); csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback ); } else { sendErrorForHeader (callback ); } } public CSBackgroundTask (ContentType contentTypeInstance , Stack stackInstance , String controller , String url , HashMap <String , Object > headers , HashMap <String , Object > urlParams , JSONObject jsonMain , String requestInfo , boolean b , CSAppConstants .RequestMethod method , ResultCallBack callback ) { if (headers != null && headers .size () > 0 ) { String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ; CSConnectionRequest csConnectionRequest = new CSConnectionRequest (contentTypeInstance ); csConnectionRequest .setURLQueries (urlParams ); csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback ); } else { sendErrorForHeader (callback ); } } private void sendErrorForHeader (ResultCallBack callbackObject ) { Error error = new Error (); error .setErrorMessage (CSAppConstants .ErrorMessage_CalledDefaultMethod ); if (callbackObject != null ) { callbackObject .onRequestFail (ResponseType .UNKNOWN , error ); } } }
1+ package com .contentstack .sdk ;
2+ import com .contentstack .sdk .utility .CSAppConstants ;
3+ import org .json .JSONObject ;
4+ import java .util .HashMap ;
5+ import java .util .LinkedHashMap ;
6+
7+
8+ class CSBackgroundTask {
9+
10+ public CSBackgroundTask (Query queryInstance , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , LinkedHashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , CSAppConstants .RequestMethod method , ResultCallBack callback ) {
11+ if (headers != null && headers .size () > 0 ) {
12+ String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ;
13+ CSConnectionRequest csConnectionRequest = new CSConnectionRequest (queryInstance );
14+ csConnectionRequest .setQueryInstance (queryInstance );
15+ csConnectionRequest .setURLQueries (urlQueries );
16+ csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback );
17+ } else {
18+ sendErrorForHeader (callback );
19+ }
20+ }
21+
22+
23+ public CSBackgroundTask (Entry entryInstance , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , HashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , boolean isOffline , CSAppConstants .RequestMethod method , ResultCallBack callBack ) {
24+ if (headers != null && headers .size () > 0 ) {
25+ String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ;
26+ CSConnectionRequest csConnectionRequest = new CSConnectionRequest (entryInstance );
27+ csConnectionRequest .setURLQueries (urlQueries );
28+ csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callBack );
29+ } else {
30+ sendErrorForHeader (callBack );
31+ }
32+ }
33+
34+
35+
36+ public CSBackgroundTask (AssetLibrary assetLibrary , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , HashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , boolean isOffline , CSAppConstants .RequestMethod method , ResultCallBack callback ) {
37+ if (headers != null && headers .size () > 0 ) {
38+ String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ;
39+ CSConnectionRequest csConnectionRequest = new CSConnectionRequest (assetLibrary );
40+ csConnectionRequest .setURLQueries (urlQueries );
41+ csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback );
42+ } else {
43+ sendErrorForHeader (callback );
44+ }
45+ }
46+
47+
48+ public CSBackgroundTask (Asset asset , Stack stackInstance , String controller , String url , LinkedHashMap <String , Object > headers , HashMap <String , Object > urlQueries , JSONObject jsonMain , String requestInfo , boolean isOffline , CSAppConstants .RequestMethod method , ResultCallBack callback ) {
49+ if (headers != null && headers .size () > 0 ) {
50+ String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ;
51+ CSConnectionRequest csConnectionRequest = new CSConnectionRequest (asset );
52+ csConnectionRequest .setURLQueries (urlQueries );
53+ csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback );
54+ } else {
55+ sendErrorForHeader (callback );
56+ }
57+
58+ }
59+
60+
61+ public CSBackgroundTask (Stack stackInstance , String controller , String url , HashMap <String , Object > headers , HashMap <String , Object > urlParams , JSONObject jsonMain , String requestInfo , boolean b , CSAppConstants .RequestMethod method , ResultCallBack callback ) {
62+ if (headers != null && headers .size () > 0 ) {
63+ String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ;
64+ CSConnectionRequest csConnectionRequest = new CSConnectionRequest (stackInstance );
65+ csConnectionRequest .setStackInstance (stackInstance );
66+ csConnectionRequest .setURLQueries (urlParams );
67+ csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback );
68+ } else {
69+ sendErrorForHeader (callback );
70+ }
71+ }
72+
73+
74+ public CSBackgroundTask (ContentType contentTypeInstance , Stack stackInstance , String controller , String url , HashMap <String , Object > headers , HashMap <String , Object > urlParams , JSONObject jsonMain , String requestInfo , boolean b , CSAppConstants .RequestMethod method , ResultCallBack callback ) {
75+ if (headers != null && headers .size () > 0 ) {
76+ String URL = stackInstance .URLSCHEMA + stackInstance .URL + url ;
77+ CSConnectionRequest csConnectionRequest = new CSConnectionRequest (contentTypeInstance );
78+ csConnectionRequest .setURLQueries (urlParams );
79+ csConnectionRequest .setParams (URL , method , controller , jsonMain , headers , requestInfo , callback );
80+ } else {
81+ sendErrorForHeader (callback );
82+ }
83+ }
84+
85+ private void sendErrorForHeader (ResultCallBack callbackObject ) {
86+ Error error = new Error ();
87+ error .setErrorMessage (CSAppConstants .ErrorMessage_CalledDefaultMethod );
88+ if (callbackObject != null ) {
89+ callbackObject .onRequestFail (ResponseType .UNKNOWN , error );
90+ }
91+ }
92+ }
0 commit comments