-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: using PreUpdateEventListener and filters
PostPosted: Tue Feb 14, 2012 8:12 am 
Newbie

Joined: Tue Feb 14, 2012 7:56 am
Posts: 1
Hello,
I have grails application with hibernate filter, that determine access rights to table rows. It works fine on select, but now I want to control update. I've added PreUpdateEventListener that looks like:
Code:
  ......
  public static final int METHOD_READ= 1
  public static final int METHOD_UPDATE= 2
  ......
  public boolean onPreUpdate(PreUpdateEvent event) {
    // control only need classes
    if (!needClassNames.contains(event.entity.class.name))
        return false;

    Session session = ....//get current session
    Filter filter = session.getEnabledFilter(getFilterName(event.entity.class.name))
    filter.setParameter('method', METHOD_UPDATE)
    ArrayList list = Book.executeQuery("select s.id from "+event.entity.class.name+" s where s.id = ?)", [event.entity.id]) 
    //Book is a some domain class, not equals to event.entity.class
    //will be added filter code and if current user hasn't permission to 'method' METHOD_UPDATE sql query will return zero values
   
     return (list == null || list.size() == 0)
  }

while executing Book.executeQuery it call onPreUpdate again, goes to this line and so on. finally it crash with stack overflow exception by this infinite self calling. can anybody help me?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.