/*
* If gadgetDef is not found, throw an exception, something went wrong, most likely a bad UUID or URL.
*/
if (null == gadgetDef)
{
throw new ExecutionException("Unable to instantiate gadgetDef.");
}
// increment the indexes of any gadgets in that zone
shiftGadget(tab.getGadgets());
// get the owner
// create the new gadget at the top of the last zone
Gadget gadget = new Gadget(gadgetDef, 0, 0, owner, request.getUserPrefs() == null ? "" : request
.getUserPrefs());
// insert the new gadget - room has been made for it
tab.getGadgets().add(gadget);
// commit our operations
tabMapper.flush();
deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + owner.getId()));
// return it
return gadget;
}
catch (NoResultException ex)
{
log.error("Could not add Gadget because tab not found: " + owner.getUniqueId());
throw new ExecutionException("Could not add Gadget because tab not found: " + owner.getUniqueId());
}
}