From 7eb3b141e5e4e719e1ef77ea06b6bac7610ae913 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 11 Jul 2016 10:16:36 +0300 Subject: cleanup sql --- juick-api/src/main/java/com/juick/api/Utils.java | 84 ------------------------ 1 file changed, 84 deletions(-) (limited to 'juick-api/src') diff --git a/juick-api/src/main/java/com/juick/api/Utils.java b/juick-api/src/main/java/com/juick/api/Utils.java index ca0518e1..0ce69e4b 100644 --- a/juick-api/src/main/java/com/juick/api/Utils.java +++ b/juick-api/src/main/java/com/juick/api/Utils.java @@ -20,18 +20,12 @@ package com.juick.api; import com.juick.server.UserQueries; import org.springframework.jdbc.core.JdbcTemplate; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Part; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; import java.util.Base64; import java.util.UUID; @@ -41,40 +35,6 @@ import java.util.UUID; */ public class Utils { - public static String getCookie(HttpServletRequest request, String name) { - Cookie cookies[] = request.getCookies(); - if (cookies != null) { - for (int i = 0; i < cookies.length; i++) { - if (cookies[i].getName().equals(name)) { - return cookies[i].getValue(); - } - } - } - return null; - } - - public static com.juick.User getVisitorUser(JdbcTemplate sql, HttpServletRequest request) { - String hash = getCookie(request, "hash"); - if (hash != null) { - return com.juick.server.UserQueries.getUserByHash(sql, hash); - } else { - return null; - } - } - - public static int getVisitorUID(JdbcTemplate sql, HttpServletRequest request) { - Cookie cookies[] = request.getCookies(); - if (cookies != null) { - for (int i = 0; i < cookies.length; i++) { - if (cookies[i].getName().equals("hash")) { - String hash = cookies[i].getValue(); - return com.juick.server.UserQueries.getUIDbyHash(sql, hash); - } - } - } - return 0; - } - public static int getHttpAuthUID(JdbcTemplate sql, HttpServletRequest request) { String auth = request.getHeader("Authorization"); if (auth != null && auth.length() > 8 && auth.startsWith("Basic ")) { @@ -95,50 +55,6 @@ public class Utils { return 0; } - public static void sendPermanentRedirect(HttpServletResponse response, String location) { - response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); - response.setHeader("Location", location); - } - - public static void finishSQL(ResultSet rs, Statement stmt) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - } - } - } - - public static String convertArray2String(ArrayList mids) { - String q = ""; - for (int i = 0; i < mids.size(); i++) { - if (i > 0) { - q += ","; - } - q += mids.get(i); - } - return q; - } - - public static String encodeHTML(String str) { - String ret = str; - ret = ret.replaceAll("<", "<"); - ret = ret.replaceAll(">", ">"); - return str; - } - - public static String encodeSphinx(String str) { - String ret = str; - ret = ret.replaceAll("@", "\\\\@"); - return ret; - } - public static int parseInt(String str, int def) { int ret = def; if (str != null) { -- cgit v1.2.3