1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.comarquage.modules.solr.search;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39 import fr.paris.lutece.plugins.comarquage.modules.solr.utils.parsers.CoMarquageSolrPublicParser;
40 import fr.paris.lutece.plugins.search.solr.business.field.Field;
41 import fr.paris.lutece.plugins.search.solr.indexer.SolrIndexer;
42 import fr.paris.lutece.plugins.search.solr.indexer.SolrIndexerService;
43 import fr.paris.lutece.plugins.search.solr.indexer.SolrItem;
44 import fr.paris.lutece.portal.service.util.AppLogService;
45 import fr.paris.lutece.portal.service.util.AppPropertiesService;
46
47
48
49
50
51
52 public class SolrComarquagePublicIndexer implements SolrIndexer
53 {
54 private static final String PROPERTY_DESCRIPTION = "comarquage-solr.indexing.publicIndexer.description";
55 private static final String PROPERTY_NAME = "comarquage-solr.indexing.publicIndexer.name";
56 private static final String PROPERTY_VERSION = "comarquage-solr.indexing.publicIndexer.version";
57 private static final String PROPERTY_INDEXER_ENABLE = "comarquage-solr.indexing.publicIndexer.enable";
58
59 private static final String COM_INDEXATION_ERROR = "[SolrComarquagePublicIndexer] An error occured during the indexation of a plublic element ";
60
61
62
63
64 public String getDescription( )
65 {
66 return AppPropertiesService.getProperty( PROPERTY_DESCRIPTION );
67 }
68
69
70
71
72 public String getName( )
73 {
74 return AppPropertiesService.getProperty( PROPERTY_NAME );
75 }
76
77
78
79
80 public String getVersion( )
81 {
82 return AppPropertiesService.getProperty( PROPERTY_VERSION );
83 }
84
85
86
87
88 public List<String> indexDocuments( )
89 {
90
91 CoMarquageSolrPublicParser localParser = new CoMarquageSolrPublicParser( );
92
93
94 List<SolrItem> listDocuments = localParser.getPublicSolrItems( );
95
96 List<String> lstErrors = new ArrayList<String>( );
97
98 for ( SolrItem solrItem : listDocuments )
99 {
100 try
101 {
102 SolrIndexerService.write( solrItem );
103 }
104 catch ( Exception e )
105 {
106 lstErrors.add( SolrIndexerService.buildErrorMessage( e ) );
107 AppLogService.error( COM_INDEXATION_ERROR , e );
108 }
109 }
110
111 return lstErrors;
112 }
113
114
115
116
117 public boolean isEnable( )
118 {
119 return "true".equalsIgnoreCase( AppPropertiesService.getProperty( PROPERTY_INDEXER_ENABLE ) );
120 }
121
122
123
124
125 public List<Field> getAdditionalFields( )
126 {
127
128 return new ArrayList<Field>( );
129 }
130
131
132
133
134 public List<SolrItem> getDocuments( String strIdDocument )
135 {
136
137 return null;
138 }
139
140
141
142
143 public String getResourceUid( String strResourceId, String strResourceType )
144 {
145
146 return null;
147 }
148
149
150
151
152 public List<String> getResourcesName( )
153 {
154
155 return null;
156 }
157 }