aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com/juick/api/Utils.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-11 10:16:36 +0300
committerGravatar Vitaly Takmazov2016-07-11 10:16:36 +0300
commit7eb3b141e5e4e719e1ef77ea06b6bac7610ae913 (patch)
tree1573abb9b47f5001053ed07b8ba9164c8fc5a188 /juick-api/src/main/java/com/juick/api/Utils.java
parentf0a60dd95eff153c022bca0c71fed39b901dd547 (diff)
cleanup sql
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/Utils.java')
-rw-r--r--juick-api/src/main/java/com/juick/api/Utils.java84
1 files changed, 0 insertions, 84 deletions
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<Integer> 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("<", "&lt;");
- ret = ret.replaceAll(">", "&gt;");
- 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) {