Commit 4c7a9a37 authored by michael.simon's avatar michael.simon
Browse files

Update AS at Userregistration

parent 5c48701a
......@@ -29,6 +29,8 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Type;
import edu.kit.scc.webreg.entity.as.AttributeSourceServiceEntity;
@Entity(name = "ServiceEntity")
@Table(name = "service")
public class ServiceEntity extends AbstractBaseEntity {
......@@ -61,6 +63,9 @@ public class ServiceEntity extends AbstractBaseEntity {
@OneToMany(targetEntity = PolicyEntity.class, mappedBy = "service")
private Set<PolicyEntity> policies;
@OneToMany(targetEntity = AttributeSourceServiceEntity.class, mappedBy = "service")
private Set<AttributeSourceServiceEntity> attributeSourceService;
@NotNull
@Column(name="register_bean", length=256, nullable=false)
private String registerBean;
......@@ -244,4 +249,13 @@ public class ServiceEntity extends AbstractBaseEntity {
this.mandatoryValueRulePackage = mandatoryValueRulePackage;
}
public Set<AttributeSourceServiceEntity> getAttributeSourceService() {
return attributeSourceService;
}
public void setAttributeSourceService(
Set<AttributeSourceServiceEntity> attributeSourceService) {
this.attributeSourceService = attributeSourceService;
}
}
......@@ -26,6 +26,8 @@ import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import edu.kit.scc.webreg.entity.as.ASUserAttrEntity;
@Entity(name = "UserEntity")
@Table(name = "usertable")
public class UserEntity extends AbstractBaseEntity {
......@@ -81,6 +83,9 @@ public class UserEntity extends AbstractBaseEntity {
@OneToMany(targetEntity = UserGroupEntity.class, mappedBy="user")
private Set<UserGroupEntity> groups;
@OneToMany(targetEntity = ASUserAttrEntity.class, mappedBy="user")
private Set<ASUserAttrEntity> userAttrs;
@Enumerated(EnumType.STRING)
private UserStatus userStatus;
......@@ -271,4 +276,12 @@ public class UserEntity extends AbstractBaseEntity {
public void setLastFailedUpdate(Date lastFailedUpdate) {
this.lastFailedUpdate = lastFailedUpdate;
}
public Set<ASUserAttrEntity> getUserAttrs() {
return userAttrs;
}
public void setUserAttrs(Set<ASUserAttrEntity> userAttrs) {
this.userAttrs = userAttrs;
}
}
......@@ -22,7 +22,6 @@ import javax.persistence.Table;
import edu.kit.scc.webreg.entity.AbstractBaseEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.UserGroupEntity;
@Entity(name = "ASUserAttrEntity")
@Table(name = "attribute_src_ua")
......
......@@ -35,11 +35,13 @@ 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.entity.as.AttributeSourceServiceEntity;
import edu.kit.scc.webreg.exc.MisconfiguredServiceException;
import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.RegistryService;
import edu.kit.scc.webreg.service.ServiceService;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.service.reg.AttributeSourceQueryService;
import edu.kit.scc.webreg.service.reg.RegisterUserService;
import edu.kit.scc.webreg.util.FacesMessageGenerator;
import edu.kit.scc.webreg.util.SessionManager;
......@@ -87,6 +89,9 @@ public class RegisterServiceBean implements Serializable {
@Inject
private KnowledgeSessionService knowledgeSessionService;
@Inject
private AttributeSourceQueryService asQueryService;
@Inject
private FacesMessageGenerator messageGenerator;
......@@ -101,7 +106,7 @@ public class RegisterServiceBean implements Serializable {
id = service.getId();
}
service = serviceService.findWithPolicies(id);
service = serviceService.findByIdWithAttrs(id, "policies", "attributeSourceService");
List<RegistryEntity> r = registryService.findByServiceAndUserAndNotStatus(service, user,
RegistryStatus.DELETED, RegistryStatus.DEPROVISIONED);
......@@ -111,6 +116,15 @@ public class RegisterServiceBean implements Serializable {
return;
}
for (AttributeSourceServiceEntity asse : service.getAttributeSourceService()) {
logger.info("Updating attribute source {}", asse.getAttributeSource().getName());
try {
asQueryService.updateUserAttributes(user, asse.getAttributeSource(), "user-" + user.getId());
} catch (RegisterException e) {
logger.info("Updating attribute source exception", e);
}
}
policyHolderList = new ArrayList<RegisterServiceBean.PolicyHolder>();
List<PolicyEntity> policiesTemp = new ArrayList<PolicyEntity>(service.getPolicies());
......
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