1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package fr.cnes.doi.resource.admin;
20
21 import fr.cnes.doi.application.AdminApplication;
22 import fr.cnes.doi.resource.AbstractResource;
23 import fr.cnes.doi.settings.Consts;
24 import fr.cnes.doi.settings.DoiSettings;
25 import java.util.Map;
26 import java.util.concurrent.ConcurrentHashMap;
27 import org.apache.logging.log4j.Logger;
28 import org.restlet.data.LocalReference;
29 import org.restlet.data.MediaType;
30 import org.restlet.data.Method;
31 import org.restlet.data.Status;
32 import org.restlet.ext.freemarker.TemplateRepresentation;
33 import org.restlet.ext.wadl.MethodInfo;
34 import org.restlet.representation.Representation;
35 import org.restlet.resource.ClientResource;
36 import org.restlet.resource.Get;
37 import org.restlet.resource.ResourceException;
38
39
40
41
42
43
44 public class FooterIhmResource extends AbstractResource {
45
46
47
48
49 private volatile Logger LOG;
50
51 @Override
52 protected void doInit() throws ResourceException {
53 super.doInit();
54 final AdminApplication app = (AdminApplication) getApplication();
55 LOG = app.getLog();
56 LOG.traceEntry();
57 setDescription("This resource handles the GUI footer.");
58 LOG.traceExit();
59 }
60
61
62
63
64
65
66
67 private Map<String, String> createDataModel() {
68 LOG.traceEntry();
69 final Map<String, String> dataModel = new ConcurrentHashMap<>();
70 dataModel.put("doi_prefix", DoiSettings.getInstance().getString(Consts.INIST_DOI));
71 dataModel.put("attribution", DoiSettings.getInstance().getString(Consts.ATTRIBUTION, ""));
72 return LOG.traceExit(dataModel);
73 }
74
75
76
77
78
79
80 @Get
81 public Representation getFooter() {
82 LOG.traceEntry();
83 final Map<String, String> dataModel = createDataModel();
84 final Representation configFtl = new ClientResource(LocalReference.createClapReference(
85 "class/ihm_footer.ftl")).get();
86 return LOG.traceExit(new TemplateRepresentation(configFtl, dataModel, MediaType.TEXT_ALL));
87 }
88
89 @Override
90 protected void describeGet(final MethodInfo info) {
91 info.setName(Method.GET);
92 info.setDocumentation("Returns the GUI footer");
93 addResponseDocToMethod(info, createResponseDoc(
94 Status.SUCCESS_OK, "Operation successful",
95 stringRepresentation())
96 );
97 }
98
99 }