Skip to content

Commit

Permalink
Fix: (semi-speculative) resolve errors on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Sep 14, 2022
1 parent fa5aa83 commit 8c5fef0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
8 changes: 4 additions & 4 deletions web/src/main/java/org/openmrs/OpenmrsCharacterEscapes.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
*/
package org.openmrs;

import org.codehaus.jackson.SerializableString;
import org.codehaus.jackson.io.CharacterEscapes;
import org.codehaus.jackson.io.SerializedString;
import com.fasterxml.jackson.core.SerializableString;
import com.fasterxml.jackson.core.io.CharacterEscapes;
import com.fasterxml.jackson.core.io.SerializedString;

/**
* An instance of this class can be passed to an ObjectMapper instance when serializing objects to
* JSON using the jackson API so as to escape html and scripts inside html tags
*/
public class OpenmrsCharacterEscapes extends CharacterEscapes {

private int[] asciiEscapes;
private final int[] asciiEscapes;

public OpenmrsCharacterEscapes() {
// start with set of characters known to require escaping (double-quote, backslash etc)
Expand Down
12 changes: 5 additions & 7 deletions web/src/main/java/org/openmrs/web/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
package org.openmrs.web;

import org.apache.commons.io.IOUtils;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.openmrs.api.context.Context;
import org.openmrs.logging.OpenmrsLoggingUtil;
import org.openmrs.module.MandatoryModuleException;
import org.openmrs.module.Module;
import org.openmrs.module.ModuleFactory;
Expand Down Expand Up @@ -221,10 +220,9 @@ public void contextInitialized(ServletContextEvent event) {

//ensure that we always log the runtime properties file that we are using
//since openmrs is just booting, the log levels are not yet set. TRUNK-4835
Logger contextLog = Logger.getLogger(getClass());
contextLog.setLevel(Level.INFO);
contextLog.info("Using runtime properties file: "
+ OpenmrsUtil.getRuntimePropertiesFilePathName(WebConstants.WEBAPP_NAME));
OpenmrsLoggingUtil.applyLogLevel(getClass().toString(), "INFO");
log.info("Using runtime properties file: {}",
OpenmrsUtil.getRuntimePropertiesFilePathName(WebConstants.WEBAPP_NAME));
}

Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
Expand Down
18 changes: 9 additions & 9 deletions web/src/main/java/org/openmrs/web/filter/StartupFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
*/
package org.openmrs.web.filter;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
Expand All @@ -37,6 +35,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
Expand All @@ -49,11 +48,13 @@
import org.apache.velocity.tools.config.FactoryConfiguration;
import org.apache.velocity.tools.config.ToolConfiguration;
import org.apache.velocity.tools.config.ToolboxConfiguration;
import org.codehaus.jackson.map.ObjectMapper;
import org.openmrs.OpenmrsCharacterEscapes;
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;
import org.openmrs.util.*;
import org.openmrs.logging.MemoryAppender;
import org.openmrs.logging.OpenmrsLoggingUtil;
import org.openmrs.util.LocaleUtility;
import org.openmrs.util.OpenmrsUtil;
import org.openmrs.web.WebConstants;
import org.openmrs.web.filter.initialization.InitializationFilter;
import org.openmrs.web.filter.update.UpdateFilter;
Expand Down Expand Up @@ -325,7 +326,7 @@ protected String getTemplatePrefix() {
* @param result A map to be returned as a JSON document
*/
protected void addLogLinesToResponse(Map<String, Object> result) {
MemoryAppender appender = OpenmrsUtil.getMemoryAppender();
MemoryAppender appender = OpenmrsLoggingUtil.getMemoryAppender();
if (appender != null) {
List<String> logLines = appender.getLogLines();

Expand All @@ -349,7 +350,7 @@ protected void addLogLinesToResponse(Map<String, Object> result) {
*/
protected String toJSONString(Object object) {
ObjectMapper mapper = new ObjectMapper();
mapper.getJsonFactory().setCharacterEscapes(new OpenmrsCharacterEscapes());
mapper.getFactory().setCharacterEscapes(new OpenmrsCharacterEscapes());
try {
return mapper.writeValueAsString(object);
}
Expand Down Expand Up @@ -401,9 +402,8 @@ public ToolContext getToolContext(String locale) {
// from tool context, then changing its locale property and putting this tool back to the context
// First, we need to obtain the value of default key annotation of our localization tool
// class using reflection
Annotation annotation = LocalizationTool.class.getAnnotation(DefaultKey.class);
DefaultKey defaultKeyAnnotation = (DefaultKey) annotation;
String key = defaultKeyAnnotation.value();
DefaultKey annotation = LocalizationTool.class.getAnnotation(DefaultKey.class);
String key = annotation.value();
//
LocalizationTool localizationTool = (LocalizationTool) toolContext.get(key);
localizationTool.setLocale(systemLocale);
Expand Down

0 comments on commit 8c5fef0

Please sign in to comment.