diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..25511a1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target/
+/new/IF3110-03-Simple-Blog-Service/nbproject/private/
\ No newline at end of file
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..31afc8d
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: sh target/bin/webapp
\ No newline at end of file
diff --git a/nb-configuration.xml b/nb-configuration.xml
new file mode 100644
index 0000000..00d593e
--- /dev/null
+++ b/nb-configuration.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+ 1.7-web
+ http://localhost:8080/IF3110-03-Simple-Blog-Service/simpleblog?wsdl
+
+
diff --git a/assets/css/screen.css b/old files/assets/css/screen.css
similarity index 100%
rename from assets/css/screen.css
rename to old files/assets/css/screen.css
diff --git a/assets/img/favicon.ico b/old files/assets/img/favicon.ico
similarity index 100%
rename from assets/img/favicon.ico
rename to old files/assets/img/favicon.ico
diff --git a/assets/img/pre.png b/old files/assets/img/pre.png
similarity index 100%
rename from assets/img/pre.png
rename to old files/assets/img/pre.png
diff --git a/index.html b/old files/index.html
similarity index 100%
rename from index.html
rename to old files/index.html
diff --git a/new_post.html b/old files/new_post.html
similarity index 100%
rename from new_post.html
rename to old files/new_post.html
diff --git a/post.html b/old files/post.html
similarity index 100%
rename from post.html
rename to old files/post.html
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5f6cc30
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,191 @@
+
+
+ 4.0.0
+
+ com.mycompany
+ IF3110-03-Simple-Blog-Service
+ 1.0-SNAPSHOT
+ war
+
+ IF3110-03-Simple-Blog-Service
+
+
+ ${project.build.directory}/endorsed
+ UTF-8
+
+
+
+
+ com.sun.xml.ws
+ webservices-rt
+ 1.4
+ provided
+
+
+ javax
+ javaee-web-api
+ 7.0
+ provided
+
+
+ com.firebase
+ firebase-client-android
+ 2.0.3
+
+
+ org.json
+ json
+ 20090211
+
+
+ org.eclipse.jetty
+ jetty-server
+ 8.0.0.RC0
+
+
+ org.eclipse.jetty
+ jetty-webapp
+ 8.0.0.RC0
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxws
+ 2.4.2
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+ 2.4.2
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.2.4-1
+
+
+
+ org.apache.cxf
+ cxf-bundle-jaxrs
+ 2.4.2
+
+
+ org.eclipse.jetty
+ jetty-security
+
+
+ org.eclipse.jetty
+ jetty-io
+
+
+ org.eclipse.jetty
+ jetty-util
+
+
+ org.eclipse.jetty
+ jetty-continuation
+
+
+ org.eclipse.jetty
+ jetty-http
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ 1.7
+ 1.7
+
+ ${endorsed.dir}
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 2.3
+
+ false
+
+
+ src
+ WEB-INF
+
+ jax-ws-catalog.xml
+ wsdl/**
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.6
+
+
+ validate
+
+ copy
+
+
+ ${endorsed.dir}
+ true
+
+
+ javax
+ javaee-endorsed-api
+ 7.0
+ jar
+
+
+
+
+
+
+
+ org.jvnet.jax-ws-commons
+ jaxws-maven-plugin
+ 2.2.1
+
+
+
+ wsimport
+
+
+
+ localhost_8080/IF3110-03-Simple-Blog-Service/simpleblog.wsdl
+
+ http://localhost:8080/IF3110-03-Simple-Blog-Service/simpleblog?wsdl
+ ${project.build.directory}/jaxws/stale/simpleblog.stale
+
+ wsimport-generate-simpleblog
+ generate-sources
+
+
+
+
+ javax.xml
+ webservices-api
+ 1.4
+
+
+
+ ${project.build.directory}/generated-sources/jaxws-wsimport
+ true
+ true
+ true
+ ${basedir}/src/jax-ws-catalog.xml
+
+
+
+
+
+
diff --git a/src/jax-ws-catalog.xml b/src/jax-ws-catalog.xml
new file mode 100644
index 0000000..cb0d492
--- /dev/null
+++ b/src/jax-ws-catalog.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/chamerling/heroku/jetty/JettyServer.java b/src/main/java/org/chamerling/heroku/jetty/JettyServer.java
new file mode 100644
index 0000000..569a557
--- /dev/null
+++ b/src/main/java/org/chamerling/heroku/jetty/JettyServer.java
@@ -0,0 +1,39 @@
+package org.chamerling.heroku.jetty;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+public class JettyServer {
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception{
+ String webappDirLocation = "src/main/webapp/";
+
+ //The port that we should run on can be set into an environment variable
+ //Look for that variable and default to 8080 if it isn't there.
+ String webPort = System.getenv("PORT");
+ if(webPort == null || webPort.isEmpty()) {
+ webPort = "9191";
+ }
+
+ Server server = new Server(Integer.valueOf(webPort));
+ WebAppContext root = new WebAppContext();
+
+ root.setContextPath("/");
+ root.setDescriptor(webappDirLocation+"/WEB-INF/web.xml");
+ root.setResourceBase(webappDirLocation);
+
+ //Parent loader priority is a class loader setting that Jetty accepts.
+ //By default Jetty will behave like most web containers in that it will
+ //allow your application to replace non-server libraries that are part of the
+ //container. Setting parent loader priority to true changes this behavior.
+ //Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
+ root.setParentLoaderPriority(true);
+
+ server.setHandler(root);
+
+ server.start();
+ server.join();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/chamerling/heroku/service/HelloService.java b/src/main/java/org/chamerling/heroku/service/HelloService.java
new file mode 100644
index 0000000..9b99b8d
--- /dev/null
+++ b/src/main/java/org/chamerling/heroku/service/HelloService.java
@@ -0,0 +1,18 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.chamerling.heroku.service;
+
+import javax.jws.WebService;
+
+/**
+ * @author chamerling
+ *
+ */
+@WebService
+public interface HelloService {
+
+ String sayHi(String input);
+}
\ No newline at end of file
diff --git a/src/main/java/org/chamerling/heroku/service/HelloServiceImpl.java b/src/main/java/org/chamerling/heroku/service/HelloServiceImpl.java
new file mode 100644
index 0000000..d4a041a
--- /dev/null
+++ b/src/main/java/org/chamerling/heroku/service/HelloServiceImpl.java
@@ -0,0 +1,20 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.chamerling.heroku.service;
+
+/**
+ * @author chamerling
+ *
+ */
+public class HelloServiceImpl implements HelloService {
+
+ @Override
+ public String sayHi(String input) {
+ System.out.println("Hello invoked : " + input);
+ return String.format("Hello '%s'", input);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/paket/Comment.java b/src/main/java/paket/Comment.java
new file mode 100644
index 0000000..c3d39c1
--- /dev/null
+++ b/src/main/java/paket/Comment.java
@@ -0,0 +1,64 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package paket;
+
+/**
+ *
+ * @author Mario
+ */
+public class Comment {
+
+ String tanggal, konten, email, nama;
+ Integer id, post_id;
+
+ public Integer getPost_id() {
+ return post_id;
+ }
+
+ public void setPost_id(Integer post_id) {
+ this.post_id = post_id;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getTanggal() {
+ return tanggal;
+ }
+
+ public void setTanggal(String tanggal) {
+ this.tanggal = tanggal;
+ }
+
+ public String getKonten() {
+ return konten;
+ }
+
+ public void setKonten(String konten) {
+ this.konten = konten;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getNama() {
+ return nama;
+ }
+
+ public void setNama(String nama) {
+ this.nama = nama;
+ }
+}
diff --git a/src/main/java/paket/Post.java b/src/main/java/paket/Post.java
new file mode 100644
index 0000000..68892ca
--- /dev/null
+++ b/src/main/java/paket/Post.java
@@ -0,0 +1,75 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package paket;
+
+/**
+ *
+ * @author Mario
+ */
+public class Post {
+
+ String judul, tanggal, konten, id;
+ Boolean ispublished, del;
+
+// Post(String id, String judul, String tanggal, String konten, boolean ispublished, boolean del) {
+// throw new UnsupportedOperationException("Not supported yet.");
+// //To change body of generated methods, choose Tools | Templates.
+// this.id=id;
+// this.judul=judul;
+// this.tanggal=tanggal;
+// this.konten=konten;
+// this.ispublished=ispublished;
+// this.del=del;
+// }
+
+ public String getJudul() {
+ return judul;
+ }
+
+ public void setJudul(String judul) {
+ this.judul = judul;
+ }
+
+ public String getTanggal() {
+ return tanggal;
+ }
+
+ public void setTanggal(String tanggal) {
+ this.tanggal = tanggal;
+ }
+
+ public String getKonten() {
+ return konten;
+ }
+
+ public void setKonten(String konten) {
+ this.konten = konten;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Boolean getIspublished() {
+ return ispublished;
+ }
+
+ public void setIspublished(Boolean ispublished) {
+ this.ispublished = ispublished;
+ }
+
+ public Boolean getDel() {
+ return del;
+ }
+
+ public void setDel(Boolean del) {
+ this.del = del;
+ }
+}
diff --git a/src/main/java/paket/User.java b/src/main/java/paket/User.java
new file mode 100644
index 0000000..8d535b8
--- /dev/null
+++ b/src/main/java/paket/User.java
@@ -0,0 +1,57 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package paket;
+
+/**
+ *
+ * @author Mario
+ */
+public class User {
+
+ String nama, email, role, pass;
+ Integer id;
+
+ public String getNama() {
+ return nama;
+ }
+
+ public void setNama(String nama) {
+ this.nama = nama;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String getPass() {
+ return pass;
+ }
+
+ public void setPass(String pass) {
+ this.pass = pass;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+}
diff --git a/src/main/java/paket/simpleblog.java b/src/main/java/paket/simpleblog.java
new file mode 100644
index 0000000..0361d28
--- /dev/null
+++ b/src/main/java/paket/simpleblog.java
@@ -0,0 +1,467 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package paket;
+
+import com.firebase.client.Firebase;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.jws.WebService;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import org.apache.cxf.helpers.IOUtils;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+//import org.json.simple.JSONArray;
+//import org.json.simple.JSONObject;
+//import org.json.simple.parser.JSONParser;
+
+
+/**
+ *
+ * @author TOSHIBA
+ */
+@WebService(serviceName = "simpleblog")
+public class simpleblog {
+
+ private final Firebase fbase;
+ String dbname = "https://boiling-torch-615.firebaseio.com/";
+
+ public simpleblog() {
+ this.fbase = new Firebase(dbname);
+ }
+
+ /**
+ * Web service operation
+ * @param mode
+ * @return
+ * @throws java.io.IOException
+ * @throws java.text.ParseException
+ * @throws org.codehaus.jettison.json.JSONException
+ */
+
+ @WebMethod(operationName = "listPost")
+ public List listPost() throws IOException, ParseException, JSONException {
+ //TODO write your implementation code here:
+ List list = new ArrayList<>();
+
+ try{
+ URL url = new URL(fbase + "post.json");
+ URLConnection connection = url.openConnection();
+ JSONObject json = new JSONObject(IOUtils.toString(connection.getInputStream()));
+
+ Iterator keys = json.keys();
+ while (keys.hasNext()) {
+ JSONObject jsonPost = json.getJSONObject(keys.next());
+ Post post = new Post();
+ post.setId(jsonPost.getString("id"));
+ post.setJudul(jsonPost.getString("judul"));
+ post.setKonten(jsonPost.getString("konten"));
+ post.setTanggal(jsonPost.getString("tanggal"));
+ post.setIspublished(jsonPost.getBoolean("published"));
+ list.add(post);
+ }
+ }catch ( JSONException | IOException ex){
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ return list;
+ }
+
+ /**
+ * Web service operation
+ * @param id
+ * @return
+ */
+ @WebMethod(operationName = "deletePost")
+ public Boolean deletePost(@WebParam(name = "id") Integer id) {
+ String key = getPostKey(id);
+ if (key == null) return false;
+
+ // push ke firebase
+ fbase.child("post").child(key).child("published").setValue(-1, true);
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @param id
+ * @return
+ */
+ @WebMethod(operationName = "publishPost")
+ public Boolean publishPost(@WebParam(name = "id") Integer id) {
+ String key = getPostKey(id);
+ if (key == null) return false;
+
+ // push ke firebase
+ fbase.child("post").child(key).child("published").setValue(1, true);
+
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @param nama
+ * @param email
+ * @param role
+ * @param password
+ * @return
+ */
+ @WebMethod(operationName = "addUser")
+ public Boolean addUser(@WebParam(name = "nama") String nama, @WebParam(name = "email") String email, @WebParam(name = "role") String role, @WebParam(name = "password") String password) {
+ Firebase users = fbase.child("user");
+ HashMap newUser = new HashMap<>();
+ newUser.put("nama", nama);
+ newUser.put("email", email);
+ newUser.put("role", role);
+ newUser.put("password", password);
+ users.push().setValue(newUser);
+
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @return
+ */
+ @WebMethod(operationName = "listUser")
+ public List listUser() {
+ List list = new ArrayList<>();
+ try {
+ URL url = new URL(fbase + "user" + ".json");
+ URLConnection connection = url.openConnection();
+ JSONObject json = new JSONObject(IOUtils.toString(connection.getInputStream()));
+
+ Iterator keys = json.keys();
+ while (keys.hasNext()) {
+ JSONObject jsonUser = json.getJSONObject(keys.next());
+ User user = new User();
+ user.setId(jsonUser.getInt("id"));
+ user.setNama(jsonUser.getString("username"));
+ user.setPass(jsonUser.getString("password"));
+ user.setEmail(jsonUser.getString("email"));
+ user.setRole(jsonUser.getString("role"));
+ list.add(user);
+ }
+ } catch (JSONException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return list;
+ }
+
+ /**
+ * Web service operation
+ * @param id
+ * @param nama
+ * @param role
+ * @param email
+ * @param password
+ * @return
+ */
+ @WebMethod(operationName = "editUser")
+ public Boolean editUser(@WebParam(name = "id") Integer id, @WebParam(name = "nama") String nama, @WebParam(name = "role") String role, @WebParam(name = "email") String email, @WebParam(name = "password") String password) {
+ String key = getUserKey(id);
+ if (key == null) return false;
+
+ // masukkan konten ke HashMap
+ Map map = new HashMap<>();
+ map.put("id", id);
+ map.put("username", nama);
+ map.put("password", password);
+ map.put("email", email);
+ map.put("role", role);
+
+ // push ke firebase
+ fbase.child("user").push().setValue(map, true);
+
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @param id
+ * @return
+ */
+ @WebMethod(operationName = "deleteUser")
+ public Boolean deleteUser(@WebParam(name = "id") Integer id) {
+ String key = getUserKey(id);
+ if (key == null) return false;
+
+ // push ke firebase
+ fbase.child("user").child(key).removeValue();
+
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @param postId
+ * @param nama
+ * @param email
+ * @param konten
+ * @return
+ */
+ @WebMethod(operationName = "addComment")
+ public Boolean addComment(@WebParam(name = "postId") String postId, @WebParam(name = "nama") String nama, @WebParam(name = "email") String email, @WebParam(name = "konten") String konten) {
+ Map map = new HashMap<>();
+ map.put("id", getNewCommentId());
+ map.put("postId", postId);
+ map.put("name", nama);
+ map.put("email", email);
+ map.put("content", konten);
+ map.put("time", (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(Calendar.getInstance().getTime()) + " UTC");
+
+ // push ke firebase
+ fbase.child("comment").push().setValue(map, true);
+
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @param postId
+ * @return
+ */
+ @WebMethod(operationName = "listComment")
+ public List listComment(Integer postId) {
+ List list = new ArrayList<>();
+ try {
+ URL url = new URL(fbase + "comment" + ".json");
+ URLConnection connection = url.openConnection();
+ JSONObject json = new JSONObject(IOUtils.toString(connection.getInputStream()));
+
+ Iterator keys = json.keys();
+ while (keys.hasNext()) {
+ JSONObject jsonComment = json.getJSONObject(keys.next());
+ Comment comment = new Comment();
+ comment.setId(jsonComment.getInt("id"));
+ comment.setPost_id(jsonComment.getInt("postId"));
+ comment.setNama(jsonComment.getString("name"));
+ comment.setEmail(jsonComment.getString("email"));
+ comment.setKonten(jsonComment.getString("content"));
+ comment.setTanggal(jsonComment.getString("time"));
+
+ if (comment.getPost_id() == postId) {
+ list.add(comment);
+ }
+ }
+ } catch (JSONException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return list;
+ }
+
+ /**
+ * Web service operation
+ * @param id
+ * @return
+ */
+ @WebMethod(operationName = "deleteComment")
+ public Boolean deleteComment(@WebParam(name = "id") Integer id) {
+ //TODO write your implementation code here:
+ return null;
+ }
+
+ /**
+ * Web service operation
+ * @param query
+ * @return
+ * @throws java.io.IOException
+ * @throws java.text.ParseException
+ * @throws org.codehaus.jettison.json.JSONException
+ */
+ @WebMethod(operationName = "search")
+ public List search(@WebParam(name = "query") String query) throws IOException, ParseException, JSONException {
+ List allPost = listPost();
+ List list = new ArrayList<>();
+
+ String[] token = query.toLowerCase().split(" \t\n\r");
+ for (Post post : allPost) {
+ String text = post.getJudul().toLowerCase() + " " + post.getKonten().toLowerCase();
+ boolean match = true;
+ for (String word : token) {
+ if (!text.contains(word)) {
+ match = false;
+ break;
+ }
+ }
+ if (match) {
+ list.add(post);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Web service operation
+ * @param judul
+ * @param konten
+ * @param tanggal
+ * @return
+ */
+ @WebMethod(operationName = "addPost")
+ public Boolean addPost(@WebParam(name = "judul") String judul, @WebParam(name = "konten") String konten, @WebParam(name = "tanggal") String tanggal) {
+ Firebase posts = fbase.child("post");
+ Map newPost = new HashMap<>();
+ newPost.put("judul", judul);
+ newPost.put("konten", konten);
+ newPost.put("tanggal", tanggal);
+ newPost.put("published", false);
+ newPost.put("deleted", false);
+ posts.push().setValue(newPost);
+ return true;
+ }
+
+ /**
+ * Web service operation
+ * @param id
+ * @param judul
+ * @param konten
+ * @param tanggal
+ * @return
+ */
+ @WebMethod(operationName = "editPost")
+ @RequestWrapper(className = "paket.editPost")
+ @ResponseWrapper(className = "paket.editPostResponse")
+ public Boolean editPost(@WebParam(name = "id") Integer id, @WebParam(name = "judul") String judul, @WebParam(name = "konten") String konten, @WebParam(name = "tanggal") String tanggal) {
+ Firebase post = fbase.child("post").child(id.toString());
+ Map newPost = new HashMap<>();
+ newPost.put("judul", judul);
+ newPost.put("konten", konten);
+ newPost.put("tanggal", tanggal);
+ post.updateChildren(newPost);
+ return true;
+ }
+
+ /* Mengembalikan key dari post dengan id tertentu */
+ private String getPostKey(Integer id) {
+ String key = null;
+ try {
+ URL url = new URL(fbase + "post" + ".json");
+ URLConnection connection = url.openConnection();
+ JSONObject json = new JSONObject(IOUtils.toString(connection.getInputStream()));
+
+ Iterator keys = json.keys();
+ while (keys.hasNext()) {
+ String currentKey = keys.next();
+ if (json.getJSONObject(currentKey).getInt("id") == id) {
+ key = currentKey;
+ break;
+ }
+ }
+ } catch (JSONException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return key;
+ }
+
+ /* Mengembalikan key dari post dengan id tertentu */
+ private String getUserKey(Integer id) {
+ String key = null;
+ try {
+ URL url = new URL(fbase + "post" + ".json");
+ URLConnection connection = url.openConnection();
+ JSONObject json = new JSONObject(IOUtils.toString(connection.getInputStream()));
+
+ Iterator keys = json.keys();
+ while (keys.hasNext()) {
+ String currentKey = keys.next();
+ if (json.getJSONObject(currentKey).getInt("id") == id) {
+ key = currentKey;
+ break;
+ }
+ }
+ } catch (JSONException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(simpleblog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return key;
+ }
+
+ /* Mengembalikan post id baru */
+ private Integer getNewPostId() {
+ Integer id = 0;
+ try {
+ // retrieve value from firebase
+ URL url = new URL(fbase + "post_id_counter" + ".json");
+ URLConnection connection = url.openConnection();
+ id = Integer.parseInt(IOUtils.toString(connection.getInputStream()));
+
+ // update id and update the value in firebase
+ id++;
+ fbase.child("post_id_counter").setValue(id);
+ }
+ catch (IOException e) {
+ // do nothing
+ e.printStackTrace();
+ }
+ return id;
+ }
+
+ /* Mengembalikan user id baru */
+ private Integer getNewUserId() {
+ Integer id = 0;
+ try {
+ // retrieve value from firebase
+ URL url = new URL(fbase + "user_id_counter" + ".json");
+ URLConnection connection = url.openConnection();
+ id = Integer.parseInt(IOUtils.toString(connection.getInputStream()));
+
+ // update id and update the value in firebase
+ id++;
+ fbase.child("user_id_counter").setValue(id);
+ }
+ catch (IOException e) {
+ // do nothing
+ e.printStackTrace();
+ }
+ return id;
+ }
+
+ /* Mengembalikan user id baru */
+ private Integer getNewCommentId() {
+ Integer id = 0;
+ try {
+ // retrieve value from firebase
+ URL url = new URL(fbase + "comment_id_counter" + ".json");
+ URLConnection connection = url.openConnection();
+ id = Integer.parseInt(IOUtils.toString(connection.getInputStream()));
+
+ // update id and update the value in firebase
+ id++;
+ fbase.child("comment_id_counter").setValue(id);
+ }
+ catch (IOException e) {
+ // do nothing
+ e.printStackTrace();
+ }
+ return id;
+ }
+}
diff --git a/src/main/webapp/WEB-INF/beans.xml b/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..6d081c1
--- /dev/null
+++ b/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/glassfish-web.xml b/src/main/webapp/WEB-INF/glassfish-web.xml
new file mode 100644
index 0000000..13e0059
--- /dev/null
+++ b/src/main/webapp/WEB-INF/glassfish-web.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+ Keep a copy of the generated servlet class' java code.
+
+
+
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f3c7499
--- /dev/null
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+ contextConfigLocation
+ WEB-INF/beans.xml
+
+
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ CXFServlet
+ IF3110-II-29 SimpleBlog Service
+
+ org.apache.cxf.transport.servlet.CXFServlet
+
+ 1
+
+
+
+ CXFServlet
+ /*
+
+
\ No newline at end of file
diff --git a/src/wsdl/localhost_8080/IF3110-03-Simple-Blog-Service/simpleblog.wsdl b/src/wsdl/localhost_8080/IF3110-03-Simple-Blog-Service/simpleblog.wsdl
new file mode 100644
index 0000000..d41e034
--- /dev/null
+++ b/src/wsdl/localhost_8080/IF3110-03-Simple-Blog-Service/simpleblog.wsdl
@@ -0,0 +1,523 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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