Commit 6407c592 authored by michael.simon's avatar michael.simon
Browse files

somewhat tested functionality, adding and removing works

parent c5dce2bb
......@@ -18,6 +18,7 @@ import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.LocalGroupEntity;
import edu.kit.scc.webreg.entity.ServiceBasedGroupEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.ServiceGroupStatus;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.UserGroupEntity;
......@@ -59,4 +60,7 @@ public interface GroupDao extends BaseDao<GroupEntity, Long> {
ServiceBasedGroupEntity persistWithServiceFlags(
ServiceBasedGroupEntity entity, Set<ServiceEntity> services);
void setServiceFlags(ServiceBasedGroupEntity entity,
ServiceGroupStatus status);
}
......@@ -93,6 +93,14 @@ public class JpaGroupDao extends JpaBaseDao<GroupEntity, Long> implements GroupD
return entity;
}
@Override
public void setServiceFlags(ServiceBasedGroupEntity entity, ServiceGroupStatus status) {
List<ServiceGroupFlagEntity> flagList = groupFlagDao.findByGroup(entity);
for (ServiceGroupFlagEntity groupFlag : flagList) {
groupFlag.setStatus(status);
}
}
@Override
public void addUserToGroup(UserEntity user, GroupEntity group) {
UserGroupEntity userGroup = createNewUserGroup();
......
......@@ -21,7 +21,9 @@ import edu.kit.scc.webreg.dao.as.AttributeSourceGroupDao;
import edu.kit.scc.webreg.entity.AuditStatus;
import edu.kit.scc.webreg.entity.EventType;
import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.ServiceBasedGroupEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.ServiceGroupStatus;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.as.ASUserAttrEntity;
import edu.kit.scc.webreg.entity.as.ASUserAttrValueEntity;
......@@ -171,9 +173,9 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
ASUserAttrValueStringEntity asStringValue = (ASUserAttrValueStringEntity) asValue;
if (! s.equals(asStringValue.getValueString())) {
asStringValue.setValueString(s);
auditor.logAction("as-workflow", "UPDATE VALUE (String)", key, asStringValue.getValueString() + " -> " + s, AuditStatus.SUCCESS);
logger.debug("Updating value for key {}: {} -> {}", key, asStringValue.getValueString(), s);
asStringValue.setValueString(s);
changed = true;
}
......@@ -200,6 +202,7 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
if (asValue == null || asValue.getValueString() == null || asValue.getValueString().equals("")) {
//delete all groups for this user
for (AttributeSourceGroupEntity group : oldGroupList) {
logger.debug("Removeing {} grom group {}", user.getEppn(), group.getName());
groupDao.removeUserGromGroup(user, group);
allChangedGroups.add(group);
}
......@@ -218,7 +221,7 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
groupsToRemove.removeAll(newGroups);
for(String s : groupsToRemove) {
logger.debug("Removeing {} grom group {}", user.getEppn(), s);
logger.debug("Removing {} grom group {}", user.getEppn(), s);
groupDao.removeUserGromGroup(user, oldGroupsMap.get(s));
allChangedGroups.add(oldGroupsMap.get(s));
}
......@@ -246,6 +249,12 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
}
}
for (GroupEntity group : allChangedGroups) {
if (group instanceof ServiceBasedGroupEntity) {
groupDao.setServiceFlags((ServiceBasedGroupEntity) group, ServiceGroupStatus.DIRTY);
}
}
if (allChangedGroups.size() > 0) {
EventSubmitter eventSubmitter;
try {
......
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