Package com.nabalive.framework.web.exception

Examples of com.nabalive.framework.web.exception.HttpException


                            Query<User> query = userDAO.createQuery().filter("_id", user.getId());
                            user.setPassword(password);
                            userDAO.update(query, userDAO.createUpdateOperations().set("password", user.getPassword()).unset("resetId"));
                            response.writeJSON("ok");
                        }
                        throw new HttpException(HttpResponseStatus.INTERNAL_SERVER_ERROR, "bab reset ID");
                    }
                })
                .get(new Route("/user/reset/mail") {
                    @Override
                    public void handle(Request request, Response response, Map<String, String> map) throws Exception {
View Full Code Here


                        Nabaztag nabaztag;
                        try{
                            nabaztag = checkNotNull(nabaztagDAO.findOne("macAddress", mac));
                        }catch(NullPointerException e){
                            throw new HttpException(HttpResponseStatus.UNAUTHORIZED, "mac address doesn't exists");
                        }
                       
                        if (!token.equalsIgnoreCase(nabaztag.getApikey())) {
                            throw new HttpException(HttpResponseStatus.UNAUTHORIZED, "token is not valid");
                        }

                        StringBuilder commands = new StringBuilder();
                        if(chor != null){
                            String url = "http://" + host + "/api/chor?data=" + chor;
View Full Code Here

                .post(new Route("/vl/record.jsp") {
                    @Override
                    public void handle(Request request, Response response, Map<String, String> map) throws Exception {
                        String mac = checkNotNull(request.getParam("sn")).toLowerCase();
                        if (!connectionManager.containsKey(mac))
                            throw new HttpException(HttpResponseStatus.NOT_FOUND, "sn is not connected");

                        Nabaztag nabaztag = checkNotNull(nabaztagDAO.findOne("macAddress", mac));

                        ChannelBuffer content = request.request.getContent();
                        logger.debug("record orig size: {}", content.readableBytes());
View Full Code Here

                route.handle(request, response, map);
                return;
            }
        }

        throw new HttpException(HttpResponseStatus.NOT_FOUND);
    }
View Full Code Here

                        logger.debug("received json: {}", request.content);
                        Map<String, String> nabMap = mapper.readValue(request.content, Map.class);
                        String mac = CharMatcher.JAVA_LETTER_OR_DIGIT.retainFrom(checkNotNull(nabMap.get("mac")).toLowerCase());

                        if (!connectionManager.containsKey(mac)) {
                            throw new HttpException(HttpResponseStatus.INTERNAL_SERVER_ERROR, "Nabaztag not Connected");
                        }

                        Nabaztag nabaztag = new Nabaztag();
                        nabaztag.setMacAddress(mac);
                        nabaztag.setName(nabMap.get("name"));
                        nabaztag.setApikey(UUID.randomUUID().toString());
                        nabaztag.setOwner(token.getUserId());

                        try {
                            nabaztagDAO.save(nabaztag);
                        } catch (MongoException.DuplicateKey e) {
                            ImmutableMap<String, String> error = (new ImmutableMap.Builder<String, String>()).put("error", "Adresse mac déjà enregistrée").build();
                            response.writeJSON(error);
                            return;
                        }

                        messageService.sendMessage(mac, "ST " + OPERATIONNEL_URL + "\nMW\n");
                        response.writeJSON(nabaztag);
                    }
                })
                .post(new Route("/nabaztags") {
                    @Override
                    public void handle(Request request, Response response, Map<String, String> map) throws Exception {
                        Token token = TokenUtil.decode(checkNotNull(request.getParamOrHeader("token")), Token.class);
                        String mac = CharMatcher.JAVA_LETTER_OR_DIGIT.retainFrom(checkNotNull(request.getParam("mac")).toLowerCase());
                        String name = request.getParam("name");

                        if (!connectionManager.containsKey(mac)) {
                            throw new HttpException(HttpResponseStatus.INTERNAL_SERVER_ERROR, "Nabaztag not Connected");
                        }

                        Nabaztag nabaztag = new Nabaztag();
                        nabaztag.setMacAddress(mac);
                        nabaztag.setName(name);
View Full Code Here

                    @Override
                    public void handle(Request request, Response response, Map<String, String> map) throws Exception {
                        Token token = TokenUtil.decode(checkNotNull(request.getParamOrHeader("token")), Token.class);
                        User user = checkNotNull(userDAO.get(token.getUserId()));
                        if (!user.getPermissions().contains("admin"))
                            throw new HttpException(HttpResponseStatus.UNAUTHORIZED, "UNAUTHORIZED access");

                        response.writeJSON(connectionManager.keySet());
                    }
                });
    }
View Full Code Here

TOP

Related Classes of com.nabalive.framework.web.exception.HttpException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.