Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Iparapheur Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephane Routhiau
Iparapheur Core
Commits
3fcc016e
Commit
3fcc016e
authored
1 year ago
by
lhameury
Browse files
Options
Downloads
Patches
Plain Diff
Fix issue on ParapheurUserPreferencesImpl
We have to check that user exists before setting or getting preferences
parent
81d4db90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iparapheur-core/src/main/java/com/atolcd/parapheur/repo/impl/ParapheurUserPreferencesImpl.java
+30
-17
30 additions, 17 deletions
...lcd/parapheur/repo/impl/ParapheurUserPreferencesImpl.java
with
30 additions
and
17 deletions
iparapheur-core/src/main/java/com/atolcd/parapheur/repo/impl/ParapheurUserPreferencesImpl.java
+
30
−
17
View file @
3fcc016e
...
...
@@ -44,6 +44,8 @@ package com.atolcd.parapheur.repo.impl;
import
com.atolcd.parapheur.repo.ParapheurUserPreferences
;
import
org.alfresco.error.AlfrescoRuntimeException
;
import
org.alfresco.service.cmr.preference.PreferenceService
;
import
org.alfresco.service.cmr.security.PersonService
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
...
...
@@ -59,23 +61,36 @@ import java.util.Map;
*/
public
class
ParapheurUserPreferencesImpl
implements
ParapheurUserPreferences
{
private
final
Logger
logger
=
Logger
.
getLogger
(
ParapheurUserPreferences
.
class
);
@Qualifier
(
"PreferenceService"
)
@Autowired
private
PreferenceService
preferenceService
;
@Autowired
private
PersonService
personService
;
private
void
setPreference
(
String
username
,
String
key
,
Serializable
value
)
{
Map
<
String
,
Serializable
>
preferenceMap
=
preferenceService
.
getPreferences
(
username
);
preferenceMap
.
put
(
key
,
value
);
preferenceService
.
setPreferences
(
username
,
preferenceMap
);
if
(
personService
.
personExists
(
username
))
{
Map
<
String
,
Serializable
>
preferenceMap
=
preferenceService
.
getPreferences
(
username
);
preferenceMap
.
put
(
key
,
value
);
preferenceService
.
setPreferences
(
username
,
preferenceMap
);
}
else
{
logger
.
error
(
String
.
format
(
"Impossible de définir les préférences de l'utilisateur %s : l'utilisateur n'existe pas"
,
username
));
}
}
private
Serializable
getPreference
(
String
username
,
String
key
,
Serializable
defaultValue
)
{
Serializable
value
=
null
;
try
{
Map
<
String
,
Serializable
>
preferenceMap
=
preferenceService
.
getPreferences
(
username
);
value
=
preferenceMap
.
get
(
key
);
if
(
personService
.
personExists
(
username
))
{
Map
<
String
,
Serializable
>
preferenceMap
=
preferenceService
.
getPreferences
(
username
);
value
=
preferenceMap
.
get
(
key
);
}
else
{
logger
.
warn
(
String
.
format
(
"Récupération de préférences d'un utilisateur non-existant : %s"
,
username
));
}
}
catch
(
AlfrescoRuntimeException
e
)
{
logger
.
error
(
String
.
format
(
"Erreur à la récupération des préférences utilisateur de %s"
,
username
),
e
);
}
return
(
value
==
null
)?
defaultValue
:
value
;
}
...
...
@@ -154,17 +169,15 @@ public class ParapheurUserPreferencesImpl implements ParapheurUserPreferences {
@Override
public
void
setNotificationMailForUsername
(
String
username
,
String
mail
)
{
if
((
mail
==
null
)
||
mail
.
trim
().
isEmpty
())
{
preferenceService
.
clearPreferences
(
username
,
NOTIFICATION_MAIL_PREFERENCE
);
}
else
{
setPreference
(
username
,
NOTIFICATION_MAIL_PREFERENCE
,
mail
);
if
(
personService
.
personExists
(
username
))
{
if
((
mail
==
null
)
||
mail
.
trim
().
isEmpty
())
{
preferenceService
.
clearPreferences
(
username
,
NOTIFICATION_MAIL_PREFERENCE
);
}
else
{
setPreference
(
username
,
NOTIFICATION_MAIL_PREFERENCE
,
mail
);
}
}
else
{
logger
.
error
(
String
.
format
(
"Impossible de définir les préférences de l'utilisateur %s : l'utilisateur n'existe pas"
,
username
));
}
}
/* Setters */
public
void
setPreferenceService
(
PreferenceService
preferenceService
)
{
this
.
preferenceService
=
preferenceService
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment