Class PersistenceAccountingService

java.lang.Object
org.gcube.documentstore.persistence.PersistenceBackend
org.gcube.documentstore.persistence.PersistenceAccountingService

public class PersistenceAccountingService extends org.gcube.documentstore.persistence.PersistenceBackend
Author:
Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it, Luca Frosini (ISTI - CNR) luca.frosini@isti.cnr.it, Biagio Peccerillo (ISTI - CNR) biagio.peccerillo@isti.cnr.it
  • Field Details

    • PATH_SERVICE_INSERT_ACCOUNTING

      public static final String PATH_SERVICE_INSERT_ACCOUNTING
      See Also:
    • APPLICATION_JSON_CHARSET_UTF_8

      public static final String APPLICATION_JSON_CHARSET_UTF_8
      See Also:
    • URL_PROPERTY_KEY

      public static final String URL_PROPERTY_KEY
      See Also:
    • SERVICE_GROUP

      public static final String SERVICE_GROUP
      The group and the name of the SoftwareFacet identifying the accounting service EService in the IS, i.e. the Maven coordinates of the service, as SmartGears publishes them; the entry name is the name of its servlet, as published in its AccessPointFacet.
      See Also:
    • SERVICE_NAME

      public static final String SERVICE_NAME
      See Also:
    • SERVICE_ENTRY_NAME

      public static final String SERVICE_ENTRY_NAME
      See Also:
    • url

      protected String url
  • Constructor Details

    • PersistenceAccountingService

      public PersistenceAccountingService()
  • Method Details

    • forceURL

      protected static void forceURL(String url)
    • prepareConnection

      protected void prepareConnection(org.gcube.documentstore.persistence.PersistenceBackendConfiguration configuration) throws Exception
      Specified by:
      prepareConnection in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception
    • getStringBuilder

      protected StringBuilder getStringBuilder(InputStream inputStream) throws IOException
      Throws:
      IOException
    • parseHttpURLConnection

      protected String parseHttpURLConnection(HttpURLConnection connection) throws jakarta.ws.rs.WebApplicationException
      Throws:
      jakarta.ws.rs.WebApplicationException
    • send

      protected void send(org.gcube.documentstore.records.Record... records) throws Exception
      Posts the records to the accounting service with the secret of the current thread. The library runs every persistence with its own credentials (document-store-lib LibraryCredentials), so this is the library's secret for its working Context, not the secret of the caller which produced the records.

      A request which reached the service without a response status (e.g. the read timeout expired) has an unknown outcome: the service may have accounted the records. A request which received a success status is delivered, whatever happens afterwards.

      Parameters:
      records - the records
      Throws:
      org.gcube.documentstore.exception.PersistenceOutcomeUnknownException - if the request reached the service but no response status was received
      Exception - if the records were not accounted
    • reallyAccount

      protected void reallyAccount(org.gcube.documentstore.records.Record record) throws Exception
      Specified by:
      reallyAccount in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception
    • accountWithFallback

      protected void accountWithFallback(org.gcube.documentstore.records.Record... records) throws Exception
      Overrides:
      accountWithFallback in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception
    • openConnection

      protected void openConnection() throws Exception
      Specified by:
      openConnection in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception
    • closeConnection

      protected void closeConnection() throws Exception
      Specified by:
      closeConnection in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception
    • isConnectionActive

      public boolean isConnectionActive() throws Exception
      Specified by:
      isConnectionActive in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception
    • clean

      protected void clean() throws Exception
      Specified by:
      clean in class org.gcube.documentstore.persistence.PersistenceBackend
      Throws:
      Exception