Commit 0498147f authored by michael.simon's avatar michael.simon
Browse files

move complete user reconciliation in transaction

parent dfb7b860
......@@ -10,19 +10,14 @@
******************************************************************************/
package edu.kit.scc.webreg.event;
import java.util.List;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import edu.kit.scc.webreg.entity.RegistryEntity;
import edu.kit.scc.webreg.entity.RegistryStatus;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.RegistryService;
import edu.kit.scc.webreg.service.reg.RegisterUserService;
public class UserReconsiliationExecutor extends
......@@ -50,7 +45,6 @@ public class UserReconsiliationExecutor extends
try {
InitialContext ic = new InitialContext();
RegistryService registryService = (RegistryService) ic.lookup("global/bwreg/bwreg-service/RegistryServiceImpl!edu.kit.scc.webreg.service.RegistryService");
RegisterUserService registerUserService = (RegisterUserService) ic.lookup("global/bwreg/bwreg-service/RegisterUserServiceImpl!edu.kit.scc.webreg.service.reg.RegisterUserService");
UserEntity user = getEvent().getEntity();
......@@ -60,16 +54,11 @@ public class UserReconsiliationExecutor extends
return;
}
List<RegistryEntity> registryList = registryService.findByIdentityAndStatus(user.getIdentity(), RegistryStatus.ACTIVE);
for (RegistryEntity registry : registryList) {
try {
registerUserService.reconsiliation(registry, fullRecon, executor);
} catch (RegisterException e) {
logger.warn("Could not recon registry {}: {}", registry.getId(), e);
}
try {
registerUserService.reconsiliationByUser(user, fullRecon, executor);
} catch (RegisterException e) {
logger.warn("Could not recon registries for user {}: {}", user.getId(), e);
}
} catch (NamingException e) {
logger.warn("Could execute: {}", e);
}
......
......@@ -73,4 +73,6 @@ public interface RegisterUserService {
void completeReconciliation(ServiceEntity service, Boolean fullRecon, Boolean withGroups, Boolean onlyActive,
String executor);
void reconsiliationByUser(UserEntity user, Boolean fullRecon, String executor) throws RegisterException;
}
......@@ -17,9 +17,13 @@ import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
import javax.inject.Inject;
import org.slf4j.Logger;
import edu.kit.scc.webreg.audit.Auditor;
import edu.kit.scc.webreg.dao.RegistryDao;
import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.RegistryEntity;
import edu.kit.scc.webreg.entity.RegistryStatus;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException;
......@@ -29,9 +33,15 @@ import edu.kit.scc.webreg.service.reg.RegisterUserWorkflow;
@Stateless
public class RegisterUserServiceImpl implements RegisterUserService {
@Inject
private Logger logger;
@Inject
private Registrator registrator;
@Inject
private RegistryDao registryDao;
@Override
public RegistryEntity registerUser(UserEntity user, ServiceEntity service, List<Long> policiesIdList, String executor)
throws RegisterException {
......@@ -66,6 +76,18 @@ public class RegisterUserServiceImpl implements RegisterUserService {
registrator.deleteGroup(group, service, executor);
}
@Override
public void reconsiliationByUser(UserEntity user, Boolean fullRecon, String executor) throws RegisterException {
List<RegistryEntity> registryList = registryDao.findByIdentityAndStatus(user.getIdentity(), RegistryStatus.ACTIVE);
for (RegistryEntity registry : registryList) {
try {
registrator.reconsiliation(registry, fullRecon, executor, null);
} catch (RegisterException e) {
logger.warn("Could not recon registry {}: {}", registry.getId(), e);
}
}
}
@Override
public void reconsiliation(RegistryEntity registry, Boolean fullRecon, String executor) throws RegisterException {
registrator.reconsiliation(registry, fullRecon, executor, null);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment