Commit 7c5e80f9 authored by michael.simon's avatar michael.simon
Browse files

change how members are added in project updater

parent 390fc43a
......@@ -56,6 +56,17 @@ public class JpaProjectDao extends JpaBaseDao<ProjectEntity, Long> implements Pr
.setParameter("project", project).getResultList();
}
@Override
public ProjectMembershipEntity findByIdentityAndProject(IdentityEntity identity, ProjectEntity project) {
try {
return (ProjectMembershipEntity) em.createQuery("select r from ProjectMembershipEntity r where r.identity = :identity and r.project = :project")
.setParameter("identity", identity).setParameter("project", project).getSingleResult();
}
catch (NoResultException e) {
return null;
}
}
@SuppressWarnings("unchecked")
@Override
public List<ProjectIdentityAdminEntity> findAdminsForProject(ProjectEntity project) {
......
......@@ -51,4 +51,6 @@ public interface ProjectDao extends BaseDao<ProjectEntity, Long> {
List<ExternalProjectEntity> findByExternalName(String externalName);
ExternalOidcProjectEntity findByExternalNameOidc(String externalName, OidcRpConfigurationEntity rpConfig);
ProjectMembershipEntity findByIdentityAndProject(IdentityEntity identity, ProjectEntity project);
}
package edu.kit.scc.webreg.service.project;
import java.util.UUID;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
......
......@@ -89,7 +89,10 @@ public class ProjectUpdater {
project.setShortName(shortName);
project.setRpConfig(rpConfig);
dao.addMemberToProject(project, user.getIdentity(), ProjectMembershipType.MEMBER);
if (dao.findByIdentityAndProject(user.getIdentity(), project) == null) {
dao.addMemberToProject(project, user.getIdentity(), ProjectMembershipType.MEMBER);
}
syncAllMembersToGroup(project, "idty-" + user.getIdentity());
triggerGroupUpdate(project, "idty-" + user.getIdentity());
}
......
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