Skip to content

Commit b7907ac

Browse files
committed
add stylesheets versions to info and better logging of requests
1 parent 93622b7 commit b7907ac

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>pl.psnc.dl.ege</groupId>
55
<artifactId>ege-framework</artifactId>
6-
<version>0.5.4</version>
6+
<version>0.5.5</version>
77
<name>EGE Framework</name>
88
<properties>
99

src/main/java/pl/psnc/dl/ege/configuration/EGEConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public final class EGEConstants {
4242
public static final String TEIROOT = oxgProps.getProperty("TEI","/usr/share/xml/tei/");
4343
public static final String OpenOfficeConfig = oxgProps.getProperty("OpenOfficeConfig","/usr/lib/libreoffice/");
4444
public static final String DEFAULT_LOCALE = oxgProps.getProperty("defaultLocale","en");
45-
public static final String DEFAULT_PROFILE = oxgProps.getProperty("defaultProfile","default");
45+
public static final String DEFAULT_PROFILE = oxgProps.getProperty("defaultProfile","default");
46+
public static final String MEIROOT = oxgProps.getProperty("MEI","/usr/share/xml/mei/");
4647
// name for document family consisting of text documents
4748
public static final String TEXTFAMILY = "Documents";
4849
public static final String TEXTFAMILYCODE = "text";

src/main/java/pl/psnc/dl/ege/webapp/servlethelpers/Conversion.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class Conversion {
8383
* of possible conversions paths.
8484
*/
8585
public static void doGetHelper(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
86+
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
8687
try {
8788
RequestResolver rr = new ConversionRequestResolver(request,
8889
Method.GET);
@@ -238,6 +239,7 @@ protected static void printConversionPossibilities(HttpServletResponse response,
238239
public static void doPostHelper(
239240
HttpServletRequest request,
240241
HttpServletResponse response) throws ServletException, IOException {
242+
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath());
241243
try {
242244
ConversionRequestResolver rr = new ConversionRequestResolver(
243245
request, Method.POST);

src/main/java/pl/psnc/dl/ege/webapp/servlethelpers/Customization.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Customization {
4040
public void doGetHelper(
4141
HttpServletRequest request,
4242
HttpServletResponse response) throws ServletException, IOException {
43-
43+
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
4444
try {
4545
//resolve request and catch any errors
4646
RequestResolver rr = new CustomizationRequestResolver(request,
@@ -112,6 +112,7 @@ private void printAvailableCustomizationSettings(HttpServletResponse response,
112112
public void doPostHelper(
113113
HttpServletRequest request,
114114
HttpServletResponse response) throws ServletException, IOException {
115+
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath());
115116
try {
116117
RequestResolver rr = new CustomizationRequestResolver(request,
117118
Method.POST);
@@ -141,7 +142,7 @@ private void performCustomization(String[] csString, RequestResolver rr,
141142
String usedCustomization = csString[2];
142143
String usedOutputFormat = csString[3];
143144

144-
LOGGER.warn("performCustomization(usedCS: " + usedCS
145+
LOGGER.debug("performCustomization(usedCS: " + usedCS
145146
+ ", usedSource" + usedSource
146147
+ ", usedCustomization" + usedCustomization
147148
+ ", usedOutputFormat" + usedOutputFormat + ")");
@@ -211,7 +212,7 @@ private void performCustomization(String[] csString, RequestResolver rr,
211212
fileextension = ".xml";
212213
}
213214
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + fileextension + "\"");
214-
LOGGER.warn("Going to perform customization");
215+
LOGGER.debug("Going to perform customization");
215216

216217
((EGEImpl) ege).performCustomization(cs, source, customization,
217218
usedOutputFormat, response.getOutputStream(),

src/main/java/pl/psnc/dl/ege/webapp/servlethelpers/Info.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package pl.psnc.dl.ege.webapp.servlethelpers;
22

3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
35
import org.json.JSONException;
46
import org.json.JSONObject;
7+
import pl.psnc.dl.ege.EGE;
8+
import pl.psnc.dl.ege.EGEImpl;
9+
import pl.psnc.dl.ege.configuration.EGEConstants;
510
import pl.psnc.dl.ege.webapp.request.InfoRequestResolver;
611
import pl.psnc.dl.ege.webapp.request.Method;
712
import pl.psnc.dl.ege.webapp.request.RequestResolver;
@@ -11,16 +16,24 @@
1116
import javax.servlet.http.HttpServlet;
1217
import javax.servlet.http.HttpServletRequest;
1318
import javax.servlet.http.HttpServletResponse;
19+
import java.io.File;
1420
import java.io.IOException;
1521
import java.io.InputStream;
1622
import java.io.PrintWriter;
23+
import java.nio.charset.StandardCharsets;
24+
import java.nio.file.Files;
25+
import java.nio.file.Paths;
1726
import java.util.Properties;
1827

28+
1929
public class Info extends HttpServlet {
2030
HttpServlet servlet;
31+
private static final Logger LOGGER = LogManager
32+
.getLogger(Info.class);
2133

2234
public void doGetHelper(HttpServletRequest request, HttpServletResponse response, HttpServlet httpservlet)
2335
throws IOException, ServletException {
36+
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
2437
servlet = httpservlet;
2538
//String serverInfo = servlet.getServletContext().getServerInfo();
2639
try {
@@ -30,10 +43,22 @@ public void doGetHelper(HttpServletRequest request, HttpServletResponse response
3043
//json_info.put("server-version", serverInfo);
3144
//json_info.put("os-info", System.getProperty("os.name") + " " + System.getProperty("os.version"));
3245
json_info.put("java-version", Runtime.version().toString());
46+
EGE ege = new EGEImpl();
47+
//get info from each converter
48+
//add info which sources are used /usr/share/xml/tei/odd/VERSION
49+
//TEIROOT default is /usr/share/xml/tei/
50+
String versionodd = Files.readString(Paths.get(EGEConstants.TEIROOT + "odd/VERSION"), StandardCharsets.UTF_8);
51+
String versionstylesheets = Files.readString(Paths.get(EGEConstants.TEIROOT + "stylesheet/VERSION"), StandardCharsets.UTF_8);
52+
json_info.put("tei-odd-version", versionodd);
53+
json_info.put("tei-stylesheet-version", versionstylesheets);
54+
//add info which MEI sources are used
55+
//To do: /usr/share/xml/mei/music-encoding/mei401...
3356
//resolve request and catch any errors
3457
RequestResolver rr = new InfoRequestResolver(request,
3558
Method.GET);
3659
//print available info
60+
//EGE ege = new EGEImpl();
61+
//List<ConversionsPath> paths = ege.findConversionPaths(idt);
3762
printInfo(response, rr, json_info);
3863
}
3964
catch (RequestResolvingException ex) {

src/main/java/pl/psnc/dl/ege/webapp/servlethelpers/Validation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void doGetHelper(HttpServletRequest request,
4040
HttpServletResponse response)
4141
throws ServletException, IOException
4242
{
43+
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
4344
try {
4445
//resolve request and catch any errors
4546
RequestResolver rr = new ValidationRequestResolver(request,

0 commit comments

Comments
 (0)