Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
c4fd84af
Commit
c4fd84af
authored
13 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OMA-14: return the informations about attachments with the messages
parent
5eb92eb8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/modules/fo/restapi/ForumWebService.java
+8
-1
8 additions, 1 deletion
...ain/java/org/olat/modules/fo/restapi/ForumWebService.java
src/test/java/org/olat/restapi/ForumTest.java
+11
-0
11 additions, 0 deletions
src/test/java/org/olat/restapi/ForumTest.java
with
19 additions
and
1 deletion
src/main/java/org/olat/modules/fo/restapi/ForumWebService.java
+
8
−
1
View file @
c4fd84af
...
@@ -28,6 +28,7 @@ import java.io.File;
...
@@ -28,6 +28,7 @@ import java.io.File;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -51,6 +52,7 @@ import javax.ws.rs.core.Request;
...
@@ -51,6 +52,7 @@ import javax.ws.rs.core.Request;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
javax.ws.rs.core.Response.Status
;
import
javax.ws.rs.core.StreamingOutput
;
import
javax.ws.rs.core.StreamingOutput
;
import
javax.ws.rs.core.UriBuilder
;
import
javax.ws.rs.core.UriInfo
;
import
javax.ws.rs.core.UriInfo
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
...
@@ -579,7 +581,12 @@ public class ForumWebService {
...
@@ -579,7 +581,12 @@ public class ForumWebService {
VFSContainer
container
=
fom
.
getMessageContainer
(
mess
.
getForum
().
getKey
(),
mess
.
getKey
());
VFSContainer
container
=
fom
.
getMessageContainer
(
mess
.
getForum
().
getKey
(),
mess
.
getKey
());
List
<
FileVO
>
attachments
=
new
ArrayList
<
FileVO
>();
List
<
FileVO
>
attachments
=
new
ArrayList
<
FileVO
>();
for
(
VFSItem
item:
container
.
getItems
(
new
SystemItemFilter
()))
{
for
(
VFSItem
item:
container
.
getItems
(
new
SystemItemFilter
()))
{
String
uri
=
uriInfo
.
getAbsolutePathBuilder
().
path
(
format
(
item
.
getName
())).
build
().
toString
();
UriBuilder
attachmentUri
=
uriInfo
.
getBaseUriBuilder
().
path
(
"repo"
)
.
path
(
"forums"
).
path
(
mess
.
getForum
().
getKey
().
toString
())
.
path
(
"posts"
).
path
(
mess
.
getKey
().
toString
())
.
path
(
"attachments"
).
path
(
format
(
item
.
getName
()));
String
uri
=
attachmentUri
.
build
().
toString
();
if
(
item
instanceof
VFSLeaf
)
{
if
(
item
instanceof
VFSLeaf
)
{
attachments
.
add
(
new
FileVO
(
"self"
,
uri
,
item
.
getName
(),
((
VFSLeaf
)
item
).
getSize
()));
attachments
.
add
(
new
FileVO
(
"self"
,
uri
,
item
.
getName
(),
((
VFSLeaf
)
item
).
getSize
()));
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/olat/restapi/ForumTest.java
+
11
−
0
View file @
c4fd84af
...
@@ -393,6 +393,17 @@ public class ForumTest extends OlatJerseyTestCase {
...
@@ -393,6 +393,17 @@ public class ForumTest extends OlatJerseyTestCase {
assertNotNull
(
message
.
getAttachments
());
assertNotNull
(
message
.
getAttachments
());
assertEquals
(
2
,
message
.
getAttachments
().
length
);
assertEquals
(
2
,
message
.
getAttachments
().
length
);
for
(
FileVO
attachment:
message
.
getAttachments
())
{
String
title
=
attachment
.
getTitle
();
assertNotNull
(
title
);
String
href
=
attachment
.
getHref
();
URI
attachmentUri
=
new
URI
(
href
);
GetMethod
getAttachment
=
createGet
(
attachmentUri
,
"*/*"
,
true
);
int
attachmentCode
=
c
.
executeMethod
(
getAttachment
);
assertEquals
(
200
,
attachmentCode
);
}
//check if the file exists
//check if the file exists
ForumManager
fm
=
ForumManager
.
getInstance
();
ForumManager
fm
=
ForumManager
.
getInstance
();
VFSContainer
container
=
fm
.
getMessageContainer
(
message
.
getForumKey
(),
message
.
getKey
());
VFSContainer
container
=
fm
.
getMessageContainer
(
message
.
getForumKey
(),
message
.
getKey
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment