| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,12 @@ | |||
| 1 | 1 | # CHANGELOG | |
| 2 | 2 | ||
| 3 | + ## v2.3.1 | ||
| 4 | + | ||
| 5 | + ### Date: 03-Nov-2025 | ||
| 6 | + | ||
| 7 | + - Github issue fix | ||
| 8 | + - Improved error messages | ||
| 9 | + | ||
| 3 | 10 | ## v2.3.0 | |
| 4 | 11 | ||
| 5 | 12 | ### Date: 29-Sep-2025 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | <modelVersion>4.0.0</modelVersion> | |
| 6 | 6 | <groupId>com.contentstack.sdk</groupId> | |
| 7 | 7 | <artifactId>java</artifactId> | |
| 8 | - <version>2.3.0</version> | ||
| 8 | + <version>2.3.1</version> | ||
| 9 | 9 | <packaging>jar</packaging> | |
| 10 | 10 | <name>contentstack-java</name> | |
| 11 | 11 | <description>Java SDK for Contentstack Content Delivery API</description> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,7 +179,11 @@ public AssetLibrary addParam(@NotNull String paramKey, @NotNull Object paramValu | |||
| 179 | 179 | if (isValidKey(paramKey) && isValidValue(paramValue)) { | |
| 180 | 180 | urlQueries.put(paramKey, paramValue); | |
| 181 | 181 | } else { | |
| 182 | - logger.warning("Invalid key or value"); | ||
| 182 | + if (!isValidKey(paramKey)) { | ||
| 183 | + logger.warning(ErrorMessages.INVALID_PARAMETER_KEY); | ||
| 184 | + } else { | ||
| 185 | + logger.warning(ErrorMessages.INVALID_PARAMETER_VALUE); | ||
| 186 | + } | ||
| 183 | 187 | } | |
| 184 | 188 | return this; | |
| 185 | 189 | } | |
@@ -310,9 +314,10 @@ public void getResultObject(List<Object> objects, JSONObject jsonObject, boolean | |||
| 310 | 314 | ||
| 311 | 315 | List<Asset> assets = new ArrayList<>(); | |
| 312 | 316 | ||
| 313 | - // if (objects == null || objects.isEmpty()) { | ||
| 314 | - // System.out.println("Objects list is null or empty"); | ||
| 315 | - // } | ||
| 317 | + if (objects == null || objects.isEmpty()) { | ||
| 318 | + logger.warning(ErrorMessages.MISSING_ASSETS_LIST); | ||
| 319 | + return; | ||
| 320 | + } | ||
| 316 | 321 | ||
| 317 | 322 | if (objects != null && !objects.isEmpty()) { | |
| 318 | 323 | for (Object object : objects) { | |
@@ -328,9 +333,9 @@ public void getResultObject(List<Object> objects, JSONObject jsonObject, boolean | |||
| 328 | 333 | assets.add(asset); | |
| 329 | 334 | } | |
| 330 | 335 | } | |
| 331 | - // else { | ||
| 332 | - // System.out.println("Object is not an instance of AssetModel"); | ||
| 333 | - // } | ||
| 336 | + else { | ||
| 337 | + logger.warning(ErrorMessages.INVALID_OBJECT_TYPE_ASSET_MODEL); | ||
| 338 | + } | ||
| 334 | 339 | ||
| 335 | 340 | if (callback != null) { | |
| 336 | 341 | callback.onRequestFinish(ResponseType.NETWORK, assets); | |
@@ -351,7 +356,11 @@ public AssetLibrary where(String key, String value) { | |||
| 351 | 356 | queryParams.put(key,value); | |
| 352 | 357 | urlQueries.put("query", queryParams); | |
| 353 | 358 | } else { | |
| 354 | - throw new IllegalArgumentException("Invalid key or value"); | ||
| 359 | + if (!isValidKey(key)) { | ||
| 360 | + throw new IllegalArgumentException(ErrorMessages.INVALID_PARAMETER_KEY); | ||
| 361 | + } else { | ||
| 362 | + throw new IllegalArgumentException(ErrorMessages.INVALID_PARAMETER_VALUE); | ||
| 363 | + } | ||
| 355 | 364 | } | |
| 356 | 365 | return this; | |
| 357 | 366 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ public AssetsModel(JSONObject response) { | |||
| 31 | 31 | List<?> assetsList = (List<?>) rawAssets; | |
| 32 | 32 | listResponse = new JSONArray(assetsList); // Convert to JSONArray | |
| 33 | 33 | } else if (rawAssets != null) { | |
| 34 | - throw new IllegalArgumentException("Invalid type for 'assets' key: " + rawAssets.getClass().getName()); | ||
| 34 | + throw new IllegalArgumentException(ErrorMessages.INVALID_ASSETS_TYPE); | ||
| 35 | 35 | } | |
| 36 | 36 | if (listResponse != null) { | |
| 37 | 37 | listResponse.forEach(model -> { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,7 +93,7 @@ protected void checkHeader(@NotNull Map<String, Object> headers) { | |||
| 93 | 93 | final Logger logger = Logger.getLogger("CSBackgroundTask"); | |
| 94 | 94 | if (headers.size() == 0) { | |
| 95 | 95 | try { | |
| 96 | - throw new IllegalAccessException("CSBackgroundTask Header Exception"); | ||
| 96 | + throw new IllegalAccessException(ErrorMessages.MISSING_REQUEST_HEADERS); | ||
| 97 | 97 | } catch (IllegalAccessException e) { | |
| 98 | 98 | logger.log(Level.SEVERE, e.getLocalizedMessage(), e); | |
| 99 | 99 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,7 +158,7 @@ private String getParams(HashMap<String, Object> params) { | |||
| 158 | 158 | urlParams += urlParams.equals("?") ? key + "=" + value : "&" + key + "=" + value; | |
| 159 | 159 | } | |
| 160 | 160 | } catch (Exception e1) { | |
| 161 | - logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); | ||
| 161 | + logger.log(Level.SEVERE, ErrorMessages.URL_PARAMETER_ENCODING_FAILED, e1); | ||
| 162 | 162 | } | |
| 163 | 163 | } | |
| 164 | 164 | return urlParams; | |
@@ -187,7 +187,7 @@ public void send() { | |||
| 187 | 187 | try { | |
| 188 | 188 | getService(url); | |
| 189 | 189 | } catch (IOException | JSONException e) { | |
| 190 | - logger.log(Level.SEVERE, e.getLocalizedMessage(), e); | ||
| 190 | + logger.log(Level.SEVERE, ErrorMessages.URL_PARAMETER_ENCODING_FAILED, e); | ||
| 191 | 191 | } | |
| 192 | 192 | } | |
| 193 | 193 | ||
@@ -238,7 +238,7 @@ private void getService(String requestUrl) throws IOException { | |||
| 238 | 238 | connectionRequest.onRequestFinished(CSHttpConnection.this); | |
| 239 | 239 | } catch (JSONException e) { | |
| 240 | 240 | // Handle non-JSON response | |
| 241 | - setError("Invalid JSON response"); | ||
| 241 | + setError(ErrorMessages.INVALID_JSON_RESPONSE); | ||
| 242 | 242 | } | |
| 243 | 243 | } else { | |
| 244 | 244 | assert response.errorBody() != null; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,7 @@ public class ContentType { | |||
| 40 | 40 | public JSONObject contentTypeData; | |
| 41 | 41 | ||
| 42 | 42 | protected ContentType() throws IllegalAccessException { | |
| 43 | - throw new IllegalAccessException("Can Not Access Private Modifier"); | ||
| 43 | + throw new IllegalAccessException(ErrorMessages.DIRECT_INSTANTIATION_CONTENT_TYPE); | ||
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | 46 | protected ContentType(String contentTypeUid) { | |
@@ -158,7 +158,7 @@ public void fetch(@NotNull JSONObject params, final ContentTypesCallback callbac | |||
| 158 | 158 | } | |
| 159 | 159 | params.put("environment", headers.get("environment")); | |
| 160 | 160 | if (contentTypeUid == null || contentTypeUid.isEmpty()) { | |
| 161 | - throw new IllegalAccessException("contentTypeUid is required"); | ||
| 161 | + throw new IllegalAccessException(ErrorMessages.CONTENT_TYPE_UID_REQUIRED); | ||
| 162 | 162 | } | |
| 163 | 163 | fetchContentTypes(urlString, params, headers, callback); | |
| 164 | 164 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ public void setJSON(JSONObject responseJSON) { | |||
| 29 | 29 | try { | |
| 30 | 30 | this.response = new JSONObject((LinkedHashMap<?, ?>) responseJSON.get(ctKey)); | |
| 31 | 31 | } catch (Exception e) { | |
| 32 | - System.err.println("Error processing 'content_type': " + e.getMessage()); | ||
| 32 | + System.err.println(ErrorMessages.INVALID_CONTENT_TYPE_DATA + " Technical details: " + e.getMessage()); | ||
| 33 | 33 | } | |
| 34 | 34 | } | |
| 35 | 35 | String ctListKey = "content_types"; | |
@@ -44,14 +44,14 @@ public void setJSON(JSONObject responseJSON) { | |||
| 44 | 44 | JSONObject jsonModel = new JSONObject((LinkedHashMap<?, ?>) model); | |
| 45 | 45 | objectList.add(jsonModel); | |
| 46 | 46 | } else { | |
| 47 | - System.err.println("Invalid type in 'content_types' list. Expected LinkedHashMap."); | ||
| 47 | + System.err.println(ErrorMessages.INVALID_CONTENT_TYPES_LIST); | ||
| 48 | 48 | } | |
| 49 | 49 | }); | |
| 50 | 50 | } | |
| 51 | 51 | this.response = new JSONArray(objectList); | |
| 52 | 52 | this.responseJSONArray = new JSONArray(objectList); | |
| 53 | 53 | } catch (Exception e) { | |
| 54 | - System.err.println("Error processing 'content_types': " + e.getMessage()); | ||
| 54 | + System.err.println(ErrorMessages.INVALID_CONTENT_TYPE_DATA + " Technical details: " + e.getMessage()); | ||
| 55 | 55 | } | |
| 56 | 56 | } | |
| 57 | 57 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ public class Contentstack { | |||
| 19 | 19 | ||
| 20 | 20 | // Modifier Protected | |
| 21 | 21 | protected Contentstack() throws IllegalAccessException { | |
| 22 | - throw new IllegalAccessException("Can Not Access Private Modifier"); | ||
| 22 | + throw new IllegalAccessException(ErrorMessages.DIRECT_INSTANTIATION_CONTENTSTACK); | ||
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | 25 | /** | |
@@ -88,13 +88,13 @@ private static void validateCredentials(String stackApiKey, String deliveryToken | |||
| 88 | 88 | Objects.requireNonNull(environment, "Environment can not be null"); | |
| 89 | 89 | ||
| 90 | 90 | if (stackApiKey.isEmpty()) { | |
| 91 | - throw new IllegalAccessException("API Key can not be empty"); | ||
| 91 | + throw new IllegalAccessException(ErrorMessages.MISSING_API_KEY); | ||
| 92 | 92 | } | |
| 93 | 93 | if (deliveryToken.isEmpty()) { | |
| 94 | - throw new IllegalAccessException("Delivery Token can not be empty"); | ||
| 94 | + throw new IllegalAccessException(ErrorMessages.MISSING_DELIVERY_TOKEN); | ||
| 95 | 95 | } | |
| 96 | 96 | if (environment.isEmpty()) { | |
| 97 | - throw new IllegalAccessException("Environment can not be empty"); | ||
| 97 | + throw new IllegalAccessException(ErrorMessages.MISSING_ENVIRONMENT); | ||
| 98 | 98 | } | |
| 99 | 99 | } | |
| 100 | 100 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,7 @@ protected EntriesModel(JSONObject responseJSON) { | |||
| 33 | 33 | } | |
| 34 | 34 | } catch (Exception e) { | |
| 35 | 35 | Logger logger = Logger.getLogger(EntriesModel.class.getSimpleName()); | |
| 36 | - logger.log(Level.SEVERE, e.getLocalizedMessage(), e); | ||
| 36 | + logger.log(Level.SEVERE, ErrorMessages.ENTRIES_PROCESSING_FAILED, e); | ||
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments