diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc82db1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# NetBeans specific # +simple-blog/nbproject/ +simple-blog/nbproject/private/ +simple-blog/build/ +simple-blog/nbbuild/ +simple-blog/dist/ +simple-blog/nbdist/ +simple-blog/nbactions.xml +simple-blog/nb-configuration.xml + +# Class Files # +*.class diff --git a/simple-blog/build.xml b/simple-blog/build.xml new file mode 100644 index 0000000..9359e53 --- /dev/null +++ b/simple-blog/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project simple-blog. + + + diff --git a/simple-blog/src/conf/MANIFEST.MF b/simple-blog/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/simple-blog/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/simple-blog/src/java/simpleblog/DatabaseController.java b/simple-blog/src/java/simpleblog/DatabaseController.java new file mode 100644 index 0000000..438de42 --- /dev/null +++ b/simple-blog/src/java/simpleblog/DatabaseController.java @@ -0,0 +1,172 @@ +package simpleblog; + +/* + * 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. + */ + +import java.io.Serializable; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Resource; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.SessionScoped; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; +import static org.apache.tomcat.jni.User.username; +import simpleblog.heroku.service.IOException_Exception; +import simpleblog.heroku.service.SimpleblogService; +import simpleblog.heroku.service.SimpleblogServiceImplService; +import simpleblog.heroku.service.User; +/** + * + * @author Luqman + */ +@ManagedBean(name="databaseController") +@SessionScoped +public class DatabaseController implements Serializable { + + private User user; + private DataSource ds; + private Context initCtx; + private Context envCtx; + private Connection conn; + private PreparedStatement ps; + private User selectedUser; + private List lusers; + /** + * Creates a new instance of dbTest + */ + public DatabaseController() { + System.out.println("db ctrl dibuat"); + selectedUser = new User(); + } + public User getSelectedUser() { + if(selectedUser == null) + selectedUser = new User(); + return selectedUser; + } + + public void setSelectedUser(User selectedUser) { + this.selectedUser = selectedUser; + } + + public User loginValidator(String username, String password) throws IOException_Exception{ + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + setUser(service.getUser(username, password)); + + return getUser(); + } + public User getUser() { + if(user == null) + user = new User(); + return user; + } + public User intialUser(){ + user = new User(); + return user; + } + /** + * @param user the user to set + */ + public void setUser(User user) { + this.user = user; + } + public List getUserList() throws IOException_Exception{ + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + List list = new ArrayList(); + list = service.getUserList(); + return list; + } + public void add() throws SQLException{ + try { + initCtx = new InitialContext(); + envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + } catch (NamingException e) { + } + if(ds==null) + throw new SQLException("Can't get data source"); + + //get database connection + conn = ds.getConnection(); + if(conn==null) + throw new SQLException("Can't get database connection"); + else{ + ps = conn.prepareStatement("INSERT INTO user (username,name,email,password,role) VALUES('"+user.getUsername()+"','"+user.getName()+"','"+user.getEmail()+"','"+user.getPassword()+"','"+user.getRole()+"')"); + ps.executeUpdate(); + conn.close(); + ps.close();} + System.out.println("Berhasil"); + user = null; + } + + + public void delete() throws SQLException{ + try { + initCtx = new InitialContext(); + envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + } catch (NamingException e) { + } + if(ds==null) + throw new SQLException("Can't get data source"); + + //get database connection + conn = ds.getConnection(); + if(conn==null) + throw new SQLException("Can't get database connection"); + else{ + ps = conn.prepareStatement("DELETE FROM user WHERE id = "+selectedUser.getId()+""); + ps.executeUpdate(); + conn.close(); + ps.close();} + System.out.println("Berhasil"); + } + public void update() throws SQLException{ + try { + initCtx = new InitialContext(); + envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + } catch (NamingException e) { + } + if(ds==null) + throw new SQLException("Can't get data source"); + + //get database connection + conn = ds.getConnection(); + if(conn==null) + throw new SQLException("Can't get database connection"); + else{ + ps = conn.prepareStatement("UPDATE user SET email='"+selectedUser.getEmail()+"',username='"+selectedUser.getUsername()+"',name='"+selectedUser.getName()+"',password='"+selectedUser.getPassword()+"',role='"+selectedUser.getRole()+"' WHERE id = '"+selectedUser.getId()+"'"); + ps.executeUpdate(); + System.out.println(selectedUser.getName()); + conn.close(); + ps.close();} + System.out.println("Berhasil"); + } + public void settingSelectedUser() throws IOException_Exception{ + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + selectedUser = service.getUserById(selectedUser.getId()); + } + + public void nullUser(){ + user = new User(); + user.setRole(null); + } + + public void redirectTable() throws Exception{ + ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); + externalContext.redirect("faces/ShowTable.xhtml"); + } +} diff --git a/simple-blog/src/java/simpleblog/PostController.java b/simple-blog/src/java/simpleblog/PostController.java new file mode 100644 index 0000000..12585aa --- /dev/null +++ b/simple-blog/src/java/simpleblog/PostController.java @@ -0,0 +1,357 @@ +/* + * 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 simpleblog; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Serializable; +import static java.lang.Integer.parseInt; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; +import javax.faces.bean.ViewScoped; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.servlet.ServletContext; +import javax.servlet.http.Part; +import javax.sql.DataSource; +import simpleblog.heroku.service.IOException_Exception; +import simpleblog.heroku.service.Post; +import simpleblog.heroku.service.SimpleblogService; +import simpleblog.heroku.service.SimpleblogServiceImplService; +import simpleblog.model.User; + +/** + * + * @author Luqman + */ +@ManagedBean +@ViewScoped +public class PostController implements Serializable { + private DataSource ds; + private String title; + private String date; + private String content; + private String post_id; + private Part image; + private Post post; + + /** + * Creates a new instance of PostController + */ + + public PostController(){ + title = new String(); + date = new String(); + content = new String(); + post = new Post(); + } + + public void setNull(){ + title = null; + date = null; + content = null; + } + + public void getDatabasePost() throws IOException_Exception{ + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + Post tmp_post = service.getPost(parseInt(getPost_id())); + String[] tmp_date = tmp_post.getDate().split(" "); + tmp_post.setDate(tmp_date[0]); + post = tmp_post; + } + + public List getPostList() throws SQLException, NamingException, IOException_Exception + { + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + return service.getPostList(1); + } + + public boolean insertPost(User user) throws NamingException, SQLException{ + try { + Date dates = new Date(); + date = date + " " + dates.getHours() + ":" + dates.getMinutes() + ":" + dates.getSeconds(); + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + PreparedStatement ps = con.prepareStatement( + "INSERT INTO post (user_id, title, date, content, status) VALUES ('"+ user.getId() +"','"+ title +"','"+ date +"','"+ content +"','0')"); + ps.executeUpdate(); + ps = con.prepareStatement("SELECT LAST_INSERT_ID();"); + ResultSet result = ps.executeQuery(); + result.first(); + uploadImage(result.getInt(1)); + + con.close(); + + ps.close(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + + public void uploadImage(int imageId) throws IOException + { + String fileExtension = getFileExtension(getImage()); + String basePath = "D:" + File.separator; + + File outputFilePath = new File(getImagePath()+ File.separator + "resources"+File.separator+"images" + File.separator + imageId + "." + fileExtension); + InputStream inputStream = null; + OutputStream outputStream = null; + System.out.println("Nama file " + outputFilePath.getAbsolutePath()); + + try { + inputStream = image.getInputStream(); + outputStream = new FileOutputStream(outputFilePath); + + int read = 0; + final byte[] bytes = new byte[1024*1024*5]; + while ((read = inputStream.read(bytes)) != -1) { + outputStream.write(bytes, 0, read); + } + + } catch (IOException e) { + } finally { + if (outputStream != null) { + outputStream.close(); + } + if (inputStream != null) { + inputStream.close(); + } + } + } + + public String getImagePath() + { + ExternalContext ctx; + ctx = FacesContext.getCurrentInstance().getExternalContext(); + String absoluteWebPath = ctx.getRealPath("/"); + return absoluteWebPath; + } + + private String getFileExtension(Part part) { + final String partHeader = part.getHeader("content-disposition"); + System.out.println("***** partHeader: " + partHeader); + for (String content : part.getHeader("content-disposition").split(";")) { + if (content.trim().startsWith("filename")) { + String fileName = content.substring(content.indexOf('=') + 1).trim().replace("\"", ""); + String[] subFileName = fileName.split("\\."); + return subFileName[subFileName.length-1]; + } + } + return null; + } + + + public boolean editPost() throws NamingException, SQLException{ + try { + Date dates = new Date(); + post.setDate(post.getDate() + " " + dates.getHours() + ":" + dates.getMinutes() + ":" + dates.getSeconds()); + System.out.println("UPDATE post SET title= '"+ post.getTitle() +"', date= '"+ post.getDate() +"', content= '"+ post.getContent() +"' WHERE id = '"+ post_id +"'"); + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + PreparedStatement ps = con.prepareStatement( + "UPDATE post SET title= '"+ post.getTitle() +"', date= '"+ post.getDate() +"', content= '"+ post.getContent() +"' WHERE id = '"+ post_id +"'"); + ps.executeUpdate(); + con.close(); + ps.close(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public String actionInsertPost(User user) throws NamingException, SQLException{ + if(insertPost(user)){ + return "index"; + } + else return ""; + } + + public String actionEditPost() throws NamingException, SQLException{ + if(editPost()){ + return "index"; + } + else return ""; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the date + */ + public String getDate() { + return date; + } + + /** + * @param date the date to set + */ + public void setDate(String date) { + this.date = date; + } + + /** + * @return the content + */ + public String getContent() { + return content; + } + + /** + * @param content the content to set + */ + public void setContent(String content) { + this.content = content; + } + + /** + * @return the post + */ + public Post getPost() { + return post; + } + + /** + * @param post the post to set + */ + public void setPost(Post post) { + this.post = post; + } + + /** + * @return the post_id + */ + public String getPost_id() { + return post_id; + } + + /** + * @param post_id the post_id to set + */ + public void setPost_id(String post_id) { + this.post_id = post_id; + } + + public Part getImage() { + return image; + } + + public void setImage(Part image) { + this.image = image; + } + + + public void softDelete(){ + try { + System.out.println("UPDATE post SET status = 2 WHERE id =" + post_id); + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + PreparedStatement ps = con.prepareStatement( + "UPDATE post SET status = 2 WHERE id =" + post_id); + ps.executeUpdate(); + con.close(); + ps.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void hardDelete(int id){ + try { + System.out.println("DELETE FROM post WHERE id = "+post_id); + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + PreparedStatement ps = con.prepareStatement( + "DELETE FROM post WHERE id = "+id); + ps.executeUpdate(); + con.close(); + ps.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void redirectIndex() throws Exception{ + ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); + externalContext.redirect("index.xhtml"); + } + + public List getSoftDeletedPost() throws SQLException, NamingException, IOException_Exception + { + List list = new ArrayList(); + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + return service.getPostList(2); + } + + public String restorePost(int post_id) + { + DataSource ds; + try { + Date dates = new Date(); + System.out.println("UPDATE post SET status=1 WHERE id = '"+ post_id +"'"); + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + PreparedStatement ps = con.prepareStatement("UPDATE post SET status=1 WHERE id = '"+ post_id +"'"); + ps.executeUpdate(); + con.close(); + ps.close(); + return ""; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + +} diff --git a/simple-blog/src/java/simpleblog/PublishPostController.java b/simple-blog/src/java/simpleblog/PublishPostController.java new file mode 100644 index 0000000..d78218a --- /dev/null +++ b/simple-blog/src/java/simpleblog/PublishPostController.java @@ -0,0 +1,61 @@ +/* + * 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 simpleblog; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ViewScoped; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; +import simpleblog.heroku.service.IOException_Exception; +import simpleblog.heroku.service.SimpleblogService; +import simpleblog.heroku.service.SimpleblogServiceImplService; +import simpleblog.heroku.service.Post; + +/** + * + * @author Luqman + */ +@ManagedBean +@ViewScoped +public class PublishPostController { + + public List getPostList() throws SQLException, NamingException, IOException_Exception + { + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + return service.getPostList(0); + } + public String publishPost(int post_id) + { + DataSource ds; + try { + Date dates = new Date(); + System.out.println("UPDATE post SET status=1 WHERE id = '"+ post_id +"'"); + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + PreparedStatement ps = con.prepareStatement("UPDATE post SET status=1 WHERE id = '"+ post_id +"'"); + ps.executeUpdate(); + con.close(); + ps.close(); + return ""; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } +} diff --git a/simple-blog/src/java/simpleblog/UserController.java b/simple-blog/src/java/simpleblog/UserController.java new file mode 100644 index 0000000..411431f --- /dev/null +++ b/simple-blog/src/java/simpleblog/UserController.java @@ -0,0 +1,254 @@ +package simpleblog; + +/* + * 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. + */ + +import java.io.IOException; +import java.io.Serializable; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.SessionScoped; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import simpleblog.model.CookieHelper; +import simpleblog.heroku.service.User; +import java.io.Serializable; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Resource; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.SessionScoped; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; +import simpleblog.heroku.service.IOException_Exception; +import simpleblog.heroku.service.SimpleblogService; +import simpleblog.heroku.service.SimpleblogServiceImplService; +import simpleblog.model.Post; + +/** + * + * @author Ichwan Haryo Sembodo + */ +@ManagedBean +@SessionScoped +public class UserController implements Serializable{ + + private CookieHelper cookie; + private User user; + private String username; + private String password; + + /** + * Creates a new instance of UserController + */ + public UserController() { + System.out.println("user ctrl dibuat"); + user = new User(); + user.setRole("guest"); + cookie = new CookieHelper(); + } + + public User loginValidator(String username, String password) throws IOException_Exception{ + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + user = service.getUser(username, password); + + return user; + } + + /** + * @return the user + */ + public User getUser() throws IOException_Exception { + return loginValidator(username, password); + } + + /** + * @param user the user to set + */ + public void setUser(User user) { + System.out.println("set user"); + this.user = user; + } + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * @param username the username to set + */ + public void setUsername(String username) { + System.out.println("set username"); + this.username = username; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password the password to set + */ + public void setPassword(String password) { + System.out.println("set password"); + this.password = password; + } + + public boolean showEditHapus(int id){ + System.out.println("=========show edit hapus method========="); + System.out.println("role diset = " + user.getRole()); + System.out.println("user id = " + user.getId()); + System.out.println("post user id = " + id); + if(user.getRole().equals("admin")) + { + return true; + } + else if(user.getRole().equals("owner") && user.getId() == id) + { + return true; + } + else if(user.getRole().equals("editor")) + { + return true; + } + return false; + } + + public String actionLogin() throws IOException_Exception{ + System.out.println("=========action login method========="); + getUser(); + if(showEditHapus(user.getId())){ + cookie.setCookie("username", username, 86400); + cookie.setCookie("password", password, 86400); + return ""; + } + else return ""; + } + + /** + * @return the cookie + */ + public CookieHelper getCookie() { + return cookie; + } + + /** + * @param cookie the cookie to set + */ + public void setCookie(CookieHelper cookie) { + this.cookie = cookie; + } + + public boolean isUsernamePasswordExist() throws IOException_Exception{ + System.out.println("=========is Username Password exist method========="); + if(cookie.getCookie("username") != null && cookie.getCookie("password") != null){ + System.out.println("username cookie = " + cookie.getCookie("username").getValue()); + System.out.println("password cookie = " + cookie.getCookie("password").getValue()); + if(user.getRole().equals("guest")){ + if(username == null && password == null){ + setUsername(cookie.getCookie("username").getValue()); + setPassword(cookie.getCookie("password").getValue()); + getUser(); + if(showEditHapus(user.getId())){ + System.out.println("cookie != null dan guest dan username & password == null dan valid"); + return true; + } + else{ + System.out.println("cookie != null dan guest dan username & password == null dan tidak valid"); + return false; + } + } + else { + if(username.equals("") && password.equals("")){ + System.out.println("cookie != null dan guest dan username & password = ''"); + return false; + } + else{ + System.out.println("cookie != null dan guest dan username & password = " + username + " & " + password); + return true; + } + } + } + else { + System.out.println("cookie != null dan !guest dan username & password != null"); + return true; + } + } + else{ + if(username != null && password != null){ + if(showEditHapus(user.getId())){ + System.out.println("cookie = null dan username & password != null dan valid"); + return true; + } + else { + System.out.println("cookie = null dan username & password != null dan tidak valid"); + return false; + } + } + else { + System.out.println("cookie = null dan username & password = null"); + return false; + } + } + } + + public String actionLogout(){ + System.out.println("=========action logout method========="); + cookie.setCookie("username", null, 0); + cookie.setCookie("password", null, 0); + User tmp = new User(); + user = tmp; + user.setRole("guest"); + setUsername(""); + System.out.println("set username to null"); + setPassword(""); + System.out.println("set password to null"); + System.out.println("cookie dihapus"); + System.out.println("username time left = "+cookie.getCookie("username").getMaxAge()); + System.out.println("password time left = "+cookie.getCookie("password").getMaxAge()); + System.out.println("username cookie = " + cookie.getCookie("username").getValue()); + System.out.println("password cookie = " + cookie.getCookie("password").getValue()); + return ""; + } + + public void redirect() throws IOException{ + ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); + externalContext.redirect("faces/index.xhtml"); + } + + public void test(){ + System.out.println("=======================selesai iterasi=========================="); + } + + public boolean isAdmin(){ + return user.getRole().equals("admin"); + } + + public boolean isOwner(){ + return user.getRole().equals("owner"); + } + + public boolean isEditor(){ + return user.getRole().equals("editor"); + } + + public boolean isGuest(){ + return user.getRole().equals("guest"); + } + +} diff --git a/simple-blog/src/java/simpleblog/ViewPostController.java b/simple-blog/src/java/simpleblog/ViewPostController.java new file mode 100644 index 0000000..9ebaf3f --- /dev/null +++ b/simple-blog/src/java/simpleblog/ViewPostController.java @@ -0,0 +1,145 @@ +/* + * 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 simpleblog; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.PostConstruct; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.RequestScoped; +import javax.faces.bean.SessionScoped; +import javax.faces.bean.ViewScoped; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; +import simpleblog.heroku.service.IOException_Exception; +import simpleblog.heroku.service.SimpleblogService; +import simpleblog.heroku.service.SimpleblogServiceImplService; +import simpleblog.heroku.service.Comment; +import simpleblog.heroku.service.Post; +import simpleblog.model.ViewPost; + +/** + * + * @author Luqman + */ +@ManagedBean(eager=true) +@ViewScoped +public class ViewPostController { + private int postId; + private Post viewPost; + + public void getPost() throws IOException_Exception + { + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + Post post = service.getPost(postId); + viewPost = post; + System.out.println("<><> "+post.getId()); + System.out.println("<><> "+post.getTitle()); + System.out.println("<><> "+post.getDate()); + System.out.println("<><> "+post.getContent()); + } + + private String inputName; + private String inputEmail; + private String inputComment; + + public List getComment() throws IOException_Exception + { + List list = new ArrayList(); + try { + System.out.println("Bakemono "+inputName); + System.out.println("Bakemono "+inputEmail); + System.out.println("Bakemono "+inputComment); + DataSource ds; + Context initCtx = new InitialContext(); + Context envCtx = (Context) initCtx.lookup("java:comp/env"); + ds = (DataSource) envCtx.lookup("jdbc/simpleBlogDb"); + + Connection con = ds.getConnection(); + + PreparedStatement ps; + ResultSet result; + if(getInputName() != null && getInputName() != "") + { + System.out.println("Bakemono : "+"INSERT INTO comment (post_id,name,email,content) VALUES ('"+postId+"','"+getInputName()+"','"+getInputEmail()+"','"+getInputComment()+"')"); + ps = con.prepareStatement("INSERT INTO comment (post_id,name,email,content) VALUES ('"+postId+"','"+getInputName()+"','"+getInputEmail()+"','"+getInputComment()+"')"); + ps.executeUpdate(); + setInputName(null); + setInputEmail(null); + setInputComment(null); + } + SimpleblogService service = new SimpleblogServiceImplService().getSimpleblogServiceImplPort(); + list = service.getCommentList(postId); + } catch (NamingException ex) { + Logger.getLogger(ViewPostController.class.getName()).log(Level.SEVERE, null, ex); + } catch (SQLException ex) { + Logger.getLogger(ViewPostController.class.getName()).log(Level.SEVERE, null, ex); + } + return list; + } + + /** + * @return the postId + */ + public int getPostId() { + return postId; + } + + /** + * @param postId the postId to set + */ + public void setPostId(int postId) { + this.postId = postId; + } + + /** + * @return the viewPost + */ + public Post getViewPost() { + return viewPost; + } + + /** + * @param viewPost the viewPost to set + */ + public void setViewPost(Post viewPost) { + this.viewPost = viewPost; + } + + public String getInputName() { + return inputName; + } + + public void setInputName(String inputName) { + this.inputName = inputName; + } + + public String getInputEmail() { + return inputEmail; + } + + public void setInputEmail(String inputEmail) { + this.inputEmail = inputEmail; + } + + public String getInputComment() { + return inputComment; + } + + public void setInputComment(String inputComment) { + this.inputComment = inputComment; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/Comment.java b/simple-blog/src/java/simpleblog/heroku/service/Comment.java new file mode 100644 index 0000000..b9d8802 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/Comment.java @@ -0,0 +1,179 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for comment complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="comment">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="content" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="date" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="email" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="postId" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "comment", propOrder = { + "content", + "date", + "email", + "id", + "name", + "postId" +}) +public class Comment { + + protected String content; + protected String date; + protected String email; + protected int id; + protected String name; + protected int postId; + + /** + * Gets the value of the content property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getContent() { + return content; + } + + /** + * Sets the value of the content property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setContent(String value) { + this.content = value; + } + + /** + * Gets the value of the date property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDate() { + return date; + } + + /** + * Sets the value of the date property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDate(String value) { + this.date = value; + } + + /** + * Gets the value of the email property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEmail() { + return email; + } + + /** + * Sets the value of the email property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEmail(String value) { + this.email = value; + } + + /** + * Gets the value of the id property. + * + */ + public int getId() { + return id; + } + + /** + * Sets the value of the id property. + * + */ + public void setId(int value) { + this.id = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the postId property. + * + */ + public int getPostId() { + return postId; + } + + /** + * Sets the value of the postId property. + * + */ + public void setPostId(int value) { + this.postId = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetCommentList.java b/simple-blog/src/java/simpleblog/heroku/service/GetCommentList.java new file mode 100644 index 0000000..18dc918 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetCommentList.java @@ -0,0 +1,52 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getCommentList complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getCommentList">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getCommentList", propOrder = { + "arg0" +}) +public class GetCommentList { + + protected int arg0; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetCommentListResponse.java b/simple-blog/src/java/simpleblog/heroku/service/GetCommentListResponse.java new file mode 100644 index 0000000..2855066 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetCommentListResponse.java @@ -0,0 +1,69 @@ + +package simpleblog.heroku.service; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getCommentListResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getCommentListResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://service.heroku.simpleblog/}comment" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getCommentListResponse", propOrder = { + "_return" +}) +public class GetCommentListResponse { + + @XmlElement(name = "return") + protected List _return; + + /** + * Gets the value of the return property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the return property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getReturn().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Comment } + * + * + */ + public List getReturn() { + if (_return == null) { + _return = new ArrayList(); + } + return this._return; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetPost.java b/simple-blog/src/java/simpleblog/heroku/service/GetPost.java new file mode 100644 index 0000000..42be710 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetPost.java @@ -0,0 +1,52 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getPost complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getPost">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getPost", propOrder = { + "arg0" +}) +public class GetPost { + + protected int arg0; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetPostList.java b/simple-blog/src/java/simpleblog/heroku/service/GetPostList.java new file mode 100644 index 0000000..ab17e56 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetPostList.java @@ -0,0 +1,52 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getPostList complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getPostList">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getPostList", propOrder = { + "arg0" +}) +public class GetPostList { + + protected int arg0; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetPostListResponse.java b/simple-blog/src/java/simpleblog/heroku/service/GetPostListResponse.java new file mode 100644 index 0000000..c255f3b --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetPostListResponse.java @@ -0,0 +1,69 @@ + +package simpleblog.heroku.service; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getPostListResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getPostListResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://service.heroku.simpleblog/}post" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getPostListResponse", propOrder = { + "_return" +}) +public class GetPostListResponse { + + @XmlElement(name = "return") + protected List _return; + + /** + * Gets the value of the return property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the return property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getReturn().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Post } + * + * + */ + public List getReturn() { + if (_return == null) { + _return = new ArrayList(); + } + return this._return; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetPostResponse.java b/simple-blog/src/java/simpleblog/heroku/service/GetPostResponse.java new file mode 100644 index 0000000..c799c71 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetPostResponse.java @@ -0,0 +1,62 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getPostResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getPostResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://service.heroku.simpleblog/}post" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getPostResponse", propOrder = { + "_return" +}) +public class GetPostResponse { + + @XmlElement(name = "return") + protected Post _return; + + /** + * Gets the value of the return property. + * + * @return + * possible object is + * {@link Post } + * + */ + public Post getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + * @param value + * allowed object is + * {@link Post } + * + */ + public void setReturn(Post value) { + this._return = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetUser.java b/simple-blog/src/java/simpleblog/heroku/service/GetUser.java new file mode 100644 index 0000000..1121588 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetUser.java @@ -0,0 +1,87 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getUser complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getUser">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getUser", propOrder = { + "arg0", + "arg1" +}) +public class GetUser { + + protected String arg0; + protected String arg1; + + /** + * Gets the value of the arg0 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + + /** + * Gets the value of the arg1 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg1() { + return arg1; + } + + /** + * Sets the value of the arg1 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg1(String value) { + this.arg1 = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetUserById.java b/simple-blog/src/java/simpleblog/heroku/service/GetUserById.java new file mode 100644 index 0000000..45e9a7a --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetUserById.java @@ -0,0 +1,52 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getUserById complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getUserById">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getUserById", propOrder = { + "arg0" +}) +public class GetUserById { + + protected int arg0; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetUserByIdResponse.java b/simple-blog/src/java/simpleblog/heroku/service/GetUserByIdResponse.java new file mode 100644 index 0000000..551f46c --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetUserByIdResponse.java @@ -0,0 +1,62 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getUserByIdResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getUserByIdResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://service.heroku.simpleblog/}user" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getUserByIdResponse", propOrder = { + "_return" +}) +public class GetUserByIdResponse { + + @XmlElement(name = "return") + protected User _return; + + /** + * Gets the value of the return property. + * + * @return + * possible object is + * {@link User } + * + */ + public User getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + * @param value + * allowed object is + * {@link User } + * + */ + public void setReturn(User value) { + this._return = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetUserList.java b/simple-blog/src/java/simpleblog/heroku/service/GetUserList.java new file mode 100644 index 0000000..ad02941 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetUserList.java @@ -0,0 +1,32 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getUserList complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getUserList">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getUserList") +public class GetUserList { + + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetUserListResponse.java b/simple-blog/src/java/simpleblog/heroku/service/GetUserListResponse.java new file mode 100644 index 0000000..6fb485b --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetUserListResponse.java @@ -0,0 +1,69 @@ + +package simpleblog.heroku.service; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getUserListResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getUserListResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://service.heroku.simpleblog/}user" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getUserListResponse", propOrder = { + "_return" +}) +public class GetUserListResponse { + + @XmlElement(name = "return") + protected List _return; + + /** + * Gets the value of the return property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the return property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getReturn().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link User } + * + * + */ + public List getReturn() { + if (_return == null) { + _return = new ArrayList(); + } + return this._return; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/GetUserResponse.java b/simple-blog/src/java/simpleblog/heroku/service/GetUserResponse.java new file mode 100644 index 0000000..cc1d4a9 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/GetUserResponse.java @@ -0,0 +1,62 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getUserResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getUserResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://service.heroku.simpleblog/}user" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getUserResponse", propOrder = { + "_return" +}) +public class GetUserResponse { + + @XmlElement(name = "return") + protected User _return; + + /** + * Gets the value of the return property. + * + * @return + * possible object is + * {@link User } + * + */ + public User getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + * @param value + * allowed object is + * {@link User } + * + */ + public void setReturn(User value) { + this._return = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/IOException.java b/simple-blog/src/java/simpleblog/heroku/service/IOException.java new file mode 100644 index 0000000..8033935 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/IOException.java @@ -0,0 +1,32 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for IOException complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="IOException">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "IOException") +public class IOException { + + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/IOException_Exception.java b/simple-blog/src/java/simpleblog/heroku/service/IOException_Exception.java new file mode 100644 index 0000000..4d26668 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/IOException_Exception.java @@ -0,0 +1,54 @@ + +package simpleblog.heroku.service; + +import javax.xml.ws.WebFault; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebFault(name = "IOException", targetNamespace = "http://service.heroku.simpleblog/") +public class IOException_Exception + extends Exception +{ + + /** + * Java type that goes as soapenv:Fault detail element. + * + */ + private IOException faultInfo; + + /** + * + * @param faultInfo + * @param message + */ + public IOException_Exception(String message, IOException faultInfo) { + super(message); + this.faultInfo = faultInfo; + } + + /** + * + * @param faultInfo + * @param cause + * @param message + */ + public IOException_Exception(String message, IOException faultInfo, Throwable cause) { + super(message, cause); + this.faultInfo = faultInfo; + } + + /** + * + * @return + * returns fault bean: simpleblog.heroku.service.IOException + */ + public IOException getFaultInfo() { + return faultInfo; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/ObjectFactory.java b/simple-blog/src/java/simpleblog/heroku/service/ObjectFactory.java new file mode 100644 index 0000000..399bd6d --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/ObjectFactory.java @@ -0,0 +1,293 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the simpleblog.heroku.service package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _GetPost_QNAME = new QName("http://service.heroku.simpleblog/", "getPost"); + private final static QName _GetCommentList_QNAME = new QName("http://service.heroku.simpleblog/", "getCommentList"); + private final static QName _GetPostResponse_QNAME = new QName("http://service.heroku.simpleblog/", "getPostResponse"); + private final static QName _GetCommentListResponse_QNAME = new QName("http://service.heroku.simpleblog/", "getCommentListResponse"); + private final static QName _GetPostListResponse_QNAME = new QName("http://service.heroku.simpleblog/", "getPostListResponse"); + private final static QName _GetUserById_QNAME = new QName("http://service.heroku.simpleblog/", "getUserById"); + private final static QName _GetPostList_QNAME = new QName("http://service.heroku.simpleblog/", "getPostList"); + private final static QName _GetUserResponse_QNAME = new QName("http://service.heroku.simpleblog/", "getUserResponse"); + private final static QName _GetUser_QNAME = new QName("http://service.heroku.simpleblog/", "getUser"); + private final static QName _GetUserByIdResponse_QNAME = new QName("http://service.heroku.simpleblog/", "getUserByIdResponse"); + private final static QName _GetUserList_QNAME = new QName("http://service.heroku.simpleblog/", "getUserList"); + private final static QName _IOException_QNAME = new QName("http://service.heroku.simpleblog/", "IOException"); + private final static QName _GetUserListResponse_QNAME = new QName("http://service.heroku.simpleblog/", "getUserListResponse"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: simpleblog.heroku.service + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GetPostList } + * + */ + public GetPostList createGetPostList() { + return new GetPostList(); + } + + /** + * Create an instance of {@link GetUserResponse } + * + */ + public GetUserResponse createGetUserResponse() { + return new GetUserResponse(); + } + + /** + * Create an instance of {@link GetUserById } + * + */ + public GetUserById createGetUserById() { + return new GetUserById(); + } + + /** + * Create an instance of {@link GetUserByIdResponse } + * + */ + public GetUserByIdResponse createGetUserByIdResponse() { + return new GetUserByIdResponse(); + } + + /** + * Create an instance of {@link GetUser } + * + */ + public GetUser createGetUser() { + return new GetUser(); + } + + /** + * Create an instance of {@link GetUserListResponse } + * + */ + public GetUserListResponse createGetUserListResponse() { + return new GetUserListResponse(); + } + + /** + * Create an instance of {@link GetUserList } + * + */ + public GetUserList createGetUserList() { + return new GetUserList(); + } + + /** + * Create an instance of {@link IOException } + * + */ + public IOException createIOException() { + return new IOException(); + } + + /** + * Create an instance of {@link GetPostResponse } + * + */ + public GetPostResponse createGetPostResponse() { + return new GetPostResponse(); + } + + /** + * Create an instance of {@link GetPost } + * + */ + public GetPost createGetPost() { + return new GetPost(); + } + + /** + * Create an instance of {@link GetCommentList } + * + */ + public GetCommentList createGetCommentList() { + return new GetCommentList(); + } + + /** + * Create an instance of {@link GetCommentListResponse } + * + */ + public GetCommentListResponse createGetCommentListResponse() { + return new GetCommentListResponse(); + } + + /** + * Create an instance of {@link GetPostListResponse } + * + */ + public GetPostListResponse createGetPostListResponse() { + return new GetPostListResponse(); + } + + /** + * Create an instance of {@link Post } + * + */ + public Post createPost() { + return new Post(); + } + + /** + * Create an instance of {@link Comment } + * + */ + public Comment createComment() { + return new Comment(); + } + + /** + * Create an instance of {@link User } + * + */ + public User createUser() { + return new User(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetPost }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getPost") + public JAXBElement createGetPost(GetPost value) { + return new JAXBElement(_GetPost_QNAME, GetPost.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetCommentList }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getCommentList") + public JAXBElement createGetCommentList(GetCommentList value) { + return new JAXBElement(_GetCommentList_QNAME, GetCommentList.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetPostResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getPostResponse") + public JAXBElement createGetPostResponse(GetPostResponse value) { + return new JAXBElement(_GetPostResponse_QNAME, GetPostResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetCommentListResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getCommentListResponse") + public JAXBElement createGetCommentListResponse(GetCommentListResponse value) { + return new JAXBElement(_GetCommentListResponse_QNAME, GetCommentListResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetPostListResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getPostListResponse") + public JAXBElement createGetPostListResponse(GetPostListResponse value) { + return new JAXBElement(_GetPostListResponse_QNAME, GetPostListResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetUserById }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getUserById") + public JAXBElement createGetUserById(GetUserById value) { + return new JAXBElement(_GetUserById_QNAME, GetUserById.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetPostList }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getPostList") + public JAXBElement createGetPostList(GetPostList value) { + return new JAXBElement(_GetPostList_QNAME, GetPostList.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetUserResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getUserResponse") + public JAXBElement createGetUserResponse(GetUserResponse value) { + return new JAXBElement(_GetUserResponse_QNAME, GetUserResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetUser }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getUser") + public JAXBElement createGetUser(GetUser value) { + return new JAXBElement(_GetUser_QNAME, GetUser.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetUserByIdResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getUserByIdResponse") + public JAXBElement createGetUserByIdResponse(GetUserByIdResponse value) { + return new JAXBElement(_GetUserByIdResponse_QNAME, GetUserByIdResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetUserList }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getUserList") + public JAXBElement createGetUserList(GetUserList value) { + return new JAXBElement(_GetUserList_QNAME, GetUserList.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link IOException }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "IOException") + public JAXBElement createIOException(IOException value) { + return new JAXBElement(_IOException_QNAME, IOException.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetUserListResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://service.heroku.simpleblog/", name = "getUserListResponse") + public JAXBElement createGetUserListResponse(GetUserListResponse value) { + return new JAXBElement(_GetUserListResponse_QNAME, GetUserListResponse.class, null, value); + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/Post.java b/simple-blog/src/java/simpleblog/heroku/service/Post.java new file mode 100644 index 0000000..58de442 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/Post.java @@ -0,0 +1,171 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for post complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="post">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="content" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="date" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="status" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="title" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="userId" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "post", propOrder = { + "content", + "date", + "id", + "status", + "title", + "userId" +}) +public class Post { + + protected String content; + protected String date; + protected int id; + protected int status; + protected String title; + protected int userId; + + /** + * Gets the value of the content property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getContent() { + return content; + } + + /** + * Sets the value of the content property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setContent(String value) { + this.content = value; + } + + /** + * Gets the value of the date property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDate() { + return date; + } + + /** + * Sets the value of the date property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDate(String value) { + this.date = value; + } + + /** + * Gets the value of the id property. + * + */ + public int getId() { + return id; + } + + /** + * Sets the value of the id property. + * + */ + public void setId(int value) { + this.id = value; + } + + /** + * Gets the value of the status property. + * + */ + public int getStatus() { + return status; + } + + /** + * Sets the value of the status property. + * + */ + public void setStatus(int value) { + this.status = value; + } + + /** + * Gets the value of the title property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Sets the value of the title property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Gets the value of the userId property. + * + */ + public int getUserId() { + return userId; + } + + /** + * Sets the value of the userId property. + * + */ + public void setUserId(int value) { + this.userId = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/SimpleblogService.java b/simple-blog/src/java/simpleblog/heroku/service/SimpleblogService.java new file mode 100644 index 0000000..2219770 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/SimpleblogService.java @@ -0,0 +1,129 @@ + +package simpleblog.heroku.service; + +import java.util.List; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebService(name = "SimpleblogService", targetNamespace = "http://service.heroku.simpleblog/") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface SimpleblogService { + + + /** + * + * @param arg1 + * @param arg0 + * @return + * returns simpleblog.heroku.service.User + * @throws IOException_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getUser", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetUser") + @ResponseWrapper(localName = "getUserResponse", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetUserResponse") + public User getUser( + @WebParam(name = "arg0", targetNamespace = "") + String arg0, + @WebParam(name = "arg1", targetNamespace = "") + String arg1) + throws IOException_Exception + ; + + /** + * + * @param arg0 + * @return + * returns java.util.List + * @throws IOException_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getPostList", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetPostList") + @ResponseWrapper(localName = "getPostListResponse", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetPostListResponse") + public List getPostList( + @WebParam(name = "arg0", targetNamespace = "") + int arg0) + throws IOException_Exception + ; + + /** + * + * @param arg0 + * @return + * returns java.util.List + * @throws IOException_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getCommentList", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetCommentList") + @ResponseWrapper(localName = "getCommentListResponse", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetCommentListResponse") + public List getCommentList( + @WebParam(name = "arg0", targetNamespace = "") + int arg0) + throws IOException_Exception + ; + + /** + * + * @param arg0 + * @return + * returns simpleblog.heroku.service.Post + * @throws IOException_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getPost", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetPost") + @ResponseWrapper(localName = "getPostResponse", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetPostResponse") + public Post getPost( + @WebParam(name = "arg0", targetNamespace = "") + int arg0) + throws IOException_Exception + ; + + /** + * + * @param arg0 + * @return + * returns simpleblog.heroku.service.User + * @throws IOException_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getUserById", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetUserById") + @ResponseWrapper(localName = "getUserByIdResponse", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetUserByIdResponse") + public User getUserById( + @WebParam(name = "arg0", targetNamespace = "") + int arg0) + throws IOException_Exception + ; + + /** + * + * @return + * returns java.util.List + * @throws IOException_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getUserList", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetUserList") + @ResponseWrapper(localName = "getUserListResponse", targetNamespace = "http://service.heroku.simpleblog/", className = "simpleblog.heroku.service.GetUserListResponse") + public List getUserList() + throws IOException_Exception + ; + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/SimpleblogServiceImplService.java b/simple-blog/src/java/simpleblog/heroku/service/SimpleblogServiceImplService.java new file mode 100644 index 0000000..fea54eb --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/SimpleblogServiceImplService.java @@ -0,0 +1,94 @@ + +package simpleblog.heroku.service; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "SimpleblogServiceImplService", targetNamespace = "http://service.heroku.simpleblog/", wsdlLocation = "http://if3110-iii-25-simple-blog.herokuapp.com/SimpleblogService?wsdl") +public class SimpleblogServiceImplService + extends Service +{ + + private final static URL SIMPLEBLOGSERVICEIMPLSERVICE_WSDL_LOCATION; + private final static WebServiceException SIMPLEBLOGSERVICEIMPLSERVICE_EXCEPTION; + private final static QName SIMPLEBLOGSERVICEIMPLSERVICE_QNAME = new QName("http://service.heroku.simpleblog/", "SimpleblogServiceImplService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("http://if3110-iii-25-simple-blog.herokuapp.com/SimpleblogService?wsdl"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + SIMPLEBLOGSERVICEIMPLSERVICE_WSDL_LOCATION = url; + SIMPLEBLOGSERVICEIMPLSERVICE_EXCEPTION = e; + } + + public SimpleblogServiceImplService() { + super(__getWsdlLocation(), SIMPLEBLOGSERVICEIMPLSERVICE_QNAME); + } + + public SimpleblogServiceImplService(WebServiceFeature... features) { + super(__getWsdlLocation(), SIMPLEBLOGSERVICEIMPLSERVICE_QNAME, features); + } + + public SimpleblogServiceImplService(URL wsdlLocation) { + super(wsdlLocation, SIMPLEBLOGSERVICEIMPLSERVICE_QNAME); + } + + public SimpleblogServiceImplService(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, SIMPLEBLOGSERVICEIMPLSERVICE_QNAME, features); + } + + public SimpleblogServiceImplService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public SimpleblogServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns SimpleblogService + */ + @WebEndpoint(name = "SimpleblogServiceImplPort") + public SimpleblogService getSimpleblogServiceImplPort() { + return super.getPort(new QName("http://service.heroku.simpleblog/", "SimpleblogServiceImplPort"), SimpleblogService.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns SimpleblogService + */ + @WebEndpoint(name = "SimpleblogServiceImplPort") + public SimpleblogService getSimpleblogServiceImplPort(WebServiceFeature... features) { + return super.getPort(new QName("http://service.heroku.simpleblog/", "SimpleblogServiceImplPort"), SimpleblogService.class, features); + } + + private static URL __getWsdlLocation() { + if (SIMPLEBLOGSERVICEIMPLSERVICE_EXCEPTION!= null) { + throw SIMPLEBLOGSERVICEIMPLSERVICE_EXCEPTION; + } + return SIMPLEBLOGSERVICEIMPLSERVICE_WSDL_LOCATION; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/User.java b/simple-blog/src/java/simpleblog/heroku/service/User.java new file mode 100644 index 0000000..4f9fc99 --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/User.java @@ -0,0 +1,187 @@ + +package simpleblog.heroku.service; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for user complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="user">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="email" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="password" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="role" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="username" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "user", propOrder = { + "email", + "id", + "name", + "password", + "role", + "username" +}) +public class User { + + protected String email; + protected int id; + protected String name; + protected String password; + protected String role; + protected String username; + + /** + * Gets the value of the email property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEmail() { + return email; + } + + /** + * Sets the value of the email property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEmail(String value) { + this.email = value; + } + + /** + * Gets the value of the id property. + * + */ + public int getId() { + return id; + } + + /** + * Sets the value of the id property. + * + */ + public void setId(int value) { + this.id = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the password property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPassword() { + return password; + } + + /** + * Sets the value of the password property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPassword(String value) { + this.password = value; + } + + /** + * Gets the value of the role property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRole() { + return role; + } + + /** + * Sets the value of the role property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRole(String value) { + this.role = value; + } + + /** + * Gets the value of the username property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUsername() { + return username; + } + + /** + * Sets the value of the username property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUsername(String value) { + this.username = value; + } + +} diff --git a/simple-blog/src/java/simpleblog/heroku/service/package-info.java b/simple-blog/src/java/simpleblog/heroku/service/package-info.java new file mode 100644 index 0000000..c6091bc --- /dev/null +++ b/simple-blog/src/java/simpleblog/heroku/service/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://service.heroku.simpleblog/") +package simpleblog.heroku.service; diff --git a/simple-blog/src/java/simpleblog/model/Comment.java b/simple-blog/src/java/simpleblog/model/Comment.java new file mode 100644 index 0000000..f906a3e --- /dev/null +++ b/simple-blog/src/java/simpleblog/model/Comment.java @@ -0,0 +1,68 @@ +/* + * 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 simpleblog.model; + +/** + * + * @author Luqman + */ +public class Comment { + private int id; + private int postId; + private String name; + private String email; + private String date; + private String content; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPostId() { + return postId; + } + + public void setPostId(int postId) { + this.postId = postId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/simple-blog/src/java/simpleblog/model/CookieHelper.java b/simple-blog/src/java/simpleblog/model/CookieHelper.java new file mode 100644 index 0000000..ef68c5e --- /dev/null +++ b/simple-blog/src/java/simpleblog/model/CookieHelper.java @@ -0,0 +1,70 @@ +package simpleblog.model; + + +import javax.faces.context.FacesContext; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/* + * 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. + */ + +/** + * + * @author Ichwan Haryo Sembodo + */ +public class CookieHelper { + + public void setCookie(String name, String value,int expiry) { + + FacesContext facesContext = FacesContext.getCurrentInstance(); + + HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); + Cookie cookie = null; + + Cookie[] userCookies = request.getCookies(); + if (userCookies != null && userCookies.length > 0 ) { + for (int i = 0; i < userCookies.length; i++) { + if (userCookies[i].getName().equals(name)) { + cookie = userCookies[i]; + break; + } + } + } + + if (cookie != null) { + cookie.setValue(value); + } else { + cookie = new Cookie(name, value); + //cookie.setPath(request.getContextPath()); + } + + cookie.setMaxAge(expiry); + + HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); + response.setContentType("text/html"); + response.addCookie(cookie); + } + + public Cookie getCookie(String name) { + + FacesContext facesContext = FacesContext.getCurrentInstance(); + + HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); + Cookie cookie = null; + + Cookie[] userCookies = request.getCookies(); + if (userCookies != null && userCookies.length > 0 ) { + for (int i = 0; i < userCookies.length; i++) { + if (userCookies[i].getName().equals(name)) { + cookie = userCookies[i]; + return cookie; + } + } + } + return null; + } +} \ No newline at end of file diff --git a/simple-blog/src/java/simpleblog/model/Post.java b/simple-blog/src/java/simpleblog/model/Post.java new file mode 100644 index 0000000..e9aefa8 --- /dev/null +++ b/simple-blog/src/java/simpleblog/model/Post.java @@ -0,0 +1,104 @@ +/* + * 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 simpleblog.model; + +/** + * + * @author Luqman + */ +public class Post { + private int id; + private String title; + private String content; + private String date; + private int userId; + private int status; + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the content + */ + public String getContent() { + return content; + } + + /** + * @param content the content to set + */ + public void setContent(String content) { + this.content = content; + } + + /** + * @return the date + */ + public String getDate() { + return date; + } + + /** + * @param date the date to set + */ + public void setDate(String date) { + this.date = date; + } + + /** + * @return the userId + */ + public int getUserId() { + return userId; + } + + /** + * @param userId the userId to set + */ + public void setUserId(int userId) { + this.userId = userId; + } + + /** + * @return the status + */ + public int getStatus() { + return status; + } + + /** + * @param status the status to set + */ + public void setStatus(int status) { + this.status = status; + } +} diff --git a/simple-blog/src/java/simpleblog/model/User.java b/simple-blog/src/java/simpleblog/model/User.java new file mode 100644 index 0000000..0bd78c4 --- /dev/null +++ b/simple-blog/src/java/simpleblog/model/User.java @@ -0,0 +1,110 @@ +package simpleblog.model; + +/* + * 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. + */ + +/** + * + * @author Ichwan Haryo Sembodo + */ +public class User { + private int id; + private String email; + private String username; + private String name; + private String password; + private String role; + + public User(){ + role = "guest"; + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * @param email the email to set + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * @param username the username to set + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * @return the role + */ + public String getRole() { + return role; + } + + /** + * @param role the role to set + */ + public void setRole(String role) { + this.role = role; + } + + +} diff --git a/simple-blog/src/java/simpleblog/model/ViewPost.java b/simple-blog/src/java/simpleblog/model/ViewPost.java new file mode 100644 index 0000000..cf21f3b --- /dev/null +++ b/simple-blog/src/java/simpleblog/model/ViewPost.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 simpleblog.model; + +/** + * + * @author Luqman + */ +public class ViewPost { + private int id; + private String title; + private String content; + private String date; + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the content + */ + public String getContent() { + return content; + } + + /** + * @param content the content to set + */ + public void setContent(String content) { + this.content = content; + } + + /** + * @return the date + */ + public String getDate() { + return date; + } + + /** + * @param date the date to set + */ + public void setDate(String date) { + this.date = date; + } + +} diff --git a/simple-blog/update.bat b/simple-blog/update.bat new file mode 100644 index 0000000..7219b81 --- /dev/null +++ b/simple-blog/update.bat @@ -0,0 +1 @@ +wsimport -keep -d nbproject -s src/java http://if3110-iii-25-simple-blog.herokuapp.com/SimpleblogService?wsdl \ No newline at end of file diff --git a/simple-blog/web/DeleteTable.xhtml b/simple-blog/web/DeleteTable.xhtml new file mode 100644 index 0000000..c6ac701 --- /dev/null +++ b/simple-blog/web/DeleteTable.xhtml @@ -0,0 +1,18 @@ + + + + + + + + + Simple Blog + + + + + \ No newline at end of file diff --git a/simple-blog/web/EditTable.xhtml b/simple-blog/web/EditTable.xhtml new file mode 100644 index 0000000..324acd1 --- /dev/null +++ b/simple-blog/web/EditTable.xhtml @@ -0,0 +1,61 @@ + + + + + + + + + Insert Data + + + + +
+ +
+
+
+
+ \ No newline at end of file diff --git a/simple-blog/web/InsertTabel.xhtml b/simple-blog/web/InsertTabel.xhtml new file mode 100644 index 0000000..ba81bd5 --- /dev/null +++ b/simple-blog/web/InsertTabel.xhtml @@ -0,0 +1,60 @@ + + + + + + + + Insert Data + + + + +
+ +
+
+
+
+ \ No newline at end of file diff --git a/simple-blog/web/META-INF/context.xml b/simple-blog/web/META-INF/context.xml new file mode 100644 index 0000000..dd73d3e --- /dev/null +++ b/simple-blog/web/META-INF/context.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/simple-blog/web/ShowTable.xhtml b/simple-blog/web/ShowTable.xhtml new file mode 100644 index 0000000..216888b --- /dev/null +++ b/simple-blog/web/ShowTable.xhtml @@ -0,0 +1,80 @@ + + + + + + + + + + +
+ +
+
+ + + +
+
+ + \ No newline at end of file diff --git a/simple-blog/web/WEB-INF/web.xml b/simple-blog/web/WEB-INF/web.xml new file mode 100644 index 0000000..c215fbc --- /dev/null +++ b/simple-blog/web/WEB-INF/web.xml @@ -0,0 +1,30 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/redirectIndex.xhtml + + + MySQL Datasource example + jdbc/simpleBlogDb + javax.sql.DataSource + Container + + diff --git a/simple-blog/web/addPost.xhtml b/simple-blog/web/addPost.xhtml new file mode 100644 index 0000000..acb8cf9 --- /dev/null +++ b/simple-blog/web/addPost.xhtml @@ -0,0 +1,44 @@ + + + + + + +

