1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.workflow.modules.mylutecevalidation.service;
35
36 import fr.paris.lutece.plugins.mylutece.modules.directory.authentication.business.MyluteceDirectoryUser;
37 import fr.paris.lutece.plugins.mylutece.modules.directory.authentication.business.MyluteceDirectoryUserHome;
38 import fr.paris.lutece.plugins.mylutece.modules.directory.authentication.service.MyluteceDirectoryPlugin;
39 import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceHistory;
40 import fr.paris.lutece.plugins.workflowcore.service.resource.IResourceHistoryService;
41 import fr.paris.lutece.plugins.workflowcore.service.task.SimpleTask;
42 import fr.paris.lutece.portal.service.plugin.Plugin;
43 import fr.paris.lutece.portal.service.plugin.PluginService;
44
45 import org.apache.commons.lang.StringUtils;
46
47 import java.util.Locale;
48
49 import javax.inject.Inject;
50 import javax.servlet.http.HttpServletRequest;
51
52
53
54
55
56
57
58 public class TaskMyluteceValidation extends SimpleTask
59 {
60 @Inject
61 private IResourceHistoryService _resourceHistoryService;
62
63
64
65
66 @Override
67 public void processTask( int nIdResourceHistory, HttpServletRequest request, Locale locale )
68 {
69 Plugin myluteceDirectoryPlugin = PluginService.getPlugin( MyluteceDirectoryPlugin.PLUGIN_NAME );
70 ResourceHistory resourceHistory = _resourceHistoryService.findByPrimaryKey( nIdResourceHistory );
71
72
73 MyluteceDirectoryUser user = MyluteceDirectoryUserHome.findByPrimaryKey( resourceHistory.getIdResource( ),
74 myluteceDirectoryPlugin );
75
76 if ( user != null )
77 {
78 user.setStatus( MyluteceDirectoryUser.STATUS_ACTIVATED );
79 MyluteceDirectoryUserHome.update( user, myluteceDirectoryPlugin );
80 }
81 }
82
83
84
85
86 @Override
87 public String getTitle( Locale locale )
88 {
89 return StringUtils.EMPTY;
90 }
91 }