This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects

Resolve "Edu-Sharing-Integration: deleteNode in zusätzliches try-catch"

Compare and
1 file
+ 18
12
Compare changes
  • Side-by-side
  • Inline
@@ -254,7 +254,8 @@ public class EduSharingService {
return this.getEduSharingStatus(resourceId).orElseThrow();
} catch (Exception e) {
if (eduSharingId != null && !update) {
this.deleteNode(eduSharingId);
// delete the node if it was created in this method and the upload failed
this.deleteNodeSilently(eduSharingId);
}
throw e;
}
@@ -368,19 +369,24 @@ public class EduSharingService {
return dto;
}
private void deleteNode(@NotNull String nodeId) {
final var uri = UriComponentsBuilder
.newInstance()
.path("/rest/node/v1/nodes/{repository}/{node}")
.queryParam("recycle", false)
.build(this.eduSharingConfiguration.getDefaultRepository(), nodeId);
@SuppressWarnings({ "PMD.AvoidCatchingGenericException", "PMD.PreserveStackTrace" })
private void deleteNodeSilently(@NotNull String nodeId) {
try {
final var uri = UriComponentsBuilder
.newInstance()
.path("/rest/node/v1/nodes/{repository}/{node}")
.queryParam("recycle", false)
.build(this.eduSharingConfiguration.getDefaultRepository(), nodeId);
final var answer = this.webClient.delete().uri(uri.toString()).accept(MediaType.APPLICATION_JSON).retrieve();
final var answer = this.webClient.delete().uri(uri.toString()).accept(MediaType.APPLICATION_JSON).retrieve();
ResponseEntity<String> response = answer.toEntity(String.class).block();
if (response == null || !response.getStatusCode().is2xxSuccessful()) {
LOGGER.error("DELETE request to " + uri.toString() + " failed!");
LOGGER.error(response.getBody());
ResponseEntity<String> response = answer.toEntity(String.class).block();
if (response == null || !response.getStatusCode().is2xxSuccessful()) {
LOGGER.error("DELETE request to " + uri + " failed!");
LOGGER.error(response.getBody());
}
} catch (final Exception e) {
LOGGER.error("Error on deleteNode for resource " + nodeId, e);
}
}