Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
ARSnova LMS Connector
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARSnova
ARSnova LMS Connector
Commits
2eee5e87
Commit
2eee5e87
authored
Jul 16, 2014
by
Daniel Gerhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NPE, handle HttpMessageNotReadableException for empty results
parent
105ae266
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
connector-service/src/main/java/de/thm/arsnova/connector/dao/StudipRestConnectorDaoImpl.java
...thm/arsnova/connector/dao/StudipRestConnectorDaoImpl.java
+26
-12
No files found.
connector-service/src/main/java/de/thm/arsnova/connector/dao/StudipRestConnectorDaoImpl.java
View file @
2eee5e87
...
...
@@ -111,19 +111,33 @@ public class StudipRestConnectorDaoImpl implements ConnectorDao {
public
List
<
Course
>
getMembersCourses
(
final
String
username
)
{
logger
.
trace
(
"Retrieve courses for {}"
,
username
);
List
<
Course
>
courses
=
new
ArrayList
<>();
ResponseEntity
<
StudipCoursesWrapper
>
courseWrapperEntity
=
restTemplate
.
exchange
(
userMembershipUri
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
getAuthorizationHeader
()),
StudipCoursesWrapper
.
class
,
getUserByName
(
username
).
getId
()
);
for
(
StudipCourse
sipCourse
:
courseWrapperEntity
.
getBody
().
getStudy
())
{
courses
.
add
(
buildCourse
(
sipCourse
,
UserRole
.
MEMBER
));
StudipUser
user
=
getUserByName
(
username
);
if
(
null
==
user
)
{
return
courses
;
}
for
(
StudipCourse
sipCourse
:
courseWrapperEntity
.
getBody
().
getWork
())
{
courses
.
add
(
buildCourse
(
sipCourse
,
UserRole
.
TEACHER
));
try
{
ResponseEntity
<
StudipCoursesWrapper
>
courseWrapperEntity
=
restTemplate
.
exchange
(
userMembershipUri
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
getAuthorizationHeader
()),
StudipCoursesWrapper
.
class
,
user
.
getId
()
);
List
<
StudipCourse
>
sipCourses
;
if
(
null
!=
(
sipCourses
=
courseWrapperEntity
.
getBody
().
getStudy
()))
{
for
(
StudipCourse
sipCourse
:
sipCourses
)
{
courses
.
add
(
buildCourse
(
sipCourse
,
UserRole
.
MEMBER
));
}
}
if
(
null
!=
(
sipCourses
=
courseWrapperEntity
.
getBody
().
getWork
()))
{
for
(
StudipCourse
sipCourse
:
sipCourses
)
{
courses
.
add
(
buildCourse
(
sipCourse
,
UserRole
.
TEACHER
));
}
}
}
catch
(
RestClientException
|
HttpMessageNotReadableException
e
)
{
/* Stud.IP sends an empty array instead of an object if no courses are found */
}
return
courses
;
...
...
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