Class AcmeJsonResource

    • Method Detail

      • 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.
        Throws:
        AcmeLazyLoadingException - if an AcmeException occured while fetching the current state from the server.
      • 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 fetch() to fetch the current state from the server.
      • invalidate

        protected void invalidate()
        Invalidates the state of this resource. Enforces a fetch() when getJSON() is invoked.

        Subclasses can override this method to purge internal caches that are based on the JSON structure. Remember to invoke super.invalidate()!

      • update

        public void update()
                    throws AcmeException
        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 in AcmeRetryAfterException.getRetryAfter(). Note that the status of the resource is updated even if this exception was thrown.
        See Also:
        fetch()
      • fetch

        public Optional<Instantfetch()
                                throws AcmeException
        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:
        update()
      • setRetryAfter

        protected void setRetryAfter​(@Nullable
                                     Instant retryAfter)
        Sets a Retry-After instant.
        Since:
        3.2.0
      • getRetryAfter

        public Optional<InstantgetRetryAfter()
        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