accountList) {
+ this.accountList = accountList;
+ }
+
+ public static int getUserId() {
+ return userId;
+ }
+
+ public static void setUserId(int userId) {
+ Accounts.userId = userId;
+ }
+
+}
diff --git a/src/main/java/org/ntlab/TagServer/utils/DemonUtil.java b/src/main/java/org/ntlab/TagServer/utils/DemonUtil.java
new file mode 100644
index 0000000..b50df4f
--- /dev/null
+++ b/src/main/java/org/ntlab/TagServer/utils/DemonUtil.java
@@ -0,0 +1,16 @@
+package org.ntlab.TagServer.utils;
+
+public class DemonUtil {
+ public static float getDistance(double lat1, double lng1, double lat2, double lng2, int precision) {
+ double R = 6378.137; // km
+ double lat = Math.toRadians(lat2 - lat1);
+ double lng = Math.toRadians(lng2 - lng1);
+ double A = Math.sin(lat / 2) * Math.sin(lat / 2) + Math.cos(Math.toRadians(lat1))
+ * Math.cos(Math.toRadians(lat2)) * Math.sin(lng / 2) * Math.sin(lng / 2);
+ double C = 2 * Math.atan2(Math.sqrt(A), Math.sqrt(1 - A));
+ double decimalNo = Math.pow(10, precision);
+ double distance = R * C;
+ distance = Math.round(decimalNo * distance / 1) / decimalNo;
+ return (float) distance * 1000;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/ntlab/TagServer/utils/JSONConsumer.java b/src/main/java/org/ntlab/TagServer/utils/JSONConsumer.java
new file mode 100644
index 0000000..0d61cbd
--- /dev/null
+++ b/src/main/java/org/ntlab/TagServer/utils/JSONConsumer.java
@@ -0,0 +1,43 @@
+package org.ntlab.TagServer.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import net.arnx.jsonic.JSON;
+import net.arnx.jsonic.JSONException;
+
+@Provider
+@Consumes(MediaType.APPLICATION_JSON)
+public class JSONConsumer implements MessageBodyReader {
+
+ @Override
+ public boolean isReadable(java.lang.Class type, java.lang.reflect.Type genericType,
+ java.lang.annotation.Annotation[] annotations, MediaType mediaType) {
+ return true;
+ }
+
+ @Override
+ public Object readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
+ // TODO Auto-generated method stub
+ try {
+ return JSON.decode(entityStream, genericType);
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ return null;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ return null;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/ntlab/TagServer/utils/JSONProvider.java b/src/main/java/org/ntlab/TagServer/utils/JSONProvider.java
new file mode 100644
index 0000000..38ed438
--- /dev/null
+++ b/src/main/java/org/ntlab/TagServer/utils/JSONProvider.java
@@ -0,0 +1,39 @@
+package org.ntlab.TagServer.utils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import net.arnx.jsonic.JSON;
+
+@Provider()
+@Produces(MediaType.APPLICATION_JSON)
+public class JSONProvider implements MessageBodyWriter {
+ @Override
+ public long getSize(Object arg0, Class arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+ try {
+ return JSON.encode(arg0).getBytes("UTF-8").length;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public boolean isWriteable(Class arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+ return true;
+ }
+
+ @Override
+ public void writeTo(Object arg0, Class arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap arg5,
+ OutputStream arg6) throws IOException, WebApplicationException {
+ JSON.encode(arg0, arg6);
+ }
+}
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..c871cc1
--- /dev/null
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ Jersey Web Application
+ org.glassfish.jersey.servlet.ServletContainer
+
+ jersey.config.server.provider.packages
+ org.ntlab.TagServer
+
+ 1
+
+
+ Jersey Web Application
+ /webapi/*
+
+
diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp
new file mode 100644
index 0000000..a064b45
--- /dev/null
+++ b/src/main/webapp/index.jsp
@@ -0,0 +1,8 @@
+
+
+ Jersey RESTful Web Application!
+ Jersey resource
+
Visit Project Jersey website
+ for more information on Jersey!
+
+