[seam-issues] [JBoss JIRA] Resolved: (SEAMSECURITY-70) Calling RoleManager.removeRole(Roletype rt, User u, Group g) throws an NPE
Jason Porter (JIRA)
jira-events at lists.jboss.org
Fri Aug 12 03:28:02 EDT 2011
[ https://issues.jboss.org/browse/SEAMSECURITY-70?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jason Porter resolved SEAMSECURITY-70.
--------------------------------------
Fix Version/s: 3.1.0.Beta1
Resolution: Done
> Calling RoleManager.removeRole(Roletype rt,User u, Group g) throws an NPE
> -------------------------------------------------------------------------
>
> Key: SEAMSECURITY-70
> URL: https://issues.jboss.org/browse/SEAMSECURITY-70
> Project: Seam Security
> Issue Type: Bug
> Reporter: Charles Louppe
> Assignee: Jason Porter
> Fix For: 3.1.0.Beta1
>
>
> Hi,
> I tried to use the function removeRole(Roletype rt,User u, Group g) of the class RoleManagerImpl which throws me an NullPointerException.
> I have fixed the bug, which was in the class JPAIdentityStore in the method removeRelationship :
> {code:java}
> public void removeRelationship(IdentityStoreInvocationContext ctx,
> IdentityObject fromIdentity, IdentityObject toIdentity,
> IdentityObjectRelationshipType relationshipType,
> String relationshipName) throws IdentityException {
> Property<?> fromProperty = modelProperties.get(PROPERTY_RELATIONSHIP_FROM);
> Property<?> toProperty = modelProperties.get(PROPERTY_RELATIONSHIP_TO);
> Property<?> relationshipTypeProp = modelProperties.get(PROPERTY_RELATIONSHIP_TYPE);
> EntityManager em = getEntityManager(ctx);
> CriteriaBuilder builder = em.getCriteriaBuilder();
> CriteriaQuery<?> criteria = builder.createQuery(identityClass);
> Root<?> root = criteria.from(identityClass);
> List<Predicate> predicates = new ArrayList<Predicate>();
> predicates.add(builder.equal(root.get(fromProperty.getName()),
> lookupIdentity(fromIdentity, em)));
> predicates.add(builder.equal(root.get(toProperty.getName()),
> lookupIdentity(toIdentity, em)));
> predicates.add(builder.equal(root.get(relationshipTypeProp.getName()),
> lookupRelationshipType(relationshipType, em)));
> criteria.where(predicates.toArray(new Predicate[predicates.size()]));
> Object relationship = em.createQuery(criteria).getSingleResult();
> em.remove(relationship);
> }
> {code}
> The bug is due to those following lines :
> CriteriaQuery<?> criteria = builder.createQuery(identityClass);
> Root<?> root = criteria.from(identityClass);
> It should be instead :
> CriteriaQuery<?> criteria = builder.createQuery(relationshipClass);
> Root<?> root = criteria.from(relationshipClass);
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list