1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package fr.cnes.doi.logging.api;
20
21 import fr.cnes.doi.application.DoiMdsApplication;
22 import fr.cnes.doi.resource.mds.DoiResource;
23 import fr.cnes.doi.resource.mds.DoisResource;
24 import fr.cnes.doi.resource.mds.MetadataResource;
25 import fr.cnes.doi.resource.mds.MetadatasResource;
26 import fr.cnes.doi.server.DoiServer;
27 import fr.cnes.doi.services.DoiMonitoring;
28 import fr.cnes.doi.settings.Consts;
29 import fr.cnes.doi.settings.DoiSettings;
30 import fr.cnes.doi.utils.spec.Requirement;
31 import org.restlet.Context;
32 import org.restlet.data.Method;
33 import org.restlet.routing.Filter;
34 import org.restlet.service.LogService;
35
36
37
38
39
40
41 @Requirement(reqId = Requirement.DOI_ARCHI_020, reqName = Requirement.DOI_ARCHI_020_NAME)
42 public class DoiLogDataServer extends LogService {
43
44
45
46
47
48
49
50 public DoiLogDataServer(final String logName,
51 final boolean isEnabled) {
52 super(isEnabled);
53 this.setLoggerName(logName);
54 this.setResponseLogFormat(DoiSettings.getInstance().getString(Consts.LOG_FORMAT));
55 }
56
57
58
59
60
61
62
63 @Override
64 public Filter createInboundFilter(final Context context) {
65 return new MonitoringLogFilter(context, initMonitoring(), this);
66 }
67
68
69
70
71
72
73 private DoiMonitoring initMonitoring() {
74
75 final DoiMonitoring monitoring = new DoiMonitoring();
76 monitoring.register(Method.GET,
77 DoiServer.MDS_URI + DoiMdsApplication.DOI_URI,
78 DoisResource.LIST_ALL_DOIS
79 );
80 monitoring.register(Method.POST,
81 DoiServer.MDS_URI + DoiMdsApplication.DOI_URI,
82 DoisResource.CREATE_DOI
83 );
84 monitoring.register(Method.GET,
85 DoiServer.MDS_URI + DoiMdsApplication.DOI_URI + DoiMdsApplication.DOI_NAME_URI,
86 DoiResource.GET_DOI
87 );
88 monitoring.register(Method.POST,
89 DoiServer.MDS_URI + DoiMdsApplication.METADATAS_URI,
90 MetadatasResource.CREATE_METADATA
91 );
92 monitoring.register(Method.GET,
93 DoiServer.MDS_URI + DoiMdsApplication.METADATAS_URI
94 + DoiMdsApplication.DOI_NAME_URI,
95 MetadataResource.GET_METADATA
96 );
97 monitoring.register(Method.DELETE,
98 DoiServer.MDS_URI + DoiMdsApplication.METADATAS_URI
99 + DoiMdsApplication.DOI_NAME_URI,
100 MetadataResource.DELETE_METADATA
101 );
102
103 return monitoring;
104 }
105
106 }