22
33import org .jetbrains .annotations .NotNull ;
44import org .json .JSONObject ;
5-
5+ import org .json .JSONArray ;
6+ import lombok .Getter ;
7+ import lombok .Setter ;
68import java .util .HashMap ;
79import java .util .Iterator ;
810import java .util .LinkedHashMap ;
2022 * @version 1.0.0
2123 * @since 01-11-2017
2224 */
25+
26+ @ Getter
27+ @ Setter
2328public class ContentType {
2429
2530 protected static final Logger logger = Logger .getLogger (ContentType .class .getSimpleName ());
2631 protected String contentTypeUid ;
2732 protected Stack stackInstance = null ;
2833 protected LinkedHashMap <String , Object > headers = null ;
2934
35+ // NEW: Content type data fields for POJO access (public for Lombok-generated getters)
36+ public String title ;
37+ public String description ;
38+ public String uid ;
39+ public JSONArray schema ;
40+ public JSONObject contentTypeData ;
41+
3042 protected ContentType () throws IllegalAccessException {
3143 throw new IllegalAccessException ("Can Not Access Private Modifier" );
3244 }
@@ -156,7 +168,17 @@ private void fetchContentTypes(String urlString, JSONObject params, HashMap<Stri
156168 if (callback != null ) {
157169 HashMap <String , Object > urlParams = getUrlParams (params );
158170 new CSBackgroundTask (this , stackInstance , Constants .FETCHCONTENTTYPES , urlString , headers , urlParams ,
159- Constants .REQUEST_CONTROLLER .CONTENTTYPES .toString (), callback );
171+ // Constants.REQUEST_CONTROLLER.CONTENTTYPES.toString(), callback);
172+ Constants .REQUEST_CONTROLLER .CONTENTTYPES .toString (), new ContentTypesCallback () {
173+ @ Override
174+ public void onCompletion (ContentTypesModel model , Error error ) {
175+ if (error == null ) {
176+ // NEW: Store content type data in this instance for POJO access
177+ model .setContentTypeData (ContentType .this );
178+ }
179+ callback .onCompletion (model , error );
180+ }
181+ });
160182 }
161183 }
162184
@@ -173,4 +195,20 @@ private HashMap<String, Object> getUrlParams(JSONObject urlQueriesJSON) {
173195 return hashMap ;
174196 }
175197
198+ /**
199+ * Set content type data from JSON response.
200+ * This method is called internally by ContentTypesModel.
201+ *
202+ * @param ctData the content type data JSONObject
203+ */
204+ protected void setContentTypeData (JSONObject ctData ) {
205+ if (ctData != null ) {
206+ this .title = ctData .optString ("title" );
207+ this .description = ctData .optString ("description" );
208+ this .uid = ctData .optString ("uid" );
209+ this .schema = ctData .optJSONArray ("schema" );
210+ this .contentTypeData = ctData ;
211+ }
212+ }
213+
176214}
0 commit comments