HorseService.java 2.3 KB
Newer Older
1 2 3 4
package at.ac.tuwien.sepm.assignment.individual.service;

import at.ac.tuwien.sepm.assignment.individual.entity.Horse;
import at.ac.tuwien.sepm.assignment.individual.exception.NotFoundException;
5 6
import at.ac.tuwien.sepm.assignment.individual.util.ValidationException;
import org.springframework.dao.DataAccessException;
7 8 9
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
10 11 12 13 14 15 16 17 18 19 20 21

public interface HorseService {
    /**
     * @param id of the horse to find.
     * @return the horse with the specified id.
     * @throws RuntimeException  will be thrown if something goes wrong during data processing.
     * @throws NotFoundException will be thrown if the horse could not be found in the system.
     */
    Horse findOneById(Long id);

    /**
     * @param horse to add.
22
     * @return the new horse.
23
     * @throws ValidationException will be thrown if something goes wrong during verification.
24
     * @throws DataAccessException will be thrown if the horse could not be saved in the database.
25 26
     */
    Horse addHorse(Horse horse);
27

28 29 30
    /**
     * @param horse that specifies the new horse values alongside with the id of the horse to update
     * @return the updated horse
31
     * @throws ValidationException will be thrown if something goes wrong during verification.
32
     * @throws DataAccessException will be thrown if the horse could not be saved in the database.
33
     * @throws IOException         will be thrown if the old horse image could not be deleted
34
     */
35 36 37 38 39 40 41 42 43
    Horse updateHorse(Horse horse) throws ValidationException, DataAccessException, IOException;

    /**
     * @param id of the horse to delete
     * @throws NotFoundException   will be thrown if the horse could not be found in the system
     * @throws DataAccessException will be thrown if the horse could not be deleted from the database
     * @throws IOException         will be thrown if the horse image could not be deleted
     */
    void deleteHorse(Long id) throws NotFoundException, DataAccessException, IOException;
44

45 46
    /**
     * @param img image to upload
47
     * @throws IOException         will be thrown if something goes wrong with saving the file
48
     * @throws ValidationException will be thrown if the file is in the incorrect format
49
     */
50
    void saveImage(MultipartFile img) throws IOException, ValidationException;
51
}