package com.juick.api; import com.juick.server.UserQueries; import java.io.IOException; import java.sql.Connection; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author ugnich */ public class Users { Connection sql; public Users(Connection sql) { this.sql = sql; } public void doGetUserRead(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException { int uid = vuid; String paramUID = request.getParameter("user_id"); if (paramUID != null) { try { uid = Integer.parseInt(paramUID); } catch (NumberFormatException e) { } } if (uid > 0) { ArrayList uids = UserQueries.getUserRead(sql, vuid); if (uids.size() > 0) { ArrayList users = UserQueries.getUsersByID(sql, uids); if (users.size() > 0) { String json = com.juick.json.Users.arrayToString(users); Main.replyJSON(request, response, json); return; } } } response.sendError(404); } public void doGetUserReaders(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException { int uid = vuid; String paramUID = request.getParameter("user_id"); if (paramUID != null) { try { uid = Integer.parseInt(paramUID); } catch (NumberFormatException e) { } } if (uid > 0) { ArrayList uids = UserQueries.getUserReaders(sql, vuid); if (uids.size() > 0) { ArrayList users = UserQueries.getUsersByID(sql, uids); if (users.size() > 0) { String json = com.juick.json.Users.arrayToString(users); Main.replyJSON(request, response, json); return; } } } response.sendError(404); } }