Added gitignore; Common module created; TTResponse created; TTLogger created; Auth RMI created;
This commit is contained in:
parent
ac694a1776
commit
f18d7c4bb4
90 changed files with 844 additions and 2105 deletions
12
Commons/Commons.iml
Normal file
12
Commons/Commons.iml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="com.github.cliftonlabs:json-simple:2.1.2" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
13
Commons/src/interfaces/ITTAuth.java
Normal file
13
Commons/src/interfaces/ITTAuth.java
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package interfaces;
|
||||
import models.TTResponse;
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
/**
|
||||
* Created by loke on 15/06/2017.
|
||||
*/
|
||||
public interface ITTAuth extends Remote {
|
||||
TTResponse login(String userName, String password) throws RemoteException;
|
||||
TTResponse logout(String userName, String token) throws RemoteException;
|
||||
}
|
||||
18
Commons/src/models/TTResponse.java
Normal file
18
Commons/src/models/TTResponse.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package models;
|
||||
import org.json.simple.JsonObject;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by loke on 15/06/2017.
|
||||
*/
|
||||
public class TTResponse implements Serializable{
|
||||
public String message;
|
||||
public Integer code;
|
||||
public JsonObject data;
|
||||
|
||||
public TTResponse(String message, Integer code, JsonObject data) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
54
Commons/src/utilities/TTLogger.java
Normal file
54
Commons/src/utilities/TTLogger.java
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
package utilities;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by loke on 15/06/2017.
|
||||
*/
|
||||
public class TTLogger {
|
||||
|
||||
|
||||
private static File logFile;
|
||||
private static PrintWriter out;
|
||||
private static BufferedWriter bw;
|
||||
private static FileWriter fw;
|
||||
|
||||
public TTLogger(File logFile) throws IOException {
|
||||
this.logFile = logFile;
|
||||
|
||||
}
|
||||
public static void write(String msg){
|
||||
try {
|
||||
fw = new FileWriter(logFile, true);
|
||||
bw = new BufferedWriter(fw);
|
||||
out = new PrintWriter(bw);
|
||||
System.out.println(msg);
|
||||
Date d = new Date();
|
||||
out.append(d.toString());
|
||||
out.append(" - ");
|
||||
out.append(msg);
|
||||
out.append("\n");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue