Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
K
key_value-server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
amir.yosef
key_value-server
Commits
30c1e7c6
Commit
30c1e7c6
authored
Aug 20, 2024
by
amir.yosef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating handling wrong args ( SET & INFO & GET )
parent
7254798d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
3 deletions
+4
-3
GetCommand.java
src/command/GetCommand.java
+1
-1
InfoCommand.java
src/command/InfoCommand.java
+1
-1
SetCommand.java
src/command/SetCommand.java
+2
-1
No files found.
src/command/GetCommand.java
View file @
30c1e7c6
...
@@ -18,7 +18,7 @@ public class GetCommand implements CommandExecutable<byte[]> {
...
@@ -18,7 +18,7 @@ public class GetCommand implements CommandExecutable<byte[]> {
@Override
@Override
public
byte
[]
execute
()
{
public
byte
[]
execute
()
{
if
(!
validator
.
validateGetCommand
(
args
))
{
if
(!
validator
.
validateGetCommand
(
args
))
{
return
"wrong args"
.
getBytes
(
);
return
Response
.
getResponse
(
"wrong args"
);
}
}
String
response
=
storage
.
get
(
args
.
getFirst
().
toLowerCase
());
String
response
=
storage
.
get
(
args
.
getFirst
().
toLowerCase
());
if
(
response
==
null
||
response
.
isEmpty
()
||
response
.
isBlank
())
{
if
(
response
==
null
||
response
.
isEmpty
()
||
response
.
isBlank
())
{
...
...
src/command/InfoCommand.java
View file @
30c1e7c6
...
@@ -20,7 +20,7 @@ public class InfoCommand implements CommandExecutable<byte[]> {
...
@@ -20,7 +20,7 @@ public class InfoCommand implements CommandExecutable<byte[]> {
@Override
@Override
public
byte
[]
execute
()
{
public
byte
[]
execute
()
{
if
(!
validator
.
validateInfoCommand
(
args
))
{
if
(!
validator
.
validateInfoCommand
(
args
))
{
return
"unsupported args"
.
getBytes
(
);
return
Response
.
getResponse
(
"unsupported args"
);
}
}
String
command
=
args
.
getFirst
();
String
command
=
args
.
getFirst
();
if
(
command
.
equalsIgnoreCase
(
Command
.
REPLICATION
.
getValue
()))
{
if
(
command
.
equalsIgnoreCase
(
Command
.
REPLICATION
.
getValue
()))
{
...
...
src/command/SetCommand.java
View file @
30c1e7c6
...
@@ -2,6 +2,7 @@ package command;
...
@@ -2,6 +2,7 @@ package command;
import
model.Command
;
import
model.Command
;
import
storage.Storage
;
import
storage.Storage
;
import
util.Response
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -20,7 +21,7 @@ public class SetCommand implements CommandExecutable<byte[]> {
...
@@ -20,7 +21,7 @@ public class SetCommand implements CommandExecutable<byte[]> {
@Override
@Override
public
byte
[]
execute
()
{
public
byte
[]
execute
()
{
if
(!
validator
.
validateSetCommand
(
args
))
{
if
(!
validator
.
validateSetCommand
(
args
))
{
return
"wrong args"
.
getBytes
(
);
return
Response
.
getResponse
(
"wrong args"
);
}
}
Map
<
String
,
String
>
commandsMap
=
IntStream
.
iterate
(
2
,
i
->
i
<
args
.
size
(),
i
->
i
+
2
)
Map
<
String
,
String
>
commandsMap
=
IntStream
.
iterate
(
2
,
i
->
i
<
args
.
size
(),
i
->
i
+
2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment