Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
Fixed message translation #451 #416
Browse files Browse the repository at this point in the history
  • Loading branch information
monitobeko committed Dec 14, 2016
1 parent fdae945 commit 40efe49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
12 changes: 6 additions & 6 deletions Server/src/main/java/io/hawkcd/core/MessageDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.hawkcd.core.publisher.PublisherFactory;
import io.hawkcd.core.session.ISessionManager;
import io.hawkcd.core.session.SessionFactory;
import io.hawkcd.core.subscriber.MessageTranslator;
import io.hawkcd.model.Entity;
import io.hawkcd.model.dto.WsContractDto;
import io.hawkcd.model.enums.PermissionType;
Expand All @@ -17,13 +16,14 @@ public class MessageDispatcher {

public static void dispatchIncomingMessage(Message message) {
if (Config.getConfiguration().isSingleNode()) {
WsContractDto contractDto;
WsContractDto contractDto = null;
if (message.isTargetOwner()) { // if this is list
contractDto = MessageConverter.convert(message);
} else { // if single message
contractDto = MessageTranslator.translateMessageToContract(message);
SessionFactory.getSessionManager().sendToAllSessions(contractDto);
} else if(message.isUserUpdate()){
List<String> ids = (List<String>) message.getEnvelope();
SessionFactory.getSessionManager().updateSessionLoggedUser(ids.toArray(new String[ids.size()]));
}
SessionFactory.getSessionManager().sendToAllSessions(contractDto);
} else {
PublisherFactory.createPublisher().publish("global", message);
}
Expand All @@ -42,7 +42,7 @@ public static void dispatchOutgoingMessage(Message message) {
sessionManager.updateSessionLoggedUser(ids.toArray(new String[ids.size()]));
} else { // when is single message meant to be broadcast
Map<String, PermissionType> permissionTypeByUser = message.getPermissionTypeByUser();
WsContractDto contract = MessageTranslator.translateMessageToContract(message);
WsContractDto contract = MessageConverter.convert(message);

for (Map.Entry<String, PermissionType> entry : permissionTypeByUser.entrySet()) {
WSSocket session = sessionManager.getSessionByUserId(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -75,7 +76,7 @@ private List<AuthorizationGrant> sortGrants(List<AuthorizationGrant> grants) {
.stream()
.sorted(Comparator.comparingInt(g -> g.getPermissionEntity().getPriorityLevel()))
.collect(Collectors.toList());
sortedGrants = Lists.reverse(sortedGrants);
Collections.reverse(sortedGrants);

return sortedGrants;
}
Expand Down

This file was deleted.

0 comments on commit 40efe49

Please sign in to comment.