44
44
45
45
import javax .servlet .http .HttpServletRequest ;
46
46
import javax .servlet .http .HttpServletResponse ;
47
- import javax .ws .rs .DefaultValue ;
48
47
import javax .ws .rs .HttpMethod ;
49
48
import javax .ws .rs .core .Response ;
50
49
import java .io .IOException ;
@@ -67,7 +66,7 @@ public class ApiServiceExecuteRestfulApi {
67
66
68
67
@ RequestMapping (value = "/execute/{path:.*}" ,method = RequestMethod .POST )
69
68
public Message post (@ PathVariable ("path" ) VariableString path , @ RequestBody QueryRequest queryRequest ,
70
- HttpServletRequest req ) {
69
+ HttpServletRequest req ) {
71
70
String userName = SecurityFilter .getLoginUsername (req );
72
71
return getResponse (userName ,path .getPath (), queryRequest , HttpMethod .POST );
73
72
}
@@ -94,8 +93,8 @@ public Message get(@PathVariable("path") VariableString path,
94
93
queryRequest .setParams (params );
95
94
}
96
95
String paramsJsonStr = req .getParameter ("params" );
97
- JavaType javaType = BDPJettyServerHelper .jacksonJson ().getTypeFactory ().constructParametricType (Map .class ,String .class ,Object .class );
98
- Map <String ,Object > parmas = BDPJettyServerHelper .jacksonJson ().readValue (paramsJsonStr , javaType );
96
+ JavaType javaType = BDPJettyServerHelper .jacksonJson ().getTypeFactory ().constructParametricType (Map .class , String .class , Object .class );
97
+ Map <String , Object > parmas = BDPJettyServerHelper .jacksonJson ().readValue (paramsJsonStr , javaType );
99
98
queryRequest .setParams (parmas );
100
99
101
100
if (StringUtils .isEmpty (queryRequest .getModuleName ())) {
@@ -107,14 +106,14 @@ public Message get(@PathVariable("path") VariableString path,
107
106
108
107
@ RequestMapping (value = "/execute/{path:.*}" ,method = RequestMethod .PUT )
109
108
public Message put (@ PathVariable ("path" ) VariableString path , @ RequestBody QueryRequest queryRequest ,
110
- HttpServletRequest req ) {
109
+ HttpServletRequest req ) {
111
110
String userName = SecurityFilter .getLoginUsername (req );
112
111
return getResponse (userName ,path .getPath (), queryRequest , HttpMethod .PUT );
113
112
}
114
113
115
114
@ RequestMapping (value = "/execute/{path:.*}" ,method = RequestMethod .DELETE )
116
115
public Message delete (@ PathVariable ("path" ) VariableString path , @ RequestBody QueryRequest queryRequest ,
117
- HttpServletRequest req ) {
116
+ HttpServletRequest req ) {
118
117
String userName = SecurityFilter .getLoginUsername (req );
119
118
return getResponse (userName ,path .getPath (), queryRequest , HttpMethod .DELETE );
120
119
}
@@ -131,7 +130,7 @@ public void getDirFileTrees(HttpServletRequest req, HttpServletResponse resp,
131
130
@ RequestParam (required = false , name = "taskId" ) String taskId ) throws IOException , ApiServiceQueryException {
132
131
String userName = SecurityFilter .getLoginUsername (req );
133
132
if (StringUtils .isEmpty (path )) {
134
- throw new ApiServiceQueryException (80004 , path );
133
+ throw new ApiServiceQueryException (80004 , path );
135
134
}
136
135
String dirFileTree ="" ;
137
136
ApiServiceJob apiServiceJob = queryService .getJobByTaskId (taskId );
@@ -154,18 +153,18 @@ public void getDirFileTrees(HttpServletRequest req, HttpServletResponse resp,
154
153
155
154
@ RequestMapping (value = "/openFile" ,method = RequestMethod .GET )
156
155
public void openFile (HttpServletRequest req ,
157
- @ RequestParam (required = false , name = "path" ) String path ,
158
- @ RequestParam (required = false , name = "taskId" ) String taskId ,
159
- @ DefaultValue ("1" ) @ RequestParam ( required = false , name = "page" ) Integer page ,
160
- @ DefaultValue ( "5000" ) @ RequestParam (required = false , name = "pageSize" ) Integer pageSize ,
161
- @ DefaultValue ( "utf-8" ) @ RequestParam (required = false , name = "charset" ) String charset ,
162
- HttpServletResponse resp ) throws IOException , ApiServiceQueryException {
156
+ @ RequestParam (required = false , name = "path" ) String path ,
157
+ @ RequestParam (required = false , name = "taskId" ) String taskId ,
158
+ @ RequestParam ( required = false , defaultValue = ("1" ), name = "page" ) Integer page ,
159
+ @ RequestParam (required = false , defaultValue = "5000" , name = "pageSize" ) Integer pageSize ,
160
+ @ RequestParam (required = false , name = "charset" , defaultValue = "utf-8 " ) String charset ,
161
+ HttpServletResponse resp ) throws IOException , ApiServiceQueryException {
163
162
String userName = SecurityFilter .getLoginUsername (req );
164
163
if (StringUtils .isEmpty (path )) {
165
- throw new ApiServiceQueryException (80004 , path );
164
+ throw new ApiServiceQueryException (80004 , path );
166
165
}
167
166
if (StringUtils .isEmpty (taskId )){
168
- throw new ApiServiceQueryException (80005 , "taskId is null" );
167
+ throw new ApiServiceQueryException (80005 , "taskId is null" );
169
168
}
170
169
String fileContent ="" ;
171
170
ApiServiceJob apiServiceJob = queryService .getJobByTaskId (taskId );
@@ -186,12 +185,12 @@ public void resultsetToExcel(
186
185
HttpServletResponse resp ,
187
186
@ RequestParam (required = false , name = "path" ) String path ,
188
187
@ RequestParam (required = false , name = "taskId" ) String taskId ,
189
- @ DefaultValue ( "utf-8" ) @ RequestParam (required = false , name = "charset" ) String charset ,
190
- @ DefaultValue ( "csv" ) @ RequestParam (required = false , name = "outputFileType" ) String outputFileType ,
191
- @ DefaultValue ( "," ) @ RequestParam (required = false , name = "csvSeperator" ) String csvSeperator ,
192
- @ DefaultValue ( "downloadResultset" ) @ RequestParam (required = false , name = "outputFileName" ) String outputFileName ,
193
- @ DefaultValue ( "result" ) @ RequestParam (required = false , name = "sheetName" ) String sheetName ,
194
- @ DefaultValue ( "NULL" ) @ RequestParam (required = false , name = "nullValue" ) String nullValue ) throws ApiServiceQueryException , IOException {
188
+ @ RequestParam (required = false , name = "charset" , defaultValue = ( "utf-8" ) ) String charset ,
189
+ @ RequestParam (required = false , name = "outputFileType" , defaultValue = ( "csv" ) ) String outputFileType ,
190
+ @ RequestParam (required = false , name = "csvSeperator" , defaultValue = ( "," ) ) String csvSeperator ,
191
+ @ RequestParam (required = false , name = "outputFileName" , defaultValue = ( "downloadResultset" ) ) String outputFileName ,
192
+ @ RequestParam (required = false , name = "sheetName" , defaultValue = ( "result" ) ) String sheetName ,
193
+ @ RequestParam (required = false , name = "nullValue" , defaultValue = ( "NULL" ) ) String nullValue ) throws ApiServiceQueryException , IOException {
195
194
196
195
resp .addHeader ("Content-Disposition" , "attachment;filename="
197
196
+ new String (outputFileName .getBytes ("UTF-8" ), "ISO8859-1" ) + "." + outputFileType );
@@ -211,7 +210,7 @@ public void resultsetToExcel(
211
210
212
211
String userName = SecurityFilter .getLoginUsername (req );
213
212
if (StringUtils .isEmpty (path )) {
214
- throw new ApiServiceQueryException (80005 , path );
213
+ throw new ApiServiceQueryException (80005 , path );
215
214
}
216
215
InputStream inputStream ;
217
216
ApiServiceJob apiServiceJob = queryService .getJobByTaskId (taskId );
@@ -256,7 +255,7 @@ public Message getTaskByID(HttpServletRequest req, @PathVariable("id") Long task
256
255
}
257
256
}
258
257
259
- private Message getResponse (String user ,String path , QueryRequest queryRequest , String httpMethod ) {
258
+ private Message getResponse (String user , String path , QueryRequest queryRequest , String httpMethod ) {
260
259
Response response = ApiUtils .doAndResponse (() -> {
261
260
validParam (queryRequest );
262
261
String token = queryRequest .getParams ().get (ApiServiceConfiguration .API_SERVICE_TOKEN_KEY .getValue ()).toString ();
@@ -283,7 +282,7 @@ private Message getResponse(String user,String path, QueryRequest queryRequest,
283
282
return messageVo ;
284
283
}
285
284
286
- HashMap <String ,Object > queryRes = new HashMap <>();
285
+ HashMap <String , Object > queryRes = new HashMap <>();
287
286
queryRes .put ("taskId" ,query .getTaskId ());
288
287
queryRes .put ("execId" ,query .getExecId ());
289
288
messageVo = new MessageVo ().setData (queryRes );
0 commit comments