1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.broadcastproxy.service;
35
36 import java.util.List;
37 import java.util.Map;
38
39 import org.json.simple.JSONObject;
40
41 import fr.paris.lutece.plugins.broadcastproxy.business.Feed;
42 import fr.paris.lutece.plugins.broadcastproxy.business.IBroadcastProvider;
43 import fr.paris.lutece.plugins.broadcastproxy.business.Subscription;
44 import fr.paris.lutece.portal.service.init.LuteceInitException;
45 import fr.paris.lutece.portal.service.spring.SpringContextService;
46 import fr.paris.lutece.portal.service.util.AppLogService;
47
48 public class BroadcastService
49 {
50
51 private static final String BEAN_BROADCAST_PROVIDER = "broadcastproxy.provider";
52
53 private static IBroadcastProvider _broadcastProvider;
54 private static BroadcastService _instance;
55
56
57
58
59 private BroadcastService( )
60 {
61 }
62
63
64
65
66
67
68 public String getName( )
69 {
70 return _broadcastProvider.getName( );
71 }
72
73
74
75
76
77
78 public static synchronized BroadcastService getInstance( )
79 {
80 if ( _instance == null )
81 {
82 _instance = new BroadcastService( );
83 _instance.init( );
84 }
85
86 return _instance;
87 }
88
89
90
91
92
93
94
95 private synchronized void init( )
96 {
97 if ( _broadcastProvider == null )
98 {
99 _broadcastProvider = (IBroadcastProvider) SpringContextService.getBean( BEAN_BROADCAST_PROVIDER );
100 AppLogService.info( "BroadcastProvider loaded : " + _broadcastProvider.getName( ) );
101 }
102 }
103
104
105
106
107
108
109
110
111 public boolean updateSubscribtions( String userId, List<Subscription> subscriptionsList ) throws Exception
112 {
113 return _broadcastProvider.updateSubscribtions( userId, subscriptionsList );
114 }
115
116
117
118
119
120
121
122
123
124 public boolean updateSubscribtions( String userId, String jsonSubscriptions, String strAccountId ) throws Exception
125 {
126 return _broadcastProvider.updateSubscribtions( userId, jsonSubscriptions, strAccountId );
127 }
128
129
130
131
132
133
134
135
136
137 public boolean updateArrondissementSubscribtions( String userId, String jsonSubscriptions, String strAccountId ) throws Exception
138 {
139 return _broadcastProvider.updateArrondissementSubscribtions( userId, jsonSubscriptions, strAccountId );
140 }
141
142
143
144
145
146
147
148
149
150 public boolean update( Subscription sub, String strAccountId ) throws Exception
151 {
152 return _broadcastProvider.update( sub, strAccountId );
153 }
154
155
156
157
158
159
160 public List<Feed> getFeeds( )
161 {
162 return _broadcastProvider.getFeeds( );
163 }
164
165
166
167
168
169
170
171 public String getAllSubscriptionByGroup( String typeSubscription, String strAccountId )
172 {
173 return _broadcastProvider.getAllSubscriptionByGroup( typeSubscription, strAccountId );
174 }
175
176
177
178
179
180
181
182
183 public List<JSONObject> getUserSubscriptionIds( String strUserId, String strAccountId )
184 {
185 return _broadcastProvider.getUserSubscriptionIds( strUserId, strAccountId );
186 }
187 }