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
10d3c6c2
Commit
10d3c6c2
authored
13 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OMA-54: add informations at the repo/courses level
parent
016a2a71
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/restapi/repository/course/CoursesWebService.java
+0
-82
0 additions, 82 deletions
...org/olat/restapi/repository/course/CoursesWebService.java
with
0 additions
and
82 deletions
src/main/java/org/olat/restapi/repository/course/CoursesWebService.java
+
0
−
82
View file @
10d3c6c2
...
...
@@ -160,88 +160,6 @@ public class CoursesWebService {
}
}
/**
* Get courses informations viewable by the authenticated user
* @response.representation.200.qname {http://www.example.com}courseVO
* @response.representation.200.mediaType application/xml, application/json, application/json;pagingspec=1.0
* @response.representation.200.doc List of visible courses
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSEVOes}
* @param start
* @param limit
* @param httpRequest The HTTP request
* @param request The REST request
* @return
*/
@GET
@Path
(
"infos"
)
@Produces
({
MediaType
.
APPLICATION_XML
,
MediaType
.
APPLICATION_JSON
})
public
Response
getCourseInfoList
(
@QueryParam
(
"start"
)
@DefaultValue
(
"0"
)
Integer
start
,
@QueryParam
(
"limit"
)
@DefaultValue
(
"25"
)
Integer
limit
,
@Context
HttpServletRequest
httpRequest
,
@Context
Request
request
)
{
RepositoryManager
rm
=
RepositoryManager
.
getInstance
();
//fxdiff VCRP-1,2: access control of resources
Roles
roles
=
getRoles
(
httpRequest
);
Identity
identity
=
getIdentity
(
httpRequest
);
SearchRepositoryEntryParameters
params
=
new
SearchRepositoryEntryParameters
(
identity
,
roles
,
CourseModule
.
getCourseTypeName
());
if
(
MediaTypeVariants
.
isPaged
(
httpRequest
,
request
))
{
int
totalCount
=
rm
.
countGenericANDQueryWithRolesRestriction
(
params
,
true
);
List
<
RepositoryEntry
>
repoEntries
=
rm
.
genericANDQueryWithRolesRestriction
(
params
,
start
,
limit
,
true
);
List
<
CourseInfoVO
>
infos
=
new
ArrayList
<
CourseInfoVO
>();
for
(
RepositoryEntry
entry:
repoEntries
)
{
CourseInfoVO
info
=
collect
(
identity
,
roles
,
entry
);
if
(
info
!=
null
)
{
infos
.
add
(
info
);
}
}
CourseInfoVO
[]
vos
=
infos
.
toArray
(
new
CourseInfoVO
[
infos
.
size
()]);
CourseInfoVOes
voes
=
new
CourseInfoVOes
();
voes
.
setInfos
(
vos
);
voes
.
setTotalCount
(
totalCount
);
return
Response
.
ok
(
voes
).
build
();
}
else
{
return
Response
.
serverError
().
status
(
Status
.
FORBIDDEN
).
build
();
}
}
private
CourseInfoVO
collect
(
Identity
identity
,
Roles
roles
,
RepositoryEntry
entry
)
{
CourseInfoVO
info
=
new
CourseInfoVO
();
info
.
setRepoEntryKey
(
entry
.
getKey
());
info
.
setSoftKey
(
entry
.
getSoftkey
());
info
.
setDisplayName
(
entry
.
getDisplayname
());
ACFrontendManager
acManager
=
(
ACFrontendManager
)
CoreSpringFactory
.
getBean
(
"acFrontendManager"
);
AccessResult
result
=
acManager
.
isAccessible
(
entry
,
identity
,
false
);
if
(
result
.
isAccessible
())
{
final
ICourse
course
=
CourseFactory
.
loadCourse
(
entry
.
getOlatResource
());
final
List
<
FolderVO
>
folders
=
new
ArrayList
<
FolderVO
>();
final
List
<
ForumVO
>
forums
=
new
ArrayList
<
ForumVO
>();
final
IdentityEnvironment
ienv
=
new
IdentityEnvironment
(
identity
,
roles
);
new
CourseTreeVisitor
(
course
,
ienv
).
visit
(
new
Visitor
()
{
@Override
public
void
visit
(
INode
node
)
{
if
(
node
instanceof
BCCourseNode
)
{
BCCourseNode
bcNode
=
(
BCCourseNode
)
node
;
folders
.
add
(
BCWebService
.
createFolderVO
(
ienv
,
course
,
bcNode
,
false
));
}
else
if
(
node
instanceof
FOCourseNode
)
{
FOCourseNode
forumNode
=
(
FOCourseNode
)
node
;
forums
.
add
(
ForumCourseNodeWebService
.
createForumVO
(
course
,
forumNode
,
null
));
}
}
});
info
.
setKey
(
course
.
getResourceableId
());
info
.
setTitle
(
course
.
getCourseTitle
());
info
.
setFolders
(
folders
.
toArray
(
new
FolderVO
[
folders
.
size
()]));
info
.
setForums
(
forums
.
toArray
(
new
ForumVO
[
forums
.
size
()]));
}
return
info
;
}
private
CourseVO
[]
toCourseVo
(
List
<
RepositoryEntry
>
repoEntries
)
{
List
<
CourseVO
>
voList
=
new
ArrayList
<
CourseVO
>();
...
...
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