@GET @Path("/names/getAll") public Response getAllUserNames() { return ok(userDao.users.keySet()); }
@GET @Path("/realtime") public Response getReatime() { return ok(Collections.singletonList( new Stat(sessionDao, userDao, blockingIOProcessor, globalStats, reportScheduler, false))); }
@GET @Path("/stop") @Metric(HTTP_START_OTA) public Response stopOTA(@Context ChannelHandlerContext ctx) { User initiator = ctx.channel().attr(AuthHeadersBaseHttpHandler.USER).get(); otaManager.stop(initiator); return ok(); }
@GET @Path("restore") public Response getNewResetPage(@QueryParam("token") String token, @QueryParam("email") String email) { //we do not check token here, as we used single host but we may have many servers //ResetPassToken user = tokensPool.getBaseToken(token); //if (user == null) { // return badRequest("Your token was not found or it is outdated. Please try again."); //} log.info("{} landed.", email); String resetUrl = "http://" + resetClickHost + "/restore?token=" + token + "&email=" + email; String body = newResetPage.replace(Placeholders.RESET_URL, resetUrl); return ok(body, MediaType.TEXT_HTML); }
@GET @Path("landing") public Response generateResetPage(@QueryParam("token") String token) { BaseToken baseToken = tokensPool.getBaseToken(token); if (baseToken == null) { return badRequest("Your token was not found or it is outdated. Please try again."); } log.info("{} landed.", baseToken.email); String page = pageContent.replace(Placeholders.EMAIL, baseToken.email).replace(Placeholders.TOKEN, token); return ok(page, MediaType.TEXT_HTML); }
@GET @Path("/requestsPerUser") public Response getRequestPerUser(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { List<RequestPerSecondResponse> res = new ArrayList<>(); for (Map.Entry<UserKey, Session> entry : sessionDao.userSession.entrySet()) { Session session = entry.getValue(); int appReqRate = session.getAppRequestRate(); int hardReqRate = session.getHardRequestRate(); if (appReqRate > 0 || hardReqRate > 0) { res.add(new RequestPerSecondResponse(entry.getKey().email, appReqRate, hardReqRate)); } } return ok(sort(res, sortField, sortOrder)); }
@GET @Path("") public Response getConfigs(@QueryParam("_filters") String filterParam, @QueryParam("_page") int page, @QueryParam("_perPage") int size, @QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { List<Config> configs = new ArrayList<>(); configs.add(new Config(SERVER_PROPERTIES_FILENAME)); configs.add(new Config(MAIL_PROPERTIES_FILENAME)); configs.add(new Config(GCM_PROPERTIES_FILENAME)); configs.add(new Config(DB_PROPERTIES_FILENAME)); configs.add(new Config(TWITTER_PROPERTIES_FILENAME)); configs.add(new Config(TOKEN_MAIL_BODY)); return appendTotalCountHeader( ok(sort(configs, sortField, sortOrder), page, size), configs.size() ); }
@GET @Path("{token}/project") @Metric(HTTP_GET_PROJECT) public Response getDashboard(@PathParam("token") String token) { TokenValue tokenValue = tokenManager.getTokenValueByToken(token); if (tokenValue == null) { log.debug("Requested token {} not found.", token); return badRequest("Invalid token."); } return ok(JsonParser.toJsonRestrictiveDashboardForHTTP(tokenValue.dash)); }
@GET @Path("{token}/data/{pin}") @Metric(HTTP_GET_HISTORY_DATA)
@GET @Path("{token}/rtc") @Metric(HTTP_GET_PIN_DATA) public Response getWidgetPinData(@PathParam("token") String token) { TokenValue tokenValue = tokenManager.getTokenValueByToken(token); if (tokenValue == null) { log.debug("Requested token {} not found.", token); return badRequest("Invalid token."); } User user = tokenValue.user; RTC rtc = tokenValue.dash.getWidgetByType(RTC.class); if (rtc == null) { log.debug("Requested rtc widget not found. User {}", user.email); return badRequest("Requested rtc not exists in app."); } return ok(rtc.getJsonValue()); }
@GET @Path("/{id}") public Response getUserByName(@PathParam("id") String id) { String[] parts = slitByLast(id); String email = parts[0]; String appName = parts[1]; User user = userDao.getByName(email, appName); if (user == null) { return notFound(); } return ok(user); }
@GET @Path("{token}/clone") @Metric(HTTP_CLONE) public Response getClone(@Context ChannelHandlerContext ctx, @PathParam("token") String token) { blockingIOProcessor.executeDB(() -> { try { String json = dbManager.selectClonedProject(token); //no cloned project in DB, checking local storage on disk if (json == null) { json = fileManager.readClonedProjectFromDisk(token); } if (json == null) { log.debug("Requested QR not found. {}", token); ctx.writeAndFlush(serverError("Requested QR not found."), ctx.voidPromise()); } else { ctx.writeAndFlush(ok(json), ctx.voidPromise()); } } catch (Exception e) { log.error("Error cloning project.", e); ctx.writeAndFlush(serverError("Error getting cloned project."), ctx.voidPromise()); } }); return null; }
@GET @Path("{token}/isAppConnected") @Metric(HTTP_IS_APP_CONNECTED) public Response isAppConnected(@PathParam("token") String token) { TokenValue tokenValue = tokenManager.getTokenValueByToken(token); if (tokenValue == null) { log.debug("Requested token {} not found.", token); return badRequest("Invalid token."); } User user = tokenValue.user; Session session = sessionDao.get(new UserKey(user)); return ok(tokenValue.dash.isActive && session.isAppConnected()); }
@GET @Path("/widgets") public Response getWidgets(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sort(convertMapToPair(userDao.getWidgetsUsage()), sortField, sortOrder)); }
@GET @Path("/projectsPerUser") public Response getProjectsPerUser(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sortStringAsInt(convertMapToPair(userDao.getProjectsPerUser()), sortField, sortOrder)); }
@GET @Path("/connectionType") public Response getFacebookLogins(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sort(convertMapToPair(userDao.getConnectionType()), sortField, sortOrder)); }
@GET @Path("/boards") public Response getHardwareBoards(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sort(convertMapToPair(userDao.getHardwareBoards()), sortField, sortOrder)); }
@GET @Path("/messages") public Response getMessages(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sort(convertObjectToMap( new Stat(sessionDao, userDao, blockingIOProcessor, globalStats, reportScheduler, false).commands), sortField, sortOrder)); }
@GET @Path("/cpuType") public Response getBoards(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sort(convertMapToPair(userDao.getCpuType()), sortField, sortOrder)); }
@GET @Path("/facebookLogins") public Response getFacebookLogins(@QueryParam("_sortField") String sortField, @QueryParam("_sortDir") String sortOrder) { return ok(sort(convertMapToPair(userDao.getFacebookLogin()), sortField, sortOrder)); }