diff --git a/app/src/main/java/lightcontainer/protocol/Protocol.java b/app/src/main/java/lightcontainer/protocol/Protocol.java index e7449f3..07bb621 100644 --- a/app/src/main/java/lightcontainer/protocol/Protocol.java +++ b/app/src/main/java/lightcontainer/protocol/Protocol.java @@ -7,15 +7,14 @@ import java.util.regex.Pattern; /** * Protocol - * + *
* Class allowing to define new rules for the LightContainer protocol,
* also provides utility functions to work with regexes and the command to compare.
*
- * @version 1.0
- * @since 1.0
- *
- * @see Pattern
- * @author Jérémi NIHART
* This function allows you to check a command and process those groups (parameters)
* use the utility functions of {@link Protocol} to facilitate processing, see @see.
*
- * @param cmd Command on which to execute the rule.
- *
- * @since 1.0
- *
- * @see Protocol#execute(String)
- * @see #matcherCheck(String)
- * @see #matcherGetGroups()
+ * @param cmd Command on which to execute the rule.
+ * @see Protocol#execute(String)
+ * @see #matcherCheck(String)
+ * @see #matcherGetGroups()
+ * @since 1.0
*/
public abstract void execute(String cmd);
/**
* Retrieve, the hashcode of the rule.
*
- * @return Rule hashcode.
- *
- * @since 1.0
+ * @return Rule hashcode.
+ * @since 1.0
*/
@Override
public int hashCode() {
@@ -110,10 +103,9 @@ public abstract class Protocol {
/**
* Compare the equality of two rules.
*
- * @return True : if the rules are equals
- * False if not.
- *
- * @since 1.0
+ * @return True : if the rules are equals
+ * False if not.
+ * @since 1.0
*/
@Override
public boolean equals(final Object obj) {
diff --git a/app/src/main/java/lightcontainer/protocol/SbeHello.java b/app/src/main/java/lightcontainer/protocol/SbeHello.java
new file mode 100644
index 0000000..af30e5b
--- /dev/null
+++ b/app/src/main/java/lightcontainer/protocol/SbeHello.java
@@ -0,0 +1,16 @@
+package lightcontainer.protocol;
+
+public class SbeHello extends Protocol {
+
+
+ protected SbeHello() {
+ super("HELLO", "^(HELLO)\\s([A-Za-z0-9.]{5,20})\\s((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([0-5][0-9]{4})|([0-9]{1,4}))\\r\\n$");
+ }
+
+ @Override
+ public void execute(String cmd) {
+ if (matcherCheck(cmd)) {
+
+ }
+ }
+}
diff --git a/app/src/main/resources/rules.txt b/app/src/main/resources/rules.txt
index 2cfa297..511bc2b 100644
--- a/app/src/main/resources/rules.txt
+++ b/app/src/main/resources/rules.txt
@@ -21,9 +21,23 @@ login = [A-Za-z0-9]{2,20}
sbe_hello = ^(HELLO)\s([A-Za-z0-9.]{5,20})\s((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([0-5][0-9]{4})|([0-9]{1,4}))\r\n$ //TODO \r\n -> à tester pour voir si déjà dans le flux ou doit être construit
//FileFrontEnd to StorBackEnd
-ffe_sendfile = ^(SENDFILE)\s([A-Za-z0-9.]{50,200}\s[0-9]{1,10}\s[A-Za-z0-9.]{50,200})\r\n(.*)$
+ffe_sendfile = ^(SENDFILE)\s([A-Za-z0-9.]{50,200}\s[0-9]{1,10}\s[A-Za-z0-9.]{50,200})\r\n$
sbe_sendresult = ^(SEND_OK|SEND_ERROR)\r\n$
ffe_erasefile = ^(ERASEFILE)\s([A-Za-z0-9.]{50,200})\r\n$
sbe_eraseresult = ^(ERASE_OK|ERASE_ERROR)\r\n$
ffe_retrievefile = ^(RETRIEVEFILE)\s([A-Za-z0-9.]{50,200})\r\n$
-sbe_retrieveresult = ^(RETRIEVE_OK)\s([A-Za-z0-9.]{50,200}\s[0-9]{1,10}\s[A-Za-z0-9.]{50,200})\r\n(.*)|(RETRIEVE_ERROR)$
\ No newline at end of file
+sbe_retrieveresult = ^((RETRIEVE_OK)\s([A-Za-z0-9.]{50,200}\s[0-9]{1,10}\s[A-Za-z0-9.]{50,200})\r\n)|((RETRIEVE_ERROR)\r\n)$
+
+//Client to FileFrontEnd
+client_signin = ^(SIGNIN)\s([A-Za-z0-9]{2,20})\s([^\s!]{5,50})\r\n$
+client_signup = ^(SIGNUP)\s([A-Za-z0-9]{2,20})\s([^\s!]{5,50})\r\n$
+ffe_signresult = ^(SIGN_OK|SIGN_ERROR)\r\n$
+client_filelist = ^(FILELIST)\r\n$
+ffe_filelistresult = ^(FILES)\s(([^\s!]{1,20}![0-9]{1,10}){0,50})\r\n$
+client_savefile = ^(SAVE_FILE)\s([^\s!]{1,20})\s([0-9]{1,10})\r\n$
+ffe_savefileresult = ^(SAVEFILE_OK|SAVEFILE_ERROR)\r\n$
+client_getfile = ^(GETFILE)\s([^\s!]{1,20})\r\n$
+ffe_getfileresult = ^((GETFILE_OK)\s(^\s!]{1,20})\s([0-9]{1,10})\r\n)|((GETFILE_ERROR)\r\n)$
+client_removefile = ^(REMOVEFILE)\s([^\s!]{1,20})\r\n$
+ffe_removefileresult = ^(REMOVEFILE_OK|REMOVEFILE_ERROR)\r\n$
+client_signout = ^(SIGNOUT)\r\n$
\ No newline at end of file