mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-22 13:45:42 +00:00
bug5730: use UTF-8 as encoding for message files
This commit is contained in:
+28
-13
@@ -3,6 +3,7 @@ package com.sap.sailing.landscape.impl;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -102,6 +103,7 @@ import com.sap.sse.landscape.mongodb.MongoEndpoint;
|
||||
import com.sap.sse.replication.FullyInitializedReplicableTracker;
|
||||
import com.sap.sse.security.SecurityService;
|
||||
import com.sap.sse.security.SessionUtils;
|
||||
import com.sap.sse.security.shared.HasPermissions.Action;
|
||||
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
|
||||
import com.sap.sse.security.shared.OwnershipAnnotation;
|
||||
import com.sap.sse.security.shared.QualifiedObjectIdentifier;
|
||||
@@ -427,8 +429,8 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
final SailingServer from = sailingServerFactory.getSailingServer(new URL("https", hostnameFromWhichToArchive, "/"), bearerTokenOrNullForApplicationReplicaSetToArchive);
|
||||
final SailingServer archive = sailingServerFactory.getSailingServer(new URL("https", hostnameOfArchive, "/"), bearerTokenOrNullForArchive);
|
||||
logger.info("Importing master data from "+from+" to "+archive);
|
||||
sendMailToReplicaSetOwner(archiveReplicaSet, "StartingToArchiveReplicaSetIntoSubject", "StartingToArchiveReplicaSetIntoBody");
|
||||
sendMailToReplicaSetOwner(applicationReplicaSetToArchive, "StartingToArchiveReplicaSetSubject", "StartingToArchiveReplicaSetBody");
|
||||
sendMailToReplicaSetOwner(archiveReplicaSet, "StartingToArchiveReplicaSetIntoSubject", "StartingToArchiveReplicaSetIntoBody", Optional.empty());
|
||||
sendMailToReplicaSetOwner(applicationReplicaSetToArchive, "StartingToArchiveReplicaSetSubject", "StartingToArchiveReplicaSetBody", Optional.empty());
|
||||
// Note: if from.getLeaderboardGroupIds() returns an empty set, "all" leaderboards will be imported by the MDI which again is the empty set.
|
||||
// In this case, no comparison is required; in fact it wouldn't even work because passing an empty set to the archive into which the import
|
||||
// was done would implicitly compare all leaderboard groups, resulting in the entire archive server content being the "diff."
|
||||
@@ -509,8 +511,8 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
" did not work"+(mdiProgress != null ? mdiProgress.getErrorMessage() : " (no result at all)"));
|
||||
compareServersResult = null;
|
||||
}
|
||||
sendMailToReplicaSetOwner(archiveReplicaSet, "FinishedToArchiveReplicaSetIntoSubject", "FinishedToArchiveReplicaSetIntoBody");
|
||||
sendMailToReplicaSetOwner(applicationReplicaSetToArchive, "FinishedToArchiveReplicaSetSubject", "FinishedToArchiveReplicaSetBody");
|
||||
sendMailToReplicaSetOwner(archiveReplicaSet, "FinishedToArchiveReplicaSetIntoSubject", "FinishedToArchiveReplicaSetIntoBody", Optional.empty());
|
||||
sendMailToReplicaSetOwner(applicationReplicaSetToArchive, "FinishedToArchiveReplicaSetSubject", "FinishedToArchiveReplicaSetBody", Optional.empty());
|
||||
return new Util.Pair<>(mdiProgress, compareServersResult);
|
||||
}
|
||||
|
||||
@@ -1475,28 +1477,41 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
|
||||
private void sendMailAboutMasterAvailable(
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> replicaSet) throws MailException {
|
||||
sendMailToReplicaSetOwner(replicaSet, "MasterUnavailableMailSubject", "MasterUnavailableMailBody");
|
||||
sendMailToReplicaSetOwner(replicaSet, "MasterUnavailableMailSubject", "MasterUnavailableMailBody", Optional.empty());
|
||||
}
|
||||
|
||||
private void sendMailAboutMasterUnavailable(
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> replicaSet) throws MailException {
|
||||
sendMailToReplicaSetOwner(replicaSet, "MasterAvailableMailSubject", "MasterAvailableMailBody");
|
||||
sendMailToReplicaSetOwner(replicaSet, "MasterAvailableMailSubject", "MasterAvailableMailBody", Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subjectMessageKey must have a single placeholder argument representing the name of the replica set
|
||||
* @param bodyMessageKey must have a single placeholder argument representing the name of the replica set
|
||||
* @param subjectMessageKey
|
||||
* must have a single placeholder argument representing the name of the replica set
|
||||
* @param bodyMessageKey
|
||||
* must have a single placeholder argument representing the name of the replica set
|
||||
* @param alsoSendToAllUsersWithThisPermissionOnReplicaSet
|
||||
* when not empty, all users that have permission to this {@link SecuredSecurityTypes#SERVER SERVER}
|
||||
* action on the {@code replicaSet} will receive the e-mail in addition to the server owner. No user
|
||||
* will receive the e-mail twice.
|
||||
*/
|
||||
private void sendMailToReplicaSetOwner(
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> replicaSet,
|
||||
final String subjectMessageKey, final String bodyMessageKey) throws MailException {
|
||||
final String subjectMessageKey, final String bodyMessageKey, Optional<Action> alsoSendToAllUsersWithThisPermissionOnReplicaSet) throws MailException {
|
||||
final OwnershipAnnotation serverOwnership = getSecurityService().getOwnership(getReplicaSetQualifiedObjectIdentifier(replicaSet));
|
||||
final User serverOwner;
|
||||
final ResourceBundleStringMessagesImpl stringMessages = new ResourceBundleStringMessagesImpl(STRING_MESSAGES_BASE_NAME, getClass().getClassLoader());
|
||||
final ResourceBundleStringMessagesImpl stringMessages = new ResourceBundleStringMessagesImpl(STRING_MESSAGES_BASE_NAME, getClass().getClassLoader(), StandardCharsets.UTF_8.name());
|
||||
final Set<User> usersToSendMailTo = new HashSet<>();
|
||||
if (serverOwnership != null && serverOwnership.getAnnotation() != null && (serverOwner = serverOwnership.getAnnotation().getUserOwner()) != null) {
|
||||
getSecurityService().sendMail(serverOwner.getName(),
|
||||
stringMessages.get(serverOwner.getLocaleOrDefault(), subjectMessageKey, replicaSet.getServerName()),
|
||||
stringMessages.get(serverOwner.getLocaleOrDefault(), bodyMessageKey, replicaSet.getServerName()));
|
||||
usersToSendMailTo.add(serverOwner);
|
||||
}
|
||||
alsoSendToAllUsersWithThisPermissionOnReplicaSet.ifPresent(
|
||||
serverAction -> getSecurityService().getUsersWithPermissions(getReplicaSetQualifiedObjectIdentifier(replicaSet).getPermission(serverAction))
|
||||
.forEach(usersToSendMailTo::add));
|
||||
for (final User user : usersToSendMailTo) {
|
||||
getSecurityService().sendMail(user.getName(),
|
||||
stringMessages.get(user.getLocaleOrDefault(), subjectMessageKey, replicaSet.getServerName()),
|
||||
stringMessages.get(user.getLocaleOrDefault(), bodyMessageKey, replicaSet.getServerName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user