Commit c6f37cff authored by michael.simon's avatar michael.simon
Browse files

Test for Attribute Source query

parent 7e3d5a47
...@@ -27,9 +27,9 @@ public class JpaASUserAttrDao extends JpaBaseDao<ASUserAttrEntity, Long> impleme ...@@ -27,9 +27,9 @@ public class JpaASUserAttrDao extends JpaBaseDao<ASUserAttrEntity, Long> impleme
@Override @Override
public ASUserAttrEntity findASUserAttr(UserEntity user, AttributeSourceEntity attributeSource) { public ASUserAttrEntity findASUserAttr(UserEntity user, AttributeSourceEntity attributeSource) {
try { try {
return (ASUserAttrEntity) em.createQuery("select a from ASUserAttrEntity e where " return (ASUserAttrEntity) em.createQuery("select a from ASUserAttrEntity a where "
+ "a.user = :user and a.attributeSource = :attributeSource") + "a.user = :user and a.attributeSource = :attributeSource")
.setParameter("user", user).setParameter("attributeSource", "attributeSource").getSingleResult(); .setParameter("user", user).setParameter("attributeSource", attributeSource).getSingleResult();
} }
catch (NoResultException e) { catch (NoResultException e) {
return null; return null;
......
...@@ -83,7 +83,7 @@ public class HttpUrlSingleAttributeSource extends ...@@ -83,7 +83,7 @@ public class HttpUrlSingleAttributeSource extends
if (entity != null) { if (entity != null) {
try { try {
String r = EntityUtils.toString(entity); String r = EntityUtils.toString(entity);
logger.debug("Got String {}", r);
} catch (ParseException e) { } catch (ParseException e) {
throw new RegisterException(e); throw new RegisterException(e);
} catch (IOException e) { } catch (IOException e) {
...@@ -91,6 +91,9 @@ public class HttpUrlSingleAttributeSource extends ...@@ -91,6 +91,9 @@ public class HttpUrlSingleAttributeSource extends
} }
} }
} }
else {
logger.debug("Status HttpUrlSingleAS is not OK. It is {} - {}", response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());
}
} }
} }
...@@ -12,16 +12,22 @@ package edu.kit.scc.webreg.bean.admin.as; ...@@ -12,16 +12,22 @@ package edu.kit.scc.webreg.bean.admin.as;
import java.io.Serializable; import java.io.Serializable;
import javax.enterprise.context.RequestScoped; import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent; import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.as.AttributeSourceEntity; import edu.kit.scc.webreg.entity.as.AttributeSourceEntity;
import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.AttributeSourceService; import edu.kit.scc.webreg.service.AttributeSourceService;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.service.reg.AttributeSourceQueryService;
@Named("showAttributeSourceBean") @ManagedBean
@RequestScoped @ViewScoped
public class ShowAttributeSourceBean implements Serializable { public class ShowAttributeSourceBean implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -29,13 +35,41 @@ public class ShowAttributeSourceBean implements Serializable { ...@@ -29,13 +35,41 @@ public class ShowAttributeSourceBean implements Serializable {
@Inject @Inject
private AttributeSourceService service; private AttributeSourceService service;
@Inject
private UserService userService;
@Inject
private AttributeSourceQueryService asQueryService;
@Inject
private Logger logger;
private AttributeSourceEntity entity; private AttributeSourceEntity entity;
private Long id; private Long id;
private String testUsername;
public void preRenderView(ComponentSystemEvent ev) { public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
entity = service.findByIdWithAttrs(id, "asProps"); entity = service.findByIdWithAttrs(id, "asProps");
} }
}
public void testSource() {
UserEntity user = userService.findByEppn(testUsername);
if (user == null) {
logger.info("User {} not found", testUsername);
return;
}
try {
asQueryService.updateUserAttributes(user, entity, "test");
} catch (RegisterException e) {
logger.info("Exception!", e);
}
}
public Long getId() { public Long getId() {
return id; return id;
...@@ -52,4 +86,12 @@ public class ShowAttributeSourceBean implements Serializable { ...@@ -52,4 +86,12 @@ public class ShowAttributeSourceBean implements Serializable {
public void setEntity(AttributeSourceEntity entity) { public void setEntity(AttributeSourceEntity entity) {
this.entity = entity; this.entity = entity;
} }
public String getTestUsername() {
return testUsername;
}
public void setTestUsername(String testUsername) {
this.testUsername = testUsername;
}
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<h2><h:outputText value="#{messages.job_class}: #{showAttributeSourceBean.entity.name}"/></h2> <h2><h:outputText value="#{messages.job_class}: #{showAttributeSourceBean.entity.name}"/></h2>
<div class="panel"> <div class="panel">
<p:panel header="#{messages.job_class}"> <p:panel header="#{messages.attribute_source}">
<p:panelGrid id="baseData" columns="2"> <p:panelGrid id="baseData" columns="2">
...@@ -69,6 +69,17 @@ ...@@ -69,6 +69,17 @@
</p:panel> </p:panel>
</div> </div>
<div class="panel">
<p:panel header="#{messages.tools}">
<p:panelGrid id="testData" columns="2">
<h:outputText value="#{messages.eppn}:" />
<p:inputText value="#{showAttributeSourceBean.testUsername}" />
</p:panelGrid>
<p:commandButton action="#{showAttributeSourceBean.testSource()}" value="#{messages.test_source}"/>
</p:panel>
</div>
</h:form> </h:form>
</ui:define> </ui:define>
......
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