Skip to content

Commit

Permalink
No Active Dashboard Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
doom369 committed Mar 24, 2015
1 parent a765b98 commit e8212bd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions README_FOR_APP_DEVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Response message structure:
5 - user hasn’t made login command
6 - user is not allowed to perform this operation (most probably is not logged or socket has been closed)
7 - hardware is offline
8 - no active dashboard. User has to activated dashboard.
9 - token is invalid
11 - user is already logged in. Happens in cases when same user tries to login for more than one time.
12 - tweet exception, exception occurred during posting request to Twitter could be in case messages are the same in a row;
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/cc/blynk/common/enums/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class Response {
public static final int USER_NOT_AUTHENTICATED = 5;
public static final int NOT_ALLOWED = 6;
public static final int DEVICE_NOT_IN_NETWORK = 7;
public static final int NO_ACTIVE_DASHBOARD = 8;
public static final int INVALID_TOKEN = 9;
public static final int USER_ALREADY_LOGGED_IN = 11;
public static final int TWEET_EXCEPTION = 12;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void testActivateWorkflow() throws Exception {
verify(clientPair.appClient.responseMock, timeout(500)).channelRead(any(), eq(produce(2, OK)));

clientPair.appClient.send("hardware ar 1 1");
verify(clientPair.appClient.responseMock, timeout(500)).channelRead(any(), eq(produce(3, ILLEGAL_COMMAND)));
verify(clientPair.appClient.responseMock, timeout(500)).channelRead(any(), eq(produce(3, NO_ACTIVE_DASHBOARD)));

clientPair.appClient.send("activate 1");
verify(clientPair.appClient.responseMock, timeout(500)).channelRead(any(), eq(produce(4, OK)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cc.blynk.server.exceptions;

import cc.blynk.common.enums.Response;
import cc.blynk.common.exceptions.BaseServerException;

/**
* The Blynk Project.
* Created by Dmitriy Dumanskiy.
* Created on 2/23/2015.
*/
public class NoActiveDashboardException extends BaseServerException {

public NoActiveDashboardException(String message, int msgId) {
super(message, msgId, Response.NO_ACTIVE_DASHBOARD);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import cc.blynk.common.utils.ServerProperties;
import cc.blynk.server.dao.*;
import cc.blynk.server.exceptions.DeviceNotInNetworkException;
import cc.blynk.server.exceptions.IllegalCommandException;
import cc.blynk.server.exceptions.NoActiveDashboardException;
import cc.blynk.server.model.auth.Session;
import cc.blynk.server.model.auth.User;
import cc.blynk.server.model.auth.nio.ChannelState;
Expand Down Expand Up @@ -45,7 +45,7 @@ protected void messageReceived(ChannelHandlerContext ctx, User user, HardwareMes
Session.sendMessageTo(message.updateMessageBody(body), session.appChannels);
} else {
if (user.getUserProfile().getActiveDashId() == null) {
throw new IllegalCommandException("No active dashboard.", message.id);
throw new NoActiveDashboardException("No active dashboard.", message.id);
}

if (session.hardwareChannels.size() == 0) {
Expand Down

0 comments on commit e8212bd

Please sign in to comment.