17
17
*/
18
18
package ru .mystamps .web .feature .series .importing .event ;
19
19
20
- import java .util .List ;
21
-
22
20
import javax .annotation .PostConstruct ;
23
21
24
22
import org .slf4j .Logger ;
30
28
31
29
import ru .mystamps .web .feature .series .importing .RawParsedDataDto ;
32
30
import ru .mystamps .web .feature .series .importing .SeriesImportService ;
33
- import ru .mystamps .web .feature .series .importing .extractor .JsoupSiteParser ;
34
31
import ru .mystamps .web .feature .series .importing .extractor .SeriesInfo ;
35
32
import ru .mystamps .web .feature .series .importing .extractor .SiteParser ;
36
- import ru .mystamps .web .feature .series .importing .extractor .SiteParserConfiguration ;
37
33
import ru .mystamps .web .feature .series .importing .extractor .SiteParserService ;
38
- import ru .mystamps .web .feature .series .importing .extractor .TimedSiteParser ;
39
34
40
35
/**
41
36
* Listener of the {@link DownloadingSucceeded} event.
@@ -54,14 +49,10 @@ public class DownloadingSucceededEventListener
54
49
private final Logger log ;
55
50
private final SeriesImportService seriesImportService ;
56
51
private final SiteParserService siteParserService ;
57
- private final List <SiteParser > siteParsers ;
58
52
private final ApplicationEventPublisher eventPublisher ;
59
53
60
54
@ PostConstruct
61
55
public void init () {
62
- // TODO: remove migration logic after finishing migration
63
- siteParsers .forEach (this ::migrateParser );
64
-
65
56
log .info ("Registered site parsers: {}" , siteParserService .findParserNames ());
66
57
}
67
58
@@ -107,43 +98,4 @@ public void onApplicationEvent(DownloadingSucceeded event) {
107
98
seriesImportService .saveParsedData (requestId , data );
108
99
}
109
100
110
- @ SuppressWarnings ({ "PMD.AvoidReassigningParameters" , "checkstyle:parameterassignment" })
111
- private void migrateParser (SiteParser parser ) {
112
- if (parser instanceof TimedSiteParser ) {
113
- parser = ((TimedSiteParser )parser ).getOrigin ();
114
- }
115
-
116
- if (!(parser instanceof JsoupSiteParser )) {
117
- log .warn (
118
- "Could not migrate unknown (non-Jsoup based) parser: {}" ,
119
- parser .getClass ().getName ()
120
- );
121
- return ;
122
- }
123
-
124
- JsoupSiteParser jsoupParser = (JsoupSiteParser )parser ;
125
-
126
- SiteParserConfiguration cfg = jsoupParser .toConfiguration ();
127
- String url = cfg .getMatchedUrl ();
128
- String name = cfg .getName ();
129
- if (siteParserService .findForUrl (url ) != null ) {
130
- log .warn (
131
- "Parser '{}': already exist in database and "
132
- + "can be removed from application*.properties file" ,
133
- name
134
- );
135
- return ;
136
- }
137
-
138
- log .info ("Parser '{}': migrating to database" , name );
139
-
140
- siteParserService .add (cfg );
141
-
142
- log .warn (
143
- "Parser '{}': successfully migrated and "
144
- + "can be removed from application*.properties file" ,
145
- name
146
- );
147
- }
148
-
149
101
}
0 commit comments