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.dansmarue.modules.rest.service;
35
36 import java.util.HashMap;
37 import java.util.Map;
38
39 import org.apache.commons.lang.StringUtils;
40
41 import fr.paris.lutece.plugins.dansmarue.modules.rest.util.constants.SignalementRestConstants;
42 import fr.paris.lutece.portal.service.util.AppLogService;
43 import fr.paris.lutece.portal.service.util.AppPropertiesService;
44 import fr.paris.lutece.util.httpaccess.HttpAccess;
45 import fr.paris.lutece.util.httpaccess.HttpAccessException;
46 import net.sf.json.JSONObject;
47
48
49
50
51 public class RamenClientService
52 {
53
54
55
56
57
58
59
60
61
62
63 public String getDossiersCourrantsByGeom( Double lng, Double lat )
64 {
65 StringBuilder strUrl = new StringBuilder( AppPropertiesService.getProperty( SignalementRestConstants.PROPERTY_URL_RAMEN_REST ) );
66 strUrl.append( SignalementRestConstants.QUESTION_MARK );
67
68 strUrl.append( SignalementRestConstants.PARAMETER_LATITUDE );
69 strUrl.append( SignalementRestConstants.EQUAL );
70 strUrl.append( lat );
71
72 strUrl.append( SignalementRestConstants.AMPERSAND );
73
74 strUrl.append( SignalementRestConstants.PARAMETER_LONGITUDE );
75 strUrl.append( SignalementRestConstants.EQUAL );
76 strUrl.append( lng );
77
78 strUrl.append( SignalementRestConstants.AMPERSAND );
79
80 strUrl.append( SignalementRestConstants.PARAMETER_RADIUS );
81 strUrl.append( SignalementRestConstants.EQUAL );
82 strUrl.append( AppPropertiesService.getProperty( SignalementRestConstants.PROPERTY_RADIUS ) );
83
84 String strReponseXml = StringUtils.EMPTY;
85 HttpAccess httpAccess = new HttpAccess( );
86
87 try
88 {
89 strReponseXml = httpAccess.doGet( strUrl.toString( ) );
90 }
91 catch( HttpAccessException e )
92 {
93 AppLogService.error( e.getMessage( ), e );
94 }
95
96 return strReponseXml;
97 }
98
99
100
101
102
103
104
105
106
107
108 public String getDossiersCourrantsByGeommWithLimit( Double lng, Double lat )
109 {
110
111 String strReponse = null;
112
113 StringBuilder strUrl = new StringBuilder( AppPropertiesService.getProperty( SignalementRestConstants.PROPERTY_URL_RAMEN_REST_GEO_WITH_LIMIT ) );
114
115 HttpAccess httpAccess = new HttpAccess( );
116
117 JSONObject jsonObj = new JSONObject( );
118 jsonObj.accumulate( SignalementRestConstants.PARAMETER_RADIUS,
119 Integer.valueOf( ( AppPropertiesService.getProperty( SignalementRestConstants.PROPERTY_RADIUS ) ) ) );
120 jsonObj.accumulate( SignalementRestConstants.PARAMETER_LONGITUDE, lng );
121 jsonObj.accumulate( SignalementRestConstants.PARAMETER_LATITUDE, lat );
122
123 Map<String, String> headersRequest = new HashMap<>( );
124 Map<String, String> headersResponse = new HashMap<>( );
125
126 try
127 {
128
129 strReponse = httpAccess.doPostJSON( strUrl.toString( ), jsonObj.toString( ), headersRequest, headersResponse );
130
131 }
132 catch( HttpAccessException e )
133 {
134 AppLogService.error( e.getMessage( ), e );
135 }
136
137 return strReponse;
138 }
139 }