diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..52a791d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ea0b3a9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index a45eb6b..add96f7 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -32,14 +32,12 @@ public class MavenWrapperDownloader { * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to * use instead of the default one. */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; /** * Path where the maven-wrapper.jar will be saved to. */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; + private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar"; /** * Name of the property which should be used to override the default download url for the wrapper. @@ -89,7 +87,7 @@ public static void main(String args[]) { System.out.println("Done"); System.exit(0); } catch (Throwable e) { - System.out.println("- Error downloading"); + System.out.println("-Error downloading"); e.printStackTrace(); System.exit(1); } @@ -111,8 +109,8 @@ protected PasswordAuthentication getPasswordAuthentication() { rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(destination); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); rbc.close(); + fos.close(); } } diff --git a/pom.xml b/pom.xml index 57f2dd1..afeabf1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,20 +6,20 @@ org.springframework.boot spring-boot-starter-parent - 2.5.7 + 3.0.4 com.uci utils - 2.2.5 + 2.2.6 utils Demo project for Spring Boot - 11 + 17 4.7.2 4.7.2 @@ -66,6 +66,19 @@ + + org.apache.logging.log4j + log4j-slf4j-impl + 2.14.1 + + + org.slf4j + slf4j-api + + + + + javax.ws.rs diff --git a/src/main/java/com/uci/utils/bot/util/BotUtil.java b/src/main/java/com/uci/utils/bot/util/BotUtil.java index b02ef83..713bda2 100644 --- a/src/main/java/com/uci/utils/bot/util/BotUtil.java +++ b/src/main/java/com/uci/utils/bot/util/BotUtil.java @@ -82,13 +82,13 @@ public static String getBotValid(String status, String startDate, String endDate * @return */ public static Boolean checkBotValidFromJsonNode(JsonNode data) { - String status = data.findValue("status").asText(); - String startDate = data.findValue("startDate").asText(); - String endDate = data.findValue("endDate").asText(); + String botstatus = data.findValue("status").asText(); + String botstartDate = data.findValue("startDate").asText(); + String botendDate = data.findValue("endDate").asText(); - log.info("Bot Status: "+status+", Start Date: "+startDate+", End Date: "+endDate); + log.info("Bot Status: "+botstatus+", Start Date: "+botstartDate+", End Date: "+botendDate); - return checkBotValid(status, startDate, endDate); + return checkBotValid(botstatus, botstartDate, botendDate); } /** @@ -99,14 +99,17 @@ public static Boolean checkBotValidFromJsonNode(JsonNode data) { * @return */ public static Boolean checkBotValid(String status, String startDate, String endDate) { - if(checkBotLiveStatus(status) && checkBotStartDateValid(startDate) - && checkBotEndDateValid(endDate) - && !(startDate == null || startDate == "null" || startDate.isEmpty())) { - return true; - } - return false; + boolean isBotValid = checkBotLiveStatus(status) && + checkBotStartDateValid(startDate) && + checkBotEndDateValid(endDate) && + startDate != null && + !startDate.equals("null") && + !startDate.isEmpty(); + + return isBotValid; } + /** * Check if bot' status is live/enabled * @param status diff --git a/src/main/java/com/uci/utils/bot/util/FileUtil.java b/src/main/java/com/uci/utils/bot/util/FileUtil.java index 77c5a09..d143655 100644 --- a/src/main/java/com/uci/utils/bot/util/FileUtil.java +++ b/src/main/java/com/uci/utils/bot/util/FileUtil.java @@ -114,13 +114,15 @@ public static String getUploadedFileName(String mimeType, String name) { * @return */ public static String validateFileSizeByInputBytes(byte[] inputBytes, Double maxSizeForMedia) { - /* Discard if file size is greater than MAX_SIZE_FOR_MEDIA */ if (maxSizeForMedia != null && inputBytes.length > maxSizeForMedia) { - return "file size is greater than limit : " + inputBytes.length; + String errorMessage = "File size is greater than the limit: " + inputBytes.length; + return errorMessage; } + return ""; } + /** * Function to get Mime type of file from url * @param url @@ -199,19 +201,29 @@ public static boolean isFileTypeDocument(String mime_type) { * @param mime_type * @return */ +// public static boolean isValidFileType(String mime_type) { +// ArrayList list = getImageFileTypes(); +// list.addAll(getAudioFileTypes()); +// list.addAll(getVideoFileTypes()); +// list.addAll(getDocumentFileTypes()); +// for(int i=0; i < list.size(); i++) { +// if(list.get(i).equals(mime_type)) { +// return true; +// } +// } +// return false; +// } public static boolean isValidFileType(String mime_type) { - ArrayList list = getImageFileTypes(); - list.addAll(getAudioFileTypes()); - list.addAll(getVideoFileTypes()); - list.addAll(getDocumentFileTypes()); - for(int i=0; i < list.size(); i++) { - if(list.get(i).equals(mime_type)) { - return true; - } - } - return false; + ArrayList validFileTypes = new ArrayList<>(); + validFileTypes.addAll(getImageFileTypes()); + validFileTypes.addAll(getAudioFileTypes()); + validFileTypes.addAll(getVideoFileTypes()); + validFileTypes.addAll(getDocumentFileTypes()); + + return validFileTypes.contains(mime_type); } - + + /** * Get Image file types list * @return