Renamed view packages
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 5 Oct 2016 00:31:47 +0000 (02:31 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 5 Oct 2016 00:31:47 +0000 (02:31 +0200)
src/main/java/com/prueba/controllers/web/PagesController.java
src/main/java/com/prueba/services/impl/LoginServiceImpl.java
src/main/java/com/prueba/view/LoginFormImpl.java [new file with mode: 0644]
src/main/java/com/prueba/view/PageImpl.java [new file with mode: 0644]
src/main/java/com/prueba/view/login/LoginFormImpl.java [deleted file]
src/main/java/com/prueba/view/page/PageImpl.java [deleted file]

index c420a52..d17a53f 100644 (file)
@@ -6,7 +6,7 @@ import java.io.OutputStream;
 import com.prueba.controllers.Controller;
 import com.prueba.core.http.sessions.SessionContext;
 import com.prueba.core.http.sessions.SessionInfo;
-import com.prueba.view.page.PageImpl;
+import com.prueba.view.PageImpl;
 import com.sun.net.httpserver.HttpExchange;
 
 public class PagesController implements Controller {
index 8df3e78..dd3a6f0 100644 (file)
@@ -11,7 +11,7 @@ import com.prueba.core.http.sessions.SessionContext;
 import com.prueba.core.http.sessions.SessionInfo;
 import com.prueba.core.http.sessions.Sessions;
 import com.prueba.model.dao.AccountDao;
-import com.prueba.view.login.LoginFormImpl;
+import com.prueba.view.LoginFormImpl;
 import com.sun.net.httpserver.Headers;
 import com.sun.net.httpserver.HttpExchange;
 
@@ -54,7 +54,6 @@ public class LoginServiceImpl {
                }
 
                httpExchange.sendResponseHeaders(200, html.length());
-               
                try (final OutputStream os = httpExchange.getResponseBody()) {
                        os.write(html.getBytes());
                }
diff --git a/src/main/java/com/prueba/view/LoginFormImpl.java b/src/main/java/com/prueba/view/LoginFormImpl.java
new file mode 100644 (file)
index 0000000..41bbfda
--- /dev/null
@@ -0,0 +1,48 @@
+package com.prueba.view;
+
+import static org.rendersnake.HtmlAttributesFactory.for_;
+import static org.rendersnake.HtmlAttributesFactory.id;
+import static org.rendersnake.HtmlAttributesFactory.type;
+
+import java.io.IOException;
+
+import org.rendersnake.HtmlCanvas;
+
+public class LoginFormImpl {
+    private static final String ID_USERNAME = "username";
+    private static final String ID_PASSWORD = "password";
+    private static final String VAR_USERNAME = "username";
+    private static final String VAR_PASSWORD = "password";
+
+       public String doNoRequiredLogin() throws IOException {
+               final HtmlCanvas html = new HtmlCanvas();
+               return html
+                         .html()
+                           .body()
+                              .h1().content("NO REQUIRED LOGIN")
+                           ._body()
+                         ._html()
+                         .toHtml();
+       }
+       
+       public String doRequiredLogin(String requestedURI) throws IOException {
+               final HtmlCanvas html = new HtmlCanvas();
+               return html
+                       .html()
+               .form(id("sample").action(requestedURI).method("post"))
+                   .label(for_(ID_USERNAME)).write("Username:")._label()
+                   .input(
+                       id(ID_USERNAME)
+                       .name(VAR_USERNAME))
+               .br()
+                   .label(for_(ID_PASSWORD)).write("Password:")._label()
+                   .input(
+                       type("password")
+                       .id(ID_PASSWORD)
+                       .name(VAR_PASSWORD))
+               .br()
+                   .input(type("submit").value("Log me in"))
+               ._form()
+               .toHtml();
+       }
+}
diff --git a/src/main/java/com/prueba/view/PageImpl.java b/src/main/java/com/prueba/view/PageImpl.java
new file mode 100644 (file)
index 0000000..c9cf80e
--- /dev/null
@@ -0,0 +1,24 @@
+package com.prueba.view;
+
+import static org.rendersnake.HtmlAttributesFactory.href;
+
+import java.io.IOException;
+
+import org.rendersnake.HtmlCanvas;
+
+public class PageImpl {
+
+       public String doPage(int number, String userName) throws IOException {
+               final HtmlCanvas html = new HtmlCanvas();
+               return html
+                         .html()
+                           .body()
+                              .h1().content("PAGE: " + number)
+                              .h1().content("Hello " + userName)
+                              .h1().a(href("/app/login/logout.html")).write("Logout")._a()._h1()
+                           ._body()
+                         ._html()
+                         .toHtml();
+       }
+
+}
diff --git a/src/main/java/com/prueba/view/login/LoginFormImpl.java b/src/main/java/com/prueba/view/login/LoginFormImpl.java
deleted file mode 100644 (file)
index e42b135..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.prueba.view.login;
-
-import static org.rendersnake.HtmlAttributesFactory.for_;
-import static org.rendersnake.HtmlAttributesFactory.id;
-import static org.rendersnake.HtmlAttributesFactory.type;
-
-import java.io.IOException;
-
-import org.rendersnake.HtmlCanvas;
-
-public class LoginFormImpl {
-    private static final String ID_USERNAME = "username";
-    private static final String ID_PASSWORD = "password";
-    private static final String VAR_USERNAME = "username";
-    private static final String VAR_PASSWORD = "password";
-
-       public String doNoRequiredLogin() throws IOException {
-               final HtmlCanvas html = new HtmlCanvas();
-               return html
-                         .html()
-                           .body()
-                              .h1().content("NO REQUIRED LOGIN")
-                           ._body()
-                         ._html()
-                         .toHtml();
-       }
-       
-       public String doRequiredLogin(String requestedURI) throws IOException {
-               final HtmlCanvas html = new HtmlCanvas();
-               return html
-                       .html()
-               .form(id("sample").action(requestedURI).method("post"))
-                   .label(for_(ID_USERNAME)).write("Username:")._label()
-                   .input(
-                       id(ID_USERNAME)
-                       .name(VAR_USERNAME))
-               .br()
-                   .label(for_(ID_PASSWORD)).write("Password:")._label()
-                   .input(
-                       type("password")
-                       .id(ID_PASSWORD)
-                       .name(VAR_PASSWORD))
-               .br()
-                   .input(type("submit").value("Log me in"))
-               ._form()
-               .toHtml();
-       }
-}
diff --git a/src/main/java/com/prueba/view/page/PageImpl.java b/src/main/java/com/prueba/view/page/PageImpl.java
deleted file mode 100644 (file)
index f258825..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.prueba.view.page;
-
-import static org.rendersnake.HtmlAttributesFactory.href;
-
-import java.io.IOException;
-
-import org.rendersnake.HtmlCanvas;
-
-public class PageImpl {
-
-       public String doPage(int number, String userName) throws IOException {
-               final HtmlCanvas html = new HtmlCanvas();
-               return html
-                         .html()
-                           .body()
-                              .h1().content("PAGE: " + number)
-                              .h1().content("Hello " + userName)
-                              .h1().a(href("/app/login/logout.html")).write("Logout")._a()._h1()
-                           ._body()
-                         ._html()
-                         .toHtml();
-       }
-
-}