use of org.eclipse.sw360.portal.portlets.moderation.ModerationPortletUtils in project sw360portal by sw360.
the class ModerationPortlet method renderStandardView.
public void renderStandardView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
User user = UserCacheHolder.getUserFromRequest(request);
List<ModerationRequest> openModerationRequests = null;
List<ModerationRequest> closedModerationRequests = null;
try {
ModerationService.Iface client = thriftClients.makeModerationClient();
List<ModerationRequest> moderationRequests = client.getRequestsByModerator(user);
Map<Boolean, List<ModerationRequest>> partitionedModerationRequests = moderationRequests.stream().collect(Collectors.groupingBy(ModerationPortletUtils::isOpenModerationRequest));
openModerationRequests = partitionedModerationRequests.get(true);
closedModerationRequests = partitionedModerationRequests.get(false);
} catch (TException e) {
log.error("Could not fetch moderation requests from backend!", e);
}
request.setAttribute(MODERATION_REQUESTS, CommonUtils.nullToEmptyList(openModerationRequests));
request.setAttribute(CLOSED_MODERATION_REQUESTS, CommonUtils.nullToEmptyList(closedModerationRequests));
request.setAttribute(IS_USER_AT_LEAST_CLEARING_ADMIN, PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user) ? "Yes" : "No");
super.doView(request, response);
}
use of org.eclipse.sw360.portal.portlets.moderation.ModerationPortletUtils in project sw360portal by sw360.
the class MyTaskAssignmentsPortlet method doView.
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
List<ModerationRequest> openModerations = null;
try {
User user = UserCacheHolder.getUserFromRequest(request);
List<ModerationRequest> moderations = thriftClients.makeModerationClient().getRequestsByModerator(user);
openModerations = moderations.stream().filter(ModerationPortletUtils::isOpenModerationRequest).collect(Collectors.toList());
} catch (TException e) {
log.error("Could not fetch your moderations from backend", e);
}
request.setAttribute(PortalConstants.MODERATION_REQUESTS, CommonUtils.nullToEmptyList(openModerations));
super.doView(request, response);
}
Aggregations