1
2
3
4
5 package com.hack23.cia.service.impl.common;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9 import org.springframework.transaction.annotation.Propagation;
10 import org.springframework.transaction.annotation.Transactional;
11
12 import com.hack23.cia.model.application.impl.common.ImageContent;
13 import com.hack23.cia.service.api.common.ImageContentRequest;
14 import com.hack23.cia.service.api.common.ImageContentResponse;
15 import com.hack23.cia.service.api.common.ServiceRequest;
16 import com.hack23.cia.service.api.common.ServiceResponse;
17 import com.hack23.cia.service.dao.ResourceDAO;
18
19 /***
20 * The Class ImageContentRequestService.
21 */
22 @Transactional(propagation = Propagation.REQUIRED)
23 public class ImageContentRequestService
24 implements BusinessService {
25
26 /*** The Constant LOGGER. */
27 private static final Log LOGGER = LogFactory
28 .getLog(ImageContentRequestService.class);
29
30 /*** The resource dao. */
31 private final ResourceDAO resourceDAO;
32
33 /***
34 * Instantiates a new image content request service.
35 *
36 * @param resourceDAO the resource dao
37 */
38 public ImageContentRequestService(final ResourceDAO resourceDAO) {
39 super();
40 this.resourceDAO = resourceDAO;
41 }
42
43
44
45
46 @Override
47 public final Class getSupportedService() {
48 return ImageContentRequest.class;
49 }
50
51
52
53
54 @Override
55 public final ServiceResponse processService(final ServiceRequest serviceRequest) {
56 final ImageContentRequest request = (ImageContentRequest) serviceRequest;
57 final ImageContent imageContent = resourceDAO.getImageContentByFileName(request.getFileName());
58 LOGGER.info("Got image :" + imageContent);
59 return new ImageContentResponse(null, imageContent);
60 }
61
62 }