String cloneKey = SharedDataHelper.getInternalSharedDataKey(instance, cloneSharedDataKey);
IWidget widget = instance.getWidget();
IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
for (ISharedData sharedData : new SharedContext(instance).getSharedData())
{
ISharedData clone = persistenceManager.newInstance(ISharedData.class);
clone.setDkey(sharedData.getDkey());
clone.setDvalue(sharedData.getDvalue());
clone.setSharedDataKey(cloneKey);
persistenceManager.save(clone);
}
boolean ok = persistenceManager.save(widget);
if (!ok) throw new InvalidParametersException();
}