Skip to content

Commit cab316d

Browse files
fixed #197
1 parent c5a392c commit cab316d

File tree

3 files changed

+72
-51
lines changed

3 files changed

+72
-51
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ maven-build.log.txt
2020
maven-testing.log.txt
2121
spring-boot.log.txt
2222
maven-testing-site.log.txt
23+
test.log.txt
2324
docs2
2425
.bundle
2526
.sass-cache

src/main/java/org/woehlke/twitterwall/oodm/entities/parts/EntitiesFilter.java

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ protected Set<Mention> findByUserDescription(String description,Task task) {
4545

4646
protected String getFormattedTextForMentions(Set<Mention> mentions, String formattedText) {
4747
for (Mention mention : mentions) {
48-
49-
if(mention.isProxy() && mention.hasUser() && (!mention.getScreenName().isEmpty())) {
50-
51-
String USER_PROFILE_INPUT[] = {
52-
"@(" + mention.getScreenName() + ")(" + stopChar + ")",
53-
"@(" + mention.getScreenName() + ")$"
54-
};
55-
56-
String USER_PROFILE_OUTPUT[] = {
57-
" <a class=\"tweet-action tweet-profile1\" href=\"https://twitter.com/$1\" target=\"_blank\">@$1</a>$2",
58-
" <a class=\"tweet-action tweet-profile2\" href=\"https://twitter.com/$1\" target=\"_blank\">@$1</a> "
59-
};
60-
61-
for(int i=0;i<2;i++){
62-
Pattern userPattern = Pattern.compile(USER_PROFILE_INPUT[i]);
63-
Matcher m = userPattern.matcher(formattedText);
64-
formattedText = m.replaceAll(USER_PROFILE_OUTPUT[i]);
48+
if(mention != null) {
49+
if (mention.isProxy() && mention.hasUser() && (!mention.getScreenName().isEmpty())) {
50+
51+
String USER_PROFILE_INPUT[] = {
52+
"@(" + mention.getScreenName() + ")(" + stopChar + ")",
53+
"@(" + mention.getScreenName() + ")$"
54+
};
55+
56+
String USER_PROFILE_OUTPUT[] = {
57+
" <a class=\"tweet-action tweet-profile1\" href=\"https://twitter.com/$1\" target=\"_blank\">@$1</a>$2",
58+
" <a class=\"tweet-action tweet-profile2\" href=\"https://twitter.com/$1\" target=\"_blank\">@$1</a> "
59+
};
60+
61+
for (int i = 0; i < 2; i++) {
62+
Pattern userPattern = Pattern.compile(USER_PROFILE_INPUT[i]);
63+
Matcher m = userPattern.matcher(formattedText);
64+
formattedText = m.replaceAll(USER_PROFILE_OUTPUT[i]);
65+
}
6566
}
6667
}
6768
}
@@ -247,13 +248,14 @@ protected String getFormattedTextForMedia(Set<Media> media, String formattedText
247248

248249
public String getFormattedUrlForUrls(Set<Url> urls, String formattedText) {
249250
for (Url url : urls) {
251+
if(url!=null) {
252+
String USER_PROFILE_INPUT = url.getUrl();
253+
String USER_PROFILE_OUTPUT = "<a href=\"" + url.getExpanded() + "\" class=\"tw-url-db\" target=\"_blank\">" + url.getDisplay() + "</a>";
250254

251-
String USER_PROFILE_INPUT=url.getUrl();
252-
String USER_PROFILE_OUTPUT="<a href=\"" + url.getExpanded() + "\" class=\"tw-url-db\" target=\"_blank\">" + url.getDisplay() + "</a>";
253-
254-
Pattern myUrl = Pattern.compile(USER_PROFILE_INPUT);
255-
Matcher m = myUrl.matcher(formattedText);
256-
formattedText = m.replaceAll(USER_PROFILE_OUTPUT);
255+
Pattern myUrl = Pattern.compile(USER_PROFILE_INPUT);
256+
Matcher m = myUrl.matcher(formattedText);
257+
formattedText = m.replaceAll(USER_PROFILE_OUTPUT);
258+
}
257259
}
258260
return formattedText;
259261
}
@@ -323,29 +325,30 @@ protected String getFormattedTextForUrls( String formattedText) {
323325

324326
protected String getFormattedTextForUrls(Set<Url> urls, String formattedText) {
325327
for (Url url : urls) {
328+
if(url!=null) {
329+
String USER_PROFILE_INPUT[] = {
330+
"(" + url.getDisplay() + ")(" + stopChar + ")",
331+
"(" + url.getDisplay() + ")$",
332+
"(" + url.getExpanded() + ")(" + stopChar + ")",
333+
"(" + url.getExpanded() + ")$",
334+
"(" + url.getUrl() + ")(" + stopChar + ")",
335+
"(" + url.getUrl() + ")$"
336+
};
326337

327-
String USER_PROFILE_INPUT[] = {
328-
"(" + url.getDisplay() + ")(" + stopChar + ")",
329-
"(" + url.getDisplay() + ")$",
330-
"(" + url.getExpanded() + ")(" + stopChar + ")",
331-
"(" + url.getExpanded() + ")$",
332-
"(" + url.getUrl() + ")(" + stopChar + ")",
333-
"(" + url.getUrl() + ")$"
334-
};
335-
336-
String USER_PROFILE_OUTPUT[] = {
337-
" <a href=\"" + url.getExpanded() + "\" class=\"tw-display1\" target=\"_blank\">" + url.getDisplay() + "</a>$2",
338-
" <a href=\"" + url.getExpanded() + "\" class=\"tw-display2\" target=\"_blank\">" + url.getDisplay() + "</a> ",
339-
" <a href=\"" + url.getExpanded() + "\" class=\"tw-expanded1\" target=\"_blank\">" + url.getDisplay() + "</a>$2",
340-
" <a href=\"" + url.getExpanded() + "\" class=\"tw-expanded2\" target=\"_blank\">" + url.getDisplay() + "</a> ",
341-
" <a href=\"" + url.getExpanded() + "\" class=\"tw-url1\" target=\"_blank\">" + url.getDisplay() + "</a>$2",
342-
" <a href=\"" + url.getExpanded() + "\" class=\"tw-url2\" target=\"_blank\">" + url.getDisplay() + "</a> "
343-
};
338+
String USER_PROFILE_OUTPUT[] = {
339+
" <a href=\"" + url.getExpanded() + "\" class=\"tw-display1\" target=\"_blank\">" + url.getDisplay() + "</a>$2",
340+
" <a href=\"" + url.getExpanded() + "\" class=\"tw-display2\" target=\"_blank\">" + url.getDisplay() + "</a> ",
341+
" <a href=\"" + url.getExpanded() + "\" class=\"tw-expanded1\" target=\"_blank\">" + url.getDisplay() + "</a>$2",
342+
" <a href=\"" + url.getExpanded() + "\" class=\"tw-expanded2\" target=\"_blank\">" + url.getDisplay() + "</a> ",
343+
" <a href=\"" + url.getExpanded() + "\" class=\"tw-url1\" target=\"_blank\">" + url.getDisplay() + "</a>$2",
344+
" <a href=\"" + url.getExpanded() + "\" class=\"tw-url2\" target=\"_blank\">" + url.getDisplay() + "</a> "
345+
};
344346

345-
for(int i=0;i<6;i++){
346-
Pattern userPattern = Pattern.compile(USER_PROFILE_INPUT[i]);
347-
Matcher m = userPattern.matcher(formattedText);
348-
formattedText = m.replaceAll(USER_PROFILE_OUTPUT[i]);
347+
for (int i = 0; i < 6; i++) {
348+
Pattern userPattern = Pattern.compile(USER_PROFILE_INPUT[i]);
349+
Matcher m = userPattern.matcher(formattedText);
350+
formattedText = m.replaceAll(USER_PROFILE_OUTPUT[i]);
351+
}
349352
}
350353
}
351354
return formattedText;

src/main/resources/application.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,33 @@ twitterwall:
109109
skipFortesting: false
110110
facade:
111111
idTwitterToFetchForTweetTest:
112-
- 876329508009279488
113-
- 876356335784394752
112+
- 892553199974051840
113+
- 892553162351104000
114+
- 892553014896209920
115+
- 892552353399934978
116+
- 892552210428702721
117+
- 892551293587292164
118+
- 892550794662293504
119+
- 892550756007419904
120+
- 892549571653640197
121+
- 892549439499493376
122+
- 892548971725324292
123+
- 892545231819862017
124+
- 892544854055542785
125+
- 892544476165660674
126+
- 892544026913538048
127+
- 892543813574578176
128+
- 892517820147396608
129+
- 892460788731977728
130+
- 892411864394674177
131+
- 892233432482193409
132+
- 892057269130731526
133+
- 892053994893213696
114134
- 876676270913880066
115135
- 876566077836337152
116136
- 876563676395962368
117-
- 876514968933478400
118-
- 876514568671023104
119-
- 876513930478313472
120-
- 876510758632386563
121-
- 876496934676180992
137+
- 876356335784394752
138+
- 876329508009279488
122139
idTwitterToFetchForUserControllerTest:
123140
#t3c_berlin
124141
# - 876433563561938944

0 commit comments

Comments
 (0)