diff options
author | Vitaly Takmazov | 2018-02-18 01:07:19 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-02-18 01:07:19 +0300 |
commit | 69e7a6af07742a075716fa9c30087c68170f6dc6 (patch) | |
tree | b76672c35b036a0b006dce096ec817e03e4c4b44 | |
parent | bfab7023d8e635de6189e0f2bea6dad2c8ddd7b6 (diff) |
server: merge rss
18 files changed, 75 insertions, 193 deletions
diff --git a/juick-rss/build.gradle b/juick-rss/build.gradle deleted file mode 100644 index 44f2334e..00000000 --- a/juick-rss/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: 'java' -apply plugin: 'war' -apply plugin: 'org.akhikhl.gretty' - -dependencies { - compile project(':juick-server-jdbc') - compile project(':juick-server-web') - compile 'com.rometools:rome:1.9.0' - compile 'com.rometools:rome-modules:1.9.0' - providedRuntime 'mysql:mysql-connector-java:5.1.40' - - testCompile "junit:junit:${rootProject.junitVersion}" - testCompile "org.hamcrest:hamcrest-all:${rootProject.hamcrestVersion}" - testCompile "org.mockito:mockito-core:${rootProject.mockitoVersion}" - testCompile "org.springframework:spring-test:${rootProject.springFrameworkVersion}" -} - -compileJava.options.encoding = 'UTF-8' - -gretty { - httpPort = 8080 - contextPath = '/' - servletContainer = 'tomcat8' -} - -configurations { - all*.exclude module: 'commons-logging' -} diff --git a/juick-rss/src/main/java/com/juick/rss/configuration/RssAppConfiguration.java b/juick-rss/src/main/java/com/juick/rss/configuration/RssAppConfiguration.java deleted file mode 100644 index 2069b14e..00000000 --- a/juick-rss/src/main/java/com/juick/rss/configuration/RssAppConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * 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.rss.configuration; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; - -import javax.inject.Inject; - -/** - * Created by aalexeev on 11/12/16. - */ -@Configuration -@PropertySource("classpath:juick.conf") -public class RssAppConfiguration { - @Inject - private Environment env; -} diff --git a/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java b/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java deleted file mode 100644 index 617da288..00000000 --- a/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * 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.rss.configuration; - -import org.apache.commons.codec.CharEncoding; -import org.springframework.web.filter.CharacterEncodingFilter; -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -import javax.servlet.Filter; - -/** - * Created by vt on 09/02/16. - */ -public class RssInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class<?>[] getRootConfigClasses() { - return new Class<?>[]{RssAppConfiguration.class}; - } - - @Override - protected Class<?>[] getServletConfigClasses() { - return new Class<?>[]{RssMvcConfiguration.class}; - } - - @Override - protected String[] getServletMappings() { - return new String[]{"/"}; - } - - @Override - protected Filter[] getServletFilters() { - CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8); - return new Filter[]{characterEncodingFilter}; - } - - @Override - protected String getServletName() { - return "RSS dispatcher servlet"; - } -} diff --git a/juick-rss/src/main/java/com/juick/rss/configuration/RssMvcConfiguration.java b/juick-rss/src/main/java/com/juick/rss/configuration/RssMvcConfiguration.java deleted file mode 100644 index c9d69f99..00000000 --- a/juick-rss/src/main/java/com/juick/rss/configuration/RssMvcConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * 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.rss.configuration; - -import com.juick.rss.MessagesView; -import com.juick.rss.RepliesView; -import com.juick.server.configuration.BaseWebConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.view.BeanNameViewResolver; -import org.springframework.web.servlet.view.feed.AbstractRssFeedView; - -/** - * Created by vitalyster on 28.06.2016. - */ -@Configuration -@ComponentScan(basePackages = {"com.juick.rss"}) -public class RssMvcConfiguration extends BaseWebConfiguration { - @Bean - public BeanNameViewResolver beanNameViewResolver() { - return new BeanNameViewResolver(); - } - @Bean - AbstractRssFeedView messages() { - return new MessagesView(); - } - @Bean - AbstractRssFeedView replies() { - return new RepliesView(); - } -} diff --git a/juick-rss/src/main/resources/rome.properties b/juick-rss/src/main/resources/rome.properties deleted file mode 100644 index e57f6391..00000000 --- a/juick-rss/src/main/resources/rome.properties +++ /dev/null @@ -1,2 +0,0 @@ -rss_2.0.item.ModuleParser.classes=com.juick.rss.extension.JuickModuleParser -rss_2.0.item.ModuleGenerator.classes=com.juick.rss.extension.JuickModuleGenerator
\ No newline at end of file diff --git a/juick-rss/src/main/webapp/WEB-INF/web.xml b/juick-rss/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 7e1c30d0..00000000 --- a/juick-rss/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> - -</web-app> diff --git a/juick-server/build.gradle b/juick-server/build.gradle index 8d894913..2642e9ee 100644 --- a/juick-server/build.gradle +++ b/juick-server/build.gradle @@ -24,6 +24,8 @@ dependencies { exclude group: 'xmlpull' } providedCompile 'xpp3:xpp3:1.1.4c' + compile 'com.rometools:rome:1.9.0' + compile 'com.rometools:rome-modules:1.9.0' testCompile project(path: ':juick-core', configuration: 'testArtifacts') testCompile project(path: ':juick-server-web', configuration: 'testArtifacts') diff --git a/juick-rss/src/main/java/com/juick/rss/controllers/FeedsController.java b/juick-server/src/main/java/com/juick/server/api/rss/Feeds.java index 7555f128..51c32cac 100644 --- a/juick-rss/src/main/java/com/juick/rss/controllers/FeedsController.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/Feeds.java @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss.controllers; +package com.juick.server.api.rss; import com.juick.User; import com.juick.server.util.HttpBadRequestException; @@ -35,14 +35,14 @@ import java.util.List; * Created by vitalyster on 13.12.2016. */ @Controller -public class FeedsController { +public class Feeds { @Inject private MessagesService messagesService; @Inject private UserService userService; - @RequestMapping(value = "/{userName}/blog", method = RequestMethod.GET) + @RequestMapping(value = "/rss/{userName}/blog", method = RequestMethod.GET) public ModelAndView getBlog(@PathVariable String userName) { User user = userService.getUserByName(userName); if (user.getUid() > 0) { @@ -56,7 +56,7 @@ public class FeedsController { throw new HttpBadRequestException(); } - @RequestMapping(value = "/", method = RequestMethod.GET) + @RequestMapping(value = "/rss/", method = RequestMethod.GET) public ModelAndView getLast(@RequestParam(value = "hours", required = false, defaultValue = "0") Integer hours) { List<Integer> mids = messagesService.getLastMessages(hours); ModelAndView modelAndView = new ModelAndView(); @@ -64,7 +64,7 @@ public class FeedsController { modelAndView.addObject("messages", messagesService.getMessages(mids)); return modelAndView; } - @RequestMapping(value = "/comments", method = RequestMethod.GET) + @RequestMapping(value = "/rss/comments", method = RequestMethod.GET) public ModelAndView getLastReplies(@RequestParam(value = "hours", required = false, defaultValue = "0") Integer hours) { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("replies"); diff --git a/juick-rss/src/main/java/com/juick/rss/MessagesView.java b/juick-server/src/main/java/com/juick/server/api/rss/MessagesView.java index d560b4e9..f61757a6 100644 --- a/juick-rss/src/main/java/com/juick/rss/MessagesView.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/MessagesView.java @@ -15,12 +15,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss; +package com.juick.server.api.rss; import com.juick.Message; import com.juick.User; -import com.juick.rss.extension.JuickModule; -import com.juick.rss.extension.JuickModuleImpl; +import com.juick.server.api.rss.extension.JuickModule; +import com.juick.server.api.rss.extension.JuickModuleImpl; import com.juick.util.MessageUtils; import com.rometools.modules.atom.modules.AtomLinkModule; import com.rometools.modules.atom.modules.AtomLinkModuleImpl; diff --git a/juick-rss/src/main/java/com/juick/rss/RepliesView.java b/juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java index 9db61049..b53e9750 100644 --- a/juick-rss/src/main/java/com/juick/rss/RepliesView.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss; +package com.juick.server.api.rss; import com.juick.server.helpers.ResponseReply; import com.juick.util.MessageUtils; diff --git a/juick-rss/src/main/java/com/juick/rss/extension/JuickModule.java b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModule.java index d8c1ef1e..a4198518 100644 --- a/juick-rss/src/main/java/com/juick/rss/extension/JuickModule.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModule.java @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss.extension; +package com.juick.server.api.rss.extension; import com.rometools.rome.feed.module.Module; diff --git a/juick-rss/src/main/java/com/juick/rss/extension/JuickModuleGenerator.java b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModuleGenerator.java index b38c2ab8..eb103136 100644 --- a/juick-rss/src/main/java/com/juick/rss/extension/JuickModuleGenerator.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModuleGenerator.java @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss.extension; +package com.juick.server.api.rss.extension; import com.rometools.rome.feed.module.Module; import com.rometools.rome.io.ModuleGenerator; diff --git a/juick-rss/src/main/java/com/juick/rss/extension/JuickModuleImpl.java b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModuleImpl.java index c2ae1fbe..dbdd8c85 100644 --- a/juick-rss/src/main/java/com/juick/rss/extension/JuickModuleImpl.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModuleImpl.java @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss.extension; +package com.juick.server.api.rss.extension; import com.rometools.rome.feed.CopyFrom; import com.rometools.rome.feed.module.ModuleImpl; diff --git a/juick-rss/src/main/java/com/juick/rss/extension/JuickModuleParser.java b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModuleParser.java index a11e50b5..a3d0e175 100644 --- a/juick-rss/src/main/java/com/juick/rss/extension/JuickModuleParser.java +++ b/juick-server/src/main/java/com/juick/server/api/rss/extension/JuickModuleParser.java @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss.extension; +package com.juick.server.api.rss.extension; import com.rometools.rome.feed.module.Module; import com.rometools.rome.io.ModuleParser; diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java index 55050f7e..ad417807 100644 --- a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java +++ b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java @@ -18,6 +18,8 @@ package com.juick.server.configuration; import com.juick.server.WebsocketManager; +import com.juick.server.api.rss.MessagesView; +import com.juick.server.api.rss.RepliesView; import com.juick.server.component.JuickServerComponent; import com.juick.server.component.JuickServerReconnectManager; import com.juick.service.UserService; @@ -32,6 +34,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.view.BeanNameViewResolver; +import org.springframework.web.servlet.view.feed.AbstractRssFeedView; import org.springframework.web.socket.client.WebSocketConnectionManager; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.config.annotation.EnableWebSocket; @@ -149,6 +153,18 @@ public class ApiAppConfiguration extends BaseWebConfiguration implements WebSock cs.addConverter(new JidConverter()); return cs; } + @Bean + public BeanNameViewResolver beanNameViewResolver() { + return new BeanNameViewResolver(); + } + @Bean + AbstractRssFeedView messages() { + return new MessagesView(); + } + @Bean + AbstractRssFeedView replies() { + return new RepliesView(); + } @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable(); diff --git a/juick-server/src/main/resources/rome.properties b/juick-server/src/main/resources/rome.properties new file mode 100644 index 00000000..fdb9aaa2 --- /dev/null +++ b/juick-server/src/main/resources/rome.properties @@ -0,0 +1,2 @@ +rss_2.0.item.ModuleParser.classes=com.juick.server.api.rss.extension.JuickModuleParser +rss_2.0.item.ModuleGenerator.classes=com.juick.server.api.rss.extension.JuickModuleGenerator
\ No newline at end of file diff --git a/juick-rss/src/test/java/com/juick/rss/tests/RSSTests.java b/juick-server/src/test/java/com/juick/server/tests/RSSTests.java index 7c356771..a5e05a08 100644 --- a/juick-rss/src/test/java/com/juick/rss/tests/RSSTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/RSSTests.java @@ -15,16 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package com.juick.rss.tests; +package com.juick.server.tests; import com.juick.Message; import com.juick.Tag; import com.juick.User; -import com.juick.rss.configuration.RssAppConfiguration; -import com.juick.rss.configuration.RssMvcConfiguration; -import com.juick.service.MessagesService; -import com.juick.service.TagService; -import com.juick.service.UserService; +import com.juick.server.configuration.ApiAppConfiguration; +import com.juick.service.*; import org.apache.commons.text.RandomStringGenerator; import org.junit.Before; import org.junit.Test; @@ -59,7 +56,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebAppConfiguration public class RSSTests { @Configuration - @Import(value = {RssMvcConfiguration.class, RssAppConfiguration.class}) + @Import(value = {ApiAppConfiguration.class}) static class Config { @Bean @Primary @@ -78,6 +75,42 @@ public class RSSTests { TagService tagService() { return Mockito.mock(TagService.class); } + @Bean + CrosspostService crosspostService() { + return Mockito.mock(CrosspostService.class); + } + @Bean + EmailService emailService() { + return Mockito.mock(EmailService.class); + } + @Bean + SubscriptionService subscriptionService() { + return Mockito.mock(SubscriptionService.class); + } + @Bean + MessengerService messengerService() { + return Mockito.mock(MessengerService.class); + } + @Bean + TelegramService telegramService() { + return Mockito.mock(TelegramService.class); + } + @Bean + PMQueriesService pmQueriesService() { + return Mockito.mock(PMQueriesService.class); + } + @Bean + ShowQueriesService showQueriesService() { + return Mockito.mock(ShowQueriesService.class); + } + @Bean + PrivacyQueriesService privacyQueriesService() { + return Mockito.mock(PrivacyQueriesService.class); + } + @Bean + PushQueriesService pushQueriesService() { + return Mockito.mock(PushQueriesService.class); + } } private MockMvc mockMvc; @@ -157,7 +190,7 @@ public class RSSTests { .thenReturn(Collections.singletonList(msg)); mockMvc.perform( - get("/")) + get("/rss/")) .andExpect(status().isOk()) .andExpect(content().contentType("application/rss+xml")) .andExpect(xpath("/rss/channel/description").string("The latest messages at Juick")); diff --git a/settings.gradle b/settings.gradle index 005d592b..1dc8f277 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ rootProject.name = "Juick" -include ':juick-core', ':juick-server-core', ':juick-server-jdbc', ':juick-server-web', ':juick-server', ':juick-www', ':juick-rss', ':juick-notifications', ':juick-xmpp-wip' +include ':juick-core', ':juick-server-core', ':juick-server-jdbc', ':juick-server-web', ':juick-server', ':juick-www', ':juick-notifications', ':juick-xmpp-wip' |