|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
DocumentModel setProperty doesn't worksHi,
I try to set properties processes in my EventListener. It works wel when I create my own documentType but not when I update it. the process works without errors or warning, but doesn't update my DocumentModel. PLEASE SOME HELP. It's made me cray ! *this is my eventcontrib : * <component name="be.pcsol.project.dis.NoticeCreationListener"> <extension target="org.nuxeo.ecm.core.event.EventServiceComponent" point="listener"> <listener name="NoticeCreationListener" async="false" postCommit="false" class="be.pcsol.events.NoticeCreationListener" priority="140"> </listener> <listener name="NoticeUpdateListener" async="false" postCommit="false" class="be.pcsol.events.NoticeUpdateListener" order="157"> <event>documentModified</event> </listener> </extension> </component> *this is my eventListener classes* package be.pcsol.events; import java.io.File; import java.io.FileFilter; import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.naming.NamingException; import org.jboss.seam.Component; import org.jboss.util.Classes; import org.nuxeo.common.utils.Path; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreInstance; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DataModel; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.DocumentRef; import org.nuxeo.ecm.core.api.event.CoreEvent; import org.nuxeo.ecm.core.api.event.DocumentEventTypes; import org.nuxeo.ecm.core.api.model.Property; import org.nuxeo.ecm.core.api.model.PropertyException; import org.nuxeo.ecm.core.event.Event; import org.nuxeo.ecm.core.event.EventContext; import org.nuxeo.ecm.core.event.EventListener; import org.nuxeo.ecm.core.event.impl.DocumentEventContext; import org.nuxeo.ecm.core.io.DocumentPipe; import org.nuxeo.ecm.core.io.DocumentReader; import org.nuxeo.ecm.core.io.DocumentWriter; import org.nuxeo.ecm.core.io.impl.DocumentPipeImpl; import org.nuxeo.ecm.core.io.impl.plugins.SingleDocumentReader; import org.nuxeo.ecm.core.io.impl.plugins.XMLDirectoryWriter; import org.nuxeo.ecm.directory.Directory; import org.nuxeo.ecm.directory.DirectoryException; import org.nuxeo.ecm.directory.DirectoryServiceImpl; import org.nuxeo.ecm.directory.IdGenerator; import org.nuxeo.ecm.directory.Session; import org.nuxeo.ecm.directory.api.DirectoryService; import org.nuxeo.ecm.directory.sql.SQLDirectoryProxy; import org.nuxeo.runtime.api.Framework; import be.pcsol.beans.NoticeBeanManager; import com.cmp.dis.core.interfaces.Export; import com.mexi.utils.IOUtils; import com.mexi.utils.JNDIHelper; public class NoticeUpdateListener implements EventListener { public void handleEvent(CoreEvent coreevent) throws ClientException { coreevent.getInfo(); } public void handleEvent(Event event) throws ClientException { EventContext ctx = event.getContext(); if (!(ctx instanceof EventContext)) { return; } Object o = event.getContext(); if (o instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) event .getContext(); DocumentModel model = context.getSourceDocument(); if (model.getType().equals("Notice")) { CoreSession ses = context.getCoreSession(); String title = (String) model.getProperty("notice", "nameOfMedicalProductNL"); model.setProperty("dublincore", "title", title); String[] classesLabelTab = computeClassesLabel(model); String classesLabel = ""; if (classesLabelTab.length > 0) { for (int i = 0; i < classesLabelTab.length; i++) { classesLabel = classesLabelTab[i] + "/"; } model.setProperty("notice", "classespharmacotherapeutiquesLabel", classesLabel); } ses.saveDocument(model); } } } private String[] computeClassesLabel(DocumentModel model) throws PropertyException, ClientException { Serializable s = model .getPropertyValue("nt:classespharmacotherapeutiquesId"); int taille = 0; if (s instanceof String[]) { String[] classesId = (String[]) s; taille = classesId.length; String[] classesLabel = new String[taille]; if (classesLabel.length > 0) { for (int i = 0; i < classesId.length; i++) { classesLabel[i] = computeLabelValue( "classespharmacotherapeutiques", classesId[i]); } } return classesLabel; } else { String[] empty = new String[0]; return empty; } } /** * this method open a session in a directory (with his name) and de id (we * receive the id in de tag <nxdir: selectOneListBox>) and give the label as * string */ private String computeLabelValue(String dirName, String id) throws ClientException { // Directory dir = getDirectory(dirName); DirectoryService dirService; Session ses = null; String label; try { dirService = Framework.getLocalService(DirectoryService.class); } catch (Exception e) { throw new ClientException(e); } try { // ses = dir.getSession(); ses = dirService.open(dirName); DocumentModel entry = ses.getEntry(id, true); if (entry != null) { label = (String) entry.getProperty("vocabulary", "label"); return label; } else { return label = ""; } } finally { if (ses != null) { ses.close(); } } } } -- Posted by "meghRF4" at Nuxeo Discussions <http://nuxeo.org/discussions> View the complete thread: <http://www.nuxeo.org/discussions/thread.jspa?threadID=2960#8707> _______________________________________________ ECM mailing list ECM@... http://lists.nuxeo.com/mailman/listinfo/ecm To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm |
|
|
Re: DocumentModel setProperty doesn't worksTry to save the sassion as well after you save the document model.
ses.saveDocument(model); ses.save(); -- Posted by "cbaican" at Nuxeo Discussions <http://nuxeo.org/discussions> View the complete thread: <http://www.nuxeo.org/discussions/thread.jspa?threadID=2960#8710> _______________________________________________ ECM mailing list ECM@... http://lists.nuxeo.com/mailman/listinfo/ecm To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm |
|
|
Re: DocumentModel setProperty doesn't worksIt doesn't works but thanks to answer.
-- Posted by "meghRF4" at Nuxeo Discussions <http://nuxeo.org/discussions> View the complete thread: <http://www.nuxeo.org/discussions/thread.jspa?threadID=2960#8817> _______________________________________________ ECM mailing list ECM@... http://lists.nuxeo.com/mailman/listinfo/ecm To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm |
|
|
Re: DocumentModel setProperty doesn't worksDo you see in the debugger going through the saveDocument(model) method with the right property ?
-- Posted by "arussel" at Nuxeo Discussions <http://nuxeo.org/discussions> View the complete thread: <http://www.nuxeo.org/discussions/thread.jspa?threadID=2960#8844> _______________________________________________ ECM mailing list ECM@... http://lists.nuxeo.com/mailman/listinfo/ecm To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm |
|
|
Re: DocumentModel setProperty doesn't worksIf debugger is on, and a toogle point on this method, all like correct. (that is why I don't understand). the method setProperty... likes to work correctly. the methods save... session likes to work correctly too. I can send an attachement with code if you want. (just say to me where to send).
Best regards, megh -- Posted by "meghRF4" at Nuxeo Discussions <http://nuxeo.org/discussions> View the complete thread: <http://www.nuxeo.org/discussions/thread.jspa?threadID=2960#8849> _______________________________________________ ECM mailing list ECM@... http://lists.nuxeo.com/mailman/listinfo/ecm To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm |
| Free embeddable forum powered by Nabble | Forum Help |