Skip to content

Commit

Permalink
catch exception when heading model/dataset/runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamlandliu committed Aug 25, 2022
1 parent 3836509 commit 3995e0d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ ResponseEntity<ResponseMessage<PageInfo<DatasetVO>>> listDataset(
produces = {"application/json"},
method = RequestMethod.HEAD)
@PreAuthorize("hasAnyRole('OWNER', 'MAINTAINER', 'GUEST')")
void headDataset(@Parameter(
ResponseEntity<?> headDataset(@Parameter(
in = ParameterIn.PATH,
description = "Project url",
schema = @Schema())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,13 @@ public ResponseEntity<ResponseMessage<PageInfo<DatasetVO>>> listDataset(String p
}

@Override
public void headDataset(String projectUrl, String datasetUrl, String versionUrl) {
swDatasetService.query(projectUrl, datasetUrl, versionUrl);
public ResponseEntity<?> headDataset(String projectUrl, String datasetUrl, String versionUrl) {
try {
swDatasetService.query(projectUrl, datasetUrl, versionUrl);
return ResponseEntity.ok().build();
} catch (Exception e) {
log.info("Head dataset result: NOT FOUND");
return ResponseEntity.notFound().build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void pull(
produces = {"application/json"},
method = RequestMethod.HEAD)
@PreAuthorize("hasAnyRole('OWNER', 'MAINTAINER', 'GUEST')")
void headRuntime(
ResponseEntity<?> headRuntime(
@Parameter(
in = ParameterIn.PATH,
description = "Project url",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ public void pull(String projectUrl, String runtimeUrl, String versionUrl,
}

@Override
public void headRuntime(String projectUrl, String runtimeUrl, String versionUrl) {
runtimeService.query(projectUrl, runtimeUrl, versionUrl);
public ResponseEntity<?> headRuntime(String projectUrl, String runtimeUrl, String versionUrl) {
try {
runtimeService.query(projectUrl, runtimeUrl, versionUrl);
return ResponseEntity.ok().build();
} catch (Exception e) {
log.info("Head runtime result: NOT FOUND");
return ResponseEntity.notFound().build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void pull(
produces = {"application/json"},
method = RequestMethod.HEAD)
@PreAuthorize("hasAnyRole('OWNER', 'MAINTAINER', 'GUEST')")
void headModel(
ResponseEntity<?> headModel(
@Parameter(
in = ParameterIn.PATH,
description = "Project url",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ public void pull(String projectUrl, String modelUrl, String versionUrl, HttpServ
}

@Override
public void headModel(String projectUrl, String modelUrl, String versionUrl) {
swmpService.query(projectUrl, modelUrl, versionUrl);
public ResponseEntity<?> headModel(String projectUrl, String modelUrl, String versionUrl) {
try {
swmpService.query(projectUrl, modelUrl, versionUrl);
return ResponseEntity.ok().build();
} catch (Exception e) {
log.info("Head model result: NOT FOUND");
return ResponseEntity.notFound().build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class StarWhaleApiException extends RuntimeException {
StarWhaleException starWhaleException;
HttpStatus httpStatus;
public StarWhaleApiException(StarWhaleException starWhaleException,HttpStatus httpStatus) {
super(starWhaleException.getTip());
this.starWhaleException = starWhaleException;
this.httpStatus = httpStatus;
}
Expand Down

0 comments on commit 3995e0d

Please sign in to comment.