somoso / vaadin-appfoundation

Automatically exported from code.google.com/p/vaadin-appfoundation
0 stars 0 forks source link

Use Permissions.allow method in init application method. #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Initilize the Permissions module in init application method 
2. Try to add a permission with Permission.allow() (in init application method)

Why does this not work? I got a NullPointerException in allow method (). 
I saw that the Permissions module cannot be used before the TransactionListener 
transactionStart method has been executed.
So how can I defined permissions in init application method?

What version of the product are you using?
Vaadin 6.4.8, Appfoundation 1.3.4

Thank you for your help.

Original issue reported on code.google.com by jbrechbu...@gmail.com on 7 Jan 2011 at 1:30

GoogleCodeExporter commented 9 years ago
This is a clear bug and will be fixed asap. For now, you can use a workaround 
which will fix the problem. Instead of calling Permissions.initialize(this, 
manager), call

Permissions p = new Permissions(this, manager);
this.getContext().addTransactionListener(p); 
p.transactionStart(this, null);

Original comment by kimp...@gmail.com on 7 Jan 2011 at 2:57

GoogleCodeExporter commented 9 years ago
Thank you for your fast answer. Your workaround works perfectly.
Jachen.

Original comment by jbrechbu...@gmail.com on 7 Jan 2011 at 4:52

GoogleCodeExporter commented 9 years ago
I'm unable to reproduce the problem, from where does the NullPointerException 
originate? The transactionStart method only sets the "instance" variable to 
"this" and that is already done in the constructor, so this shouldn't be a 
problem.

Original comment by kimp...@gmail.com on 10 Jan 2011 at 6:41

GoogleCodeExporter commented 9 years ago
Ok I understood. My version of AppFoundation is too old, this bug was 
previously fixed. 
My Permissions class constructor:

  public Permissions(Application application, PermissionManager manager) {
        if (application == null) {
            throw new IllegalArgumentException("Application must be set");
        }

        if (manager == null) {
            throw new IllegalArgumentException("PermissionManager must be set");
        }

        this.application = application;
        pm = manager;
    }

The current Permissions constructor :
public Permissions(Application application, PermissionManager manager) {
        if (application == null) {
            throw new IllegalArgumentException("Application must be set");
        }

        if (manager == null) {
            throw new IllegalArgumentException("PermissionManager must be set");
        }

        instance.set(this);
        this.application = application;
        pm = manager;
    }

I just have to update to the lastest version of AppFoundation.
Sorry to have you wasting your time.
Thank you for all.
Jach.

Original comment by jbrechbu...@gmail.com on 10 Jan 2011 at 8:40

GoogleCodeExporter commented 9 years ago
No problem :)

Original comment by kimp...@gmail.com on 10 Jan 2011 at 10:47