30
30
import com .stratelia .webactiv .kmelia .control .ejb .KmeliaBm ;
31
31
import com .stratelia .webactiv .kmelia .model .KmeliaPublication ;
32
32
import com .stratelia .webactiv .kmelia .model .KmeliaRuntimeException ;
33
- import com .stratelia .webactiv .searchEngine .control .ejb .SearchEngineBm ;
34
33
import com .stratelia .webactiv .searchEngine .model .MatchingIndexEntry ;
35
34
import com .stratelia .webactiv .searchEngine .model .QueryDescription ;
36
35
import com .stratelia .webactiv .util .FileServerUtils ;
55
54
import com .stratelia .webactiv .util .publication .model .PublicationPK ;
56
55
import java .util .logging .Level ;
57
56
import java .util .logging .Logger ;
57
+ import org .silverpeas .search .PlainSearchResult ;
58
+ import org .silverpeas .search .SearchEngineFactory ;
58
59
59
60
public class KmeliaTagUtil extends ComponentTagUtil {
60
61
@@ -65,7 +66,6 @@ public class KmeliaTagUtil extends ComponentTagUtil {
65
66
private KmeliaBm kscEjb = null ;
66
67
private PublicationBm publicationBm = null ;
67
68
private NodeBm nodeBm = null ;
68
- private SearchEngineBm searchEngineBm = null ;
69
69
private CommentService commentService = null ;
70
70
private NotationBm notationBm = null ;
71
71
@@ -128,19 +128,6 @@ private KmeliaBm getKmeliaBm() {
128
128
return kscEjb ;
129
129
}
130
130
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
-
144
131
private CommentService getCommentService () {
145
132
if (commentService == null ) {
146
133
CommentServiceFactory serviceFactory = CommentServiceFactory .getFactory ();
@@ -260,11 +247,9 @@ private void checkPublicationLocation(String pubId) throws RemoteException, Visi
260
247
261
248
private void checkPublicationLocation (PublicationDetail pubDetail ) throws RemoteException ,
262
249
VisibilityException {
263
-
264
250
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 ()))) {
268
253
throw new VisibilityException ();
269
254
}
270
255
}
@@ -338,7 +323,6 @@ public Collection getLinkedPublications(String pubId) throws RemoteException, Vi
338
323
return filterPublications (getPublicationBm ().getPublications (targetPKs ));
339
324
} catch (NoSuchObjectException nsoe ) {
340
325
initPublicationEJB ();
341
- // initEJB();
342
326
return getLinkedPublications (pubId );
343
327
}
344
328
}
@@ -357,17 +341,12 @@ public Collection getPublicationsOnSameSubject(String pubId) throws RemoteExcept
357
341
getKeywords ());
358
342
query .setSearchingUser (getUserId ());
359
343
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 ();
364
345
//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 ) {
369
348
if (mie != null && !mie .getObjectId ().equals (pubId )) {
370
- if ("Publication" .equals (mie .getObjectType ())) {
349
+ if ("Publication" .equalsIgnoreCase (mie .getObjectType ())) {
371
350
pubPKs .add (getPublicationPK (mie .getObjectId ()));
372
351
}
373
352
}
@@ -385,7 +364,6 @@ public InfoDetail getInfoDetail(String pubId) throws RemoteException, Visibility
385
364
try {
386
365
checkPublicationStatus (pubId );
387
366
checkPublicationLocation (pubId );
388
-
389
367
return getPublicationBm ().getInfoDetail (getPublicationPK (pubId ));
390
368
} catch (NoSuchObjectException nsoe ) {
391
369
initEJB ();
0 commit comments