[Building Sakai] Saving a site property in 2.8.x

Erik Froese erik.froese at gmail.com
Mon Nov 14 14:30:56 PST 2011


I'm trying to save a property on a Site object in Sakai 2.8.x and I
think I'm running into a unicode problem.

First I set the property on a SiteEdit before it is sent through the
SiteService.

// sEdit is a SiteEdit Object
ResourcePropertiesEdit rp = sEdit.getPropertiesEdit();
rp.addProperty(STATE_SITE_ACCESS_SHOPPING_ALLOWED_FUNCTIONS,
StringUtils.join(allowedFunctions, "|"));

Later the sEdit is saved by calling SiteService.save(site). I'm
modifying the SiteAction class (yikes!) so its taking care of calling
save(sEdit)

What should happen is we should see a statement issued to MySQL like this:
insert into SAKAI_SITE_PROPERTY( SITE_ID, NAME, VALUE ) values
("3b1c5adf-29b6-40b3-954f-a9f841a92411", "shopping-allowed-functions",
"annc.read|asn.read|calendar.read")

What I see instead is this:

 insert into SAKAI_SITE_PROPERTY( SITE_ID, NAME, VALUE ) values
(x'33623163356164662D323962362D343062332D393534662D613966383431613932343131',x'73746174655F736974655F6163636573735F73686F7070696E675F616C6C6F7765645F66756E6374696F6E73',x'616E6E632E726561647C61736E2E726561647C63616C656E6461722E72656164')

As far as I can tell this is caused by
BasicSqlService.prepareStatement setting the statement parameters
using setBytes.

This causes the constraint violation since the SITE_ID doesn't match
anything in SAKAI_SITE.

I see this in catalina.out
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Cannot add or update a child row: a foreign key constraint fails
(`sakai`.`sakai_site_property`, CONSTRAINT
`sakai_site_property_ibfk_1` FOREIGN KEY (`SITE_ID`) REFERENCES
`SAKAI_SITE` (`SITE_ID`))

Has anyone else run into this? Any pointers?

Thanks

Erik


More information about the sakai-dev mailing list