View Javadoc
1   package fr.paris.lutece.plugins.appointment.web.file;
2   
3   import fr.paris.lutece.plugins.appointment.business.display.Display;
4   import fr.paris.lutece.plugins.appointment.service.DisplayService;
5   import fr.paris.lutece.portal.service.image.ImageResource;
6   import fr.paris.lutece.portal.service.image.ImageResourceManager;
7   import fr.paris.lutece.portal.service.image.ImageResourceProvider;
8   import fr.paris.lutece.portal.service.init.LuteceInitException;
9   import org.apache.commons.fileupload.FileItem;
10  
11  /**
12   * Image Resource Service for the appointment form icon
13   */
14  public class AppointmentFormIconService implements ImageResourceProvider
15  {
16      private static AppointmentFormIconServicee/AppointmentFormIconService.html#AppointmentFormIconService">AppointmentFormIconService _singleton = new AppointmentFormIconService( );
17      private static final String IMAGE_RESOURCE_TYPE_ID = "appointmentForm_icon";
18  
19      /**
20       * Creates a new instance of AppointmentFormIconService
21       */
22      private AppointmentFormIconService( )
23      {
24      }
25  
26      /**
27       * Init
28       *
29       * @throws LuteceInitException
30       *         if an error occurs
31       */
32      public static synchronized void init( )
33      {
34          getInstance( ).register( );
35      }
36  
37      /**
38       * Initializes the service
39       */
40      public void register( )
41      {
42          ImageResourceManager.registerProvider( this );
43      }
44  
45      /**
46       * Get the unique instance of the service
47       *
48       * @return The unique instance
49       */
50      public static AppointmentFormIconService getInstance( )
51      {
52          return _singleton;
53      }
54  
55      /**
56       * Return the Resource id
57       *
58       * @param nIdResource
59       *         The resource identifier
60       * @return The Resource Image
61       */
62      @Override
63      public ImageResource getImageResource( int nIdResource )
64      {
65          Display display = DisplayService.findDisplayWithFormId( nIdResource );
66  
67          if ( display != null )
68          {
69              return display.getIcon( );
70          }
71          return null;
72      }
73  
74      /**
75       * Return the Resource Type id
76       *
77       * @return The Resource Type Id
78       */
79      public String getResourceTypeId( )
80      {
81          return IMAGE_RESOURCE_TYPE_ID;
82      }
83  
84      /**
85       * Add Image Resource
86       *
87       * @param fileItem
88       * @return the Image File Key
89       */
90      @Override
91      public String addImageResource( FileItem fileItem )
92      {
93          return null;
94      }
95  
96  }
97