Class ClientService


  • public class ClientService
    extends java.lang.Object
    A Service to access and store Activities
    Version:
    $Id: $Id
    Author:
    medamine
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientService​(ClientStorage clientStorage)
      Constructor for ClientService.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Client createClient​(Client client)
      Create new Client that will be available for all users.
      void deleteClient​(java.lang.Long clientId, java.lang.String username)
      Delete Client identified by its id and check if username has permission to delete it.
      java.util.List<Client> getClientsList()
      Retrieves the list of Activities with offset, limit and a keyword that can be empty
      Client updateClient​(Client Client, java.lang.String username)
      Update an existing Client on datasource.
      • Methods inherited from class java.lang.Object

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

      • ClientService

        public ClientService​(ClientStorage clientStorage)

        Constructor for ClientService.

        Parameters:
        clientStorage - a ClientStorage object.
    • Method Detail

      • createClient

        public Client createClient​(Client client)
                            throws java.lang.Exception
        Create new Client that will be available for all users. If the Client already exits an EntityExistsException will be thrown.
        Parameters:
        client - Client to create
        Returns:
        stored Client in datasource
        Throws:
        java.lang.Exception - when Client already exists or an error occurs while creating Client or its attached image
      • updateClient

        public Client updateClient​(Client Client,
                                   java.lang.String username)
                            throws java.lang.Exception
        Update an existing Client on datasource. If the Client doesn't exit an EntityNotFoundException will be thrown.
        Parameters:
        Client - dto to update on store
        username - username storing Client
        Returns:
        stored Client in datasource
        Throws:
        java.lang.Exception - when Exception is thrown or an error occurs while saving Client
      • deleteClient

        public void deleteClient​(java.lang.Long clientId,
                                 java.lang.String username)
                          throws javax.persistence.EntityNotFoundException,
                                 java.lang.IllegalAccessException
        Delete Client identified by its id and check if username has permission to delete it.
        Parameters:
        clientId - technical identifier of Client
        username - user currently deleting Client
        Throws:
        javax.persistence.EntityNotFoundException - if Client wasn't found
        java.lang.IllegalAccessException - if user is not allowed to delete Client
      • getClientsList

        public java.util.List<Client> getClientsList()
        Retrieves the list of Activities with offset, limit and a keyword that can be empty
        Returns:
        List of Client that contains the list of Activities