|
On the magnolia and groovy websites (and various other blogs/support/documentation), it lists many of these methods as deprecated, however, when trying to use the new methods, I am receiving errors that lead me to believe they are not fully implemented in my copy (5.2.2) of magnolia. So, I have gone back to the original methods that were loaded with Magnolia 5.2.2.
This is my issue, the Groovy script(2) below is not failing, however, the new contact is not showing up in the contact app. Is there something I need to do to "activate" the contact so it can be "seen" the Contacts app that I am missing? Here are the details:
1) addressBook.xml
<?xml version="1.0" encoding="UTF-8"?>
<address>
<firstName>Patti</firstName>
<lastName>Horestski</lastName>
<organization>DFAS Rome</organization>
<streetAddress>325 Brooks Road</streetAddress>
<city>ROME</city>
<zip>13441-4527</zip>
<email>[email protected]</email>
</address>
2) Groovy Import Script, below:
hm = MgnlContext.getHierarchyManager("contacts")
contacts = hm.getContent('/contacts')
itemType = new ItemType('Contact')
file = new File("c:/Users/pamela_grubbs/app-reference/RemoteSystemsTempFiles/addressBook.xml")
addressBook = new XmlSlurper().parseText(file.text)
addressBook.each {
id ="/$
{it.firstName.text()[0]}${it.lastName.text()}"
content = ContentUtil.createPath(contacts, id, itemType);
println "/${it.firstName.text()[0]}
$
{it.lastName.text()}
"
content.email = it.email
content.lastName = it.lastName
content.firstName = it.firstName
content.streetAddress = it.streetAddress
content.zipCode = it.zip
content.city = it.city
content.organizationName = it.organization
}
contacts.save()
return 'done'
3) Receiving the following output:
/PHorestski
done
4) However, there is no new contact in the Contacts App. I am able to UPDATE a contact that already exists using a similar groovy script set up and the XMLSlurper and its updated information shows up immediately in the contacts app. Please let me know what I am missing. The JCR XML set-up of the Contact app used in this example is out-of-box for Magnolia 5.2.2.
|