Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tristan Cavelier
jio
Commits
982efe39
Commit
982efe39
authored
12 years ago
by
Tristan Cavelier
Browse files
Options
Download
Email Patches
Plain Diff
Error thrown by subCommands.js are improved
parent
192c14a1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
8 deletions
+74
-8
src/jio/commands/getCommand.js
src/jio/commands/getCommand.js
+18
-4
src/jio/commands/postCommand.js
src/jio/commands/postCommand.js
+15
-0
src/jio/commands/putAttachmentCommand.js
src/jio/commands/putAttachmentCommand.js
+16
-4
src/jio/commands/putCommand.js
src/jio/commands/putCommand.js
+25
-0
No files found.
src/jio/commands/getCommand.js
View file @
982efe39
...
...
@@ -9,14 +9,28 @@ var getCommand = function(spec, my) {
};
that
.
validateState
=
function
()
{
if
(
!
that
.
getDocId
())
{
if
(
typeof
that
.
getDocId
()
===
"
string
"
&&
that
.
getDocId
()
===
""
)
{
that
.
error
({
status
:
20
,
statusText
:
'
Document Id Required
'
,
error
:
'
document_id_required
'
,
message
:
'
No document id.
'
,
reason
:
'
no document id
'
"
status
"
:
20
,
"
statusText
"
:
"
Document Id Required
"
,
"
error
"
:
"
document_id_required
"
,
"
message
"
:
"
The document id is not provided
"
,
"
reason
"
:
"
Document id is undefined
"
});
return
false
;
}
if
(
typeof
that
.
getAttachmentId
()
===
"
string
"
)
{
if
(
that
.
getAttachmentId
()
===
""
)
{
that
.
error
({
"
status
"
:
23
,
"
statusText
"
:
"
Invalid Attachment Id
"
,
"
error
"
:
"
invalid_attachment_id
"
,
"
message
"
:
"
The attachment id must not be an empty string
"
,
"
reason
"
:
"
Attachment id is empty
"
});
}
return
false
;
}
return
true
;
};
...
...
This diff is collapsed.
Click to expand it.
src/jio/commands/postCommand.js
View file @
982efe39
...
...
@@ -10,6 +10,21 @@ var postCommand = function(spec, my) {
return
'
post
'
;
};
that
.
validateState
=
function
()
{
if
(
typeof
that
.
getAttachmentId
()
!==
"
undefined
"
)
{
that
.
error
({
"
status
"
:
21
,
"
statusText
"
:
"
Invalid Document Id
"
,
"
error
"
:
"
Invalid Document Id
"
,
"
message
"
:
"
The document id contains '/' characters
"
+
"
which are forbidden
"
,
"
reason
"
:
"
Document id contains '/' character(s)
"
});
return
false
;
}
return
true
;
};
that
.
executeOn
=
function
(
storage
)
{
storage
.
post
(
that
);
};
...
...
This diff is collapsed.
Click to expand it.
src/jio/commands/putAttachmentCommand.js
View file @
982efe39
...
...
@@ -11,15 +11,27 @@ var putAttachmentCommand = function(spec, my) {
that
.
executeOn
=
function
(
storage
)
{
storage
.
putAttachment
(
that
);
};
that
.
validateState
=
function
()
{
if
(
typeof
that
.
get
Cont
ent
()
!
==
'
string
'
)
{
if
(
typeof
that
.
get
Attachm
ent
Id
()
=
==
"
undefined
"
)
{
that
.
error
({
status
:
22
,
statusText
:
'
Content Required
'
,
error
:
'
content_required
'
,
message
:
'
No data to put.
'
,
reason
:
'
no data to put
'
"
status
"
:
22
,
"
statusText
"
:
"
Attachment Id Required
"
,
"
error
"
:
"
attachment_id_required
"
,
"
message
"
:
"
The attachment id must be set
"
,
"
reason
"
:
"
Attachment id not set
"
});
return
false
;
}
if
(
that
.
getAttachmentId
()
===
""
)
{
that
.
error
({
"
status
"
:
23
,
"
statusText
"
:
"
Invalid Attachment Id
"
,
"
error
"
:
"
invalid_attachment_id
"
,
"
message
"
:
"
The attachment id must not be an empty string
"
,
"
reason
"
:
"
Attachment id is empty
"
});
}
return
true
;
};
...
...
This diff is collapsed.
Click to expand it.
src/jio/commands/putCommand.js
View file @
982efe39
...
...
@@ -10,6 +10,31 @@ var putCommand = function(spec, my) {
return
'
put
'
;
};
that
.
validateState
=
function
()
{
if
(
typeof
that
.
getDocId
()
===
"
string
"
&&
that
.
getDocId
()
===
""
)
{
that
.
error
({
"
status
"
:
20
,
"
statusText
"
:
"
Document Id Required
"
,
"
error
"
:
"
document_id_required
"
,
"
message
"
:
"
The document id is not provided
"
,
"
reason
"
:
"
Document id is undefined
"
});
return
false
;
}
if
(
typeof
that
.
getAttachmentId
()
!==
"
undefined
"
)
{
that
.
error
({
"
status
"
:
21
,
"
statusText
"
:
"
Invalid Document Id
"
,
"
error
"
:
"
invalid_document_id
"
,
"
message
"
:
"
The document id contains '/' characters
"
+
"
which are forbidden
"
,
"
reason
"
:
"
Document id contains '/' character(s)
"
});
return
false
;
}
return
true
;
};
that
.
executeOn
=
function
(
storage
)
{
storage
.
put
(
that
);
};
...
...
This diff is collapsed.
Click to expand it.
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