View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.crmclient.service;
35  
36  import fr.paris.lutece.plugins.crmclient.business.CRMItemTypeEnum;
37  import fr.paris.lutece.plugins.crmclient.business.ICRMItem;
38  import fr.paris.lutece.plugins.crmclient.business.ICRMItemFactory;
39  import fr.paris.lutece.plugins.crmclient.service.processor.ICRMClientProcessor;
40  import fr.paris.lutece.plugins.crmclient.service.queue.ICRMClientQueue;
41  import fr.paris.lutece.plugins.crmclient.util.CRMException;
42  
43  import org.apache.commons.lang.StringUtils;
44  
45  import javax.inject.Inject;
46  
47  /**
48   *
49   * AbstractCRMClientService
50   *
51   */
52  public class CRMClientService implements ICRMClientService
53  {
54      // CONSTANTS
55      private static final String MEDIA_TYPE_JSON = "application/json";
56      private static final String MEDIA_TYPE_XML = "application/xml";
57      @Inject
58      private ICRMClientQueue _crmClientQueue;
59      @Inject
60      private ICRMItemFactory _crmItemFactory;
61      @Inject
62      ICRMClientProcessor _crmClientProcessor;
63  
64      /**
65       * {@inheritDoc}
66       */
67      @Override
68      public ICRMClientQueue getQueue( )
69      {
70          return _crmClientQueue;
71      }
72  
73      /**
74       * {@inheritDoc}
75       */
76      @Override
77      public void notify( String strIdDemand, String strObject, String strMessage, String strSender )
78      {
79          notify( strIdDemand, strObject, strMessage, strSender, StringUtils.EMPTY );
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      @Override
86      public void notify( String strIdDemand, String strObject, String strMessage, String strSender, String strCRMWebAppCode )
87      {
88          ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.NOTIFICATION.toString( ) );
89  
90          if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
91          {
92              crmItem.setCRMWebAppCode( strCRMWebAppCode );
93          }
94  
95          crmItem.putParameter( ICRMItem.ID_DEMAND, StringUtils.isNotBlank( strIdDemand ) ? strIdDemand : StringUtils.EMPTY );
96          crmItem.putParameter( ICRMItem.NOTIFICATION_OBJECT, StringUtils.isNotBlank( strObject ) ? strObject : StringUtils.EMPTY );
97          crmItem.putParameter( ICRMItem.NOTIFICATION_MESSAGE, StringUtils.isNotBlank( strMessage ) ? strMessage : StringUtils.EMPTY );
98          crmItem.putParameter( ICRMItem.NOTIFICATION_SENDER, StringUtils.isNotBlank( strSender ) ? strSender : StringUtils.EMPTY );
99  
100         _crmClientQueue.send( crmItem );
101     }
102 
103     /**
104      * {@inheritDoc}
105      */
106     @Override
107     public void sendUpdateDemand( String strIdDemand, String strStatusText ) throws CRMException
108     {
109         sendUpdateDemand( strIdDemand, strStatusText, StringUtils.EMPTY );
110     }
111 
112     /**
113      * /** {@inheritDoc}
114      */
115     @Override
116     public void sendUpdateDemand( String strIdDemand, String strStatusText, String strCRMWebAppCode ) throws CRMException
117     {
118         sendUpdateDemand( strIdDemand, strStatusText, strCRMWebAppCode, StringUtils.EMPTY, StringUtils.EMPTY );
119     }
120 
121     /**
122      * {@inheritDoc}
123      */
124     @Override
125     public void sendUpdateDemand( String strIdDemand, String strStatusText, String strCRMWebAppCode, String strIdStatusCRM ) throws CRMException
126     {
127         sendUpdateDemand( strIdDemand, strStatusText, strCRMWebAppCode, strIdStatusCRM, StringUtils.EMPTY );
128     }
129 
130     /**
131      * {@inheritDoc}
132      */
133     @Override
134     public void sendUpdateDemand( String strIdDemand, String strStatusText, String strCRMWebAppCode, String strIdStatusCRM, String strData )
135             throws CRMException
136     {
137         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_UPDATE.toString( ) );
138 
139         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
140         {
141             crmItem.setCRMWebAppCode( strCRMWebAppCode );
142         }
143 
144         if ( StringUtils.isNotBlank( strIdStatusCRM ) )
145         {
146             crmItem.putParameter( ICRMItem.ID_STATUS_CRM, strIdStatusCRM );
147         }
148 
149         if ( StringUtils.isNotBlank( strData ) )
150         {
151             crmItem.putParameter( ICRMItem.DEMAND_DATA, strData );
152         }
153 
154         crmItem.putParameter( ICRMItem.ID_DEMAND, StringUtils.isNotBlank( strIdDemand ) ? strIdDemand : StringUtils.EMPTY );
155         crmItem.putParameter( ICRMItem.STATUS_TEXT, StringUtils.isNotBlank( strStatusText ) ? strStatusText : StringUtils.EMPTY );
156 
157         _crmClientProcessor.doProcess( crmItem );
158     }
159 
160     @Override
161     public String sendCreateDemandByUserGuid( String strIdDemandType, String strUserGuid, String strIdStatusCRM, String strStatusText, String strData )
162             throws CRMException
163     {
164         return sendCreateDemandByUserGuid( strIdDemandType, strUserGuid, strIdStatusCRM, strStatusText, strData, StringUtils.EMPTY );
165     }
166 
167     @Override
168     public String sendCreateDemandByUserGuid( String strIdDemandType, String strUserGuid, String strIdStatusCRM, String strStatusText, String strData,
169             String strCRMWebAppCode ) throws CRMException
170     {
171 
172         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_CREATE_BY_USER_GUID.toString( ) );
173 
174         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
175         {
176             crmItem.setCRMWebAppCode( strCRMWebAppCode );
177         }
178 
179         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
180 
181         crmItem.putParameter( ICRMItem.USER_GUID, StringUtils.isNotBlank( strUserGuid ) ? strUserGuid : StringUtils.EMPTY );
182 
183         crmItem.putParameter( ICRMItem.ID_STATUS_CRM, StringUtils.isNotBlank( strIdStatusCRM ) ? strIdStatusCRM : StringUtils.EMPTY );
184 
185         crmItem.putParameter( ICRMItem.STATUS_TEXT, StringUtils.isNotBlank( strStatusText ) ? strStatusText : StringUtils.EMPTY );
186 
187         crmItem.putParameter( ICRMItem.DEMAND_DATA, StringUtils.isNotBlank( strData ) ? strData : StringUtils.EMPTY );
188 
189         return _crmClientProcessor.doProcess( crmItem );
190     }
191 
192     @Override
193     @Deprecated
194     public String sendCreateDemandByIdCRMUser( String strIdDemandType, String strIdCRMUser, String strIdStatusCRM, String strStatusText, String strData )
195             throws CRMException
196     {
197         return sendCreateDemandByIdCRMUser( strIdDemandType, strIdCRMUser, strIdStatusCRM, strStatusText, strData, StringUtils.EMPTY );
198     }
199 
200     @Override
201     @Deprecated
202     public String sendCreateDemandByIdCRMUser( String strIdDemandType, String strIdCRMUser, String strIdStatusCRM, String strStatusText, String strData,
203             String strCRMWebAppCode ) throws CRMException
204     {
205         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_CREATE_BY_ID_CRM_USER.toString( ) );
206 
207         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
208         {
209             crmItem.setCRMWebAppCode( strCRMWebAppCode );
210         }
211 
212         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
213 
214         crmItem.putParameter( ICRMItem.ID_CRM_USER, StringUtils.isNotBlank( strIdCRMUser ) ? strIdCRMUser : StringUtils.EMPTY );
215 
216         crmItem.putParameter( ICRMItem.ID_STATUS_CRM, StringUtils.isNotBlank( strIdStatusCRM ) ? strIdStatusCRM : StringUtils.EMPTY );
217 
218         crmItem.putParameter( ICRMItem.STATUS_TEXT, StringUtils.isNotBlank( strStatusText ) ? strStatusText : StringUtils.EMPTY );
219 
220         crmItem.putParameter( ICRMItem.DEMAND_DATA, StringUtils.isNotBlank( strData ) ? strData : StringUtils.EMPTY );
221 
222         return _crmClientProcessor.doProcess( crmItem );
223     }
224 
225     @Override
226     public void sendDeleteDemand( String strIdDemand ) throws CRMException
227     {
228         sendDeleteDemand( strIdDemand, StringUtils.EMPTY );
229     }
230 
231     @Override
232     public void sendDeleteDemand( String strIdDemand, String strCRMWebAppCode ) throws CRMException
233     {
234         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_DELETE.toString( ) );
235 
236         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
237         {
238             crmItem.setCRMWebAppCode( strCRMWebAppCode );
239         }
240 
241         crmItem.putParameter( ICRMItem.ID_DEMAND, StringUtils.isNotBlank( strIdDemand ) ? strIdDemand : StringUtils.EMPTY );
242 
243         _crmClientProcessor.doProcess( crmItem );
244     }
245 
246     @Override
247     public String getUserGuidFromIdDemand( String strIdDemand ) throws CRMException
248     {
249         return getUserGuidFromIdDemand( strIdDemand, StringUtils.EMPTY );
250     }
251 
252     @Override
253     public String getUserGuidFromIdDemand( String strIdDemand, String strCRMWebAppCode ) throws CRMException
254     {
255         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_USER_GUID.toString( ) );
256 
257         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
258         {
259             crmItem.setCRMWebAppCode( strCRMWebAppCode );
260         }
261 
262         crmItem.putParameter( ICRMItem.ID_DEMAND, StringUtils.isNotBlank( strIdDemand ) ? strIdDemand : StringUtils.EMPTY );
263 
264         return _crmClientProcessor.getProcess( crmItem );
265     }
266 
267     @Override
268     public String getDemandXml( String strIdDemand ) throws CRMException
269     {
270         return getDemandXml( strIdDemand, StringUtils.EMPTY );
271     }
272 
273     @Override
274     public String getDemandXml( String strIdDemand, String strCRMWebAppCode ) throws CRMException
275     {
276         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_DEMAND_XML.toString( ) );
277 
278         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
279         {
280             crmItem.setCRMWebAppCode( strCRMWebAppCode );
281         }
282 
283         crmItem.putParameter( ICRMItem.ID_DEMAND, StringUtils.isNotBlank( strIdDemand ) ? strIdDemand : StringUtils.EMPTY );
284         crmItem.putParameter( ICRMItem.MEDIA_TYPE, MEDIA_TYPE_JSON );
285 
286         return _crmClientProcessor.getProcess( crmItem );
287     }
288 
289     @Override
290     public String getDemandJson( String strIdDemand ) throws CRMException
291     {
292         return getDemandJson( strIdDemand, StringUtils.EMPTY );
293     }
294 
295     @Override
296     public String getDemandJson( String strIdDemand, String strCRMWebAppCode ) throws CRMException
297     {
298         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_DEMAND_JSON.toString( ) );
299 
300         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
301         {
302             crmItem.setCRMWebAppCode( strCRMWebAppCode );
303         }
304 
305         crmItem.putParameter( ICRMItem.ID_DEMAND, StringUtils.isNotBlank( strIdDemand ) ? strIdDemand : StringUtils.EMPTY );
306         crmItem.putParameter( ICRMItem.MEDIA_TYPE, MEDIA_TYPE_JSON );
307 
308         return _crmClientProcessor.getProcess( crmItem );
309     }
310 
311     @Override
312     @Deprecated
313     public String getUserGuidFromIdCRMUser( String strIdCRMUser ) throws CRMException
314     {
315         // TODO Auto-generated method stub
316         return getUserGuidFromIdCRMUser( strIdCRMUser, StringUtils.EMPTY );
317     }
318 
319     @Override
320     @Deprecated
321     public String getUserGuidFromIdCRMUser( String strIdCRMUser, String strCRMWebAppCode ) throws CRMException
322     {
323         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.USER_GUID.toString( ) );
324 
325         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
326         {
327             crmItem.setCRMWebAppCode( strCRMWebAppCode );
328         }
329 
330         crmItem.putParameter( ICRMItem.ID_CRM_USER, StringUtils.isNotBlank( strIdCRMUser ) ? strIdCRMUser : StringUtils.EMPTY );
331 
332         return _crmClientProcessor.getProcess( crmItem );
333     }
334 
335     @Override
336     public String getCRMUserAttribute( String strUserGuid, String strAttribute ) throws CRMException
337     {
338         return getCRMUserAttribute( strUserGuid, strAttribute, StringUtils.EMPTY );
339     }
340 
341     @Override
342     public String getCRMUserAttribute( String strUserGuid, String strAttribute, String strCRMWebAppCode ) throws CRMException
343     {
344         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.USER_ATTRIBUTE.toString( ) );
345 
346         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
347         {
348             crmItem.setCRMWebAppCode( strCRMWebAppCode );
349         }
350 
351         crmItem.putParameter( ICRMItem.USER_GUID, StringUtils.isNotBlank( strUserGuid ) ? strUserGuid : StringUtils.EMPTY );
352 
353         crmItem.putParameter( ICRMItem.USER_ATTRIBUTE, StringUtils.isNotBlank( strAttribute ) ? strAttribute : StringUtils.EMPTY );
354 
355         return _crmClientProcessor.getProcess( crmItem );
356     }
357 
358     @Override
359     public String getCRMUserAttributesXml( String strUserGuid ) throws CRMException
360     {
361         // TODO Auto-generated method stub
362         return getCRMUserAttributesXml( strUserGuid, StringUtils.EMPTY );
363     }
364 
365     @Override
366     public String getCRMUserAttributesXml( String strUserGuid, String strCRMWebAppCode ) throws CRMException
367     {
368         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.USER_ATTRIBUTES_XML.toString( ) );
369 
370         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
371         {
372             crmItem.setCRMWebAppCode( strCRMWebAppCode );
373         }
374 
375         crmItem.putParameter( ICRMItem.USER_GUID, StringUtils.isNotBlank( strUserGuid ) ? strUserGuid : StringUtils.EMPTY );
376 
377         crmItem.putParameter( ICRMItem.MEDIA_TYPE, MEDIA_TYPE_XML );
378 
379         return _crmClientProcessor.getProcess( crmItem );
380     }
381 
382     @Override
383     public String getCRMUserAttributesJson( String strUserGuid ) throws CRMException
384     {
385         // TODO Auto-generated method stub
386         return getCRMUserAttributesJson( strUserGuid, StringUtils.EMPTY );
387     }
388 
389     @Override
390     public String getCRMUserAttributesJson( String strUserGuid, String strCRMWebAppCode ) throws CRMException
391     {
392         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.USER_ATTRIBUTES_JSON.toString( ) );
393 
394         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
395         {
396             crmItem.setCRMWebAppCode( strCRMWebAppCode );
397         }
398 
399         crmItem.putParameter( ICRMItem.USER_GUID, StringUtils.isNotBlank( strUserGuid ) ? strUserGuid : StringUtils.EMPTY );
400         crmItem.putParameter( ICRMItem.MEDIA_TYPE, MEDIA_TYPE_JSON );
401 
402         return _crmClientProcessor.getProcess( crmItem );
403     }
404 
405     @Override
406     public String getDemandJsonV2( String strRemoteId, String strIdDemandType, String strCRMWebAppCode ) throws CRMException
407     {
408         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_DEMAND_JSON_V2.toString( ) );
409 
410         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
411         {
412             crmItem.setCRMWebAppCode( strCRMWebAppCode );
413         }
414 
415         crmItem.putParameter( ICRMItem.REMOTE_ID, StringUtils.isNotBlank( strRemoteId ) ? strRemoteId : StringUtils.EMPTY );
416         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
417 
418         crmItem.putParameter( ICRMItem.MEDIA_TYPE, MEDIA_TYPE_JSON );
419 
420         return _crmClientProcessor.getProcess( crmItem );
421     }
422 
423     @Override
424     public String getDemandXmlV2( String strRemoteId, String strIdDemandType, String strCRMWebAppCode ) throws CRMException
425     {
426         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_DEMAND_XML_V2.toString( ) );
427 
428         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
429         {
430             crmItem.setCRMWebAppCode( strCRMWebAppCode );
431         }
432 
433         crmItem.putParameter( ICRMItem.REMOTE_ID, StringUtils.isNotBlank( strRemoteId ) ? strRemoteId : StringUtils.EMPTY );
434         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
435         crmItem.putParameter( ICRMItem.MEDIA_TYPE, MEDIA_TYPE_JSON );
436 
437         return _crmClientProcessor.getProcess( crmItem );
438     }
439 
440     @Override
441     public void notifyV2( String strRemoteId, String strIdDemandType, String strObject, String strMessage, String strSender, String strCRMWebAppCode )
442 
443     {
444 
445         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.NOTIFICATION_V2.toString( ) );
446 
447         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
448         {
449             crmItem.setCRMWebAppCode( strCRMWebAppCode );
450         }
451 
452         crmItem.putParameter( ICRMItem.REMOTE_ID, StringUtils.isNotBlank( strRemoteId ) ? strRemoteId : StringUtils.EMPTY );
453         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
454         crmItem.putParameter( ICRMItem.NOTIFICATION_OBJECT, StringUtils.isNotBlank( strObject ) ? strObject : StringUtils.EMPTY );
455         crmItem.putParameter( ICRMItem.NOTIFICATION_MESSAGE, StringUtils.isNotBlank( strMessage ) ? strMessage : StringUtils.EMPTY );
456         crmItem.putParameter( ICRMItem.NOTIFICATION_SENDER, StringUtils.isNotBlank( strSender ) ? strSender : StringUtils.EMPTY );
457 
458         _crmClientQueue.send( crmItem );
459 
460     }
461 
462     @Override
463     public String sendCreateDemandByUserGuidV2( String strRemoteId, String strIdDemandType, String strUserGuid, String strIdStatusCRM, String strStatusText,
464             String strData, String strCRMWebAppCode ) throws CRMException
465     {
466 
467         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_CREATE_BY_USER_GUID_V2.toString( ) );
468 
469         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
470         {
471             crmItem.setCRMWebAppCode( strCRMWebAppCode );
472         }
473 
474         crmItem.putParameter( ICRMItem.REMOTE_ID, StringUtils.isNotBlank( strRemoteId ) ? strRemoteId : StringUtils.EMPTY );
475         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
476 
477         crmItem.putParameter( ICRMItem.USER_GUID, StringUtils.isNotBlank( strUserGuid ) ? strUserGuid : StringUtils.EMPTY );
478 
479         crmItem.putParameter( ICRMItem.ID_STATUS_CRM, StringUtils.isNotBlank( strIdStatusCRM ) ? strIdStatusCRM : StringUtils.EMPTY );
480 
481         crmItem.putParameter( ICRMItem.STATUS_TEXT, StringUtils.isNotBlank( strStatusText ) ? strStatusText : StringUtils.EMPTY );
482 
483         crmItem.putParameter( ICRMItem.DEMAND_DATA, StringUtils.isNotBlank( strData ) ? strData : StringUtils.EMPTY );
484 
485         return _crmClientProcessor.doProcess( crmItem );
486     }
487 
488     @Override
489     public void sendDeleteDemandV2( String strRemoteId, String strIdDemandType, String strCRMWebAppCode ) throws CRMException
490     {
491         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_DELETE_V2.toString( ) );
492 
493         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
494         {
495             crmItem.setCRMWebAppCode( strCRMWebAppCode );
496         }
497 
498         crmItem.putParameter( ICRMItem.REMOTE_ID, StringUtils.isNotBlank( strRemoteId ) ? strRemoteId : StringUtils.EMPTY );
499         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
500 
501         _crmClientProcessor.doProcess( crmItem );
502 
503     }
504 
505     @Override
506     public void sendUpdateDemandV2( String strRemoteId, String strIdDemandType, String strStatusText, String strCRMWebAppCode, String strIdStatusCRM,
507             String strData ) throws CRMException
508     {
509         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_UPDATE_V2.toString( ) );
510 
511         if ( StringUtils.isNotBlank( strCRMWebAppCode ) )
512         {
513             crmItem.setCRMWebAppCode( strCRMWebAppCode );
514         }
515 
516         if ( StringUtils.isNotBlank( strIdStatusCRM ) )
517         {
518             crmItem.putParameter( ICRMItem.ID_STATUS_CRM, strIdStatusCRM );
519         }
520 
521         if ( StringUtils.isNotBlank( strData ) )
522         {
523             crmItem.putParameter( ICRMItem.DEMAND_DATA, strData );
524         }
525 
526         crmItem.putParameter( ICRMItem.REMOTE_ID, StringUtils.isNotBlank( strRemoteId ) ? strRemoteId : StringUtils.EMPTY );
527         crmItem.putParameter( ICRMItem.ID_DEMAND_TYPE, StringUtils.isNotBlank( strIdDemandType ) ? strIdDemandType : StringUtils.EMPTY );
528 
529         crmItem.putParameter( ICRMItem.STATUS_TEXT, StringUtils.isNotBlank( strStatusText ) ? strStatusText : StringUtils.EMPTY );
530 
531         _crmClientProcessor.doProcess( crmItem );
532 
533     }
534 
535     /**
536      * {@inheritDoc}
537      */
538     @Override
539     public String getCRMDemandTypes( ) throws CRMException
540     {
541         ICRMItem crmItem = _crmItemFactory.newCRMItem( CRMItemTypeEnum.DEMAND_TYPES.toString( ) );
542 
543         return _crmClientProcessor.doProcess( crmItem );
544     }
545 }