aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/ApplicationStatus.java35
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/Auth.java22
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/EmailOpts.java24
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/NotifyOpts.java34
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/PrivacyOpts.java29
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/PrivateChats.java22
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/ResponseReply.java72
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/TagStats.java29
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/UserInfo.java43
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java426
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/ProtocolListener.java13
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java33
-rw-r--r--juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java83
-rw-r--r--juick-server/src/main/java/com/juick/server/security/NotAuthorizedAuthenticationEntryPoint.java20
-rw-r--r--juick-server/src/main/java/com/juick/server/security/entities/AnonymousUser.java132
-rw-r--r--juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java74
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java15
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java16
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java15
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpUtils.java112
-rw-r--r--juick-server/src/main/java/com/juick/server/util/ImageUtils.java66
21 files changed, 0 insertions, 1315 deletions
diff --git a/juick-server/src/main/java/com/juick/server/helpers/ApplicationStatus.java b/juick-server/src/main/java/com/juick/server/helpers/ApplicationStatus.java
deleted file mode 100644
index 61109c47..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/ApplicationStatus.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.juick.server.helpers;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-/**
- * Created by vt on 03/09/16.
- */
-public class ApplicationStatus {
- private boolean connected;
- private boolean crosspostEnabled;
-
- @Override
- public String toString() {
- return new ToStringBuilder(this)
- .append("connected", connected)
- .append("crosspostEnabled", crosspostEnabled)
- .toString();
- }
-
- public boolean isConnected() {
- return connected;
- }
-
- public void setConnected(boolean connected) {
- this.connected = connected;
- }
-
- public boolean isCrosspostEnabled() {
- return crosspostEnabled;
- }
-
- public void setCrosspostEnabled(boolean crosspostEnabled) {
- this.crosspostEnabled = crosspostEnabled;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/Auth.java b/juick-server/src/main/java/com/juick/server/helpers/Auth.java
deleted file mode 100644
index 3e1f0bd9..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/Auth.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.juick.server.helpers;
-
-/**
- * Created by vt on 09/02/16.
- */
-public class Auth {
- private String account;
- private String authCode;
-
- public Auth(String account, String authCode) {
- this.account = account;
- this.authCode = authCode;
- }
-
- public String getAccount() {
- return account;
- }
-
- public String getAuthCode() {
- return authCode;
- }
-} \ No newline at end of file
diff --git a/juick-server/src/main/java/com/juick/server/helpers/EmailOpts.java b/juick-server/src/main/java/com/juick/server/helpers/EmailOpts.java
deleted file mode 100644
index 679d1a8d..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/EmailOpts.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.juick.server.helpers;
-
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * Created by vitalyster on 09.02.2016.
- */
-public class EmailOpts {
- private String email;
- private String subscriptionHour;
-
- public EmailOpts(String email, int subscriptionHour) {
- this.email = email;
- this.subscriptionHour = StringUtils.leftPad(String.format("%d", subscriptionHour), 2, "0");
- }
-
- public String getSubscriptionHour() {
- return subscriptionHour;
- }
-
- public String getEmail() {
- return email;
- }
-} \ No newline at end of file
diff --git a/juick-server/src/main/java/com/juick/server/helpers/NotifyOpts.java b/juick-server/src/main/java/com/juick/server/helpers/NotifyOpts.java
deleted file mode 100644
index 377b0a50..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/NotifyOpts.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.juick.server.helpers;
-
-/**
- * Created by vt on 03/09/16.
- */
-public class NotifyOpts {
- private boolean repliesEnabled;
- private boolean subscriptionsEnabled;
- private boolean recommendationsEnabled;
-
- public boolean isRepliesEnabled() {
- return repliesEnabled;
- }
-
- public void setRepliesEnabled(boolean repliesEnabled) {
- this.repliesEnabled = repliesEnabled;
- }
-
- public boolean isSubscriptionsEnabled() {
- return subscriptionsEnabled;
- }
-
- public void setSubscriptionsEnabled(boolean subscriptionsEnabled) {
- this.subscriptionsEnabled = subscriptionsEnabled;
- }
-
- public boolean isRecommendationsEnabled() {
- return recommendationsEnabled;
- }
-
- public void setRecommendationsEnabled(boolean recommendationsEnabled) {
- this.recommendationsEnabled = recommendationsEnabled;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/PrivacyOpts.java b/juick-server/src/main/java/com/juick/server/helpers/PrivacyOpts.java
deleted file mode 100644
index 66cf9410..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/PrivacyOpts.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.juick.server.helpers;
-
-/**
- * Created by vt on 16/01/16.
- */
-public class PrivacyOpts {
- private int uid;
- private int privacy;
-
- public PrivacyOpts() {
-
- }
-
- public int getUid() {
- return uid;
- }
-
- public void setUid(int uid) {
- this.uid = uid;
- }
-
- public int getPrivacy() {
- return privacy;
- }
-
- public void setPrivacy(int privacy) {
- this.privacy = privacy;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/PrivateChats.java b/juick-server/src/main/java/com/juick/server/helpers/PrivateChats.java
deleted file mode 100644
index b1bfccf8..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/PrivateChats.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.juick.server.helpers;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.juick.User;
-
-import java.util.List;
-
-/**
- * Created by vt on 24/11/2016.
- */
-public class PrivateChats {
- private List<User> users;
-
- @JsonProperty("pms")
- public List<User> getUsers() {
- return users;
- }
-
- public void setUsers(List<User> users) {
- this.users = users;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/ResponseReply.java b/juick-server/src/main/java/com/juick/server/helpers/ResponseReply.java
deleted file mode 100644
index f941c743..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/ResponseReply.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.juick.server.helpers;
-
-import java.util.Date;
-
-/**
- * Created by vitalyster on 13.12.2016.
- */
-public class ResponseReply {
- private String muname;
- private int mid;
- private int rid;
- private String uname;
- private String description;
- private Date pubDate;
- private String attachmentType;
-
- public String getMuname() {
- return muname;
- }
-
- public void setMuname(String muname) {
- this.muname = muname;
- }
-
- public int getMid() {
- return mid;
- }
-
- public void setMid(int mid) {
- this.mid = mid;
- }
-
- public int getRid() {
- return rid;
- }
-
- public void setRid(int rid) {
- this.rid = rid;
- }
-
- public String getUname() {
- return uname;
- }
-
- public void setUname(String uname) {
- this.uname = uname;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getPubDate() {
- return pubDate;
- }
-
- public void setPubDate(Date pubDate) {
- this.pubDate = pubDate;
- }
-
- public String getAttachmentType() {
- return attachmentType;
- }
-
- public void setAttachmentType(String attachmentType) {
- this.attachmentType = attachmentType;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/TagStats.java b/juick-server/src/main/java/com/juick/server/helpers/TagStats.java
deleted file mode 100644
index e8720991..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/TagStats.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.juick.server.helpers;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.juick.Tag;
-
-/**
- * Created by vitalyster on 01.12.2016.
- */
-public class TagStats {
- private Tag tag;
- private int usageCount;
-
- public Tag getTag() {
- return tag;
- }
-
- public void setTag(Tag tag) {
- this.tag = tag;
- }
-
- @JsonProperty("messages")
- public int getUsageCount() {
- return usageCount;
- }
-
- public void setUsageCount(int usageCount) {
- this.usageCount = usageCount;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/UserInfo.java b/juick-server/src/main/java/com/juick/server/helpers/UserInfo.java
deleted file mode 100644
index 5a4b6894..00000000
--- a/juick-server/src/main/java/com/juick/server/helpers/UserInfo.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.juick.server.helpers;
-
-/**
- * Created by vt on 03/09/16.
- */
-public class UserInfo {
- private String fullName;
- private String country;
- private String url;
- private String description;
-
- public String getFullName() {
- return fullName;
- }
-
- public void setFullName(String fullName) {
- this.fullName = fullName;
- }
-
- public String getCountry() {
- return country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
deleted file mode 100644
index ef8641f8..00000000
--- a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ /dev/null
@@ -1,426 +0,0 @@
-package com.juick.server.protocol;
-
-import com.juick.Message;
-import com.juick.Tag;
-import com.juick.User;
-import com.juick.formatters.PlainTextFormatter;
-import com.juick.server.helpers.TagStats;
-import com.juick.server.protocol.annotation.UserCommand;
-import com.juick.service.*;
-import com.juick.util.TagUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.math.NumberUtils;
-import org.apache.commons.lang3.reflect.MethodUtils;
-
-import javax.inject.Inject;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-/**
- * Created by oxpa on 22.03.16.
- */
-
-public class JuickProtocol {
-
- private String baseUri;
- private ProtocolListener listener;
-
- @Inject
- UserService userService;
- @Inject
- TagService tagService;
- @Inject
- MessagesService messagesService;
- @Inject
- SubscriptionService subscriptionService;
- @Inject
- PMQueriesService pmQueriesService;
- @Inject
- PrivacyQueriesService privacyQueriesService;
- @Inject
- ShowQueriesService showQueriesService;
-
- public JuickProtocol(String baseUri) {
- this.baseUri = baseUri;
- }
-
- /**
- * find command by pattern and invoke
- * @param user who send command
- * @param userInput given by user
- * @return command result
- * @throws InvocationTargetException
- * @throws IllegalAccessException
- * @throws NoSuchMethodException
- */
- public String getReply(User user, String userInput) throws InvocationTargetException,
- IllegalAccessException, NoSuchMethodException {
- Optional<Method> cmd = MethodUtils.getMethodsListWithAnnotation(getClass(), UserCommand.class).stream()
- .filter(m -> Pattern.compile(m.getAnnotation(UserCommand.class).pattern(),
- m.getAnnotation(UserCommand.class).patternFlags()).matcher(userInput).matches())
- .findFirst();
- if (!cmd.isPresent()) {
- // default command - post as new message
- return postMessage(user, userInput.trim());
- } else {
- Matcher matcher = Pattern.compile(cmd.get().getAnnotation(UserCommand.class).pattern(),
- cmd.get().getAnnotation(UserCommand.class).patternFlags()).matcher(userInput.trim());
- List<String> groups = new ArrayList<>();
- while (matcher.find()) {
- for (int i = 1; i <= matcher.groupCount(); i++) {
- groups.add(matcher.group(i));
- }
- }
- return (String) getClass().getMethod(cmd.get().getName(), User.class, String[].class)
- .invoke(this, user, groups.toArray(new String[groups.size()]));
- }
- }
-
- public String postMessage(User user, String input) {
- List<Tag> tags = tagService.fromString(input, false);
- String body = input.substring(TagUtils.toString(tags).length());
- int mid = messagesService.createMessage(user.getUid(), body, null, tags);
- subscriptionService.subscribeMessage(mid, user.getUid());
- listener.messagePosted(messagesService.getMessage(mid));
- return "New message posted.\n#" + mid + " " + baseUri + mid;
- }
-
- @UserCommand(pattern = "^#\\+$", help = "#+ - Show last Juick messages")
- public String commandLast(User user, String... arguments) {
- List<Integer> mids = messagesService.getAll(user.getUid(), 0);
- List<Message> messages = messagesService.getMessages(mids);
- return "Last messages: \n"
- + messages.stream().sorted(Collections.reverseOrder()).map(PlainTextFormatter::formatPostSummary)
- .collect(Collectors.joining("\n\n"));
- }
-
- @UserCommand(pattern = "^bl$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "BL - Show your blacklist")
- public String commandBL(User user_from, String... arguments) {
- List<User> blusers;
- List<String> bltags;
-
- blusers = userService.getUserBLUsers(user_from.getUid());
- bltags = tagService.getUserBLTags(user_from.getUid());
-
-
- String txt = StringUtils.EMPTY;
- if (bltags.size() > 0) {
- for (String bltag : bltags) {
- txt += "*" + bltag + "\n";
- }
-
- if (blusers.size() > 0) {
- txt += "\n";
- }
- }
- if (blusers.size() > 0) {
- for (User bluser : blusers) {
- txt += "@" + bluser.getName() + "\n";
- }
- }
- if (txt.isEmpty()) {
- txt = "You don't have any users or tags in your blacklist.";
- }
- return txt;
- }
-
- @UserCommand(pattern = "^bl\\s+@([^\\s\\n\\+]+)", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "BL @username - add @username to your blacklist")
- public String blacklistUser(User from, String... arguments) {
- User blUser = userService.getUserByName(arguments[0]);
- if (blUser != null) {
- PrivacyQueriesService.PrivacyResult result = privacyQueriesService.blacklistUser(from, blUser);
- if (result == PrivacyQueriesService.PrivacyResult.Added) {
- return "User added to your blacklist";
- } else {
- return "User removed from your blacklist";
- }
- }
- return "User not found";
- }
-
- @UserCommand(pattern = "^bl\\s\\*(\\S+)$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "BL *tag - add *tag to your blacklist")
- public String blacklistTag(User from, String... arguments) {
- User blUser = userService.getUserByName(arguments[0]);
- if (blUser != null) {
- Tag tag = tagService.getTag(arguments[0], false);
- if (tag != null) {
- PrivacyQueriesService.PrivacyResult result = privacyQueriesService.blacklistTag(from, tag);
- if (result == PrivacyQueriesService.PrivacyResult.Added) {
- return "Tag added to your blacklist";
- } else {
- return "Tag removed from your blacklist";
- }
- }
- }
- return "Tag not found";
- }
-
- @UserCommand(pattern = "@", help = "@ - Show recommendations and popular personal blogs")
- public String commandUsers(User currentUser, String... args) {
- StringBuilder msg = new StringBuilder();
- msg.append("Recommended blogs");
- List<String> recommendedUsers = showQueriesService.getRecommendedUsers(currentUser);
- if (recommendedUsers.size() > 0) {
- for (String user : recommendedUsers) {
- msg.append("\n@").append(user);
- }
- } else {
- msg.append("\nNo recommendations now. Subscribe to more blogs. ;)");
- }
- msg.append("\n\nTop 10 personal blogs:");
- List<String> topUsers = showQueriesService.getTopUsers();
- if (topUsers.size() > 0) {
- for (String user : topUsers) {
- msg.append("\n@").append(user);
- }
- } else {
- msg.append("\nNo top users. Empty DB? ;)");
- }
- return msg.toString();
- }
-
- @UserCommand(pattern = "\\*", help = "* - Show your tags")
- public String commandTags(User currentUser, String... args) {
- List<TagStats> tags = tagService.getUserTagStats(currentUser.getUid());
- String msg = "Your tags: (tag - messages)\n" +
- tags.stream()
- .map(t -> String.format("\n*%s - %d", t.getTag().getName(), t.getUsageCount())).collect(Collectors.joining());
- return msg;
- }
-
- @UserCommand(pattern = "S", help = "S - Show your subscriptions")
- public String commandSubscriptions(User currentUser, String... args) {
- List<User> friends = userService.getUserFriends(currentUser.getUid());
- List<String> tags = subscriptionService.getSubscribedTags(currentUser);
- String msg = friends.size() > 0 ? "You are subscribed to users:" + friends.stream().map(u -> "\n@" + u.getName())
- .collect(Collectors.joining())
- : "You are not subscribed to any user.";
- msg += tags.size() > 0 ? "\nYou are subscribed to tags:" + tags.stream().map(t -> "\n*" + t)
- .collect(Collectors.joining())
- : "\nYou are not subscribed to any tag.";
- return msg;
- }
-
- @UserCommand(pattern = "!", help = "! - Show your favorite messages")
- public String commandFavorites(User currentUser, String... args) {
- List<Integer> mids = messagesService.getUserRecommendations(currentUser.getUid(), 0);
- if (mids.size() > 0) {
- List<Message> messages = messagesService.getMessages(mids);
- return "Favorite messages: \n" + String.join("\n", messages.stream().map(PlainTextFormatter::formatPost)
- .collect(Collectors.toList()));
- }
- return "No favorite messages, try to \"like\" something ;)";
- }
-
- @UserCommand(pattern = "^\\@([^\\s\\n\\+]+)(\\+?)$",
- help = "@username+ - Show user's info and last 10 messages (@username++ - second page, ..)")
- public String commandUser(User user, String... arguments) {
- User blogUser = userService.getUserByName(arguments[0]);
- int page = arguments[1].length();
- if (blogUser.getUid() > 0) {
- List<Integer> mids = messagesService.getUserBlog(blogUser.getUid(), 0, page);
- List<Message> messages = messagesService.getMessages(mids);
- return String.format("Last messages from @%s:\n%s", arguments[0],
- String.join("\n", messages.stream()
- .map(PlainTextFormatter::formatPost).collect(Collectors.toList())));
- }
- return "User not found";
- }
-
- @UserCommand(pattern = "^d\\s*\\#([0-9]+)$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "D #12345 - delete the message")
- public String commandDel(User user, String... args) {
- int mid = NumberUtils.toInt(args[0], 0);
- if (messagesService.deleteMessage(user.getUid(), mid)) {
- return String.format("Message %s deleted", mid);
- }
- return "Error";
- }
-
- @UserCommand(pattern = "^login$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "LOGIN - log in to Juick website")
- public String commandLogin(User user, String... arguments) {
- return baseUri + "?" + userService.getHashByUID(user.getUid());
- }
-
- @UserCommand(pattern = "^(#+)$", help = "# - Show last messages from your feed (## - second page, ...)")
- public String commandMyFeed(User user, String... arguments) {
- // number of # is the page count
- int page = arguments[0].length() - 1;
- List<Integer> mids = messagesService.getMyFeed(user.getUid(), page);
- List<Message> messages = messagesService.getMessages(mids);
- // TODO: add instructions for empty feed
- return "Your feed: \n" + String.join("\n",
- messages.stream().map(PlainTextFormatter::formatPost).collect(Collectors.toList()));
- }
-
- @UserCommand(pattern = "^(on|off)$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "ON/OFF - Enable/disable subscriptions delivery")
- public String commandOnOff(User user, String[] input) {
- UserService.ActiveStatus newStatus;
- String retValUpdated;
- if (input[0].toLowerCase().equals("on")) {
- newStatus = UserService.ActiveStatus.Active;
- retValUpdated = "Notifications are activated for " + user.getJid();
- } else {
- newStatus = UserService.ActiveStatus.Inactive;
- retValUpdated = "Notifications are disabled for " + user.getJid();
- }
-
- if (userService.setActiveStatusForJID(user.getJid(), newStatus)) {
- return retValUpdated;
- } else {
- return String.format("Subscriptions status for %s was not changed", user.getJid());
- }
- }
-
- @UserCommand(pattern = "^ping$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "PING - returns you a PONG")
- public String commandPing(User user, String[] input) {
- return "PONG";
- }
-
- @UserCommand(pattern = "^\\@(\\S+)\\s+([\\s\\S]+)$", help = "@username message - send PM to username")
- public String commandPM(User user_from, String... arguments) {
- String user_to = arguments[0];
- String body = arguments[1];
-
- User toUser = userService.getUserByName(user_to);
-
- if (toUser.getUid() > 0) {
- if (!userService.isInBLAny(toUser.getUid(), user_from.getUid())) {
- if (pmQueriesService.createPM(user_from.getUid(), toUser.getUid(), body)) {
- listener.privateMessage(user_from, toUser, body);
- return "Private message sent";
- }
- }
- }
- return "Error";
- }
-
- @UserCommand(pattern = "^#(\\d+)(\\+?)$", help = "#1234 - Show message (#1234+ - message with replies)")
- public String commandShow(User user, String... arguments) {
- boolean showReplies = arguments[1].length() > 0;
- int mid = NumberUtils.toInt(arguments[0], 0);
- if (mid == 0) {
- return "Error";
- }
- Message msg = messagesService.getMessage(mid);
- if (msg != null) {
- if (showReplies) {
- List<Message> replies = messagesService.getReplies(mid);
- replies.add(0, msg);
- return String.join("\n",
- replies.stream().map(PlainTextFormatter::formatPost).collect(Collectors.toList()));
- }
- return PlainTextFormatter.formatPost(msg);
- }
- return "Message not found";
- }
- @UserCommand(pattern = "^(#|\\.)(\\d+)((\\.|\\-|\\/)(\\d+))?\\s([\\s\\S]+)",
- help = "#1234 *tag *tag2 - edit tags\n#1234 text - reply to message")
- public String EditOrReply(User user, String... args) {
- int mid = NumberUtils.toInt(args[1]);
- int rid = NumberUtils.toInt(args[4], 0);
- String txt = args[5];
- List<Tag> messageTags = tagService.fromString(txt, true);
- if (messageTags.size() > 0) {
- if (user.getUid() != messagesService.getMessageAuthor(mid).getUid()) {
- return "It is not your message";
- }
- tagService.updateTags(mid, messageTags);
- return "Tags are updated";
- } else {
- int newrid = messagesService.createReply(mid, rid, user.getUid(), txt, null);
- listener.messagePosted(messagesService.getReply(mid, newrid));
- return "Reply posted.\n#" + mid + "/" + newrid + " "
- + baseUri + mid + "#" + newrid;
- }
- }
-
- @UserCommand(pattern = "^(s|u)\\s+#(\\d+)$", help = "S #1234 - subscribe to comments",
- patternFlags = Pattern.CASE_INSENSITIVE)
- public String commandSubscribeMessage(User user, String... args) {
- boolean subscribe = args[0].equalsIgnoreCase("s");
- int mid = NumberUtils.toInt(args[1], 0);
- if (messagesService.getMessage(mid) != null) {
- if (subscribe) {
- if (subscriptionService.subscribeMessage(mid, user.getUid())) {
- return "Subscribed";
- }
- } else {
- if (subscriptionService.unSubscribeMessage(mid, user.getUid())) {
- return "Unsubscribed from #" + mid;
- }
- return "You was not subscribed to #" + mid;
- }
- }
- return "Error";
- }
- @UserCommand(pattern = "^(s|u)\\s+\\@(\\S+)$", help = "S @user - subscribe to user's posts",
- patternFlags = Pattern.CASE_INSENSITIVE)
- public String commandSubscribeUser(User user, String... args) {
- boolean subscribe = args[0].equalsIgnoreCase("s");
- User toUser = userService.getUserByName(args[1]);
- if (toUser.getUid() > 0) {
- if (subscribe) {
- if (subscriptionService.subscribeUser(user, toUser)) {
- listener.userSubscribed(user, toUser);
- return "Subscribed";
- // TODO: already subscribed case
- }
- } else {
- if (subscriptionService.unSubscribeUser(user, toUser)) {
- return "Unsubscribed from @" + toUser.getName();
- }
- return "You was not subscribed to @" + toUser.getName();
- }
- }
- return "Error";
- }
- @UserCommand(pattern = "^(s|u)\\s+\\*(\\S+)$", help = "S *tag - subscribe to tag" +
- "\nU *tag - unsubscribe from tag", patternFlags = Pattern.CASE_INSENSITIVE)
- public String commandSubscribeTag(User user, String... args) {
- boolean subscribe = args[0].equalsIgnoreCase("s");
- Tag tag = tagService.getTag(args[1], true);
- if (subscribe) {
- if (subscriptionService.subscribeTag(user, tag)) {
- return "Subscribed";
- }
- } else {
- if (subscriptionService.unSubscribeTag(user, tag)) {
- return "Unsubscribed from " + tag.getName();
- }
- return "You was not subscribed to " + tag.getName();
- }
- return "Error";
- }
-
- @UserCommand(pattern = "^help$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "HELP - returns this help message")
- public String commandHelp(User user, String[] input) {
- return Arrays.stream(getClass().getDeclaredMethods())
- .filter(m -> m.isAnnotationPresent(UserCommand.class))
- .map(m -> m.getAnnotation(UserCommand.class).help())
- .collect(Collectors.joining("\n"));
- }
-
- public String getBaseUri() {
- return baseUri;
- }
-
- public ProtocolListener getListener() {
- return listener;
- }
-
- public void setListener(ProtocolListener listener) {
- this.listener = listener;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/protocol/ProtocolListener.java b/juick-server/src/main/java/com/juick/server/protocol/ProtocolListener.java
deleted file mode 100644
index 11231e04..00000000
--- a/juick-server/src/main/java/com/juick/server/protocol/ProtocolListener.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.juick.server.protocol;
-
-import com.juick.Message;
-import com.juick.User;
-
-/**
- * Created by vitalyster on 19.12.2016.
- */
-public interface ProtocolListener {
- void privateMessage(User from, User to, String body);
- void userSubscribed(User from, User to);
- void messagePosted(Message msg);
-}
diff --git a/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java b/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java
deleted file mode 100644
index 42a9bb59..00000000
--- a/juick-server/src/main/java/com/juick/server/protocol/annotation/UserCommand.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.juick.server.protocol.annotation;
-
-import org.apache.commons.lang3.StringUtils;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Created by oxpa on 22.03.16.
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface UserCommand {
- /**
- *
- * @return a command pattern
- */
- String pattern() default StringUtils.EMPTY;
-
- /**
- *
- * @return pattern flags
- */
- int patternFlags() default 0;
-
- /**
- *
- * @return a string used in HELP command output. Basically, only 1 string
- */
- String help() default StringUtils.EMPTY;
-}
diff --git a/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java b/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java
deleted file mode 100644
index b384a8c8..00000000
--- a/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.juick.server.security;
-
-import com.juick.User;
-import com.juick.server.security.entities.JuickUser;
-import com.juick.service.UserService;
-import org.springframework.security.authentication.AnonymousAuthenticationToken;
-import org.springframework.security.authentication.RememberMeAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.web.authentication.RememberMeServices;
-import org.springframework.util.Assert;
-import org.springframework.web.filter.OncePerRequestFilter;
-import org.springframework.web.util.WebUtils;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * Created by aalexeev on 4/5/17.
- */
-public class HashParamAuthenticationFilter extends OncePerRequestFilter {
- public static final String PARAM_NAME = "hash";
-
- private final UserService userService;
- private final RememberMeServices rememberMeServices;
-
-
- public HashParamAuthenticationFilter(
- final UserService userService,
- final RememberMeServices rememberMeServices) {
- Assert.notNull(userService, "userService should not be null");
- Assert.notNull(rememberMeServices, "rememberMeServices should not be null");
-
- this.userService = userService;
- this.rememberMeServices = rememberMeServices;
- }
-
- @Override
- protected void doFilterInternal(
- HttpServletRequest request,
- HttpServletResponse response,
- FilterChain filterChain) throws ServletException, IOException {
-
- String hash = getHashFromRequest(request);
-
- if (hash != null && authenticationIsRequired()) {
- User user = userService.getUserByHash(hash);
-
- if (!user.isAnonymous()) {
- Authentication authentication = new RememberMeAuthenticationToken(
- hash, new JuickUser(user), JuickUser.USER_AUTHORITY);
-
- SecurityContextHolder.getContext().setAuthentication(authentication);
-
- rememberMeServices.loginSuccess(request, response, authentication);
- }
- }
-
- filterChain.doFilter(request, response);
- }
-
- private boolean authenticationIsRequired() {
- Authentication existingAuth = SecurityContextHolder.getContext().getAuthentication();
-
- return existingAuth == null ||
- !existingAuth.isAuthenticated() ||
- existingAuth instanceof AnonymousAuthenticationToken;
- }
-
- private String getHashFromRequest(HttpServletRequest request) {
- String paramHash = request.getParameter(PARAM_NAME);
- Cookie cookieHash = WebUtils.getCookie(request, PARAM_NAME);
-
- if (paramHash == null && cookieHash != null) {
- return cookieHash.getValue();
- }
- return paramHash;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/security/NotAuthorizedAuthenticationEntryPoint.java b/juick-server/src/main/java/com/juick/server/security/NotAuthorizedAuthenticationEntryPoint.java
deleted file mode 100644
index d9dc6d61..00000000
--- a/juick-server/src/main/java/com/juick/server/security/NotAuthorizedAuthenticationEntryPoint.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.juick.server.security;
-
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.web.AuthenticationEntryPoint;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * Created by vitalyster on 25.11.2016.
- */
-public class NotAuthorizedAuthenticationEntryPoint implements AuthenticationEntryPoint {
- @Override
- public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
- throws IOException, ServletException {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/security/entities/AnonymousUser.java b/juick-server/src/main/java/com/juick/server/security/entities/AnonymousUser.java
deleted file mode 100644
index 5ee9527f..00000000
--- a/juick-server/src/main/java/com/juick/server/security/entities/AnonymousUser.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package com.juick.server.security.entities;
-
-import com.juick.User;
-
-/**
- * Created by aalexeev on 12/11/16.
- */
-public final class AnonymousUser extends User {
- public static final AnonymousUser INSTANCE = new AnonymousUser();
-
- private AnonymousUser() {
- super.setUid(getUid());
- super.setName(getName());
- super.setAvatar(getAvatar());
- super.setFullName(getFullName());
- super.setJid(getJid());
- super.setMessagesCount(getMessagesCount());
- super.setAuthHash(getAuthHash());
- super.setBanned(isBanned());
- super.setCredentials(getCredentials());
- super.setLang(getLang());
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj == this || obj instanceof AnonymousUser;
- }
-
- @Override
- public int getUid() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "Anonymous";
- }
-
- @Override
- public String getFullName() {
- return getName();
- }
-
- @Override
- public String getJid() {
- return "anonym@localhost";
- }
-
- @Override
- public String getAuthHash() {
- return null;
- }
-
- @Override
- public Integer getUnreadCount() {
- return 0;
- }
-
- @Override
- public boolean isBanned() {
- return false;
- }
-
- @Override
- public Object getAvatar() {
- return null;
- }
-
- @Override
- public String getCredentials() {
- return null;
- }
-
- @Override
- public String getLang() {
- return "__";
- }
-
- @Override
- public int getMessagesCount() {
- return 0;
- }
-
- @Override
- public boolean isAnonymous() {
- return true;
- }
-
- @Override
- public void setUid(int uid) {
- }
-
- @Override
- public void setName(String name) {
- }
-
- @Override
- public void setFullName(String fullName) {
- }
-
- @Override
- public void setJid(String jid) {
- }
-
- @Override
- public void setAuthHash(String authHash) {
- }
-
- @Override
- public void setUnreadCount(Integer count) {
- }
-
- @Override
- public void setBanned(boolean banned) {
- }
-
- @Override
- public void setAvatar(Object avatar) {
- }
-
- @Override
- public void setCredentials(String credentials) {
- }
-
- @Override
- public void setLang(String lang) {
- }
-
- @Override
- public void setMessagesCount(int messagesCount) {
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java b/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java
deleted file mode 100644
index b86d94dd..00000000
--- a/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.juick.server.security.entities;
-
-import com.juick.User;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetails;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Created by aalexeev on 11/21/16.
- */
-public class JuickUser implements UserDetails {
- static final GrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER");
- static final GrantedAuthority ROLE_ANONYMOUS = new SimpleGrantedAuthority("ROLE_ANONYMOUS");
-
- public static final List<GrantedAuthority> USER_AUTHORITY = Collections.singletonList(ROLE_USER);
- public static final List<GrantedAuthority> ANONYMOUS_AUTHORITY = Collections.singletonList(ROLE_ANONYMOUS);
-
- public static final JuickUser ANONYMOUS_USER = new JuickUser(AnonymousUser.INSTANCE, ANONYMOUS_AUTHORITY);
-
- private final com.juick.User user;
- private final Collection<? extends GrantedAuthority> authorities;
-
- public JuickUser(com.juick.User user) {
- this(user, USER_AUTHORITY);
- }
-
- public JuickUser(com.juick.User user, Collection<? extends GrantedAuthority> authorities) {
- this.user = user;
- this.authorities = authorities;
- }
-
- @Override
- public Collection<? extends GrantedAuthority> getAuthorities() {
- return authorities;
- }
-
- @Override
- public String getPassword() {
- return user.getCredentials();
- }
-
- @Override
- public String getUsername() {
- return user.getName();
- }
-
- @Override
- public boolean isAccountNonExpired() {
- return true;
- }
-
- @Override
- public boolean isAccountNonLocked() {
- return true;
- }
-
- @Override
- public boolean isCredentialsNonExpired() {
- return true;
- }
-
- @Override
- public boolean isEnabled() {
- return !user.isBanned();
- }
-
- public User getUser() {
- return user;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java b/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java
deleted file mode 100644
index 1ba1aecb..00000000
--- a/juick-server/src/main/java/com/juick/server/util/HttpBadRequestException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.juick.server.util;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Created by vt on 24/11/2016.
- */
-@ResponseStatus(value = HttpStatus.BAD_REQUEST)
-public class HttpBadRequestException extends RuntimeException {
- public HttpBadRequestException() {
- super(StringUtils.EMPTY, null, false, false);
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java b/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java
deleted file mode 100644
index 733453ba..00000000
--- a/juick-server/src/main/java/com/juick/server/util/HttpForbiddenException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.juick.server.util;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Created by vt on 24/11/2016.
- */
-@ResponseStatus(value = HttpStatus.FORBIDDEN)
-public class HttpForbiddenException extends RuntimeException {
- public HttpForbiddenException() {
- super(StringUtils.EMPTY, null, false, false);
- }
-
-}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java b/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java
deleted file mode 100644
index 942d90e2..00000000
--- a/juick-server/src/main/java/com/juick/server/util/HttpNotFoundException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.juick.server.util;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Created by vt on 24/11/2016.
- */
-@ResponseStatus(value = HttpStatus.NOT_FOUND)
-public class HttpNotFoundException extends RuntimeException {
- public HttpNotFoundException() {
- super(StringUtils.EMPTY, null, false, false);
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
deleted file mode 100644
index 31a68962..00000000
--- a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.server.util;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.UUID;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class HttpUtils {
- private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
-
- public static String receiveMultiPartFile(MultipartFile attach, String tmpDir) {
- if (attach !=null && !attach.isEmpty()) {
- String partname = attach.getOriginalFilename();
- if (partname != null && partname.length() > 0) {
- String attachmentType = partname.substring(partname.length() - 3).toLowerCase();
- if (attachmentType.equals("jpg") || attachmentType.equals("peg") || attachmentType.equals("png")) {
- if (attachmentType.equals("peg")) {
- attachmentType = "jpg";
- }
- String attachmentFName = DigestUtils.md5Hex(UUID.randomUUID().toString()) + "." + attachmentType;
- try {
- Files.write(Paths.get(tmpDir, attachmentFName),
- attach.getBytes());
- return attachmentFName;
- } catch (IOException e) {
- logger.warn("file receive error", e);
- }
- }
- }
- }
- return StringUtils.EMPTY;
- }
- public static String downloadImage(URL url, String tmpDir) throws Exception {
- String attachmentFName = null;
- Exception ex = null;
-
- InputStream is = null;
- FileOutputStream fos = null;
- try {
- URLConnection urlConn = url.openConnection();
- is = urlConn.getInputStream();
- String mime = urlConn.getContentType();
-
- String attachmentType;
- if (mime != null && mime.equals("image/jpeg")) {
- attachmentType = "jpg";
- } else if (mime != null && mime.equals("image/png")) {
- attachmentType = "png";
- } else {
- throw new Exception("Wrong file type");
- }
-
- attachmentFName = DigestUtils.md5Hex(UUID.randomUUID().toString()) + "." + attachmentType;
- fos = new FileOutputStream(Paths.get(tmpDir, attachmentFName).toString());
- byte[] buffer = new byte[10240];
- int len;
- while ((len = is.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- } catch (Exception e) {
- ex = e;
- attachmentFName = null;
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } finally {
- if (fos != null) {
- fos.close();
- }
- }
- }
-
- if (ex != null) {
- throw ex;
- } else {
- return attachmentFName;
- }
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/util/ImageUtils.java b/juick-server/src/main/java/com/juick/server/util/ImageUtils.java
deleted file mode 100644
index 61677750..00000000
--- a/juick-server/src/main/java/com/juick/server/util/ImageUtils.java
+++ /dev/null
@@ -1,66 +0,0 @@
-
-package com.juick.server.util;
-
-import org.apache.commons.io.FilenameUtils;
-import org.imgscalr.Scalr;
-
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-
-public class ImageUtils {
-
- /**
- * Move attached image from temp folder to image folder.
- * Create preview images in corresponding folders.
- *
- * @param tempFilename Name of the image file in temp folder.
- * @param outputFilename Name that will be used in in image folder.
- * @param tmpDir Path string for the temp folder.
- * @param imgDir Path string for the image folder.
- */
- public static void saveImageWithPreviews(String tempFilename, String outputFilename, String tmpDir, String imgDir)
- throws IOException {
- String ext = FilenameUtils.getExtension(outputFilename);
-
- Path outputImagePath = Paths.get(imgDir, "p", outputFilename);
- Files.move(Paths.get(tmpDir, tempFilename), outputImagePath);
- BufferedImage originalImage = ImageIO.read(outputImagePath.toFile());
-
- int width = originalImage.getWidth();
- int height = originalImage.getHeight();
- int maxDimension = (width > height) ? width : height;
- BufferedImage image1024 = (maxDimension > 1024) ? Scalr.resize(originalImage, 1024) : originalImage;
- BufferedImage image0512 = (maxDimension > 512) ? Scalr.resize(originalImage, 512) : originalImage;
- BufferedImage image0160 = (maxDimension > 160) ? Scalr.resize(originalImage, 160) : originalImage;
- ImageIO.write(image1024, ext, Paths.get(imgDir, "photos-1024", outputFilename).toFile());
- ImageIO.write(image0512, ext, Paths.get(imgDir, "photos-512", outputFilename).toFile());
- ImageIO.write(image0160, ext, Paths.get(imgDir, "ps", outputFilename).toFile());
- }
-
- /**
- * Save new avatar in all required sizes.
- *
- * @param tempFilename Name of the image file in temp folder.
- * @param uid User id that is used to build image file names.
- * @param tmpDir Path string for the temp folder.
- * @param imgDir Path string for the image folder.
- */
- public static void saveAvatar(String tempFilename, int uid, String tmpDir, String imgDir)
- throws IOException {
- String ext = FilenameUtils.getExtension(tempFilename);
- String originalName = String.format("%s.%s", uid, ext);
- Path originalPath = Paths.get(imgDir, "ao", originalName);
- Files.move(Paths.get(tmpDir, tempFilename), originalPath, StandardCopyOption.REPLACE_EXISTING);
- BufferedImage originalImage = ImageIO.read(originalPath.toFile());
-
- String targetExt = "png";
- String targetName = String.format("%s.%s", uid, targetExt);
- ImageIO.write(Scalr.resize(originalImage, 96), targetExt, Paths.get(imgDir, "a", targetName).toFile());
- ImageIO.write(Scalr.resize(originalImage, 32), targetExt, Paths.get(imgDir, "as", targetName).toFile());
- }
-} \ No newline at end of file