Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hamza
jio
Commits
94635fa2
Commit
94635fa2
authored
Jul 18, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gidstorage remove attachment method added
parent
5d29dacc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
src/jio.storage/gidstorage.js
src/jio.storage/gidstorage.js
+69
-0
No files found.
src/jio.storage/gidstorage.js
View file @
94635fa2
...
...
@@ -307,6 +307,64 @@
});
};
/**
* Generic command for putAttachment, getAttachment or removeAttachment.
*
* This command will check if the document exist with an allDocs and a
* complex query. If not exist, then it returns 404. Otherwise the
* action will be done on the attachment of the found document.
*
* @method putGetOrRemoveAttachment
* @private
* @param {Command} command The JIO command
* @param {String} method The command method
*/
priv
.
putGetOrRemoveAttachment
=
function
(
command
,
method
)
{
setTimeout
(
function
()
{
var
gid_object
,
complex_query
,
doc
=
command
.
cloneDoc
();
gid_object
=
gidParse
(
doc
.
_id
,
priv
.
constraints
);
if
(
gid_object
===
undefined
)
{
return
that
.
error
({
"
status
"
:
400
,
"
statusText
"
:
"
Bad Request
"
,
"
error
"
:
"
bad_request
"
,
"
message
"
:
"
Cannot
"
+
method
+
"
attachment
"
,
"
reason
"
:
"
metadata should respect constraints
"
});
}
complex_query
=
gidToComplexQuery
(
gid_object
);
that
.
addJob
(
'
allDocs
'
,
priv
.
sub_storage
,
{},
{
"
query
"
:
complex_query
,
"
wildcard_character
"
:
null
},
function
(
response
)
{
if
(
response
.
total_rows
===
0
)
{
return
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Cannot
"
+
method
+
"
attachment
"
,
"
reason
"
:
"
Document already exist
"
});
}
gid_object
=
doc
.
_id
;
doc
.
_id
=
response
.
rows
[
0
].
id
;
that
.
addJob
(
method
+
"
Attachment
"
,
priv
.
sub_storage
,
doc
,
{
},
function
(
response
)
{
if
(
method
!==
'
get
'
)
{
response
.
id
=
gid_object
;
}
that
.
success
(
response
);
},
function
(
err
)
{
err
.
message
=
"
Cannot
"
+
method
+
"
attachment
"
;
that
.
error
(
err
);
});
},
function
(
err
)
{
err
.
message
=
"
Cannot
"
+
method
+
"
attachment
"
;
that
.
error
(
err
);
});
});
};
/**
* See {{#crossLink "gidStorage/putOrPost:method"}}{{/#crossLink}}.
*
...
...
@@ -521,6 +579,17 @@
});
};
/**
* Removes an attachment to a document thank to its gid, a sub allDocs and a
* complex query.
*
* @method removeAttachment
* @param {Command} command The JIO command
*/
that
.
removeAttachment
=
function
(
command
)
{
priv
.
putGetOrRemoveAttachment
(
command
,
'
remove
'
);
};
/**
* Retrieve a list of document which respect gid constraints.
*
...
...
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