Search in sources :

Example 1 with ModerationPortletUtils

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);
}
Also used : ModerationService(org.eclipse.sw360.datahandler.thrift.moderation.ModerationService) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 2 with ModerationPortletUtils

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);
}
Also used : TException(org.apache.thrift.TException) ModerationPortletUtils(org.eclipse.sw360.portal.portlets.moderation.ModerationPortletUtils) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) User(org.eclipse.sw360.datahandler.thrift.users.User)

Aggregations

TException (org.apache.thrift.TException)2 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)2 User (org.eclipse.sw360.datahandler.thrift.users.User)2 ModerationService (org.eclipse.sw360.datahandler.thrift.moderation.ModerationService)1 ModerationPortletUtils (org.eclipse.sw360.portal.portlets.moderation.ModerationPortletUtils)1