Package com.oracle.content.sdk.request
Class GetCustomContentItemRequest<C extends ContentItem>
java.lang.Object
com.oracle.content.sdk.request.core.ContentRequest<T,C>
com.oracle.content.sdk.request.core.ContentRequestById<T,C>
com.oracle.content.sdk.request.core.ContentAssetRequest<GetCustomContentItemRequest,C>
com.oracle.content.sdk.request.GetCustomContentItemRequest<C>
public class GetCustomContentItemRequest<C extends ContentItem>
extends ContentAssetRequest<GetCustomContentItemRequest,C>
Request class used to request a single content item based on a specified id,
ane will parse the custom fields into a class with annotated fields. For
example, you could define a custom model that extends from
ContentItem
and annotate each field with the custom field value. The type of the field
should match the content item type. Here is an example of a custom class
with annotated fields:
{@literal @}CustomContentType("content_type")
public class CustomContentItem extends ContentItem {
{@literal @}CustomContentField("text-field")
String text;
{@literal @}CustomContentField("date-field")
ContentFieldDate dateField;
{@literal @}CustomContentField("decimal-field")
ContentFieldDecimal decimalField;
}
Each field in the custom class should be either a String value or a ContentField type that
extends from ContentField
. Then you can
reference the class as shown in the example below to get the item and populate the custom
class model.
// make call to get the item by id with the custom class
GetCustomContentItemRequest request =
new GetCustomContentItemRequest(clientAPI, CustomContentItem.class, itemID);
// synchronous call to fetch the item
ContentResponse<CustomContentItem> response = request.fetch();
if (response.isSuccess()) {
// custom content item from result
CustomContentItem item = response.getResult();
}
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.content.sdk.request.core.ContentRequestById
ContentRequestById.IdType
-
Field Summary
Fields inherited from class com.oracle.content.sdk.request.core.ContentAssetRequest
expand, EXPAND_ALL
Fields inherited from class com.oracle.content.sdk.request.core.ContentRequestById
id, idType
Fields inherited from class com.oracle.content.sdk.request.core.ContentRequest
client, links, objectClass
-
Constructor Summary
ConstructorsConstructorDescriptionGetCustomContentItemRequest
(ContentDeliveryClient client, Class objectClass, String id) GetCustomContentItemRequest
(ContentDeliveryClient client, Class objectClass, String id, ContentRequestById.IdType idType) Create request to get a content item for the given id. -
Method Summary
Modifier and TypeMethodDescriptionprotected C
deserializeObject
(com.google.gson.JsonElement jsonElement) Methods inherited from class com.oracle.content.sdk.request.core.ContentAssetRequest
deserializeContentBaseItem, expand, expand, expandAll, getCall, getExpand
Methods inherited from class com.oracle.content.sdk.request.core.ContentRequest
fetch, fetchAsync, fetchResult, getCacheControl, getThis, gson, links, linksNone, noCache, observable, observableResult
-
Constructor Details
-
GetCustomContentItemRequest
public GetCustomContentItemRequest(ContentDeliveryClient client, Class objectClass, String id, ContentRequestById.IdType idType) Create request to get a content item for the given id.- Parameters:
client
- A valid delivery clientobjectClass
- object class for custom modelid
- A valid content item ididType
- id or slug
-
GetCustomContentItemRequest
-
-
Method Details
-
deserializeObject
- Overrides:
deserializeObject
in classContentRequest<GetCustomContentItemRequest,
C extends ContentItem>
-