Skip to content

Commit c92d9c9

Browse files
author
Emmanuel Hugonnet
committed
Updating code to Silverpeas 5.9
1 parent 0b2ec56 commit c92d9c9

File tree

5 files changed

+1000
-1094
lines changed

5 files changed

+1000
-1094
lines changed

pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46

57
<parent>
68
<groupId>com.silverpeas</groupId>
79
<artifactId>parent</artifactId>
8-
<version>21</version>
10+
<version>22-SNAPSHOT</version>
911
</parent>
1012

1113
<groupId>com.silverpeas</groupId>
@@ -53,8 +55,8 @@
5355
</repositories>
5456

5557
<properties>
56-
<core.version>5.8</core.version>
57-
<component.version>5.8</component.version>
58+
<core.version>5.9-SNAPSHOT</core.version>
59+
<component.version>5.9-SNAPSHOT</component.version>
5860
</properties>
5961

6062

@@ -156,7 +158,6 @@
156158
<dependency>
157159
<groupId>com.silverpeas.core.ejb-core</groupId>
158160
<artifactId>searchengine</artifactId>
159-
<classifier>client</classifier>
160161
<version>${core.version}</version>
161162
<scope>provided</scope>
162163
</dependency>

src/main/java/com/silverpeas/tags/kmelia/KmeliaTagUtil.java

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.stratelia.webactiv.kmelia.control.ejb.KmeliaBm;
3131
import com.stratelia.webactiv.kmelia.model.KmeliaPublication;
3232
import com.stratelia.webactiv.kmelia.model.KmeliaRuntimeException;
33-
import com.stratelia.webactiv.searchEngine.control.ejb.SearchEngineBm;
3433
import com.stratelia.webactiv.searchEngine.model.MatchingIndexEntry;
3534
import com.stratelia.webactiv.searchEngine.model.QueryDescription;
3635
import com.stratelia.webactiv.util.FileServerUtils;
@@ -55,6 +54,8 @@
5554
import com.stratelia.webactiv.util.publication.model.PublicationPK;
5655
import java.util.logging.Level;
5756
import java.util.logging.Logger;
57+
import org.silverpeas.search.PlainSearchResult;
58+
import org.silverpeas.search.SearchEngineFactory;
5859

5960
public class KmeliaTagUtil extends ComponentTagUtil {
6061

@@ -65,7 +66,6 @@ public class KmeliaTagUtil extends ComponentTagUtil {
6566
private KmeliaBm kscEjb = null;
6667
private PublicationBm publicationBm = null;
6768
private NodeBm nodeBm = null;
68-
private SearchEngineBm searchEngineBm = null;
6969
private CommentService commentService = null;
7070
private NotationBm notationBm = null;
7171

@@ -128,19 +128,6 @@ private KmeliaBm getKmeliaBm() {
128128
return kscEjb;
129129
}
130130

131-
private SearchEngineBm getSearchEngineBm() {
132-
if (searchEngineBm == null) {
133-
try {
134-
searchEngineBm = (SearchEngineBm) EJBDynaProxy.createProxy(JNDINames.SEARCHBM_EJBHOME,
135-
SearchEngineBm.class);
136-
} catch (Exception e) {
137-
throw new KmeliaRuntimeException("KmeliaTagUtil.getSearchEngineBm",
138-
SilverpeasRuntimeException.ERROR, "root.EX_CANT_GET_REMOTE_OBJECT", e);
139-
}
140-
}
141-
return searchEngineBm;
142-
}
143-
144131
private CommentService getCommentService() {
145132
if (commentService == null) {
146133
CommentServiceFactory serviceFactory = CommentServiceFactory.getFactory();
@@ -260,11 +247,9 @@ private void checkPublicationLocation(String pubId) throws RemoteException, Visi
260247

261248
private void checkPublicationLocation(PublicationDetail pubDetail) throws RemoteException,
262249
VisibilityException {
263-
264250
List fathers = (List) getKmeliaBm().getPublicationFathers(pubDetail.getPK());
265-
266-
if (fathers == null || fathers.isEmpty() || (fathers.size() == 1 && ((NodePK) fathers.get(0)).
267-
getId().equals("1"))) {
251+
if (fathers == null || fathers.isEmpty() || (fathers.size() == 1
252+
&& "1".equals(((NodePK) fathers.get(0)).getId()))) {
268253
throw new VisibilityException();
269254
}
270255
}
@@ -338,7 +323,6 @@ public Collection getLinkedPublications(String pubId) throws RemoteException, Vi
338323
return filterPublications(getPublicationBm().getPublications(targetPKs));
339324
} catch (NoSuchObjectException nsoe) {
340325
initPublicationEJB();
341-
// initEJB();
342326
return getLinkedPublications(pubId);
343327
}
344328
}
@@ -357,17 +341,12 @@ public Collection getPublicationsOnSameSubject(String pubId) throws RemoteExcept
357341
getKeywords());
358342
query.setSearchingUser(getUserId());
359343
query.addSpaceComponentPair(getSpaceId(), getComponentId());
360-
getSearchEngineBm().search(query);
361-
MatchingIndexEntry[] result = getSearchEngineBm().getRange(0, getSearchEngineBm().getResultLength());
362-
363-
344+
List<MatchingIndexEntry> searchResult = SearchEngineFactory.getSearchEngine().search(query).getEntries();
364345
//get each publication according to result's list
365-
MatchingIndexEntry mie = null;
366-
List<PublicationPK> pubPKs = new ArrayList<PublicationPK>();
367-
for (int r = 0; r < result.length; r++) {
368-
mie = result[r];
346+
List<PublicationPK> pubPKs = new ArrayList<PublicationPK>(searchResult.size());
347+
for (MatchingIndexEntry mie : searchResult) {
369348
if (mie != null && !mie.getObjectId().equals(pubId)) {
370-
if ("Publication".equals(mie.getObjectType())) {
349+
if ("Publication".equalsIgnoreCase(mie.getObjectType())) {
371350
pubPKs.add(getPublicationPK(mie.getObjectId()));
372351
}
373352
}
@@ -385,7 +364,6 @@ public InfoDetail getInfoDetail(String pubId) throws RemoteException, Visibility
385364
try {
386365
checkPublicationStatus(pubId);
387366
checkPublicationLocation(pubId);
388-
389367
return getPublicationBm().getInfoDetail(getPublicationPK(pubId));
390368
} catch (NoSuchObjectException nsoe) {
391369
initEJB();

0 commit comments

Comments
 (0)