-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console - log relevant information in home, user and logs page #2777
Conversation
Can we take #2267 (comment) into account ? once the Apparently (per https://thoughts-on-java.org/mapping-blobs-and-clobs-with-hibernate-and-jpa/)there are two ways, using the I tried adding |
Ahem... gentle review poke ? :) |
need to manage conflict / rebase again ... |
Can you make the integration test pass ? Thanks. |
Yes, we can @RemiDesgrange. As said before :
|
e5e216e
to
0c29c05
Compare
There are three integration tests on attributes deletion for orgs which failed for the moment. I am trying to find out why. |
Last error in integration test was due to attributed changed size. (char varying 255) to small to set all information. If an error occurs when trying to save in database, en Error log is provided in trace, and changed value contains. JSon "error": "Error while inserting admin log in database, see admin log file" I agree with you @landryb , we should change to Lob, but I am not sure how to do it correctly. I have added @lob annotation to "changed" attribut from class "AdminLogEntry", this work perfectly for me; Tell me if I need to do something else to take type change to Log into account. |
I'm no java expert wrt this, but we shouldnt care about 'reinstall previous version if needed', no release was made with changed as varchar; that was only temporary during dev in a separate branch, so there's no compat to keep. What i found strange was not having the plain text value in the database field.... |
I need to make more test before review |
Ok I have done more test. Otherwise it's ready for review @RemiDesgrange :) thanks |
as discussed over the phone we dont need to care about the varchar->lob migration since the |
The migration should go here (but ping @pmauduit anyway), you should not use Ok solution time: you should pass a georchestra/console/src/main/java/org/georchestra/console/model/AdminLogEntry.java Line 48 in f348cc2
This will allow you to remove codes that convert back and forth from |
Rather https://github.com/georchestra/georchestra/tree/master/migrations/19.12 (the directory does not exist yet, feel free to create it) |
Nice, didnt know that json & jsonb were native postgresql data types. As for the migration, i'm still not sure there should be one, as we're only adding a new field to an existing table, and from my understanding hibernate will create the field if it doesnt exist, so there should be no need for an sql snippet ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we (@cmangeat & @pmauduit) will discuss more precisely (and conceptually) afterwards, current review comments aim at earning lisibility for further improvments proposals.
Conceptually, here are a summary so far:
- Sometimes the logging logic is made onto the controllers, sometimes in the DAO. Our opinion is that it might not be the right place to hook (either in the controller nor in the DAO), this leads to duplicating code in both places. This is probably not the role of the DAO to log, and it should stick with LDAP accesses or so.
- To complete the previous point: We were thinking about a "ogc-server-statistics"-like approach with
log.info()
using the logging framework instead. - The PR replaces the LogDAO by a LogUtils class, and unset the LogDAO from the tests. Integrating a new class is OK, but why not having set a LogUtils in the test classes instead of leaving the field unset ? This leads to unecessary
if (logUtils != null)
in the actual code. - There is a private field added to the UsersController class which is problematic, as it can lead to race conditions in case of several requests are made simultaneously on the same controller, the controller is supposed to be reentrant. There is another place in the code where such an error is made, we will comment accordingly.
- We were wondering if we could avoid the long series of "if" statements to check what and where the objects have been modified, we don't have any clue so far.
- Sometimes the log statement is made before the actual modification is made onto the LDAP, sometimes after. We think that it would be more relevant to always log after the modification has been made.
- As already reported by @rémiDesgrange, we think that using a more convenient type in the postgresql could simplify queries, as using BLOB type makes it complicated to request against.
|
||
@Autowired | ||
private AdminLogDao logDao; | ||
private Boolean isPendingChanged; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dead code ?
public void setLogDao(AdminLogDao logDao) { | ||
this.logDao = logDao; | ||
public void setPendingChanged(Boolean isPendingChanged) { | ||
this.isPendingChanged = isPendingChanged; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code ?
@@ -217,9 +205,14 @@ public synchronized void update(Account account, Account modified, String origin | |||
if (hasUserDnChanged(account, modified)) { | |||
ldapTemplate.rename(buildUserDn(account), buildUserDn(modified)); | |||
} | |||
this.setPendingChanged(this.hasUserPendingChanged(account, modified)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code ?
update(modified, originLogin); | ||
} | ||
|
||
public boolean hasUserPendingChanged(Account account, Account modified) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code ?
AdminLogEntry log = new AdminLogEntry(originLogin, user.getUid(), logType, new Date()); | ||
this.logDao.save(log); | ||
// Add log entry when role was added | ||
if (originLogin != null && logUtils != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logUtils cant be null ?
if (auth != null && auth.getName() != null && target != null) { | ||
String admin = auth.getName(); | ||
// case where we don't need to log changes | ||
if (values == null || values.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copying null in null, is not a trouble, if values is empty() can be managed at worst in the constructor.
public AdminLogEntry createLog(String target, AdminLogType type, String values) { | ||
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); | ||
|
||
AdminLogEntry log = new AdminLogEntry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be done later.
try { | ||
logDao.save(log); | ||
} catch (DataIntegrityViolationException divex) { | ||
// Value could be to large for field size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case value should be trimmed ? no relying on an exception to be thrown ?
} | ||
} else { | ||
LOG.info("Authentification Security Context is null."); | ||
log = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null, see "condition reversion" comment.
/** | ||
* Full creation by log details creation and log creation directly. | ||
* | ||
* @param target String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure these comments help
right now we have the 'correct' amount of details given the available space in most cases, can you detail examples you have in mind where the displayed info is not useful enough ?
That was a design choice in conjunction with what happens in the backend. IIrc it was a bit too complicated to "merge" changes happening at the same time, but if it needs to be revisited then so be it. How would you display all user-related changes in a single line ? |
what's the status of the PR now ? being rewritten ? reviews adressed ? |
f348cc2
to
ad0284e
Compare
Hello, there are no simple way to store Java JsonObject to JsonB postgresql type. What is the best option : 1 - do we use an external librairie ? Like this example https://vladmihalcea.com/how-to-map-json-objects-using-generic-hibernate-types/ 2 -Or to we keep @lob like it is already existing in console
3 - Or perhaps a another idea ? Regards |
need more tests (specific with logo action). |
As I said - Need more test => To finish correctly :) |
Wich line please ? |
Not cool ! :) I will check traductions ;) |
In some cases, hovering over an action label for the first time showed |
Already catched in the UI 1.0. If you over on html parent, you get "true", else you get info. I check that. |
Unless you have no info, you get "true" in some case... not good! |
I hope you have a spanish speaker ;) |
Fwiw, i think i've tested lots of cases, i'm struggling to see the console in the fr locale (cf #2890) but for me the PR is +1 at this point. |
We do :-) ping @severo One last thing Gaetan, can you import all translations into the spanish and other translation files (even if the translations are not done - ie in english) : this will allow translators to do their job. Thanks. |
Yes.
New for me, but seems great ! |
@fvanderbiest it's good for you (last commits) ? |
This looks good. Thanks. |
😵 😵 \o/ |
Link to #2267 .
Display logs detail by click to get log relevant information in admin log.
Thank you in advance for review.
@fvanderbiest @landryb @tonio @RemiDesgrange