Price price = order.getPrice();
SpecialOffer so = order.getSpecialOffer();
int nb = order.getSubscribedUsers();
int duration = order.getSubscribedYears();
UserDao userDao = DaoFactory.getUserDao();
LicenseDao licenseDao = DaoFactory.getLicenseDao();
try {
ClufImpl cluf = getActiveCluf();
userDao.fetch(u);
UserImpl user = (UserImpl)userDao.findUser(u.getLogin());
userDao.fetch(user);
if ((user.getLastAcceptedCluf() == null) || !cluf.getVersion().equals(user.getLastAcceptedCluf().getVersion())) {
user.setLastAcceptedCluf(cluf);
}
for (int i = 0; i < nb; i++) {
License l = (License) licenseDao.newHandledObject();
l.setBuyer(user);
l.setPrice(price);
l.setSpecialOffer(so);
long validUntil = getValidUntil(duration);
l.setValidUntil(validUntil);