Interface SubscriptionService

All Known Implementing Classes:
SubscriptionServiceImpl

public interface SubscriptionService
  • Method Summary

    Modifier and Type Method Description
    boolean changeSentNotification​(java.lang.String email)
    This service method changes value sentNotification of Subscription.
    void checkIfSent​(java.lang.String customerMail)
    This method is called only if the client's subscription is expiring and check if the client is already notified.
    int checkSubscriptionState​(java.lang.String customerMail)
    This method check the state of a subscription.
    void createSubscription​(java.lang.String customerMail)
    This service method register the subscription for a customer.
    java.util.ArrayList<Subscription> getActiveSubscriptions()
    This service method shows all active Subscriptions.
    java.util.ArrayList<Subscription> getExpiredSubscriptions()
    This service method shows all expired Subscriptions.
    java.util.ArrayList<Subscription> getExpiringSubscriptions()
    This service method shows all expiring Subscriptions.
    Subscription searchSubscriptionByEmail​(java.lang.String customerMail)
    This method searches in the database for a customer's subscription, given his email.
    void sendEmail​(java.lang.String customerMail, Subscription subscription)
    Send an email to the customer if his subscription is expiring.
  • Method Details

    • createSubscription

      void createSubscription​(java.lang.String customerMail) throws java.io.IOException
      This service method register the subscription for a customer. It only needs the customer email. Then it sets a standard price and the expiration date, obtained by adding an extra month to the registration date.
      Parameters:
      customerMail - the customer mail
      Throws:
      java.io.IOException
    • searchSubscriptionByEmail

      Subscription searchSubscriptionByEmail​(java.lang.String customerMail) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
      This method searches in the database for a customer's subscription, given his email.
      Parameters:
      customerMail - customer mail
      Returns:
      the Subscription.
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.io.IOException
    • checkSubscriptionState

      int checkSubscriptionState​(java.lang.String customerMail) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
      This method check the state of a subscription.
      Parameters:
      customerMail - the mail of the subscription owner
      Returns:
      1 if the subscription is valid, 0 if subscription expiring, -1 for expired subscription.
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.io.IOException
    • getExpiringSubscriptions

      java.util.ArrayList<Subscription> getExpiringSubscriptions() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
      This service method shows all expiring Subscriptions.
      Returns:
      the list of expiring Subscriptions
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.io.IOException
    • getExpiredSubscriptions

      java.util.ArrayList<Subscription> getExpiredSubscriptions() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
      This service method shows all expired Subscriptions.
      Returns:
      the list of expired Subscriptions
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.io.IOException
    • getActiveSubscriptions

      java.util.ArrayList<Subscription> getActiveSubscriptions() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
      This service method shows all active Subscriptions.
      Returns:
      the list of active Subscriptions
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.io.IOException
    • changeSentNotification

      boolean changeSentNotification​(java.lang.String email) throws java.io.IOException, java.util.concurrent.ExecutionException, java.lang.InterruptedException
      This service method changes value sentNotification of Subscription.
      Parameters:
      email - of the account
      Returns:
      true if the change has taken place, false otherwise.
      Throws:
      java.io.IOException
      java.util.concurrent.ExecutionException
      java.lang.InterruptedException
    • sendEmail

      void sendEmail​(java.lang.String customerMail, Subscription subscription) throws org.apache.commons.mail.EmailException
      Send an email to the customer if his subscription is expiring.
      Parameters:
      customerMail - Account of user to send email.
      subscription - Account subscription.
      Throws:
      org.apache.commons.mail.EmailException
    • checkIfSent

      void checkIfSent​(java.lang.String customerMail) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException, org.apache.commons.mail.EmailException
      This method is called only if the client's subscription is expiring and check if the client is already notified. if it has not been sent, this method send an email to the customer that his subscription is expiring
      Parameters:
      customerMail - the client in session to notify.
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.io.IOException
      org.apache.commons.mail.EmailException