generated from FINTLabs/fint-spring-boot-template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from FINTLabs/feature_republish_all_users
FKS-986 add scheduled user publishing component
- Loading branch information
Showing
8 changed files
with
91 additions
and
17 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
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
35 changes: 35 additions & 0 deletions
35
src/main/java/no/fintlabs/user/UserPublishingComponent.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,35 @@ | ||
package no.fintlabs.user; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Slf4j | ||
@Component | ||
public class UserPublishingComponent { | ||
private final UserEntityProducerService userEntityProducerService; | ||
private final UserService userService; | ||
|
||
public UserPublishingComponent(UserEntityProducerService userEntityProducerService, UserService userService) { | ||
this.userEntityProducerService = userEntityProducerService; | ||
this.userService = userService; | ||
} | ||
@Scheduled( | ||
initialDelayString = "${fint.kontroll.user-catalog.publishing.initial-delay}", | ||
fixedDelayString = "${fint.kontroll.user-catalog.publishing.fixed-delay}", | ||
timeUnit = TimeUnit.HOURS | ||
) | ||
public void publishUsers() { | ||
String triggerType = "scheduled job"; | ||
List<User> allUsers = userService.getAllUsers(); | ||
|
||
if (allUsers.isEmpty()) { | ||
log.info("No users to publish"); | ||
return; | ||
} | ||
userEntityProducerService.publishAllKontrollUsers(triggerType, allUsers); | ||
} | ||
} |
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