3535import org .apache .dolphinscheduler .api .audit .enums .AuditType ;
3636import org .apache .dolphinscheduler .api .enums .Status ;
3737import org .apache .dolphinscheduler .api .exceptions .ApiException ;
38+ import org .apache .dolphinscheduler .api .exceptions .ServiceException ;
3839import org .apache .dolphinscheduler .api .service .DataSourceService ;
3940import org .apache .dolphinscheduler .api .utils .PageInfo ;
4041import org .apache .dolphinscheduler .api .utils .Result ;
@@ -83,12 +84,13 @@ public class DataSourceController extends BaseController {
8384 private DataSourceService dataSourceService ;
8485
8586 /**
86- * create data source
87+ * create a new data source
8788 *
8889 * @param loginUser login user
8990 * @param jsonStr datasource param
9091 * example: {"type":"MYSQL","name":"txx","note":"","host":"localhost","port":3306,"principal":"","javaSecurityKrb5Conf":"","loginUserKeytabUsername":"","loginUserKeytabPath":"","userName":"root","password":"xxx","database":"ds","connectType":"","other":{"serverTimezone":"GMT-8"},"id":2}
91- * @return create result code
92+ * @return the created DataSource object
93+ * @throws ServiceException if the data source name already exists or parameters are invalid
9294 */
9395 @ Operation (summary = "createDataSource" , description = "CREATE_DATA_SOURCE_NOTES" )
9496 @ PostMapping ()
@@ -103,18 +105,19 @@ public Result<DataSource> createDataSource(@Parameter(hidden = true) @RequestAtt
103105 }
104106
105107 /**
106- * updateWorkflowInstance data source
108+ * update an existing data source
107109 *
108110 * @param loginUser login user
109111 * @param id datasource id
110112 * @param jsonStr datasource param
111113 * example: {"type":"MYSQL","name":"txx","note":"","host":"localhost","port":3306,"principal":"","javaSecurityKrb5Conf":"","loginUserKeytabUsername":"","loginUserKeytabPath":"","userName":"root","password":"xxx","database":"ds","connectType":"","other":{"serverTimezone":"GMT-8"},"id":2}
112- * @return update result code
114+ * @return the updated DataSource object
115+ * @throws ServiceException if the data source does not exist or parameters are invalid
113116 */
114117 @ Operation (summary = "updateDataSource" , description = "UPDATE_DATA_SOURCE_NOTES" )
115118 @ Parameters ({
116119 @ Parameter (name = "id" , description = "DATA_SOURCE_ID" , required = true , schema = @ Schema (implementation = int .class )),
117- @ Parameter (name = "dataSourceParam " , description = "DATA_SOURCE_PARAM" , required = true , schema = @ Schema (implementation = BaseDataSourceParamDTO .class ))
120+ @ Parameter (name = "jsonStr " , description = "DATA_SOURCE_PARAM" , required = true , schema = @ Schema (implementation = BaseDataSourceParamDTO .class ))
118121 })
119122 @ PutMapping (value = "/{id}" )
120123 @ ResponseStatus (HttpStatus .OK )
@@ -200,19 +203,18 @@ public Result<Object> queryDataSourceListPaging(@Parameter(hidden = true) @Reque
200203 }
201204
202205 /**
203- * connect datasource
206+ * test the connection to a data source
204207 *
205- * @param loginUser login user
206208 * @param jsonStr datasource param
207209 * example: {"type":"MYSQL","name":"txx","note":"","host":"localhost","port":3306,"principal":"","javaSecurityKrb5Conf":"","loginUserKeytabUsername":"","loginUserKeytabPath":"","userName":"root","password":"xxx","database":"ds","connectType":"","other":{"serverTimezone":"GMT-8"},"id":2}
208- * @return connect result code
210+ * @return {@code true} if the connection test was successful
211+ * @throws ServiceException if the connection fails or parameters are invalid
209212 */
210213 @ Operation (summary = "connectDataSource" , description = "CONNECT_DATA_SOURCE_NOTES" )
211214 @ PostMapping (value = "/connect" )
212215 @ ResponseStatus (HttpStatus .OK )
213216 @ ApiException (CONNECT_DATASOURCE_FAILURE )
214- public Result <Boolean > connectDataSource (@ Parameter (hidden = true ) @ RequestAttribute (value = Constants .SESSION_USER ) User loginUser ,
215- @ io .swagger .v3 .oas .annotations .parameters .RequestBody (description = "dataSourceParam" ) @ RequestBody String jsonStr ) {
217+ public Result <Boolean > connectDataSource (@ io .swagger .v3 .oas .annotations .parameters .RequestBody (description = "dataSourceParam" ) @ RequestBody String jsonStr ) {
216218 BaseDataSourceParamDTO dataSourceParam = DataSourceUtils .buildDatasourceParam (jsonStr );
217219 DataSourceUtils .checkDatasourceParam (dataSourceParam );
218220 ConnectionParam connectionParams = DataSourceUtils .buildConnectionParams (dataSourceParam );
@@ -221,11 +223,12 @@ public Result<Boolean> connectDataSource(@Parameter(hidden = true) @RequestAttri
221223 }
222224
223225 /**
224- * connection test
226+ * test the connection to an existing data source
225227 *
226228 * @param loginUser login user
227229 * @param id data source id
228- * @return A Result wrapping {@code true} if the connection is successful; otherwise, throws an exception.
230+ * @return {@code true} if the connection test was successful
231+ * @throws ServiceException if the connection fails or the data source does not exist
229232 */
230233 @ Operation (summary = "connectionTest" , description = "CONNECT_DATA_SOURCE_TEST_NOTES" )
231234 @ Parameters ({
@@ -245,7 +248,8 @@ public Result<Boolean> connectionTest(@Parameter(hidden = true) @RequestAttribut
245248 *
246249 * @param loginUser login user
247250 * @param id datasource id
248- * @return delete result
251+ * @return {@code true} if the deletion was successful
252+ * @throws ServiceException if the data source does not exist or if the user lacks permission
249253 */
250254 @ Operation (summary = "deleteDataSource" , description = "DELETE_DATA_SOURCE_NOTES" )
251255 @ Parameters ({
@@ -262,11 +266,11 @@ public Result<Boolean> deleteDataSource(@Parameter(hidden = true) @RequestAttrib
262266 }
263267
264268 /**
265- * verify datasource name
269+ * verify if a data source name is available
266270 *
267- * @param loginUser login user
268271 * @param name data source name
269- * @return true if data source name not exists, otherwise return false
272+ * @return {@code true} if the name is available (does not exist)
273+ * @throws ServiceException if the name already exists
270274 */
271275 @ Operation (summary = "verifyDataSourceName" , description = "VERIFY_DATA_SOURCE_NOTES" )
272276 @ Parameters ({
@@ -275,18 +279,17 @@ public Result<Boolean> deleteDataSource(@Parameter(hidden = true) @RequestAttrib
275279 @ GetMapping (value = "/verify-name" )
276280 @ ResponseStatus (HttpStatus .OK )
277281 @ ApiException (VERIFY_DATASOURCE_NAME_FAILURE )
278- public Result <Boolean > verifyDataSourceName (@ Parameter (hidden = true ) @ RequestAttribute (value = Constants .SESSION_USER ) User loginUser ,
279- @ RequestParam (value = "name" ) String name ) {
282+ public Result <Boolean > verifyDataSourceName (@ RequestParam (value = "name" ) String name ) {
280283 dataSourceService .verifyDataSourceName (name );
281284 return Result .success (true );
282285 }
283286
284287 /**
285- * unauthorized datasource
288+ * query the list of unauthorized data sources for a specific user
286289 *
287290 * @param loginUser login user
288291 * @param userId user id
289- * @return unauthorized data source result code
292+ * @return a list of unauthorized DataSource objects
290293 */
291294 @ Operation (summary = "unauthorizedDatasource" , description = "UNAUTHORIZED_DATA_SOURCE_NOTES" )
292295 @ Parameters ({
@@ -295,19 +298,19 @@ public Result<Boolean> verifyDataSourceName(@Parameter(hidden = true) @RequestAt
295298 @ GetMapping (value = "/unauth-datasource" )
296299 @ ResponseStatus (HttpStatus .OK )
297300 @ ApiException (UNAUTHORIZED_DATASOURCE )
298- public Result <Object > unAuthDatasource (@ Parameter (hidden = true ) @ RequestAttribute (value = Constants .SESSION_USER ) User loginUser ,
299- @ RequestParam ("userId" ) Integer userId ) {
301+ public Result <Object > getUnauthorizedDatasourceList (@ Parameter (hidden = true ) @ RequestAttribute (value = Constants .SESSION_USER ) User loginUser ,
302+ @ RequestParam ("userId" ) Integer userId ) {
300303
301304 List <DataSource > unAuthDatasourceList = dataSourceService .unAuthDatasource (loginUser , userId );
302305 return Result .success (unAuthDatasourceList );
303306 }
304307
305308 /**
306- * authorized datasource
309+ * query the list of data sources authorized for a specific user
307310 *
308311 * @param loginUser login user
309312 * @param userId user id
310- * @return authorized result code
313+ * @return a list of authorized DataSource objects
311314 */
312315 @ Operation (summary = "authedDatasource" , description = "AUTHORIZED_DATA_SOURCE_NOTES" )
313316 @ Parameters ({
@@ -316,29 +319,28 @@ public Result<Object> unAuthDatasource(@Parameter(hidden = true) @RequestAttribu
316319 @ GetMapping (value = "/authed-datasource" )
317320 @ ResponseStatus (HttpStatus .OK )
318321 @ ApiException (AUTHORIZED_DATA_SOURCE )
319- public Result <Object > authedDatasource (@ Parameter (hidden = true ) @ RequestAttribute (value = Constants .SESSION_USER ) User loginUser ,
320- @ RequestParam ("userId" ) Integer userId ) {
322+ public Result <Object > getAuthorizedDatasourceList (@ Parameter (hidden = true ) @ RequestAttribute (value = Constants .SESSION_USER ) User loginUser ,
323+ @ RequestParam ("userId" ) Integer userId ) {
321324 List <DataSource > authedDatasourceList = dataSourceService .authedDatasource (loginUser , userId );
322325 return Result .success (authedDatasourceList );
323326 }
324327
325328 /**
326- * get user info
329+ * check the active status of Kerberos authentication
327330 *
328- * @param loginUser login user
329- * @return user info data
331+ * @return {@code true} if Kerberos is active and configured for HDFS; {@code false} otherwise
330332 */
331- @ Operation (summary = "getKerberosStartupState" , description = "GET_USER_INFO_NOTES " )
333+ @ Operation (summary = "getKerberosStartupState" , description = "GET_KERBEROS_STARTUP_STATE " )
332334 @ GetMapping (value = "/kerberos-startup-state" )
333335 @ ResponseStatus (HttpStatus .OK )
334336 @ ApiException (KERBEROS_STARTUP_STATE )
335- public Result <Object > getKerberosStartupState (@ Parameter ( hidden = true ) @ RequestAttribute ( value = Constants . SESSION_USER ) User loginUser ) {
337+ public Result <Object > getKerberosStartupState () {
336338 // if upload resource is HDFS and kerberos startup is true , else false
337339 return success (Status .SUCCESS .getMsg (), CommonUtils .getKerberosStartupState ());
338340 }
339341
340342 /**
341- * Retrieves the list of tables within a specific database of a data source.
343+ * query the list of tables within a specific database of a data source
342344 *
343345 * @param loginUser the current logged-in user (injected from session)
344346 * @param datasourceId the unique identifier of the data source
@@ -361,7 +363,7 @@ public Result<Object> getTables(@Parameter(hidden = true) @RequestAttribute(valu
361363 }
362364
363365 /**
364- * Retrieves the column details (schema) for a specific table.
366+ * query the column details (schema) for a specific table
365367 *
366368 * @param loginUser the current logged-in user (injected from session)
367369 * @param datasourceId the unique identifier of the data source
@@ -387,7 +389,7 @@ public Result<Object> getTableColumns(@Parameter(hidden = true) @RequestAttribut
387389 }
388390
389391 /**
390- * Retrieves the list of databases available in a specific data source.
392+ * query the list of databases available in a specific data source
391393 *
392394 * @param loginUser the current logged-in user (injected from session)
393395 * @param datasourceId the unique identifier of the data source
0 commit comments