Skip to content

Commit ea7dfad

Browse files
doc, asset, pom, content type
1 parent c0fdb64 commit ea7dfad

File tree

17 files changed

+289
-243
lines changed

17 files changed

+289
-243
lines changed

src/main/java/com/contentstack/cms/core/CMSLogger.java renamed to src/main/java/com/contentstack/cms/core/CMALogger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
* @version 1.0.0
1212
* @since 2022-05-19
1313
*/
14-
public class CMSLogger {
14+
public class CMALogger {
1515

1616
private final Logger logger;
1717

18-
public Logger getLOGGER() {
18+
public Logger getLogger() {
1919
return logger;
2020
}
2121

22-
public CMSLogger(@NotNull Class<?> className) {
22+
public CMALogger(@NotNull Class<?> className) {
2323
logger = Logger.getLogger(className.getSimpleName());
2424
}
2525

src/main/java/com/contentstack/cms/core/CSResponse.java renamed to src/main/java/com/contentstack/cms/core/CMAResponseConvertor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
* @since 2022-05-19
1818
*/
1919

20-
public class CSResponse {
20+
public class CMAResponseConvertor {
2121

2222
private static final String MODEL_NULL_CHECK = "model class == null";
2323
private static final String RESPONSE_NULL = "response == null";
2424
private final Response<ResponseBody> response;
2525

26-
public CSResponse(Response<ResponseBody> response) {
26+
public CMAResponseConvertor(Response<ResponseBody> response) {
2727
this.response = response;
2828
}
2929

src/main/java/com/contentstack/cms/core/CMSRuntimeException.java renamed to src/main/java/com/contentstack/cms/core/CMARuntimeException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.contentstack.cms.core;
22

33
/**
4-
* CMSRuntimeException that extends Exception class
4+
* CMARuntimeException that extends Exception class
55
*
66
* @author ***REMOVED***
77
* @version 1.0.0
88
* @since 2022-05-19
99
*/
10-
public class CMSRuntimeException extends Exception { public CMSRuntimeException(String message) {
10+
public class CMARuntimeException extends Exception { public CMARuntimeException(String message) {
1111
super(message);
1212
}}

src/main/java/com/contentstack/cms/core/Callback.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/main/java/com/contentstack/cms/core/ContentstackResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.contentstack.cms.core;
22

3-
import retrofit2.Call;
43
import okhttp3.ResponseBody;
4+
import retrofit2.Call;
55
import retrofit2.Response;
66

77
import java.io.IOException;
@@ -15,15 +15,15 @@
1515
* @version 1.0.0
1616
* @since 2022-05-19
1717
*/
18-
public class ContentstackResponse<T> {
18+
class ContentstackResponse<T> {
1919

2020
Call<ResponseBody> response;
2121

22-
public Response<ResponseBody> fetch(Call<ResponseBody> response) {
22+
public Response<ResponseBody> fetch(Call<ResponseBody> response) throws CMARuntimeException {
2323
try {
2424
return response.execute();
2525
} catch (IOException e) {
26-
throw new RuntimeException(e.getLocalizedMessage());
26+
throw new CMARuntimeException(e.getLocalizedMessage());
2727
}
2828
}
2929

src/main/java/com/contentstack/cms/core/ResponseResult.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @version 1.0.0
1616
* @since 2022-05-19
1717
*/
18-
public class ResponseResult<T> {
18+
class ResponseResult<T> {
1919

2020
public T execute(Call<T> call) throws IOException {
2121
T data = null;
@@ -32,17 +32,3 @@ public T execute(Call<T> call) throws IOException {
3232
return data;
3333
}
3434
}
35-
36-
/*
37-
* class BaseCallBack<T> implements Callback<T> {
38-
*
39-
* @Override public void onResponse(Call<T> call, Response<T> response) { if
40-
* (!response.isSuccessful()) {
41-
* System.out.println("Response Fail"); } }
42-
*
43-
* @Override public void onFailure(Call<T> call, Throwable t) {
44-
* System.out.println("Response Fail" + t.toString()); } }
45-
* <p>
46-
* <p>
47-
* interface CustomCallListener<T> { public void getResult(T object); }
48-
*/

src/main/java/com/contentstack/cms/core/Util.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ protected static String defaultUserAgent() {
6666
public static void nullEmptyThrowsException(@NotNull String field) {
6767
Objects.requireNonNull(field);
6868
try {
69-
throw new CMSRuntimeException(field + " cannot take in an empty String or null value");
70-
} catch (CMSRuntimeException e) {
69+
throw new CMARuntimeException(field + " cannot take in an empty String or null value");
70+
} catch (CMARuntimeException e) {
7171
e.printStackTrace();
7272
}
7373
}

src/main/java/com/contentstack/cms/stack/Asset.java

Lines changed: 7 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import okhttp3.RequestBody;
66
import okhttp3.ResponseBody;
77
import org.jetbrains.annotations.NotNull;
8-
import org.jetbrains.annotations.Nullable;
98
import org.json.simple.JSONObject;
109
import retrofit2.Call;
1110
import retrofit2.Retrofit;
@@ -28,12 +27,14 @@ public class Asset {
2827
protected final Map<String, Object> headers;
2928
protected Map<String, Object> params;
3029
protected final AssetService service;
30+
private final Retrofit instance;
3131

3232
protected Asset(Retrofit instance, @NotNull Map<String, Object> stackHeaders) {
3333
this.headers = new HashMap<>();
3434
this.headers.put("Content-Type", "application/json");
3535
this.headers.putAll(stackHeaders);
3636
params = new HashMap<>();
37+
this.instance = instance;
3738
this.service = instance.create(AssetService.class);
3839
}
3940

@@ -81,6 +82,10 @@ protected void clearParams() {
8182
}
8283

8384

85+
public Folder folder() {
86+
return new Folder(this.instance, this.headers);
87+
}
88+
8489
/**
8590
* The Get all assets request returns comprehensive information on all assets available in a stack.
8691
* <p>
@@ -305,7 +310,7 @@ public Call<ResponseBody> generatePermanentUrl(String uid, JSONObject body) {
305310
* <br>
306311
*
307312
* @param uid
308-
* The UID of the asset you want to download. Use the Get All Assets request to get the UID of the asset..
313+
* The UID of the asset you want to download. Use the Get All Assets request to get the UID of the asset.
309314
* @param slugUrl
310315
* The unique identifier of the asset.
311316
* @return Call
@@ -555,28 +560,6 @@ public Call<ResponseBody> unpublish(
555560
return this.service.unpublish(this.headers, assetUid, requestBody);
556561
}
557562

558-
/**
559-
* The Get a single folder call gets the comprehensive details of a specific asset folder by means of folder UID.
560-
* <p>
561-
* When executing the API call to search for a subfolder, you need to provide the parent folder UID.
562-
*
563-
* @param folderUid
564-
* folder uid provide query using <p>#addParam query parameters - include_path(optional) Set this parameter
565-
* to ‘true’ to retrieve the complete path of the folder. The path will be displayed as an array of objects
566-
* which includes the names and UIDs of each parent folder.
567-
* <p>
568-
* Example:false
569-
* @return Call
570-
* @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#unpublish-an-asset">
571-
* Unpublish An Asset</a>
572-
* @see #addHeader(String, Object) to add headers
573-
* @see #addParam(String, Object) to add query params
574-
* @since 1.0.0
575-
*/
576-
public Call<ResponseBody> singleFolder(
577-
@NotNull String folderUid) {
578-
return this.service.singleFolder(this.headers, folderUid, this.params);
579-
}
580563

581564
/**
582565
* The Get a single folder by name call retrieves a specific asset folder based on the name provided.
@@ -617,81 +600,5 @@ public Call<ResponseBody> getSubfolder() {
617600
return this.service.getSubfolder(this.headers, this.params);
618601
}
619602

620-
/**
621-
* The Create a folder call is used to create an asset folder and/or add a parent folder to it (if required).
622-
* <p>
623-
* In the ‘Body’ section, you need to provide a name for the new folder.
624-
* <p>
625-
* If you want to place this folder within another folder, provide the UID of the parent folder in the Request body
626-
* as follows:
627-
* <p>
628-
* { "asset": { "name": "asset_folder_name", "parent_uid": "asset_parent_folder_uid" } }
629-
*
630-
* <b>Note:</b> Here are some points that needs to be considered when executing
631-
* this API request:
632-
* <p>
633-
* A maximum of 300 folders can be created. The maximum level of folder nesting is 5. When nesting folder, you
634-
* cannot nest a folder within the same folder or within its child folders
635-
*
636-
* @param requestBody
637-
* JSONObject request body
638-
* @return Call
639-
* @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#create-a-folder"> Create
640-
* a folder</a>
641-
* @see #addHeader(String, Object) to add headers
642-
* @see #addParam(String, Object) to add query params
643-
* @since 1.0.0
644-
*/
645-
public Call<ResponseBody> createFolder(@Nullable JSONObject requestBody) {
646-
return this.service.createFolder(this.headers, this.params, requestBody);
647-
}
648-
649-
/**
650-
* The Update or move folder request can be used either to update the details of a folder or set the parent folder
651-
* if you want to move a folder under another folder.
652-
* <p>
653-
* When executing the API request, provide the UID of the folder that you want to move/update.
654-
* <p>
655-
* In the ‘Body’ section, you need to provide a new name for your folder, and if you want to move your folder within
656-
* another folder, then you need provide the UID of the parent folder.
657-
*
658-
* <b>Note:</b> Here are some points that needs to be considered when executing
659-
* this API request:
660-
* <p>
661-
* A maximum of 300 folders can be created. The maximum level of folder nesting is 5. When nesting folder, you
662-
* cannot nest a folder within the same folder or within its child folders.
663-
*
664-
* @param folderUid
665-
* The UID of the folder that you want to either update or move
666-
* @param requestBody
667-
* JSONObject request body { "asset": { "name": "Demo" } }
668-
* @return Call
669-
* @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#update-or-move-folder">
670-
* Update ORr Move Folder</a>
671-
* @see #addHeader(String, Object) to add headers
672-
* @see #addParam(String, Object) to add query params
673-
* @since 1.0.0
674-
*/
675-
public Call<ResponseBody> updateFolder(@NotNull String folderUid, @Nullable JSONObject requestBody) {
676-
return this.service.updateFolder(this.headers, folderUid, this.params, requestBody);
677-
}
678-
679-
/**
680-
* Delete a folder call is used to delete an asset folder along with all the assets within that folder.
681-
* <p>
682-
* When executing the API call, provide the parent folder UID.
683-
*
684-
* @param folderUid
685-
* The UID of the asset folder that you want to delete
686-
* @return Call
687-
* @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-a-folder">
688-
* Delete A Folder</a>
689-
* @see #addHeader(String, Object) to add headers
690-
* @see #addParam(String, Object) to add query params
691-
* @since 1.0.0
692-
*/
693-
public Call<ResponseBody> deleteFolder(@NotNull String folderUid) {
694-
return this.service.deleteFolder(this.headers, folderUid);
695-
}
696603

697604
}

0 commit comments

Comments
 (0)