View Javadoc
1   /***
2    * Copyright (C) 2009 TM-Search Community.
3    *
4    * This file is part of TM-Search Services.
5    *
6    * Foobar is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * Foobar is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package eu.europa.tmsearch.services.business;
21  
22  import java.util.Date;
23  
24  import org.apache.log4j.Logger;
25  
26  import eu.europa.tmsearch.services.dao.RepresentativeDAO;
27  import eu.europa.tmsearch.services.resources.exceptions.ResourceNotFoundException;
28  import eu.europa.tmsearch.services.schemas.trademark.representative.RepresentativeType;
29  
30  /***
31   * An implementation of TradeMark service business logic
32   * 
33   * 
34   * @see TradeMark
35   */
36  public class RepresentativeServiceImpl implements RepresentativeService {
37  
38      private RepresentativeDAO representativeDAO;
39  
40      private static Logger log = Logger.getLogger(RepresentativeServiceImpl.class);
41  
42      /***
43       * Gets a TradeMark given a template TradeMark
44       * 
45       * @param tradeMark
46       *            A TradeMark template used as
47       * @return A TradeMark containing the trade mark
48       * @throws ResourceNotFoundException
49       *             If the trade mark does not exist
50       * @see TradeMark
51       */
52      public RepresentativeType getRepresentative(String representativeId) throws ResourceNotFoundException {
53  
54  	if (log.isDebugEnabled()) {
55  	    log.debug("Retrieving Applicant With ID --> " + representativeId);
56  	}
57  	long startList = System.currentTimeMillis();
58  
59  	RepresentativeType representativeType = representativeDAO.getRepresentative(representativeId);
60  	long endList = System.currentTimeMillis();
61  	log.info("Representative Retrieved");
62  	log.info("Representative retrieval Time = " + (endList - startList));
63  
64  	return representativeType;
65      }
66  
67      @Override
68      public Date getLastModified(String representativeId) throws ResourceNotFoundException {
69  	return representativeDAO.getLastModified(representativeId);
70      }
71  
72      @Override
73      public Date getExpires(String representativeId) throws ResourceNotFoundException {
74  	return representativeDAO.getExpires(representativeId);
75      }
76  
77      public RepresentativeDAO getRepresentativeDAO() {
78  	return representativeDAO;
79      }
80  
81      public void setRepresentativeDAO(RepresentativeDAO representativeDAO) {
82  	this.representativeDAO = representativeDAO;
83      }
84  
85  }