Skip to content

Commit

Permalink
Refactor overall
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tamura committed Feb 17, 2017
1 parent 41889f3 commit 08130b5
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
.settings
target/
logs/
server-work/
*.swp
*.log
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
<artifactId>derby</artifactId>
<version>10.8.3.0</version>
</dependency>
<dependency>
<groupId>org.tinylog</groupId>
<artifactId>tinylog</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.t246osslab.easybuggy.servers.EmbeddedJavaDb;
import org.t246osslab.easybuggy.utils.Closer;
import org.t246osslab.easybuggy.utils.DBClient;
import org.t246osslab.easybuggy.utils.HTTPResponseCreator;
import org.t246osslab.easybuggy.utils.MessageUtils;

Expand Down Expand Up @@ -44,12 +44,12 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.update", locale) + "\">");
bodyHtml.append("<br><br>");

EmbeddedJavaDb app = new EmbeddedJavaDb();
DBClient dbClient = new DBClient();
if ("asc".equals(order)) {
String message = app.updateUsers2(new int[] { 1, 2 }, locale);
String message = dbClient.updateUsers2(new int[] { 1, 2 }, locale);
bodyHtml.append(message);
} else if ("desc".equals(order)) {
String message = app.updateUsers2(new int[] { 2, 1 }, locale);
String message = dbClient.updateUsers2(new int[] { 2, 1 }, locale);
bodyHtml.append(message);
}else{
bodyHtml.append(MessageUtils.getMsg("msg.warn.select.asc.or.desc", locale));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.t246osslab.easybuggy.servers;
package org.t246osslab.easybuggy.utils;

import java.sql.Connection;
import java.sql.DriverManager;
Expand All @@ -13,12 +13,10 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.t246osslab.easybuggy.utils.ApplicationUtils;
import org.t246osslab.easybuggy.utils.MessageUtils;

public class EmbeddedJavaDb {
public class DBClient {

private static Logger log = LoggerFactory.getLogger(EmbeddedJavaDb.class);
private static Logger log = LoggerFactory.getLogger(DBClient.class);

static Connection conn;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.t246osslab.easybuggy.servers;
package org.t246osslab.easybuggy.utils;

import org.apache.directory.server.constants.ServerDNConstants;
import org.apache.directory.server.core.DefaultDirectoryService;
Expand Down Expand Up @@ -50,7 +50,7 @@ public EmbeddedADS() throws Exception {
service.getAdminSession().add(entryBar);
}

// add the people entries
// Add the people entries
LdapDN peopleDn = new LdapDN("ou=people,dc=t246osslab,dc=org");
if (!service.getAdminSession().exists(peopleDn)) {
ServerEntry e = service.newEntry(peopleDn);
Expand All @@ -59,7 +59,7 @@ public EmbeddedADS() throws Exception {
service.getAdminSession().add(e);
}

// add sample users
// Add sample users
addUser("Mark", "password", "57249037993");
addUser("David", "p@s2w0rd", "42368923031");
addUser("Peter", "pa33word", "54238496555");
Expand All @@ -75,7 +75,7 @@ public EmbeddedADS() throws Exception {
* @throws Exception If the partition can't be added
*/
private Partition addPartition(String partitionId, String partitionDn) throws Exception {
// Create a new partition named 'foo'.
// Create a new partition named
Partition partition = new JdbmPartition();
partition.setId(partitionId);
partition.setSuffix(partitionDn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.t246osslab.easybuggy.servers.EmbeddedADS;
import org.t246osslab.easybuggy.utils.Closer;
import org.t246osslab.easybuggy.utils.EmbeddedADS;
import org.t246osslab.easybuggy.utils.HTTPResponseCreator;
import org.t246osslab.easybuggy.utils.MessageUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.t246osslab.easybuggy.servers.EmbeddedJavaDb;
import org.t246osslab.easybuggy.utils.Closer;
import org.t246osslab.easybuggy.utils.DBClient;
import org.t246osslab.easybuggy.utils.HTTPResponseCreator;
import org.t246osslab.easybuggy.utils.MessageUtils;

Expand Down Expand Up @@ -69,8 +69,8 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
private String selectUsers(String name, String password, HttpServletRequest req) {

String result = "<font color=\"red\">" + MessageUtils.getMsg("msg.error.user.not.exist", req.getLocale())+ "</font><br>";
EmbeddedJavaDb app = new EmbeddedJavaDb();
ArrayList<String[]> users = app.selectUsers(name, password);
DBClient dbClient = new DBClient();
ArrayList<String[]> users = dbClient.selectUsers(name, password);
StringBuilder sb = new StringBuilder();
for (String[] user : users) {
sb.append(user[0] + ", " + user[1] + "<BR>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
import org.eclipse.jetty.webapp.WebInfConfiguration;
import org.eclipse.jetty.webapp.WebXmlConfiguration;

/**
* Embedded Jetty Server.
*/
public class EmbeddedJettyServer {

public static void main(String[] args) throws Exception {

Server server = new Server(Integer.parseInt(args[0]));
Expand Down

0 comments on commit 08130b5

Please sign in to comment.