diff --git a/README.md b/README.md index 3ae35d5..4966392 100644 --- a/README.md +++ b/README.md @@ -64,12 +64,17 @@ Available methods: offset : return list from 'offset' (negative value start counting from end) count : return 'count' items at most + +## Building The REST API Service + To build and run the REST API, type: mvn clean install mvn jetty:run (alternatively, you can use: mvn tomcat7:run) +Or deploy the WAR file (in `target`) on in your Tomcat instance. + If you wish to use MongoDB tracing, will need to provide your own local *secret* properties file, called `mapcode-secret.properties`, for example in `src/main/resources` which override the following properties: @@ -82,19 +87,35 @@ in `src/main/resources` which override the following properties: The service will work without this, but will not trace events to the database. +The source uses Java JDK 1.8, so make sure your Java compiler is set to 1.8, for example +using something like (MacOSX): + + export JAVA_HOME=`/usr/libexec/java_home -v 1.8` + + +## Smoke Testing The REST API + Try out if the web services work by entering the following URL in your web browser (this should show you a HTML help page): http://localhost:8080/mapcode + http://localhost:8080/mapcode/codes/50,5 Or use a tool like cURL: curl -X GET http://localhost:8080/mapcode + curl -X GET http://localhost:8080/mapcode/codes/50,5 -There's also an example HTML page in the examples/index.html for HTML/Javascript developers. +There's also an example HTML page in the `examples/index.html` for HTML/Javascript developers. -The source uses Java JDK 1.8, so make sure your Java compiler is set to 1.8, for example -using something like (MacOSX): - export JAVA_HOME=`/usr/libexec/java_home -v 1.8` +## Release Notes + +* 1.50.1 + + Bug fix for state IN-DD (in India). + +* 1.50.0 + + First release of the REST API, based on the Mapcode Java library, version 1.50.0. diff --git a/pom.xml b/pom.xml index 4a249ff..abf5245 100755 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ mapcode-rest-service war - 1.50.0.0 + 1.50.1.0 Mapcode REST API Web Service @@ -87,7 +87,7 @@ 3.0.11.Final 1.7.2 - 1.50.0 + 1.50.1 3.0.9 3.2 diff --git a/src/main/java/com/mapcode/services/implementation/MapcodeResourceImpl.java b/src/main/java/com/mapcode/services/implementation/MapcodeResourceImpl.java index e73bdfb..a5819eb 100644 --- a/src/main/java/com/mapcode/services/implementation/MapcodeResourceImpl.java +++ b/src/main/java/com/mapcode/services/implementation/MapcodeResourceImpl.java @@ -136,7 +136,7 @@ public void convertLatLonToMapcode( assert response != null; processor.process("convertLatLonToMapcode", LOG, response, () -> { - LOG.debug("convertLatLonToMapcode: lat={}, lon={}, precision={}, type={}, context={}, alphabet={}, include={}", + LOG.info("convertLatLonToMapcode: lat={}, lon={}, precision={}, type={}, context={}, alphabet={}, include={}", paramLatDeg, paramLonDeg, paramPrecision, paramType, paramTerritory, paramAlphabet, paramInclude); metricsCollector.allLatLonToMapcodeRequests(); @@ -293,7 +293,7 @@ public void convertMapcodeToLatLon( assert response != null; processor.process("convertMapcodeToLatLon", LOG, response, () -> { - LOG.debug("convertMapcodeToLatLon: code={}, territory={}", paramCode, paramContext); + LOG.info("convertMapcodeToLatLon: code={}, territory={}", paramCode, paramContext); metricsCollector.allMapcodeToLatLonRequests(); // Get the territory from the path (if specified). @@ -348,7 +348,7 @@ public void getTerritories( assert response != null; processor.process("getTerritories", LOG, response, () -> { - LOG.debug("getTerritories"); + LOG.info("getTerritories"); // Check value of count. if (count < 0) { @@ -380,7 +380,7 @@ public void getTerritory( assert response != null; processor.process("getTerritory", LOG, response, () -> { - LOG.debug("getTerritory: territory={}, context={}", paramTerritory, paramContext); + LOG.info("getTerritory: territory={}, context={}", paramTerritory, paramContext); // Get the territory from the URL. final Territory territory; @@ -420,7 +420,7 @@ public void getAlphabets( assert response != null; processor.process("getAlphabets", LOG, response, () -> { - LOG.debug("getAlphabets"); + LOG.info("getAlphabets"); // Check value of count. if (count < 0) { @@ -451,7 +451,7 @@ public void getAlphabet( assert response != null; processor.process("getAlphabet", LOG, response, () -> { - LOG.debug("getAlphabet: alphabet={}", paramAlphabet); + LOG.info("getAlphabet: alphabet={}", paramAlphabet); // Get the territory from the URL. final Alphabet alphabet; diff --git a/src/main/java/com/mapcode/services/implementation/SystemMetricsImpl.java b/src/main/java/com/mapcode/services/implementation/SystemMetricsImpl.java index 597b449..8056c8f 100644 --- a/src/main/java/com/mapcode/services/implementation/SystemMetricsImpl.java +++ b/src/main/java/com/mapcode/services/implementation/SystemMetricsImpl.java @@ -22,9 +22,8 @@ import com.tomtom.speedtools.metrics.MultiMetricsData; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.Level; +import org.apache.log4j.Logger; import org.apache.log4j.spi.LoggingEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.annotation.Nonnull; import javax.inject.Inject; @@ -36,8 +35,6 @@ * possible. It does, however, use the ActorSystem to provide it with a periodic timer event to store its data. */ public class SystemMetricsImpl implements SystemMetrics, SystemMetricsCollector { - private static final Logger LOG = LoggerFactory.getLogger(SystemMetricsImpl.class); - private final MultiMetricsCollector allMapcodeToLatLonRequests = MultiMetricsCollector.all(); private final MultiMetricsCollector validMapcodeToLatLonRequests = MultiMetricsCollector.all(); private final MultiMetricsCollector allLatLonToMapcodeRequests = MultiMetricsCollector.all(); @@ -58,7 +55,7 @@ public class SystemMetricsImpl implements SystemMetrics, SystemMetricsCollector public SystemMetricsImpl() { // Listen for log errors and warnings. - org.apache.log4j.Logger.getRootLogger().addAppender(new Log4jAppender()); + Logger.getRootLogger().addAppender(new Log4jAppender()); } /** @@ -66,10 +63,10 @@ public SystemMetricsImpl() { */ private class Log4jAppender extends AppenderSkeleton { @Override - protected void append(@Nonnull final LoggingEvent event) { - if (event.getLevel().equals(Level.WARN) || - event.getLevel().equals(Level.ERROR) || - event.getLevel().equals(Level.FATAL)) { + protected void append(@Nonnull final LoggingEvent loggingEvent) { + if (loggingEvent.getLevel().equals(Level.WARN) || + loggingEvent.getLevel().equals(Level.ERROR) || + loggingEvent.getLevel().equals(Level.FATAL)) { // Increase counter first, then log - on the off chance that another errors occurs... warningsAndErrors.addValue(1); } else { diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index 2fefb0c..679b216 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -39,7 +39,7 @@ - +