|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Creating stkTextImage paragraph programaticallyHello
I'm new to Magnolia, but we are planning to build some websites with it in the future, and we are currently in the process of experimentation and discovery. The project I'm currently on is creating a magnolia importer that will have to create pages and paragraphs based on the content of existing websites we own. The problem I'm running into is creating images in the repository. At first glance it seems obvious enough: just create the node structure that the stkTextImage dialog creates. Unfortunately this seems not the case. In the below (groovy) code I am creating a paragraph node, and a child 'imageBinary' node. Some utility methods are called but not shown here. StkTextImage is a container for all repository paragraph properties StkImage is a container for all repository image properties. --- def createParagraph(Content parentNode, StkTextImage paragraph) { def paraCount = parentNode.children.size() def nodeName = ("00" + ++paraCount)[-2..-1] Content paragraphNode = createOrFindContentNode(parentNode, nodeName) createOrFindContentNode(paragraphNode, 'text_files') setDataWhenValue(paragraphNode, 'subtitle', paragraph.title) setDataWhenValue(paragraphNode, 'text', paragraph.textAsHtml) paragraphNode.metaData.setTemplate('stkTextImage') StkImage img = paragraph.image if (img) { if (img.type == 'dms') { //dms specific stuff setDataWhenValue(paragraphNode, 'imageDmsUUID', img.dmsUuid) } else if (img.type == 'upload') { //upload specific stuff imageNode = createOrFindResourceNode(paragraphNode, 'imageBinary') setDataWhenValue(imageNode, "extension", img.fileExtension) setDataWhenValue(imageNode, "fileName", "${img.fileName}-(${img.width}x${img.height})") setDataWhenValue(imageNode, "height", "$img.height") setDataWhenValue(imageNode, "width", "$img.width") setDataWhenValue(imageNode, "jcr:data", new ByteArrayInputStream(img.imageByteArray)) setDataWhenValue(imageNode, "size", "$img.sizeInBytes") setDataWhenValue(imageNode, "jcr:mimeType", 'image/jpeg') setData(imageNode, "jcr:lastModified", wrapInCalendar(new Date())) } //global stuff setDataWhenValue(paragraphNode, 'image', img.type) setDataWhenValue(paragraphNode, 'imageCaption', img.caption) setDataWhenValue(paragraphNode, 'imageCopyright', img.copyright) setDataWhenValue(paragraphNode, 'imageDescription', img.description) setDataWhenValue(paragraphNode, 'imageLocation', paragraph.imageLocation) } --- This doesn't work though. The error message: --- An error occurred while executing the script. Error message is no definition found in parent node's node type for new node: no matching child node definition found for {http://www.jcp.org/jcr/1.0}data --- I've been playing around with this code for a while, and tried all kinds of different approaches. But I guess I'm on the wrong track, and need some help. Can anybody give me any advice on this? I attach two files: - the complete listing - an xml export of the created Event page (without the image obviously, the paragraph is the first one in the 'main' node) thanks, -- Ernst bunders Developer VPRO ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <user-list-unsubscribe@...> ---------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <sv:node sv:name="aflevering-5" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mgnl="http://www.magnolia.info/jcr/mgnl" xmlns:jcrfn="http://www.jcp.org/jcr/xpath-functions/1.0" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:rep="internal" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:stringutils="xalan://org.apache.commons.lang.StringUtils" xmlns:_pre="urn:schemas-microsoft-com:office:spreadsheet" xmlns:jcrutils="xalan://it.openmindonline.urmetdomus.assembler.utils.Path" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:content</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>1f7dfccd-4989-4321-9708-29277f14f58b</sv:value> </sv:property> <sv:property sv:name="abstract" sv:type="String"> <sv:value>Het afval dat we lozen verdwijnt niet, er bestaat namelijk geen verdwijnen omdat de aarde een gesloten systeem is. Ons afval lijkt alleen onzichtbaar omdat we het verdunnen met water, bedekken met aarde of weg laten blazen door de wind. Maar uiteindelijk komen we het onvermijdelijk weer tegen in ons drinkwater, de lucht die we inademen, ons voedsel en in ons lichaam. In Tegenlicht de ontwerper William McDonough en de chemicus </sv:value> </sv:property> <sv:property sv:name="date" sv:type="Date"> <sv:value>2006-09-02T21:00:17.931+02:00</sv:value> </sv:property> <sv:property sv:name="eventTitle" sv:type="String"> <sv:value>Afval = voedsel</sv:value> </sv:property> <sv:property sv:name="hideInNav" sv:type="Boolean"> <sv:value>false</sv:value> </sv:property> <sv:property sv:name="location" sv:type="String"> <sv:value>testlocatie</sv:value> </sv:property> <sv:property sv:name="popid" sv:type="Long"> <sv:value>-1</sv:value> </sv:property> <sv:property sv:name="title" sv:type="String"> <sv:value>Afval = voedsel</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:authorid" sv:type="String"> <sv:value>superuser</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.305+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> <sv:value>2009-10-22T11:41:37.305+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:template" sv:type="String"> <sv:value>stkEvent</sv:value> </sv:property> </sv:node> <sv:node sv:name="extras"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>db1b3e3d-1aba-452a-973a-1663cb0b6c72</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.310+02:00</sv:value> </sv:property> </sv:node> </sv:node> <sv:node sv:name="broadcastings"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>2eb1b4c6-f4b6-4c84-b0e8-1d4a10d7976e</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.330+02:00</sv:value> </sv:property> </sv:node> <sv:node sv:name="00"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>c990c970-d949-496c-a657-4b0e2d2a04df</sv:value> </sv:property> <sv:property sv:name="channel" sv:type="String"> <sv:value>Nederland 2 / Radio 2</sv:value> </sv:property> <sv:property sv:name="time" sv:type="Date"> <sv:value>2006-09-02T21:00:17.931+02:00</sv:value> </sv:property> <sv:property sv:name="type" sv:type="String"> <sv:value>geen herhaling</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.341+02:00</sv:value> </sv:property> </sv:node> </sv:node> <sv:node sv:name="01"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>68e51b56-0482-425d-b375-496422675db7</sv:value> </sv:property> <sv:property sv:name="channel" sv:type="String"> <sv:value>Nederland 2 / Radio 2</sv:value> </sv:property> <sv:property sv:name="time" sv:type="Date"> <sv:value>2006-09-06T09:55:17.931+02:00</sv:value> </sv:property> <sv:property sv:name="type" sv:type="String"> <sv:value>eerste herhaling</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.349+02:00</sv:value> </sv:property> </sv:node> </sv:node> </sv:node> <sv:node sv:name="item-1"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:content</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>ee7227c3-6ac0-4766-959c-e75458d8fc3e</sv:value> </sv:property> <sv:property sv:name="abstract" sv:type="String"> <sv:value>De Chinese economie groeit razendsnel en het milieu komt daarbij op de laatste plaats. Maar met de stijgende milieukosten zoekt de Chinese regering noodgedwongen naar alternatieve productiemethoden. En dus experimenteert het land met ‘McDonoughiaanse’ cradle to cradle- steden.</sv:value> </sv:property> <sv:property sv:name="hideInNav" sv:type="Boolean"> <sv:value>false</sv:value> </sv:property> <sv:property sv:name="title" sv:type="String"> <sv:value>Cradle to Cradle in China</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:authorid" sv:type="String"> <sv:value>superuser</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.377+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> <sv:value>2009-10-22T11:41:37.377+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:template" sv:type="String"> <sv:value>stkArticle</sv:value> </sv:property> </sv:node> <sv:node sv:name="extras"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>7656305d-1d83-4740-9b46-f7119914dfb1</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.379+02:00</sv:value> </sv:property> </sv:node> </sv:node> </sv:node> <sv:node sv:name="item-2"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:content</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>c8b59d32-2c8c-4dfe-ab27-4796b35d357a</sv:value> </sv:property> <sv:property sv:name="hideInNav" sv:type="Boolean"> <sv:value>false</sv:value> </sv:property> <sv:property sv:name="title" sv:type="String"> <sv:value>William McDonough</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:authorid" sv:type="String"> <sv:value>superuser</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.394+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> <sv:value>2009-10-22T11:41:37.394+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:template" sv:type="String"> <sv:value>stkArticle</sv:value> </sv:property> </sv:node> <sv:node sv:name="extras"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>7d8ce398-6c06-43d3-9efc-0a751eceb6cb</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.395+02:00</sv:value> </sv:property> </sv:node> </sv:node> </sv:node> <sv:node sv:name="item-3"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:content</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>c834c5b2-6509-4cc9-b767-528c29ffc204</sv:value> </sv:property> <sv:property sv:name="hideInNav" sv:type="Boolean"> <sv:value>false</sv:value> </sv:property> <sv:property sv:name="title" sv:type="String"> <sv:value>Michael Braungart</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:authorid" sv:type="String"> <sv:value>superuser</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.406+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> <sv:value>2009-10-22T11:41:37.406+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:template" sv:type="String"> <sv:value>stkArticle</sv:value> </sv:property> </sv:node> <sv:node sv:name="extras"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>6118fdcc-cf11-4e9b-bb52-d54c69b69690</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.407+02:00</sv:value> </sv:property> </sv:node> </sv:node> </sv:node> <sv:node sv:name="item-4"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:content</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>de5d7df3-71db-4db4-996c-a9e3562ce522</sv:value> </sv:property> <sv:property sv:name="abstract" sv:type="String"> <sv:value>Een SUV die het milieu niet belast. Het klinkt als een contradictio in terminis. Maar middels een samenwerking met McDonough en Braungart heeft Ford een concept-auto ontwikkeld die een stevige milieukeuring kan doorlopen.</sv:value> </sv:property> <sv:property sv:name="hideInNav" sv:type="Boolean"> <sv:value>false</sv:value> </sv:property> <sv:property sv:name="title" sv:type="String"> <sv:value>Ford Model U</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:authorid" sv:type="String"> <sv:value>superuser</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.426+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> <sv:value>2009-10-22T11:41:37.426+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:template" sv:type="String"> <sv:value>stkArticle</sv:value> </sv:property> </sv:node> <sv:node sv:name="extras"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>9359146b-a250-4b1c-9bdb-1b183d7064c7</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:41:37.427+02:00</sv:value> </sv:property> </sv:node> </sv:node> </sv:node> <sv:node sv:name="main"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>990282fe-a806-43da-a858-c8dc250af53d</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:53:18.020+02:00</sv:value> </sv:property> </sv:node> <sv:node sv:name="01"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>db21a990-3b08-4f84-a0e8-d62ef18e4fa8</sv:value> </sv:property> <sv:property sv:name="image" sv:type="String"> <sv:value>upload</sv:value> </sv:property> <sv:property sv:name="imageCaption" sv:type="String"> <sv:value>Afval is voedsel1</sv:value> </sv:property> <sv:property sv:name="text" sv:type="String"> <sv:value><p>In 1991 ontmoeten de ontwerper William McDonough en de chemicus Michael Braungart elkaar in een tuin ergens op een dak in New York. Ze raken in gesprek over de giftigheid van afvalstoffen en het ontwerpen van producten. Michael legt William zijn idee voor om een biologisch afbreekbare frisdrankfles te maken met daarin ingebouwd een zaadje. Je kunt de fles dan gewoon weggooien in de natuur. De fles zal dan afgebroken worden en tot voedsel dienen voor het zaadje. De natuur kent dit principe allang maar McDonough en Braungart bedachten dat het principe Afval = Voedsel ook toegepast kan worden op alle producten die de mens fabriceert.</p> <p>Drie jaar later ging hun bedrijf McDonough Braungart Design Chemistry (MBDC) van start. Essentieel in hun ontwerpstrategie is om het oude adagium 'Cradle to Grave' te vervangen door het 'Cradle to Cradle' (C2C) principe:</p> <p> - Ontwerp producten en processen zo dat de waardevolle materialen en de investeringen van triljarden dollars die gebruikt worden om ze te produceren beschikbaar blijven voor de mens en zijn natuurlijke omgeving.<br/> - Ontwerp alle producten zodanig dat ze volledig kunnen worden hergebruikt uitgaande van het principe: Afval is voedsel.<br/> - Een product moet volledig afbreekbaar zijn in de biosfeer en daar als voedsel dienen voor natuurlijke organismen.<br/> - Alle niet afbreekbare stoffen moeten beschouwd worden als een hoogwaardige grondstof voor nieuwe producten in de technosfeer.<br/> - Zorg ervoor dat er tijdens de fabricage van een product op geen enkele wijze schadelijke afvalstoffen ontstaan.</p> <p>McDonough is een graag geziene gast op het Witte Huis, want zijn milieustrategie pleit niet voor versobering en anticonsumentisme, integendeel. Groei, overvloed, economische groei en een schoon milieu gaan zeer goed hand in hand. Het klinkt utopisch en onhaalbaar, ware het niet dat het Afval = Voedsel als concept al overgenomen is door bedrijven als NIKE, Ford-motor company, kantoormeubel fabrikant Herman Miller en andere Fortune 500 ondernemingen. Recentelijk heeft ook de Chinese overheid het duo gevraagd hun ontwerpstrategie los te laten op de bouw van nieuwe huizen. China moet de komende 15 jaar voor 400 miljoen mensen nieuwe huizen bouwen. Als je dat met bakstenen zou doen zou China snel door zijn klei en zijn kolenvoorraden heen zijn. De Chinese president Hu Jintao citeert graag uit het werk van McDonough en Braungart. Hun strategie is uitgangspunt voor het officiële Chinese regeringsbeleid om te komen tot een Circular economy.</p> <p>In Tegenlicht een schets van een wereld waarin afval voedsel wordt en waarin consumenten geen vervuilers meer zijn. Utopie of werkelijkheid?</p> <p>regie: Rob van Hattum<br/> research: Gijs M. Swantee<br/> productie: Karin Spiegel/Madeleine Somer<br/> eindredactie: Doke Romeijn/Frank Wiering</p></sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:53:18.022+02:00</sv:value> </sv:property> <sv:property sv:name="mgnl:template" sv:type="String"> <sv:value>stkTextImage</sv:value> </sv:property> </sv:node> <sv:node sv:name="text_files"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>8ca9651a-e8ae-4160-a491-215cd207e8ea</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:creationdate" sv:type="Date"> <sv:value>2009-10-22T11:53:18.023+02:00</sv:value> </sv:property> </sv:node> </sv:node> </sv:node> </sv:node> </sv:node> |
|
|
Re: Creating stkTextImage paragraph programaticallyAs far as I can tell, you are not doing exactly the same things as for example DMS is doing on file upload: // write file this.fileNode = node.createNodeData("document", javax.jcr.PropertyType.BINARY); InputStream in = new FileInputStream(tmpFile); this.fileNode.setValue(in); IOUtils.closeQuietly(in); ... I don't think you should (or could) create any jcr:xxx properties directly. Why can't you try to do the same as above - i.e. get the node and call Magnolia API to store the binary data in it and let Magnolia handle all the details of how it will be stored? If you really insist on saving those binary data directly yourself, then look in the DefaultContent to see how Magnolia calls JCR APIs to do so. HTH, Jan On Thu, 2009-10-22 at 11:57 +0200, Ernst Bunders wrote: > Hello > > I'm new to Magnolia, but we are planning to build some websites with > it in the future, and we are currently in the process of > experimentation and discovery. The project I'm currently on is > creating a magnolia importer that will have to create pages and > paragraphs based on the content of existing websites we own. > > The problem I'm running into is creating images in the repository. At > first glance it seems obvious enough: just create the node structure > that the stkTextImage dialog creates. Unfortunately this seems not the > case. In the below (groovy) code I am creating a paragraph node, and > a child 'imageBinary' node. Some utility methods are called but not > shown here. > > StkTextImage is a container for all repository paragraph properties > StkImage is a container for all repository image properties. > > --- > def createParagraph(Content parentNode, StkTextImage paragraph) { > def paraCount = parentNode.children.size() > def nodeName = ("00" + ++paraCount)[-2..-1] > Content paragraphNode = createOrFindContentNode(parentNode, nodeName) > createOrFindContentNode(paragraphNode, 'text_files') > setDataWhenValue(paragraphNode, 'subtitle', paragraph.title) > setDataWhenValue(paragraphNode, 'text', paragraph.textAsHtml) > paragraphNode.metaData.setTemplate('stkTextImage') > StkImage img = paragraph.image > if (img) { > if (img.type == 'dms') { > //dms specific stuff > setDataWhenValue(paragraphNode, 'imageDmsUUID', img.dmsUuid) > } else if (img.type == 'upload') { > //upload specific stuff > imageNode = createOrFindResourceNode(paragraphNode, 'imageBinary') > setDataWhenValue(imageNode, "extension", img.fileExtension) > setDataWhenValue(imageNode, "fileName", > "${img.fileName}-(${img.width}x${img.height})") > setDataWhenValue(imageNode, "height", "$img.height") > setDataWhenValue(imageNode, "width", "$img.width") > setDataWhenValue(imageNode, "jcr:data", new > ByteArrayInputStream(img.imageByteArray)) > setDataWhenValue(imageNode, "size", "$img.sizeInBytes") > setDataWhenValue(imageNode, "jcr:mimeType", 'image/jpeg') > setData(imageNode, "jcr:lastModified", wrapInCalendar(new Date())) > } > //global stuff > setDataWhenValue(paragraphNode, 'image', img.type) > setDataWhenValue(paragraphNode, 'imageCaption', img.caption) > setDataWhenValue(paragraphNode, 'imageCopyright', img.copyright) > setDataWhenValue(paragraphNode, 'imageDescription', img.description) > setDataWhenValue(paragraphNode, 'imageLocation', paragraph.imageLocation) > } > --- > > This doesn't work though. The error message: > > --- > An error occurred while executing the script. Error message is no > definition found in parent node's node type for new node: no matching > child node definition found for {http://www.jcp.org/jcr/1.0}data > --- > > I've been playing around with this code for a while, and tried all > kinds of different approaches. But I guess I'm on the wrong track, and > need some help. > > Can anybody give me any advice on this? > > I attach two files: > - the complete listing > - an xml export of the created Event page (without the image > obviously, the paragraph is the first one in the 'main' node) > > > thanks, > > > -- > Ernst bunders > Developer VPRO > > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <user-list-unsubscribe@...> > ---------------------------------------------------------------- ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <user-list-unsubscribe@...> ---------------------------------------------------------------- |
|
|
Re: Creating stkTextImage paragraph programaticallyhi Jan Thank you. This was exactly what I was looking for. I'm quite new to the magnolia codebase (and jcr in genral), and wasn't able to locate an example of the 'magnolia way' of doing this. I will give it a try, regards, Ernst 2009/10/23 Jan Haderka <jan.haderka@...>: > > As far as I can tell, you are not doing exactly the same things as for > example DMS is doing on file upload: > > // write file > this.fileNode = node.createNodeData("document", > javax.jcr.PropertyType.BINARY); > InputStream in = new FileInputStream(tmpFile); > this.fileNode.setValue(in); > IOUtils.closeQuietly(in); > > ... I don't think you should (or could) create any jcr:xxx properties > directly. > > Why can't you try to do the same as above - i.e. get the node and call > Magnolia API to store the binary data in it and let Magnolia handle all > the details of how it will be stored? If you really insist on saving > those binary data directly yourself, then look in the DefaultContent to > see how Magnolia calls JCR APIs to do so. > > HTH, > Jan > > > > > On Thu, 2009-10-22 at 11:57 +0200, Ernst Bunders wrote: >> Hello >> >> I'm new to Magnolia, but we are planning to build some websites with >> it in the future, and we are currently in the process of >> experimentation and discovery. The project I'm currently on is >> creating a magnolia importer that will have to create pages and >> paragraphs based on the content of existing websites we own. >> >> The problem I'm running into is creating images in the repository. At >> first glance it seems obvious enough: just create the node structure >> that the stkTextImage dialog creates. Unfortunately this seems not the >> case. In the below (groovy) code I am creating a paragraph node, and >> a child 'imageBinary' node. Some utility methods are called but not >> shown here. >> >> StkTextImage is a container for all repository paragraph properties >> StkImage is a container for all repository image properties. >> >> --- >> def createParagraph(Content parentNode, StkTextImage paragraph) { >> def paraCount = parentNode.children.size() >> def nodeName = ("00" + ++paraCount)[-2..-1] >> Content paragraphNode = createOrFindContentNode(parentNode, nodeName) >> createOrFindContentNode(paragraphNode, 'text_files') >> setDataWhenValue(paragraphNode, 'subtitle', paragraph.title) >> setDataWhenValue(paragraphNode, 'text', paragraph.textAsHtml) >> paragraphNode.metaData.setTemplate('stkTextImage') >> StkImage img = paragraph.image >> if (img) { >> if (img.type == 'dms') { >> //dms specific stuff >> setDataWhenValue(paragraphNode, 'imageDmsUUID', img.dmsUuid) >> } else if (img.type == 'upload') { >> //upload specific stuff >> imageNode = createOrFindResourceNode(paragraphNode, 'imageBinary') >> setDataWhenValue(imageNode, "extension", img.fileExtension) >> setDataWhenValue(imageNode, "fileName", >> "${img.fileName}-(${img.width}x${img.height})") >> setDataWhenValue(imageNode, "height", "$img.height") >> setDataWhenValue(imageNode, "width", "$img.width") >> setDataWhenValue(imageNode, "jcr:data", new >> ByteArrayInputStream(img.imageByteArray)) >> setDataWhenValue(imageNode, "size", "$img.sizeInBytes") >> setDataWhenValue(imageNode, "jcr:mimeType", 'image/jpeg') >> setData(imageNode, "jcr:lastModified", wrapInCalendar(new Date())) >> } >> //global stuff >> setDataWhenValue(paragraphNode, 'image', img.type) >> setDataWhenValue(paragraphNode, 'imageCaption', img.caption) >> setDataWhenValue(paragraphNode, 'imageCopyright', img.copyright) >> setDataWhenValue(paragraphNode, 'imageDescription', img.description) >> setDataWhenValue(paragraphNode, 'imageLocation', paragraph.imageLocation) >> } >> --- >> >> This doesn't work though. The error message: >> >> --- >> An error occurred while executing the script. Error message is no >> definition found in parent node's node type for new node: no matching >> child node definition found for {http://www.jcp.org/jcr/1.0}data >> --- >> >> I've been playing around with this code for a while, and tried all >> kinds of different approaches. But I guess I'm on the wrong track, and >> need some help. >> >> Can anybody give me any advice on this? >> >> I attach two files: >> - the complete listing >> - an xml export of the created Event page (without the image >> obviously, the paragraph is the first one in the 'main' node) >> >> >> thanks, >> >> >> -- >> Ernst bunders >> Developer VPRO >> >> ---------------------------------------------------------------- >> For list details see >> http://www.magnolia-cms.com/home/community/mailing-lists.html >> To unsubscribe, E-mail to: <user-list-unsubscribe@...> >> ---------------------------------------------------------------- > > > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <user-list-unsubscribe@...> > ---------------------------------------------------------------- > > -- Ernst bunders Ontwikkelaar VPRO ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <user-list-unsubscribe@...> ---------------------------------------------------------------- |
|
|
Re: Creating stkTextImage paragraph programaticallyhello Jan I got it right, thanks again. I have learned that the NodeData Entity usually wraps a single jcr propety, except when it is created with PropertyType.BINARY. In that case it actually wraps a whole node, and you can set properties on this node using the setAttribute() methods (only string and Calendar values are supported). This is a bit unexpected, but non the less good to know. Also: your assumption that jcr:xx should not be set directly is not true. if you look a bit farther into the code sample you send me you find: this.fileNode.setAttribute(FileProperties.PROPERTY_CONTENTTYPE, mimetype); Where FileProperties.PROPERTY_CONTENTTYPE resolves to 'jcr:mimeType'. so, no sweat there. regards, Ernst 2009/10/23 Jan Haderka <jan.haderka@...>: > > As far as I can tell, you are not doing exactly the same things as for > example DMS is doing on file upload: > > // write file > this.fileNode = node.createNodeData("document", > javax.jcr.PropertyType.BINARY); > InputStream in = new FileInputStream(tmpFile); > this.fileNode.setValue(in); > IOUtils.closeQuietly(in); > > ... I don't think you should (or could) create any jcr:xxx properties > directly. > > Why can't you try to do the same as above - i.e. get the node and call > Magnolia API to store the binary data in it and let Magnolia handle all > the details of how it will be stored? If you really insist on saving > those binary data directly yourself, then look in the DefaultContent to > see how Magnolia calls JCR APIs to do so. > > HTH, > Jan > > > > > On Thu, 2009-10-22 at 11:57 +0200, Ernst Bunders wrote: >> Hello >> >> I'm new to Magnolia, but we are planning to build some websites with >> it in the future, and we are currently in the process of >> experimentation and discovery. The project I'm currently on is >> creating a magnolia importer that will have to create pages and >> paragraphs based on the content of existing websites we own. >> >> The problem I'm running into is creating images in the repository. At >> first glance it seems obvious enough: just create the node structure >> that the stkTextImage dialog creates. Unfortunately this seems not the >> case. In the below (groovy) code I am creating a paragraph node, and >> a child 'imageBinary' node. Some utility methods are called but not >> shown here. >> >> StkTextImage is a container for all repository paragraph properties >> StkImage is a container for all repository image properties. >> >> --- >> def createParagraph(Content parentNode, StkTextImage paragraph) { >> def paraCount = parentNode.children.size() >> def nodeName = ("00" + ++paraCount)[-2..-1] >> Content paragraphNode = createOrFindContentNode(parentNode, nodeName) >> createOrFindContentNode(paragraphNode, 'text_files') >> setDataWhenValue(paragraphNode, 'subtitle', paragraph.title) >> setDataWhenValue(paragraphNode, 'text', paragraph.textAsHtml) >> paragraphNode.metaData.setTemplate('stkTextImage') >> StkImage img = paragraph.image >> if (img) { >> if (img.type == 'dms') { >> //dms specific stuff >> setDataWhenValue(paragraphNode, 'imageDmsUUID', img.dmsUuid) >> } else if (img.type == 'upload') { >> //upload specific stuff >> imageNode = createOrFindResourceNode(paragraphNode, 'imageBinary') >> setDataWhenValue(imageNode, "extension", img.fileExtension) >> setDataWhenValue(imageNode, "fileName", >> "${img.fileName}-(${img.width}x${img.height})") >> setDataWhenValue(imageNode, "height", "$img.height") >> setDataWhenValue(imageNode, "width", "$img.width") >> setDataWhenValue(imageNode, "jcr:data", new >> ByteArrayInputStream(img.imageByteArray)) >> setDataWhenValue(imageNode, "size", "$img.sizeInBytes") >> setDataWhenValue(imageNode, "jcr:mimeType", 'image/jpeg') >> setData(imageNode, "jcr:lastModified", wrapInCalendar(new Date())) >> } >> //global stuff >> setDataWhenValue(paragraphNode, 'image', img.type) >> setDataWhenValue(paragraphNode, 'imageCaption', img.caption) >> setDataWhenValue(paragraphNode, 'imageCopyright', img.copyright) >> setDataWhenValue(paragraphNode, 'imageDescription', img.description) >> setDataWhenValue(paragraphNode, 'imageLocation', paragraph.imageLocation) >> } >> --- >> >> This doesn't work though. The error message: >> >> --- >> An error occurred while executing the script. Error message is no >> definition found in parent node's node type for new node: no matching >> child node definition found for {http://www.jcp.org/jcr/1.0}data >> --- >> >> I've been playing around with this code for a while, and tried all >> kinds of different approaches. But I guess I'm on the wrong track, and >> need some help. >> >> Can anybody give me any advice on this? >> >> I attach two files: >> - the complete listing >> - an xml export of the created Event page (without the image >> obviously, the paragraph is the first one in the 'main' node) >> >> >> thanks, >> >> >> -- >> Ernst bunders >> Developer VPRO >> >> ---------------------------------------------------------------- >> For list details see >> http://www.magnolia-cms.com/home/community/mailing-lists.html >> To unsubscribe, E-mail to: <user-list-unsubscribe@...> >> ---------------------------------------------------------------- > > > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <user-list-unsubscribe@...> > ---------------------------------------------------------------- > > -- Ernst bunders Ontwikkelaar VPRO ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <user-list-unsubscribe@...> ---------------------------------------------------------------- |
| Free embeddable forum powered by Nabble | Forum Help |