View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
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  	/* (non-Javadoc)
44  	 * @see com.hack23.cia.service.impl.common.BusinessService#getSupportedService()
45  	 */
46  	@Override
47  	public final Class getSupportedService() {
48  		return ImageContentRequest.class;
49  	}
50  
51  	/* (non-Javadoc)
52  	 * @see com.hack23.cia.service.impl.common.BusinessService#processService(com.hack23.cia.service.api.common.ServiceRequest)
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  }