if (hdb == null) {
throw new TMLScriptException("Cannot use tmlform.storeInHDB() in database " + targetContext.db().getDbReference() + " where HDB is not enabled");
}
// Create parameter object
HDBModelParams params = new HDBModelParams(HDBModel.TYPE_CONTENT);
params.setForm(this);
params.setCustomParam(parameter);
// Perform update
String source = getforminfo().getSource();
if (source.equals("content")) {
WGContent content = gettargetcontext().content();
params.setContentClass(content.getContentClass());
try {
hdb.updateContent(content, params);
return true;
}
catch (WGHierarchicalDatabaseEventCanceledException e) {
addmessage(e.getMessage());
return false;
}
}
// Perform create from here on
if (!source.equals("none") && !source.equals("newcontent")) {
throw new IllegalStateException("Cannot use tmlform.storeInHDB() when form source is not 'content', 'newcontent' or 'none'");
}
// Get desired content class
String contentClass = getforminfo().getContentClass();
if (contentClass == null) {
throw new TMLScriptException("Cannot use tmlform.storeInHDB() on form " + getformid() + " that is defined without attribute 'contentclass'");
}
params.setContentClass(contentClass);
// Get the model
HDBModel model = (HDBModel) targetContext.db().getAttribute(WGACore.DBATTRIB_HDBMODEL);
if (model == null) {
throw new TMLScriptException("Cannot use tmlform.storeInHDB() in database " + targetContext.db().getDbReference() + " where HDB model is not available");