Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4fe267e3

Přidáno uživatelem Pavel Fidranský před více než 5 roky(ů)

use commons-lang3 to check blank strings (including whitespace) instead of guava

Zobrazit rozdíly:

sources/pom.xml
67 67
            <artifactId>commons-fileupload</artifactId>
68 68
            <version>1.3.3</version>
69 69
        </dependency>
70
        <dependency>
71
            <groupId>org.apache.commons</groupId>
72
            <artifactId>commons-lang3</artifactId>
73
            <version>3.8.1</version>
74
        </dependency>
70 75

  
71 76
        <!-- Servlets and JSP -->
72 77
        <dependency>
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
1 1
package cz.zcu.kiv.offscreen.servlets;
2 2

  
3
import com.google.common.base.Strings;
4 3
import cz.zcu.kiv.offscreen.modularization.ModuleProvider;
5 4
import cz.zcu.kiv.offscreen.storage.FileLoader;
6 5
import cz.zcu.kiv.offscreen.user.DB;
7 6
import cz.zcu.kiv.offscreen.user.Diagram;
7
import org.apache.commons.lang3.StringUtils;
8 8
import org.apache.logging.log4j.LogManager;
9 9
import org.apache.logging.log4j.Logger;
10 10

  
......
59 59
            logger.debug("Invalid request");
60 60
            doGet(request, response);
