Skip to content

Commit 28b88b1

Browse files
authored
Merge pull request Silverpeas#583 from SilverTeamWork/bug-9674
Integrate fix of the bug 9674 in master
2 parents 99a2449 + 32da7d9 commit 28b88b1

File tree

28 files changed

+243
-399
lines changed

28 files changed

+243
-399
lines changed

blog/blog-library/src/main/java/org/silverpeas/components/blog/service/DefaultBlogService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ public String createPost(final PostDetail post, PdcClassification classification
161161

162162
// Create empty wysiwyg content
163163
WysiwygController
164-
.createUnindexedFileAndAttachment("", pk, pub.getCreatorId(), pub.getLanguage());
164+
.createUnindexedFileAndAttachment("", new ResourceReference(pk),
165+
pub.getCreatorId(), pub.getLanguage());
165166

166167
// Create silver content
167168
createSilverContent(con, pub, pub.getCreatorId());

forums/forums-library/src/main/java/org/silverpeas/components/forums/service/DefaultForumService.java

Lines changed: 63 additions & 116 deletions
Large diffs are not rendered by default.

forums/forums-library/src/main/java/org/silverpeas/components/forums/service/ForumsDAO.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.silverpeas.components.forums.model.Message;
3131
import org.silverpeas.components.forums.model.MessagePK;
3232
import org.silverpeas.components.forums.model.Moderator;
33-
import org.silverpeas.core.exception.SilverpeasRuntimeException;
3433
import org.silverpeas.core.persistence.jdbc.DBUtil;
3534
import org.silverpeas.core.util.DateUtil;
3635
import org.silverpeas.core.util.StringUtil;
@@ -51,6 +50,8 @@
5150
import java.util.List;
5251
import java.util.stream.Collectors;
5352

53+
import static org.silverpeas.core.SilverpeasExceptionMessages.failureOnGetting;
54+
5455
/**
5556
* Class managing database accesses for forums.
5657
*/
@@ -159,7 +160,7 @@ private ForumsDAO() {
159160
*/
160161
public static Collection<ForumDetail> selectByForumPKs(Connection con,
161162
Collection<ForumPK> forumPKs) throws SQLException {
162-
List<ForumDetail> forumDetails = new ArrayList<ForumDetail>(forumPKs.size());
163+
List<ForumDetail> forumDetails = new ArrayList<>(forumPKs.size());
163164
for (ForumPK forumPK : forumPKs) {
164165
forumDetails.add(getForumDetail(con, forumPK));
165166
}
@@ -174,7 +175,7 @@ public static Collection<ForumDetail> selectByForumPKs(Connection con,
174175
*/
175176
public static Collection<Forum> getForumsByKeys(Connection con, Collection<ForumPK> forumPKs)
176177
throws SQLException {
177-
ArrayList<Forum> forums = new ArrayList<Forum>();
178+
ArrayList<Forum> forums = new ArrayList<>();
178179
Iterator<ForumPK> iterator = forumPKs.iterator();
179180
ForumPK forumPK;
180181
Forum forum;
@@ -220,7 +221,7 @@ public static Collection<Message> getThreadsByKeys(Connection con,
220221
*/
221222
private static Collection<Message> getMessagesByKeys(Connection con,
222223
Collection<MessagePK> messagePKs, boolean onlyThreads) throws SQLException {
223-
ArrayList<Message> messages = new ArrayList<Message>();
224+
ArrayList<Message> messages = new ArrayList<>();
224225
for (MessagePK messagePK : messagePKs) {
225226
Message message = (onlyThreads ? getThread(con, messagePK) : getMessage(con, messagePK));
226227
if (message != null) {
@@ -251,7 +252,7 @@ private static Collection<Message> getMessagesByKeys(Connection con,
251252
public static List<Forum> getForumsList(Connection con, ForumPK forumPK) throws SQLException {
252253

253254

254-
List<Forum> forums = new ArrayList<Forum>();
255+
List<Forum> forums = new ArrayList<>();
255256
PreparedStatement selectStmt = null;
256257
ResultSet rs = null;
257258
try {
@@ -277,7 +278,7 @@ public static List<String> getForumsIds(Connection con, ForumPK forumPK)
277278
throws SQLException {
278279

279280

280-
ArrayList<String> forumsIds = new ArrayList<String>();
281+
ArrayList<String> forumsIds = new ArrayList<>();
281282
PreparedStatement selectStmt = null;
282283
ResultSet rs = null;
283284
try {
@@ -329,7 +330,7 @@ public static List<Forum> getForumsListByCategory(Connection con, ForumPK forumP
329330
public static List<String> getForumSonsIds(Connection con, ForumPK forumPK) throws SQLException {
330331

331332

332-
List<String> forumIds = new ArrayList<String>();
333+
List<String> forumIds = new ArrayList<>();
333334
PreparedStatement selectStmt = null;
334335
ResultSet rs = null;
335336
try {
@@ -487,9 +488,7 @@ public static String getForumCreatorId(Connection con, int forumId) throws SQLEx
487488
if (rs.next()) {
488489
return rs.getString(FORUM_COLUMN_FORUM_CREATOR);
489490
} else {
490-
throw new ForumsRuntimeException("ForumsDAO.getForumCreatorId()",
491-
SilverpeasRuntimeException.ERROR, "root.EX_CANT_LOAD_ENTITY_ATTRIBUTES",
492-
"ForumId = " + forumId + " not found in database !");
491+
throw new ForumsRuntimeException(failureOnGetting("forum", forumId));
493492
}
494493
} finally {
495494
DBUtil.close(rs, stmt);
@@ -645,7 +644,9 @@ public static void updateForum(Connection con, ForumPK forumPK, String forumName
645644
public static void deleteForum(Connection con, ForumPK forumPK) throws SQLException {
646645
String sForumId = forumPK.getId();
647646
int forumId = Integer.parseInt(sForumId);
648-
PreparedStatement deleteStmt1 = null, deleteStmt2 = null, deleteStmt3 = null;
647+
PreparedStatement deleteStmt1 = null;
648+
PreparedStatement deleteStmt2 = null;
649+
PreparedStatement deleteStmt3 = null;
649650
try {
650651
deleteStmt1 = con.prepareStatement(QUERY_DELETE_FORUM_RIGHTS);
651652
deleteStmt1.setString(1, sForumId);
@@ -715,7 +716,7 @@ public static List<Message> getMessagesList(Connection con, ForumPK forumPK)
715716
throws SQLException {
716717

717718

718-
ArrayList<Message> messages = new ArrayList<Message>();
719+
ArrayList<Message> messages = new ArrayList<>();
719720
PreparedStatement selectStmt = null;
720721
ResultSet rs = null;
721722
try {
@@ -752,7 +753,7 @@ public static List<String> getMessagesIds(Connection con, ForumPK forumPK, int m
752753
QUERY_GET_MESSAGES_IDS_BY_FORUM);
753754

754755

755-
ArrayList<String> messagesIds = new ArrayList<String>();
756+
ArrayList<String> messagesIds = new ArrayList<>();
756757
PreparedStatement selectStmt = null;
757758
ResultSet rs = null;
758759
try {
@@ -874,7 +875,7 @@ public static int getAuthorNbMessages(Connection con, String userId, String stat
874875
public static int getNbResponses(Connection con, int forumId, int messageId, String status) {
875876
PreparedStatement prepStmt = null;
876877
ResultSet rs = null;
877-
ArrayList<Integer> nextMessageIds = new ArrayList<Integer>();
878+
ArrayList<Integer> nextMessageIds = new ArrayList<>();
878879
try {
879880
prepStmt = con.prepareStatement(QUERY_GET_NB_RESPONSES);
880881
prepStmt.setInt(1, forumId);
@@ -893,7 +894,7 @@ public static int getNbResponses(Connection con, int forumId, int messageId, Str
893894
int nb = nextMessageIds.size();
894895
int nextMessageId;
895896
for (int i = 0, n = nextMessageIds.size(); i < n; i++) {
896-
nextMessageId = ((Integer) nextMessageIds.get(i)).intValue();
897+
nextMessageId = (Integer) nextMessageIds.get(i);
897898
nb += getNbResponses(con, forumId, nextMessageId, status);
898899
}
899900
return nb;
@@ -945,7 +946,7 @@ public static Message getLastMessage(Connection con, ForumPK forumPK, String sta
945946
*/
946947
public static List<Message> getLastThreads(Connection con, ForumPK[] forumPKs, int count)
947948
throws SQLException {
948-
ArrayList<Message> messages = new ArrayList<Message>();
949+
ArrayList<Message> messages = new ArrayList<>();
949950
if (forumPKs.length > 0) {
950951
StringBuilder selectQuery = new StringBuilder(
951952
"SELECT " + MESSAGE_COLUMN_MESSAGE_ID + " FROM " + MESSAGE_TABLE + " WHERE " +
@@ -960,7 +961,7 @@ public static List<Message> getLastThreads(Connection con, ForumPK[] forumPKs, i
960961
selectQuery.append(") ORDER BY ").append(MESSAGE_COLUMN_MESSAGE_DATE).append(" DESC");
961962

962963

963-
ArrayList<String> messageIds = new ArrayList<String>(count);
964+
ArrayList<String> messageIds = new ArrayList<>(count);
964965
int messagesCount = 0;
965966
PreparedStatement selectStmt = null;
966967
ResultSet rs = null;
@@ -978,7 +979,7 @@ public static List<Message> getLastThreads(Connection con, ForumPK[] forumPKs, i
978979

979980
String componentName = forumPKs[0].getComponentName();
980981
for (int i = 0; i < messagesCount; i++) {
981-
MessagePK messagePK = new MessagePK(componentName, (String) messageIds.get(i));
982+
MessagePK messagePK = new MessagePK(componentName, messageIds.get(i));
982983
messages.add(getMessage(con, messagePK));
983984
}
984985
}
@@ -995,7 +996,7 @@ public static List<Message> getLastThreads(Connection con, ForumPK[] forumPKs, i
995996
*/
996997
public static Collection<Message> getNotAnsweredLastThreads(Connection con, ForumPK[] forumPKs,
997998
int count) throws SQLException {
998-
ArrayList<Message> messages = new ArrayList<Message>();
999+
ArrayList<Message> messages = new ArrayList<>();
9991000
if (forumPKs.length > 0) {
10001001
StringBuilder selectQuery = new StringBuilder(
10011002
"SELECT " + MESSAGE_COLUMN_MESSAGE_ID + ", " + MESSAGE_COLUMN_FORUM_ID + " FROM " +
@@ -1010,7 +1011,7 @@ public static Collection<Message> getNotAnsweredLastThreads(Connection con, Foru
10101011
selectQuery.append(") ORDER BY " + MESSAGE_COLUMN_MESSAGE_DATE + " DESC");
10111012

10121013

1013-
ArrayList<String> messageIds = new ArrayList<String>(count);
1014+
ArrayList<String> messageIds = new ArrayList<>(count);
10141015
int messageId;
10151016
int forumId;
10161017
int messagesCount = 0;
@@ -1066,7 +1067,7 @@ public static Collection<Message> getNotAnsweredLastThreads(Connection con, Foru
10661067
*/
10671068
public static Collection<String> getLastMessageRSS(Connection con, String instanceId)
10681069
throws SQLException {
1069-
Collection<String> messageIds = new ArrayList<String>();
1070+
Collection<String> messageIds = new ArrayList<>();
10701071
Collection<Integer> forumIds = getAllForumsByInstanceId(con, instanceId);
10711072
Iterator<Integer> it = forumIds.iterator();
10721073
while (it.hasNext()) {
@@ -1086,7 +1087,7 @@ private static Collection<Integer> getAllForumsByInstanceId(Connection con, Stri
10861087
throws SQLException {
10871088

10881089

1089-
Collection<Integer> forumIds = new ArrayList<Integer>();
1090+
Collection<Integer> forumIds = new ArrayList<>();
10901091
PreparedStatement selectStmt = null;
10911092
ResultSet rs = null;
10921093
try {
@@ -1117,7 +1118,7 @@ private static Collection<String> getAllMessageByForum(Connection con, int forum
11171118
throws SQLException {
11181119

11191120

1120-
Collection<String> messageIds = new ArrayList<String>();
1121+
Collection<String> messageIds = new ArrayList<>();
11211122
PreparedStatement selectStmt = null;
11221123
ResultSet rs = null;
11231124
try {
@@ -1616,9 +1617,7 @@ public static ForumDetail getForumDetail(Connection con, ForumPK forumPK) throws
16161617
if (rs.next()) {
16171618
return resultSet2ForumDetail(rs, forumPK);
16181619
} else {
1619-
throw new ForumsRuntimeException("ForumsDAO.getForumDetail()",
1620-
SilverpeasRuntimeException.ERROR, "root.EX_CANT_LOAD_ENTITY_ATTRIBUTES",
1621-
"ForumId = " + forumPK.getId() + " not found in database !");
1620+
throw new ForumsRuntimeException(failureOnGetting("forum", forumPK.getId()));
16221621
}
16231622
} finally {
16241623
DBUtil.close(rs, stmt);

forums/forums-library/src/main/java/org/silverpeas/components/forums/service/ForumsRuntimeException.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,21 @@
2424

2525
package org.silverpeas.components.forums.service;
2626

27-
import org.silverpeas.core.exception.SilverpeasRuntimeException;
27+
import org.silverpeas.core.SilverpeasRuntimeException;
2828

2929
public class ForumsRuntimeException extends SilverpeasRuntimeException {
3030

31-
private static final long serialVersionUID = 2106651190069558942L;
31+
private static final long serialVersionUID = 2106651190069558943L;
3232

33-
public ForumsRuntimeException(String callingClass, int errorLevel, String message) {
34-
super(callingClass, errorLevel, message);
33+
public ForumsRuntimeException(final String message) {
34+
super(message);
3535
}
3636

37-
public ForumsRuntimeException(String callingClass, int errorLevel, String message,
38-
String extraParams) {
39-
super(callingClass, errorLevel, message, extraParams);
37+
public ForumsRuntimeException(final String message, final Throwable cause) {
38+
super(message, cause);
4039
}
4140

42-
public ForumsRuntimeException(String callingClass, int errorLevel, String message,
43-
Exception nested) {
44-
super(callingClass, errorLevel, message, nested);
41+
public ForumsRuntimeException(final Throwable cause) {
42+
super(cause);
4543
}
46-
47-
public ForumsRuntimeException(String callingClass, int errorLevel, String message,
48-
String extraParams, Exception nested) {
49-
super(callingClass, errorLevel, message, extraParams, nested);
50-
}
51-
52-
public String getModule() {
53-
return "forums";
54-
}
55-
5644
}

kmelia/kmelia-library/src/main/java/org/silverpeas/components/kmelia/service/DefaultKmeliaService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,8 +2350,8 @@ private PublicationDetail getClone(PublicationDetail refPub) {
23502350
if (refPub.getBeginHour() != null) {
23512351
clone.setBeginHour(refPub.getBeginHour());
23522352
}
2353-
if (refPub.getContent() != null) {
2354-
clone.setContent(refPub.getContent());
2353+
if (refPub.getContentPagePath() != null) {
2354+
clone.setContentPagePath(refPub.getContentPagePath());
23552355
}
23562356
clone.setCreationDate(new Date(refPub.getCreationDate().getTime()));
23572357
clone.setCreatorId(refPub.getCreatorId());

kmelia/kmelia-war/src/main/java/org/silverpeas/components/kmelia/ui/ResultSearchRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ private void setSpecificAttributes(SearchResultContentVO searchResult,
129129
template.setAttribute("pubKeywords", pubDetail.getKeywords());
130130
}
131131

132-
if (StringUtil.isDefined(pubDetail.getContent())) {
133-
template.setAttribute("pubContent", pubDetail.getContent());
132+
if (StringUtil.isDefined(pubDetail.getContentPagePath())) {
133+
template.setAttribute("pubContent", pubDetail.getContentPagePath());
134134
}
135135
String componentId = silverResult.getInstanceId();
136136
String id = silverResult.getId();

questionReply/questionReply-library/src/main/java/org/silverpeas/components/questionreply/QuestionReplyException.java

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,21 @@
2424

2525
package org.silverpeas.components.questionreply;
2626

27-
import org.silverpeas.core.exception.SilverpeasException;
27+
import org.silverpeas.core.SilverpeasException;
2828

2929
public class QuestionReplyException extends SilverpeasException {
30-
private static final long serialVersionUID = 5146623952157133392L;
30+
private static final long serialVersionUID = 5146623952157133393L;
3131

32-
/**
33-
* Constructor which calls the super constructor
34-
* @param callingClass (String) the name of the module which catchs the Exception
35-
* @param errorLevel (int) the level error of the exception
36-
* @param message (String) the level of the exception label
37-
* @param extraParams (String) the generic exception message
38-
* @param nested (Exception) the exception catched
39-
*/
40-
public QuestionReplyException(String callingClass, int errorLevel, String message,
41-
String extraParams, Exception nested) {
42-
super(callingClass, errorLevel, message, extraParams, nested);
43-
}
44-
45-
public QuestionReplyException(String callingClass, int errorLevel, String message,
46-
String extraParams) {
47-
this(callingClass, errorLevel, message, extraParams, null);
48-
}
4932

50-
public QuestionReplyException(String callingClass, int errorLevel, String message,
51-
Exception nested) {
52-
this(callingClass, errorLevel, message, "", nested);
33+
public QuestionReplyException(final String message, final String... parameters) {
34+
super(message, parameters);
5335
}
5436

55-
public QuestionReplyException(String callingClass, int errorLevel, String message) {
56-
this(callingClass, errorLevel, message, "", null);
37+
public QuestionReplyException(final String message, final Throwable cause) {
38+
super(message, cause);
5739
}
5840

59-
/**
60-
* Returns the name of this jobPeas
61-
* @return the name of this module
62-
*/
63-
@Override
64-
public String getModule() {
65-
return "QuestionReply";
41+
public QuestionReplyException(final Throwable cause) {
42+
super(cause);
6643
}
67-
6844
}

0 commit comments

Comments
 (0)