forked from Onlineberatung/onlineBeratung-userService
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
110 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...a/de/caritas/cob/userservice/api/workflow/delete/action/asker/DeleteSingleRoomAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package de.caritas.cob.userservice.api.workflow.delete.action.asker; | ||
|
||
import static de.caritas.cob.userservice.api.helper.CustomLocalDateTime.nowInUtc; | ||
import static de.caritas.cob.userservice.api.workflow.delete.model.DeletionSourceType.ASKER; | ||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
|
||
import de.caritas.cob.userservice.api.actions.ActionCommand; | ||
import de.caritas.cob.userservice.api.adapters.rocketchat.RocketChatService; | ||
import de.caritas.cob.userservice.api.exception.rocketchat.RocketChatDeleteGroupException; | ||
import de.caritas.cob.userservice.api.model.Session; | ||
import de.caritas.cob.userservice.api.workflow.delete.model.DeletionTargetType; | ||
import de.caritas.cob.userservice.api.workflow.delete.model.DeletionWorkflowError; | ||
import de.caritas.cob.userservice.api.workflow.delete.model.RocketchatRoomDeletionWorkflowDTO; | ||
import de.caritas.cob.userservice.api.workflow.delete.model.SessionDeletionWorkflowDTO; | ||
import java.util.List; | ||
import lombok.NonNull; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class DeleteSingleRoomAction implements ActionCommand<RocketchatRoomDeletionWorkflowDTO> { | ||
|
||
protected final @NonNull RocketChatService rocketChatService; | ||
|
||
public DeleteSingleRoomAction(@NonNull RocketChatService rocketChatService) { | ||
this.rocketChatService = rocketChatService; | ||
} | ||
|
||
void deleteRocketChatGroup(String rcGroupId, List<DeletionWorkflowError> workflowErrors) { | ||
if (isNotBlank(rcGroupId)) { | ||
try { | ||
this.rocketChatService.deleteGroupAsTechnicalUser(rcGroupId); | ||
} catch (RocketChatDeleteGroupException e) { | ||
log.error("UserService delete workflow error: ", e); | ||
workflowErrors.add( | ||
DeletionWorkflowError.builder() | ||
.deletionSourceType(ASKER) | ||
.deletionTargetType(DeletionTargetType.ROCKET_CHAT) | ||
.identifier(rcGroupId) | ||
.reason("Deletion of Rocket.Chat group failed") | ||
.timestamp(nowInUtc()) | ||
.build()); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Deletes the given {@link Session} in the database with the related Rocket.Chat room containing | ||
* all messages and uploads. | ||
* | ||
* @param actionTarget the {@link SessionDeletionWorkflowDTO} with the session to delete | ||
*/ | ||
@Override | ||
public void execute(RocketchatRoomDeletionWorkflowDTO actionTarget) { | ||
deleteRocketChatGroup( | ||
actionTarget.getRocketchatRoomId(), actionTarget.getDeletionWorkflowErrors()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../caritas/cob/userservice/api/workflow/delete/model/RocketchatRoomDeletionWorkflowDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.caritas.cob.userservice.api.workflow.delete.model; | ||
|
||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class RocketchatRoomDeletionWorkflowDTO { | ||
|
||
private String rocketchatRoomId; | ||
private List<DeletionWorkflowError> deletionWorkflowErrors; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters