Skip to content

Issue#1075: Project global export empty if not requested by first PioneerAdmin#90

Closed
halfcurry wants to merge 3 commits intosigmah-dev:masterfrom
halfcurry:issue#1075
Closed

Issue#1075: Project global export empty if not requested by first PioneerAdmin#90
halfcurry wants to merge 3 commits intosigmah-dev:masterfrom
halfcurry:issue#1075

Conversation

@halfcurry
Copy link
Copy Markdown

@halfcurry halfcurry commented Apr 9, 2017

0001075: Project global export empty if not requested by first PioneerAdmin

Description: On v2.2, if you are logged in as a recent user (not first PioneerAdmin), when you will make a global export of projects, your export will be empty with only an empty "Project links" tab.

No error message nor trace in the logs.
Steps To Reproduce:

  1. create a new user having the right to global export projects
  2. log in with that new user
  3. try to global export projects
    => the exported file is empty.

Solved this by disabling the user filter which is implicitly applied to the query dataset returned in ProjectHibernateDAO.java [ Read comments below ].
A user created with a custom profile, after doing a global export now gets an excel file correctly populated with the list of projects, as required.

@halfcurry
Copy link
Copy Markdown
Author

Hi, I have assessed the possible causes for why this bug may be occurring. @osarrat please review and mention if I seem to be on the right track. Thanks!

Possible Cause #1: In the class org.sigmah.server.security.impl.AccessRights , I could not find any sperm permission entry for the tokens org.sigmah.shared.command.GetOrgUnits, org.sigmah.shared.command.GetContacts, project-exports and EXPORT#EXPORT_GLOBAL

(this is based on the warnings generated in the server logs, but I am not sure because they seem to be generated for both the PioneerAdministrator and the created user.) Here are the logs :

[WARN ] {09/04/2017 16:23:30.175} [btpool0-6] o.s.s.security.impl.AccessRights - No security permission can be found for token 'org.sigmah.shared.command.GetOrgUnits'. Did you forget to declare corresponding 'sperm'?
[WARN ] {09/04/2017 16:23:30.224} [btpool0-7] o.s.s.security.impl.AccessRights - No security permission can be found for token 'org.sigmah.shared.command.GetContacts'. Did you forget to declare corresponding 'sperm'?
[WARN ] {09/04/2017 16:25:51.839} [btpool0-4] o.s.s.security.impl.AccessRights - No security permission can be found for token 'project-exports'. Did you forget to declare corresponding 'sperm'?
[WARN ] {09/04/2017 16:25:56.682} [btpool0-4] o.s.s.security.impl.AccessRights - No security permission can be found for token 'EXPORT#EXPORT_GLOBAL'. Did you forget to declare corresponding 'sperm'?

Possible Cause #2: While creating PioneerAdministrator, we set the values in the table ("INSERT INTO global_permission...") the values 'GLOBAL_EXPORT' by default.
I am not sure if this permission is also granted to any other user that the PioneerAdministrator creates.

Possible cause #3: In the table GlobalExportSettings,

The class main.java.org.sigmah.shared.command.GetGlobalExportSettings is constructed with a boolean param retrieveProjectModels.
It is called by the method onPageRequest of class org.sigmah.client.ui.presenter.admin.ParametersAdminPresenter

Here is the called line :

	// Retrieves configured export format.
	dispatch.execute(new GetGlobalExportSettings(auth().getOrganizationId(), false), new CommandResultHandler<GlobalExportSettingsDTO>() {

Why is it always called with the boolean parameter "false" ?

Copy link
Copy Markdown
Member

@osarrat osarrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revise your commit by using the existing log mechanism.


import javax.persistence.TypedQuery;

import org.mortbay.log.Log;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would better if you replicate the log mechanism used in other part of the codebase.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realised my mistake as soon as I ran it. Thanks!

@osarrat
Copy link
Copy Markdown
Member

osarrat commented Apr 11, 2017

Hi @indianauthority97 ,

Regarding the cause of this bug, you seem on the right track ! I don't know what is the cause of this bug, but continue to investigate, and you should be able to find the right cause among the three you imagine

@halfcurry
Copy link
Copy Markdown
Author

Status : Investigated PossibleCause #3 : this is not the reason, it behaves the same way for both users.

More research : Identified the place where the difference is happening.

org.sigmah.server.dao.impl.ProjectHibernateDAO

[Here, the PioneerAdminstrator export call is getting a list of all my projects, but the created user is fetching zero projects i.e. empty list of Collection pmodels in the method getProjects.

This could be related to :

org.sigmah.server.domain.util.EntityFilters
org.sigmah.server.domain.util.DomainFilters.disableUserFilter(em());

Still working on it.

@halfcurry halfcurry changed the title [WIP] Issue#1075: Project global export empty if not requested by first PioneerAdmin Issue#1075: Project global export empty if not requested by first PioneerAdmin Apr 12, 2017
@halfcurry
Copy link
Copy Markdown
Author

Hi @osarrat , I updated the issue. Please review it. Thanks!

@osarrat
Copy link
Copy Markdown
Member

osarrat commented Apr 26, 2017

Hi @indianauthority97 , congrats for this bug fix !
I have tested it locally, and your work does actually fix the bug ! Congratulations !

But I won't merge your PR in the end, because while fixing the issue #1081, I have actually made exactly the same modifications that you have done, and thus your code modification is not necessary, but your analysis and work on the fix is useful because you have found the reason of behind this bug.

@osarrat osarrat closed this Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants