// if the previous license belonged to a group
// and if the new license is groupable
try {
if (prev != null && prev.getGroup() != null && licenseUsed != null && licenseUsed.getGroup() == null
&& prev.getBuyer().getId() == licenseUsed.getBuyer().getId() && ServiceFactory.getLicenseService().isGroupable(licenseUsed)) {
Group prevGroup = prev.getGroup();
ServiceFactory.getGroupService().removeLicense(new Long(prevGroup.getId()), new Long(prev.getId()));
ServiceFactory.getGroupService().addLicense(prevGroup, licenseUsed);
}
} catch (Exception e) {
LOGGER.warn("impossible to change group for license switching: old license was: "+prev+" new license: "+licenseUsed+" for "+this, e);
}