Class AcmeJsonResource

java.lang.Object
org.shredzone.acme4j.AcmeResource
org.shredzone.acme4j.AcmeJsonResource
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Account, Authorization, Challenge, Order

public abstract class AcmeJsonResource
extends AcmeResource
An ACME resource that stores its state in a JSON structure.
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected AcmeJsonResource​(Login login, java.net.URL location)
    Create a new AcmeJsonResource.
  • Method Summary

    Modifier and Type Method Description
    JSON getJSON()
    Returns the JSON representation of the resource data.
    protected void invalidate()
    Invalidates the state of this resource.
    protected boolean isValid()
    Checks if this resource is valid.
    protected void setJSON​(JSON data)
    Sets the JSON representation of the resource data.
    void update()
    Updates this resource, by fetching the current resource data from the server.

    Methods inherited from class org.shredzone.acme4j.AcmeResource

    getLocation, getLogin, getSession, rebind

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AcmeJsonResource

      protected AcmeJsonResource​(Login login, java.net.URL location)
      Create a new AcmeJsonResource.
      Parameters:
      login - Login the resource is bound with
      location - Location URL of this resource
  • Method Details

    • getJSON

      public JSON 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.
    • setJSON

      protected void setJSON​(JSON data)
      Sets the JSON representation of the resource data.
      Parameters:
      data - New JSON data, must not be null.
    • isValid

      protected boolean isValid()
      Checks if this resource is valid.
      Returns:
      true if the resource state has been loaded from the server. If false, getJSON() would implicitly call update() to fetch the current state from the server.
    • invalidate

      protected void invalidate()
      Invalidates the state of this resource. Enforces an update() when getJSON() is invoked.
    • update

      public void update() throws AcmeException
      Updates this resource, by fetching the current resource data from the server.
      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 in AcmeRetryAfterException.getRetryAfter(). Note that the status of the resource is updated even if this exception was thrown.