If the cmsObject paramter is a Document :
1/ Cast into Document to get the stream
2/ Add the content in the index
On 10/17/06, Evangelos Vlachogiannis <[EMAIL PROTECTED]> wrote:
What I want to do is to get the DocumentStream so that I can add the
content in index. Here is my changes: Any proposal how to replace that
class please?
Index:
components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java
===================================================================
---
components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java
(revision 463916)
+++
components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java
(working copy)
@@ -34,9 +34,11 @@
import org.apache.portals.graffito.model.core.CmsObject;
import org.apache.portals.graffito.model.core.VersionnedContent;
import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.portlets.util.ServiceAccessor;
+import org.apache.portals.graffito.services.dm.DocumentModelService;
import org.apache.portals.graffito.services.search.ContentIndexService;
-/**
+/**
*
* Default implementation for [EMAIL PROTECTED]
org.apache.portals.graffito.services.core.ContentIndexService}
*
@@ -157,13 +159,19 @@
doc.add(Field.Keyword(CREATION_DATE_FIELD,
DateField.dateToString(cmsObject.getCreationDate())));
doc.add(Field.Keyword(LAST_MODIFIED_DATE_FIELD,
DateField.dateToString(cmsObject.getLastModified())));
+ DocumentModelService cms =
ServiceAccessor.getDocumentService();
+ org.apache.portals.graffito.model.dm.Document doc1 =
cms.getDocument(cmsObject.getUri());
+ String s = new
String(doc1.getDocumentStream().getContentByte(),"utf-8");
+ doc.add(Field.Text("contents", s)); //this only for text
documents
+
+ //TODO: add more more mime type (pdfbox.org for pdf etc...)
+
// Add version info
if (cmsObject instanceof VersionnedContent)
{
//TODO : add Version infos
}
-
indexWriter.addDocument(doc);
indexWriter.optimize();
result = true;
@@ -171,7 +179,9 @@
catch (IOException e)
{
log.error("Error while adding document into the Lucene
index " , e);
- }
+ } catch (ContentManagementException e) {
+ log.error("Error while getting the contents of the document
to add to the Lucene index " , e);
+ }
finally
{
try
Christophe Lombart wrote:
> The components subproject has no dependencies to the graffito
> portlets subproject (applications/graffito-portlets).
>
> Why do you want to use ServiceAccessor in ContentIndexServiceImpl ? It
> is better to use injection to access to another service.
>
>
> On 10/17/06, Evangelos Vlachogiannis <[EMAIL PROTECTED]> wrote:
>> Hi list,
>>
>> I have met a strange behavior: When I just add in class
>>
>>
components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java
>>
>>
>> the
>>
>> import org.apache.portals.graffito.portlets.util.ServiceAccessor;
>>
>> and try to compile using maven allBuild I compile get error saying that
>> there is not org.apache.portals.graffito.portlets.util package!!! Any
>> ideas pls before I get crazy??
>>
>> Thnx,
>> Vangelis
>>
>>
>
>
--
Evangelos Vlachogiannis
Researcher - University of the Aegean
Contact&More: http://www.syros.aegean.gr/users/evlach/contactme.php
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.4/477 - Release Date: 16/10/2006
--
Best regards,
Christophe