61 61

  
62
        } else if (Strings.isNullOrEmpty(data.get("file"))) {
62
        } else if (StringUtils.isBlank(data.get("file"))) {
63 63
            request.setAttribute("errorMessage", "<strong>Unsupported file</strong><br/>");
64 64
            logger.debug("Empty diagram string");
65 65
            doGet(request, response);
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDBDiagram.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3
import com.google.common.base.Strings;
4 3
import com.google.gson.Gson;
5 4
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
6 5
import cz.zcu.kiv.offscreen.user.DB;
7 6
import cz.zcu.kiv.offscreen.user.Diagram;
7
import org.apache.commons.lang3.StringUtils;
8 8
import org.apache.logging.log4j.LogManager;
9 9
import org.apache.logging.log4j.Logger;
10 10

  
......
24 24
        logger.debug("Processing request");
25 25
        String diagramId = request.getParameter("id");
26 26

  
27
        if (Strings.isNullOrEmpty(diagramId)) {
27
        if (StringUtils.isBlank(diagramId)) {
28 28
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
29 29
            logger.debug("Diagram id is empty");
30 30
            return;
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3
import com.google.common.base.Strings;
4 3
import com.google.gson.JsonObject;
5 4
import cz.zcu.kiv.offscreen.modularization.ModuleProvider;
6 5
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
7 6
import javafx.util.Pair;
7
import org.apache.commons.lang3.StringUtils;
8 8
import org.apache.logging.log4j.LogManager;
9 9
import org.apache.logging.log4j.Logger;
10
import org.apache.maven.shared.utils.StringUtils;
11 10

  
12 11
import javax.servlet.http.HttpServletRequest;
13 12
import javax.servlet.http.HttpServletResponse;
......
43 42
        String diagramType = (String) request.getSession().getAttribute("diagram_type");
44 43
        String filename = (String) request.getSession().getAttribute("diagram_filename");
45 44

  
46
        if (!Strings.isNullOrEmpty(diagramToDisplay) && diagramType != null) {
45
        if (StringUtils.isNotBlank(diagramToDisplay) && diagramType != null) {
47 46

  
48 47
            String rawJson;
49 48

  
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Login.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3
import com.google.common.base.Strings;
4 3
import com.google.gson.JsonObject;
5 4
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
6 5
import cz.zcu.kiv.offscreen.user.DB;
7 6
import cz.zcu.kiv.offscreen.user.User;
8 7
import cz.zcu.kiv.offscreen.vo.UserVO;
8
import org.apache.commons.lang3.StringUtils;
9 9
import org.apache.logging.log4j.LogManager;
10 10
import org.apache.logging.log4j.Logger;
11 11

  
12

  
13 12
import javax.servlet.http.HttpServletRequest;
14 13
import javax.servlet.http.HttpServletResponse;
15 14
import java.io.IOException;
15

  
16 16
public class Login extends BaseServlet {
17 17
    private static final Logger logger = LogManager.getLogger();
18 18

  
......
24 24

  
25 25
        JsonObject errors = new JsonObject();
26 26

  
27
        if (Strings.isNullOrEmpty(username)) {
27
        if (StringUtils.isBlank(username)) {
28 28
            errors.addProperty("username", "Please enter username.");
29 29
            logger.debug("Empty user name");
30 30
        }
31 31

  
32
        if (Strings.isNullOrEmpty(password)) {
32
        if (StringUtils.isBlank(password)) {
33 33
            errors.addProperty("password", "Please enter password.");
34 34
            logger.debug("Empty password");
35 35
        }
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Register.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3
import com.google.common.base.Strings;
4 3
import com.google.gson.JsonObject;
5 4
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
6 5
import cz.zcu.kiv.offscreen.user.DB;
7 6
import cz.zcu.kiv.offscreen.user.User;
7
import org.apache.commons.lang3.StringUtils;
8 8
import org.apache.logging.log4j.LogManager;
9 9
import org.apache.logging.log4j.Logger;
10 10

  
......
37 37

  
38 38
		JsonObject errors = new JsonObject();
39 39

  
40
		if (Strings.isNullOrEmpty(name)) {
40
		if (StringUtils.isBlank(name)) {
41 41
			errors.addProperty("name", "Please enter name.");
42 42
			logger.debug("Empty name");
43 43
		}
44 44

  
45
		if (Strings.isNullOrEmpty(email)) {
45
		if (StringUtils.isBlank(email)) {
46 46
			errors.addProperty("email", "Please enter e-mail address.");
47 47
			logger.debug("Empty e-mail address");
48 48

  
......
55 55
			logger.debug("E-mail exists");
56 56
		}
57 57

  
58
		if (Strings.isNullOrEmpty(username)) {
58
		if (StringUtils.isBlank(username)) {
59 59
			errors.addProperty("username", "Please enter username.");
60 60
			logger.debug("Empty user name");
61 61

  
......
64 64
			logger.debug("Username(nickname) exists");
65 65
		}
66 66
    	
67
    	if (Strings.isNullOrEmpty(password) || Strings.isNullOrEmpty(passwordCheck)) {
67
    	if (StringUtils.isBlank(password) || StringUtils.isBlank(passwordCheck)) {
68 68
    		errors.addProperty("password", "Please enter password.");
69 69
			logger.debug("Empty password");
70 70

  
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/RemoveDiagram.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3
import com.google.common.base.Strings;
4 3
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
5 4
import cz.zcu.kiv.offscreen.user.DB;
6 5
import cz.zcu.kiv.offscreen.user.Diagram;
6
import org.apache.commons.lang3.StringUtils;
7 7
import org.apache.logging.log4j.LogManager;
8 8
import org.apache.logging.log4j.Logger;
9 9

  
......
27 27

  
28 28
        String diagramId = request.getParameter("diagramId");
29 29

  
30
        if (Strings.isNullOrEmpty(diagramId)) {
30
        if (StringUtils.isBlank(diagramId)) {
31 31
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
32 32
            logger.debug("Empty diagram id");
33 33
            return;
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3
import com.google.common.base.Strings;
4 3
import com.google.gson.Gson;
5
import com.google.gson.JsonObject;
6 4
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
7 5
import cz.zcu.kiv.offscreen.user.DB;
8 6
import cz.zcu.kiv.offscreen.user.Diagram;
7
import org.apache.commons.lang3.StringUtils;
9 8
import org.apache.logging.log4j.LogManager;
10 9
import org.apache.logging.log4j.Logger;
11 10

  
......
38 37
        String isPublic = request.getParameter("public");
39 38

  
40 39
        // input parameters are invalid
41
        if (Strings.isNullOrEmpty(name) || Strings.isNullOrEmpty(graphJson)) {
40
        if (StringUtils.isBlank(name) || StringUtils.isBlank(graphJson)) {
42 41
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
43 42
            logger.debug("Input name or json is empty");
44 43
            return;
......
47 46
        DB db = new DB(getServletContext());
48 47
        Diagram diagram;
49 48

  
50
        if (Strings.isNullOrEmpty(diagramId)) {
49
        if (StringUtils.isBlank(diagramId)) {
51 50
            logger.debug("Creating new diagram");
52 51
            diagram = new Diagram(db);
53 52

  
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/rest/RawInput.java
1 1
package cz.zcu.kiv.offscreen.servlets.rest;
2 2

  
3
import com.google.common.base.Strings;
4 3
import cz.zcu.kiv.offscreen.servlets.BaseServlet;
4
import org.apache.commons.lang3.StringUtils;
5 5
import org.apache.logging.log4j.LogManager;
6 6
import org.apache.logging.log4j.Logger;
7 7

  
......
23 23
        String diagram = request.getParameter("rawDiagram");
24 24
        String type = "raw";
25 25

  
26
        if (Strings.isNullOrEmpty(diagram)) {
26
        if (StringUtils.isBlank(diagram)) {
27 27
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
28 28
            logger.debug("Diagram json is empty");
29 29
            return;

Také k dispozici: Unified diff