Hi,

I'm trying to listen to the event documentCreated. My bundle work fine but I 
have encoutred.

09:36:07,052 INFO  [STDOUT] Document Created: documentCreated (my listener)

09:36:07,101 ERROR [BinaryConverter] Error during Word2Text conversion
org.nuxeo.ecm.core.convert.api.ConversionException: Error during Word2Text 
conversion
        at 
org.nuxeo.ecm.core.convert.plugins.text.extractors.Word2TextConverter.convert(Word2TextConverter.java:57)
        at 
org.nuxeo.ecm.core.convert.service.ConversionServiceImpl.convert(ConversionServiceImpl.java:172)
        at 
org.nuxeo.ecm.core.convert.plugins.text.extractors.FullTextConverter.convert(FullTextConverter.java:72)
Is this a bug ?

I use a nuxeo-ep-5.2.0RC1 with java 1.5 JDK on Eclipse.Without addons on my 
nuxeo.

I have no problems with deployement of my bundle.


If I'm trying to listen documentPublished I have another problem and I can't 
find the document's data.

The result of my listener

09:47:26,868 INFO  [STDOUT] Document Published: documentPublished (my listener)

09:47:26,879 WARN  [JDBCExceptionReporter] SQL Warning: 10000, SQLState: 01J01
09:47:26,879 WARN  [JDBCExceptionReporter] Database 
'/Applications/nuxeo-ep-5.2.0-RC1/server/default/data/derby/nuxeo' not created, 
connection made to existing database instead.
09:47:26,890 ERROR [NotificationEventListener] unable to find published doc, 
exiting
09:47:26,891 WARN  [ServiceManager] Existing binding but unreachable service 
for org.nuxeo.ecm.platform.annotations.api.AnnotationsService ! Fallback on 
local service...

I think it's a bug of nuxeo (jira issue on 
http://jira.nuxeo.org/browse/NXP-3321 )

So how can find my documents datas ? 

after, my listener : 


public class DocumentCreationListener implements EventListener {

  
    public static final String HANDLED_EVENT = "Event Handled";

 

    public DocumentCreationListener() {
    }

    public void handleEvent(Event event) throws ClientException {
  
        event.getContext().getProperties().put(HANDLED_EVENT, "true");

      
        EventContext ctx=event.getContext();
        /*System.out.println("EventContext is of 
type:"+ctx.getClass().getName());*/
        if (!(ctx instanceof DocumentEventContext)) {
            return;
        }

   
        DocumentEventContext context = (DocumentEventContext) 
event.getContext();

        
        Map<String, Serializable> allProps = context.getProperties();
        System.out.println("Event name:"+event.getName()+"@"+event.getTime());
        for (String key : allProps.keySet()) {
            System.out.println("property "+key+"="+allProps.get(key));

        }
      //is the document published?
        if ((event.getName().equals(DocumentEventTypes.DOCUMENT_CREATED))) {
            System.out.println("Document Created: "+event.getName());
            //this gets the document that is the "cause" of the event, critical!
            CoreSession coreSession = event.getContext().getCoreSession();
            DocumentModel model = context.getSourceDocument();
            exportDocument(model,coreSession);
            return;
        }
        if ((event.getName().equals(DocumentEventTypes.DOCUMENT_PUBLISHED))) {
            System.out.println("Document Published: "+event.getName());
         
            CoreSession coreSession = event.getContext().getCoreSession();
            DocumentModel model = context.getSourceDocument();
            exportDocument(model,coreSession);
            return;
        }
        if ((event.getName().equals(DocumentEventTypes.DOCUMENT_CREATED))) {
            System.out.println("Document Created: "+event.getName());
            //this gets the document that is the "cause" of the event, critical!
            CoreSession coreSession = event.getContext().getCoreSession();
            DocumentModel model = context.getSourceDocument();
            exportDocument(model,coreSession);
            return;
        }
        //is the document created?
        if (!(event.getName().equals(DocumentEventTypes.DOCUMENT_PUBLISHED))) {
            System.out.println("Document Event Ignored: "+event.getName());
            return;
        }
       

       
    }
/
        private void exportDocument(DocumentModel model, CoreSession 
coreSession) {
                DocumentReader reader = null;
                DocumentWriter writer = null;
                String sid = model.getSessionId();
                //CoreSession docMgr = coreSession;
                CoreSession docMgr = CoreInstance.getInstance().getSession(sid);
                //CoreSession docMgr = event.getContext().getCoreSession()
                DocumentModel root = model;

                try {
                reader = new DocumentTreeReader(docMgr, root, true);
                  writer = new NuxeoArchiveWriter(new File("/tmp/export.zip"));
                  // creating a pipe
                  DocumentPipe pipe = new DocumentPipeImpl(10);
                  pipe.setReader(reader);
                  pipe.setWriter(writer);
                  pipe.run();   
                } catch (Exception e) {
                        e.printStackTrace();
                } finally { 
                  if (reader != null) {
                    reader.close(); 
                  }
                  if (writer != null) { 
                    writer.close(); 
                  } 
                }
                
        }

}
--
Posted by "meghRF4" at Nuxeo Discussions <http://nuxeo.org/discussions>
View the complete thread: 
<http://www.nuxeo.org/discussions/thread.jspa?threadID=2433#6614>
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm

Reply via email to