+
+
+ +
+ + + + + + + + + + +

+ + + + + +
+
+
+
+
+ + + +
+
+ + diff --git a/simple-blog/web/deletedPost.xhtml b/simple-blog/web/deletedPost.xhtml new file mode 100644 index 0000000..9cc1853 --- /dev/null +++ b/simple-blog/web/deletedPost.xhtml @@ -0,0 +1,52 @@ + + + + + Restore Post + + + + +
+ +
+
+ + + +
+
+ + diff --git a/simple-blog/web/editPost.xhtml b/simple-blog/web/editPost.xhtml new file mode 100644 index 0000000..33802c5 --- /dev/null +++ b/simple-blog/web/editPost.xhtml @@ -0,0 +1,43 @@ + + + + + + + + + + +

+
+
+ +
+ + + + + + + +

+ + + +
+
+
+
+
+ + + +
+
+ + diff --git a/simple-blog/web/index.xhtml b/simple-blog/web/index.xhtml new file mode 100644 index 0000000..f81e7a5 --- /dev/null +++ b/simple-blog/web/index.xhtml @@ -0,0 +1,55 @@ + + + + + + Simple Blog + + + + +
+ +
+
+ + + +
+
+ + diff --git a/simple-blog/web/mainTemplate.xhtml b/simple-blog/web/mainTemplate.xhtml new file mode 100644 index 0000000..29ad73d --- /dev/null +++ b/simple-blog/web/mainTemplate.xhtml @@ -0,0 +1,56 @@ + + + + + + + + + Simple Blog + + + + +
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + diff --git a/simple-blog/web/navigationBar.xhtml b/simple-blog/web/navigationBar.xhtml new file mode 100644 index 0000000..8a4dd2d --- /dev/null +++ b/simple-blog/web/navigationBar.xhtml @@ -0,0 +1,38 @@ + + + + + + + + + + + + +

