java.lang.Object
org.shredzone.acme4j.AcmeResource
org.shredzone.acme4j.AcmeJsonResource
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Account
,Authorization
,Challenge
,Order
,RenewalInfo
An extension of
AcmeResource
that also contains the current state of a resource
as JSON document. If the current state is not present, this class takes care of
fetching it from the server if necessary.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AcmeJsonResource
(Login login, URL location) Create a newAcmeJsonResource
. -
Method Summary
Modifier and TypeMethodDescriptionfetch()
Updates this resource, by fetching the current resource data from the server.getJSON()
Returns the JSON representation of the resource data.Gets an estimation when the resource status will change.protected void
Invalidates the state of this resource.protected boolean
isValid()
Checks if this resource is valid.protected void
Sets the JSON representation of the resource data.protected void
setRetryAfter
(Instant retryAfter) Sets a Retry-After instant.void
update()
Deprecated.Methods inherited from class org.shredzone.acme4j.AcmeResource
finalize, getLocation, getLogin, getSession, rebind
-
Constructor Details
-
AcmeJsonResource
Create a newAcmeJsonResource
.
-
-
Method Details
-
getJSON
Returns the JSON representation of the resource data.If there is no data,
update()
is invoked to fetch it from the server.This method can be used to read proprietary data from the resources.
- Returns:
- Resource data, as
JSON
. - Throws:
AcmeLazyLoadingException
- if anAcmeException
occured while fetching the current state from the server.
-
setJSON
Sets the JSON representation of the resource data.- Parameters:
data
- NewJSON
data, must not benull
.
-
isValid
Checks if this resource is valid. -
invalidate
-
update
Deprecated.Usefetch()
instead. It returns the retry-after value asOptional
instead of throwing anAcmeRetryAfterException
. This method will be removed in a future version.Updates this resource, by fetching the current resource data from the server.Note: Prefer to use
fetch()
instead. It is working the same way, but returns the Retry-After instant instead of throwing an exception. This method will become deprecated in a future release.- Throws:
AcmeException
- if the resource could not be fetched.AcmeRetryAfterException
- the resource is still being processed, and the server returned an estimated date when the process will be completed. If you are polling for the resource to complete, you should wait for the date given inAcmeRetryAfterException.getRetryAfter()
. Note that the status of the resource is updated even if this exception was thrown.- See Also:
-
fetch
Updates this resource, by fetching the current resource data from the server.- Returns:
- An
Optional
estimation when the resource status will change. If you are polling for the resource to complete, you should wait for the given instant before trying again. Empty if the server did not return a "Retry-After" header. - Throws:
AcmeException
- if the resource could not be fetched.- Since:
- 3.2.0
- See Also:
-
setRetryAfter
Sets a Retry-After instant.- Since:
- 3.2.0
-
getRetryAfter
Gets an estimation when the resource status will change. If you are polling for the resource to complete, you should wait for the given instant before trying a status refresh.This instant was sent with the Retry-After header at the last update.
- Returns:
- Retry-after
Instant
, or empty if there was no such header. - Since:
- 3.2.0
-
fetch()
instead.