+ + + + | + + | + + | + + + + | + + + | + + +

+
+ diff --git a/simple-blog/web/publishPost.xhtml b/simple-blog/web/publishPost.xhtml new file mode 100644 index 0000000..11497b4 --- /dev/null +++ b/simple-blog/web/publishPost.xhtml @@ -0,0 +1,51 @@ + + + + + Facelet Title + + + + +
+ +
+
+
+
+ + diff --git a/simple-blog/web/redirectDeletePost.xhtml b/simple-blog/web/redirectDeletePost.xhtml new file mode 100644 index 0000000..04daafb --- /dev/null +++ b/simple-blog/web/redirectDeletePost.xhtml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/simple-blog/web/redirectDeleteUser.xhtml b/simple-blog/web/redirectDeleteUser.xhtml new file mode 100644 index 0000000..cdeb6df --- /dev/null +++ b/simple-blog/web/redirectDeleteUser.xhtml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/simple-blog/web/redirectIndex.xhtml b/simple-blog/web/redirectIndex.xhtml new file mode 100644 index 0000000..10c4d7a --- /dev/null +++ b/simple-blog/web/redirectIndex.xhtml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/simple-blog/web/resources/css/cssLayout.css b/simple-blog/web/resources/css/cssLayout.css new file mode 100644 index 0000000..fd40910 --- /dev/null +++ b/simple-blog/web/resources/css/cssLayout.css @@ -0,0 +1,4 @@ + + + + diff --git a/simple-blog/web/resources/css/default.css b/simple-blog/web/resources/css/default.css new file mode 100644 index 0000000..9c70ad5 --- /dev/null +++ b/simple-blog/web/resources/css/default.css @@ -0,0 +1,861 @@ +@import url(http://fonts.googleapis.com/css?family=Open+Sans); +@import url(http://fonts.googleapis.com/css?family=Questrial); + +/* Reset & Basics (Inspired by E. Meyers) +================================================== */ +html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, address, cite, code, em, img, small, strong, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, embed, figure, figcaption, footer, header, hgroup, menu, nav, section, summary, time, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; } +article, aside, details, figcaption, figure, footer, header, hgroup, menu, time, nav, section { + display: block; } +html, body, .wrapper { + min-height: 100%; +} + + +/* Body +================================================== */ +html, body { + height: 100%; +} +.wrapper { + min-height: 100%; +} +body { + overflow-x: hidden; + font: 17px/28px ff-meta-serif-web-pro, "Georgia", serif; + color: #333; + background: #fff; +} + + +/* Typography +================================================== */ +h1, h2, h3, h4, h5, h6 { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-weight: normal; + text-transform: uppercase; + font-weight: 700; + color: #000; + text-rendering: optimizeLegibility; +} + +h1 { + font-size: 50px; + padding-bottom: 30px; +} + +h2 { + font-size: 45px; + padding-bottom: 25px; +} + +h3 { + font-size: 40px; + padding-bottom: 20px; +} + +h4 { + font-size: 35px; + padding-bottom: 15px; +} + +h5 { + font-size: 30px; + padding-bottom: 10px; +} + +p { + margin: 0 0 28px 0; +} + +strong { + font-weight: bold; +} +em { + font-style: italic; +} +sup { + line-height: 0; +} + +small { + font-size: 70%; +} + +cite { + font-size: 80%; + font-style: italic; + } + +/* Teaser +================================================== */ + +header#teaser h1 { + text-transform: none !important; + color: #333; + font-size: 28px !important; + font-weight: 300 !important; +} + + +/* Links +================================================== */ +a { + color: #F40034; + text-decoration: none; + -webkit-transition: color .2s ease-in-out; + -moz-transition: color .2s ease-in-out; + transition: color .2s ease-in-out; +} +a:hover { + color: #F40034; +} + +/* Layout +================================================== */ +/* White container that is the "page" */ +.wrapper { + max-width: 1500px; + margin: 0 auto; + background: #fff; +} + +/* Containers to keep content to a set width */ +.nav, +.art-header-inner, +.footer, +.art-list, +.abt, +.fourohfour { + width: 980px; +} +.nav, +.art-body-inner, +.footer, +.art-list, +.abt, +.fourohfour { + position: relative; + margin: 0 auto; +} + +/* Nav +================================================== */ +.nav { + position: absolute; + top: 0; + left: 50%; + height: 70px; + padding-top: 40px; + margin-left: -490px; /* Half width of nav */ + border-bottom: 1px solid #333; + z-index: 2; +} +.nav.fixed { + position: fixed; +} +#logo { + float: left; +} +.nav-primary { + float: right; +} +.nav-primary li { + display: inline-block; + margin-left: 10px; + font-weight: 500; +} +#logo h1, +.nav-primary li, +.nav-primary li a { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-weight: 700; + font-size: 13px; + line-height: 30px; + color: #000; + text-transform: uppercase; +} + +#logo h1 { + height: 30px; + margin-left: 0px; + letter-spacing: 1px; + font-family: 'Questrial', sans-serif; + font-size: 30px; +} + +#logo h1 span{ + color: #F40034 !important; +} + +.nav li:first-child { + margin-left: 0; /* Remove left margin from the first nav li */ +} + +/* Home Page +================================================== */ + +div#home {} + +#home > div.cover { + max-width: 980px; + margin: 0px auto; + /*padding-top: 110px;*/ +} + +div.cover { + +} + +div.cover > img { + width: 100%; + height: 100%; +} + + +/* Article +================================================== */ +.art { + margin-top: -131px; +} +/* Header */ +.art-header { + height: 600px; + /* Background image is defined in the post */ + background-position: top center; + background-attachment: fixed; + overflow: hidden; +} +/* Contains the time, title and subtitle for an article */ +.art-header-inner { + position: absolute; + top: 200px; + left: 50%; + margin-left: -490px; +} +.art-time, +.art-title, +.art-subtitle { + text-align: center; + text-transform: uppercase; +} +.art-time { + font-size: 14px; + line-height: 1.8; + letter-spacing: 4px; +} +.art-title { + font-size: 100px; + line-height: .9; + letter-spacing: -2px; + width: 100%; +} +.art-subtitle { + margin-top: 4px; + font-size: 14px; + line-height: 1.3; + letter-spacing: 4px; +} + +/* If small header, make few adjustments */ +.small .art-title { + font-size: 70px; + line-height: 65px; +} +.small.art-header-inner { + top: 320px; +} + +/* Body */ +.art-body { + + width: 100%; + background: #fff; + z-index: 100; + -webkit-box-shadow: 0 -3px 3px rgba(0,0,0,.2); + -moz-box-shadow: 0 -3px 3px rgba(0,0,0,.2); + box-shadow: 0 -3px 3px rgba(0,0,0,.2); +} +.art-body-inner { + font-family: Georgia,Cambria,"Times New Roman",Times,serif; + max-width: 640px; + padding: 80px 0 50px; + letter-spacing: 0.01rem; + font-weight: 400; + font-style: normal; + font-size: 21px; + line-height: 1.5; +} +.art-body-inner a:hover { + border-bottom: 1px solid #F40034; + padding-bottom:2px; +} +.art-body-inner ul, +.art-body-inner ol { /* For lists in the article body */ + margin-bottom: 26px; +} +.art-body-inner ul li { + list-style: disc; +} + +.art-body-inner mark { + background-color: #fdffb6; + padding: 2px; + -webkit-box-shadow: #fdffb6 0 0 5px; + -moz-box-shadow: #fdffb6 0 0 5px; + box-shadow: #fdffb6 0 0 5px; +} + +.art-body-inner blockquote { + font-size: 16px; + background: #f9f9f9; + border-left: 10px solid #ccc; + margin: 1.5em 10px; + padding: 0.5em 10px; + quotes: "\201C""\201D""\2018""\2019"; +} + +.art-body-inner blockquote p:first-child:before { + color: #ccc; + content: "“"; + font-size: 4em; + line-height: 0.1em; + margin-right: 0.25em; + vertical-align: -0.4em; +} + +.art-body-inner blockquote p { + margin-bottom: 1.5em; +} + +.art-body-inner blockquote p:last-child { + margin-bottom: 0; +} + + +.dropcap { /* First character on articles */ + float: left; + margin: 47px 10px 20px 0; + font-size: 100px; + line-height: 0; +} +.art-subhead { /* Subheads are used to break up sections of an article */ + margin: 60px 0 15px; + font-size: 20px; + line-height: 28px; + letter-spacing: 3px; +} +.callout { /* Callouts are like large pullquotes */ + font-weight: bold; +} +.art-body-inner img { + max-width: 100%; + max-height: 600px; + margin-bottom: 26px; +} +.art-body-inner img.center { + display: block; + margin-left: auto; + margin-right: auto; +} +.art-body-inner .art-reference { + font-size: 80%; + color: #999; + margin-top: 50px; +} + +/* For simple, white background posts */ +.simple .art-body { + background: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + + +/* List of Articles +================================================== */ +.art-list { + padding: 120px 0 0; +} +.art-list-body { + position: relative; + overflow: hidden; +} +.art-list-item { + padding: 40px 0; + list-style: none; + overflow: hidden; + border-bottom: 1px solid #ccc; +} +.art-list-item:last-child { + border-bottom: none; +} +.art-list-title { + font-size: 26px; + line-height: 26px; + font-weight: 700; +} +.art-list-item-title-and-time { + float: left; + width: 30%; + margin-bottom: 10px; +} +.art-list-time { + font-size: 12px; + line-height: 20px; + letter-spacing: 2px; + text-transform: uppercase; + color: #999; +} +.art-list-title a { + color: #000; +} +.art-list-title a:hover { + color: #F40034; +} +.art-list-item p { + width: 65%; + float: left; + margin-left: 5%; + margin-bottom: 0; + font-size: 16px; + line-height: 24px; +} + + +/* Footer +================================================== */ +.footer { + padding: 30px 0 40px; + overflow: hidden; + border-top: 1px solid #ccc; +} +.footer, +.footer a { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-size: 13px; + text-transform: uppercase; + color: #777; +} +.footer a:hover { + color: #000; +} +.back-to-top, +.footer-nav, +.offsite-links { + width: 45%; + float: left; +} +.psi { + width:10%; + float:left; + text-align: center; +} +.footer-nav { + text-align: center; +} +.offsite-links { + text-align: right; +} +.footer .twitter-link:hover { + color: #0084B4; +} +.footer .instagram-link:hover { + color: #3F729B; +} +.footer .github-link:hover { + color: #c5376d; +} +.footer .caffein8-link:hover{ + color: black; +} +.footer .rss-link:hover { + color: #e85d24; +} +/* Remove prev & next links on loop */ +.art-list + .footer .footer-nav, +.abt + .footer .footer-nav { + text-indent: -9999px; + text-align: left; +} + + +/* White Reverse Theme +================================================== */ +/* Nav */ +.nav.white { + border-bottom-color: #fff; + border-bottom-color: rgba(255,255,255,.3); +} +.nav.white li a, +.nav.white li, +.nav.white #logo h1 { + color: #fff; + text-shadow: 0 0 8px rgba(0,0,0,.5); +} +.nav.white #logo h1 { + background-position: top center; +} + +nav.pagination{ + text-align: right; + padding-bottom: 25px; +} +/* Art header */ +.art-header.white { + background-color: #111; +} +.art-header.white .art-time, +.art-header.white .art-title, +.art-header.white .art-subtitle { + color: #fff; + text-shadow: 0 0 8px rgba(0,0,0,.5); +} + + +/* About page +================================================== */ +.abt { + padding: 200px 0 100px; + list-style: none; +} +.abt .abt-header { + font-size: 140px; + line-height: 1; + text-transform: none; +} +.abt .abt-subheader { + font-size: 24px; + font-style: italic; + text-transform: none; + color: #777; +} +.abt-body { + -moz-column-count: 2; + -moz-column-gap: 20px; + -webkit-column-count: 2; + -webkit-column-gap: 20px; + margin-bottom: 28px; +} +.abt-signoff { + line-height: 1.3; + font-style: italic; + color: #777; +} + +/* 404 page +================================================== */ +.fourohfour { + padding: 240px 0 100px; + text-align: center; +} + +/* Code +================================================== */ + +code, tt { +background: #ededee; +color: #3C4043; +font-size: 90%; +padding: 1px 3px; +} + +pre { + width: 92%; + overflow: auto; + margin: 2rem 0; + padding: 1rem 0.8rem 1rem 1.2rem; + color: #3f3b36; + border: 1px solid #ccc; + border-left: 1rem solid #ccc; + font: lighter 1.2rem/2rem monospace; + background: url(/assets/img/pre.png) repeat 0 -0.9rem; + background-size: 1px 4rem; +} + +pre code, tt { +font-size: inherit; +white-space: -moz-pre-wrap; +white-space: pre-wrap; +background: transparent; +border: none; +padding: 0; +} + + +.gist { + font-size: 14px; +} + + +/* Responsive +================================================== */ +@media only screen and (max-width: 1080px) { + /* Set all of the 980 containers to flexible width */ + .nav, + .art-body-inner, + .art-header-inner, + .footer, + .art-list, + .abt, + .fourohfour { + width: 90%; + } + .nav, + .art-header-inner { + margin-left: -45%; + } +} + +@media only screen and (max-width: 1024px) { + /* Everything becomes scrolling and non-fading */ + .nav, + .nav.fixed { + position: relative; + opacity: 1 !important; /* Important to override JS values */ + display: inline-block; + } + .art-header-inner { + position: relative; + top: 0 !important; /* Important to override JS values */ + margin-top: 240px !important; /* Important to override JS values */ + opacity: 1 !important; /* Important to override JS values */ + } + /* Articles no longer have fixed heights */ + .art-header { + height: auto; + padding-bottom: 100px; + background-size: cover !important; + background-attachment: scroll; + } + /* Remove bottom space out if articles doesn't have a background */ + .simple .art-header { + padding-bottom: 0; + } + .art-list { + padding-top: 0; + } + .abt { + padding: 40px 0; + } + .fourohfour { + padding: 80px 0 60px; + } +} + +@media only screen and (max-width: 780px) { + .art-body-inner ul, + .art-body-inner ol { + margin-left: 20px; + } + .art-title { + letter-spacing: 0; + } + .art-subtitle, + .art-time { + font-size: 12px; + } + .nav { + padding-top: 25px; + height: 55px; + } + .art-list-item-title-and-time, + .art-list-item p { + float: none; + width: auto; + margin-left: 0; + } + .abt-body { + -moz-column-count: 1; + -webkit-column-count: 1; + } +} + +@media only screen and (max-width: 500px) { + .nav-primary li { + margin-left: 10px; + } + .nav #logo h1 { + font-size: 16px; + letter-spacing: -1px; + } + .nav li a { + font-size: 12px; + } + .art-header { + padding-bottom: 50px; + } + .art-header-inner { + margin-top: 190px !important; + } + .art-body-inner { + padding-top: 30px; + } + body { + font-size: 15px; + line-height: 24px; + } + p { + margin-bottom: 24px; + } + .footer { + padding: 10px 0 20px; + } + .back-to-top, + .footer-nav { + width: 50%; + } + .back-to-top { + text-align: left; + } + .footer-nav { + text-align: right; + } + .offsite-links { + float: left; + width: 100%; + text-align: left; + } + .offsite-links a { + font-size: 12px; + } + .art-list + .footer .footer-nav { + display: none; + } + .abt .abt-header { + font-size: 80px; + } + .abt .abt-subheader { + font-size: 18px; + } +} + + +/* Misc +================================================== */ +::selection { + background: #000; + color: #fff; +} +::-moz-selection { + background: #000; + color: #fff; +} +img.left { + float: left; + margin-right: 20px; +} +img.right { + float: right; + margin-left: 20px; +} +/* Clearfixing pile */ +.nav:before, +.art-body-inner:before, +.footer:before, +.art-list:before { + content:""; + display:table; +} +.nav:after, +.art-body-inner:after, +.footer:after, +.art-list:after { + clear:both; +} +.nav, +.art-body-inner, +.footer, +.art-list { + zoom:1; /* For IE 6/7 (trigger hasLayout) */ +} + + +@-webkit-keyframes le-fade { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@-moz-keyframes le-fade { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.art-header-inner { + -webkit-animation: le-fade .5s 0 1 ease-out; + -moz-animation: le-fade .5s 0 1 ease-out; +} + +.art-list, +.nav, +.abt, +.art-body { + -webkit-animation: le-fade .5s 0s 1 ease-out; + -moz-animation: le-fade .5s 0s 1 ease-out; +} + +hr.featured-article { + padding: 0; + border: none; + border-top: medium double #bbb; + color: #bbb; + text-align: center; +} +hr.featured-article:after { + content: "✭ Featured Article ✭"; + display: inline-block; + position: relative; + top: -0.8em; + font-size: 1.2em; + padding: 0 0.6em; + background: white; +} + +/* FORM */ + +#contact-area { + width: 600px; + margin-top: 25px; +} + +#contact-area input, #contact-area textarea { + padding: 5px; + width: 471px; + font-family: Helvetica, sans-serif; + margin: 0px 0px 10px 0px; + border: 2px solid #ccc; +} + +#contact-area textarea { + height: 90px; +} + +#contact-area textarea:focus, #contact-area input:focus { + border: 2px solid #900; +} + +#contact-area input.submit-button { + width: 100px; + +} + +label { + float: left; + text-align: right; + margin-right: 15px; + width: 100px; + padding-top: 5px; +} \ No newline at end of file diff --git a/simple-blog/web/resources/data/simple_blog.sql b/simple-blog/web/resources/data/simple_blog.sql new file mode 100644 index 0000000..dbf28f9 --- /dev/null +++ b/simple-blog/web/resources/data/simple_blog.sql @@ -0,0 +1,115 @@ +-- phpMyAdmin SQL Dump +-- version 4.1.12 +-- http://www.phpmyadmin.net +-- +-- Host: 127.0.0.1 +-- Generation Time: Nov 24, 2014 at 03:53 PM +-- Server version: 5.6.16 +-- PHP Version: 5.5.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `simple_blog` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `comment` +-- + +CREATE TABLE IF NOT EXISTS `comment` ( + `id` int(11) NOT NULL DEFAULT '0', + `post_id` int(11) NOT NULL, + `name` varchar(100) NOT NULL, + `email` varchar(100) NOT NULL, + `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `content` text NOT NULL, + PRIMARY KEY (`id`), + KEY `post_id` (`post_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `comment` +-- + +INSERT INTO `comment` (`id`, `post_id`, `name`, `email`, `date`, `content`) VALUES +(1, 1, 'sasuke uchiha', 'sasuke@gmail.com', '2014-11-24 14:53:00', 'f*ck you too!'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `post` +-- + +CREATE TABLE IF NOT EXISTS `post` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `title` varchar(100) NOT NULL, + `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `content` text NOT NULL, + `status` tinyint(1) NOT NULL, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; + +-- +-- Dumping data for table `post` +-- + +INSERT INTO `post` (`id`, `user_id`, `title`, `date`, `content`, `status`) VALUES +(1, 1, 'F*ck you!', '2014-11-24 14:44:19', 'tai kuda keinjek', 1), +(2, 1, 'kagebunshin no jutsu!', '2014-11-24 14:51:33', 'jadi jurus ini adalah...', 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user` +-- + +CREATE TABLE IF NOT EXISTS `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `email` varchar(100) NOT NULL, + `username` varchar(16) NOT NULL, + `name` varchar(100) NOT NULL, + `password` varchar(16) NOT NULL, + `role` enum('admin','owner','editor') NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; + +-- +-- Dumping data for table `user` +-- + +INSERT INTO `user` (`id`, `email`, `username`, `name`, `password`, `role`) VALUES +(1, 'naruto@gmail.com', 'naruto69', 'naruto uzumaki', 'uzumakinaruto', 'admin'); + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `comment` +-- +ALTER TABLE `comment` + ADD CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `post` +-- +ALTER TABLE `post` + ADD CONSTRAINT `post_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/simple-blog/web/resources/images/3.png b/simple-blog/web/resources/images/3.png new file mode 100644 index 0000000..0e14c9a Binary files /dev/null and b/simple-blog/web/resources/images/3.png differ diff --git a/simple-blog/web/resources/js/commentValidation.js b/simple-blog/web/resources/js/commentValidation.js new file mode 100644 index 0000000..cf37e43 --- /dev/null +++ b/simple-blog/web/resources/js/commentValidation.js @@ -0,0 +1,8 @@ +/* + * 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. + */ + + + diff --git a/simple-blog/web/resources/js/delete.js b/simple-blog/web/resources/js/delete.js new file mode 100644 index 0000000..a61dc47 --- /dev/null +++ b/simple-blog/web/resources/js/delete.js @@ -0,0 +1,20 @@ +function ConfirmDeletePost() +{ + if (confirm("Delete Post?")) + return true; + else return false; +} + +function ConfirmDeleteUser(ID) +{ + if (confirm("Delete User?")) + return true; + else return false; +} + +function ConfirmActionOnDeletedPost() +{ + if (confirm("Are you sure?")) + return true; + else return false; +} diff --git a/simple-blog/web/resources/js/emailValidation.js b/simple-blog/web/resources/js/emailValidation.js new file mode 100644 index 0000000..1228c94 --- /dev/null +++ b/simple-blog/web/resources/js/emailValidation.js @@ -0,0 +1,19 @@ +/* + * 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. + */ + +function validateEmail() { + var email = document.getElementById("Form:Email").value; + var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + if(re.test(email)){ + return true; + } + else{ + alert('Email tidak valid!'); + return false; + } +} + + diff --git a/simple-blog/web/resources/js/postValidation.js b/simple-blog/web/resources/js/postValidation.js new file mode 100644 index 0000000..b2ba0f8 --- /dev/null +++ b/simple-blog/web/resources/js/postValidation.js @@ -0,0 +1,59 @@ +function postValidation() { + var Judul = document.getElementById("Form:Judul"); + var Tanggal = document.getElementById("Form:Tanggal"); + var Konten = document.getElementById("Form:Konten"); + + if (Judul.value =="") + { + alert('Judul harus di isi!'); + return false; + } + + if (Tanggal.value =="") + { + alert('Tanggal harus di isi!'); + return false; + } + + if (Konten.value =="") + { + alert('Konten harus di isi!'); + return false; + } + + if (Tanggal.value!="") + { + var arrTanggal = Tanggal.value.split("-"); + + var tanggal = new Date(); + tanggal.setFullYear(arrTanggal[0], parseInt(arrTanggal[1])-1, arrTanggal[2]); + var date = new Date(); + + if (tanggal < date) + { + alert('Tanggal harus sama atau lebih besar dari tanggal sekarang!'); + return false; + } + } + + return true; +} + +function resetForm(FormId){ + document.forms[FormId].reset(); +} + +function makeYear(Tanggal){ + var tahun = Tanggal.charAt(0) + Tanggal.charAt(1) + Tanggal.charAt(2) + Tanggal.charAt(3); + return parseInt(tahun); +} + +function makeMonth(Tanggal){ + var bulan = Tanggal.charAt(5) + Tanggal.charAt(6); + return parseInt(bulan); +} + +function makeDay(Tanggal){ + var hari = Tanggal.charAt(8) + Tanggal.charAt(9); + return parseInt(hari); +} \ No newline at end of file diff --git a/simple-blog/web/viewPost.xhtml b/simple-blog/web/viewPost.xhtml new file mode 100644 index 0000000..52975fd --- /dev/null +++ b/simple-blog/web/viewPost.xhtml @@ -0,0 +1,81 @@ + + + + + + + + + + Facelet Title + + + + +
+ +
+
+ +

#{viewPostController.viewPost.title}

+

+
+
+ +
+ +
+
+ +

#{viewPostController.viewPost.content}

+ +
+ +

Komentar

+ +
+ + + + + +

+ + + + +
+
+ +
    + + +
  • +
    +

    #{comment.name}

    +
    #{comment.date}
    +
    +

    #{comment.content} …

    +
  • +
    +
    +
+
+
+ +
+
+ + + +
+
+ \ No newline at end of file