Search in sources :

Example 1 with CommonUtils.nullToEmptyList

use of org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList 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 CommonUtils.nullToEmptyList

use of org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList in project sw360portal by sw360.

the class MySubscriptionsPortlet method doView.

@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    List<Component> components = null;
    List<Release> releases = null;
    try {
        final User user = UserCacheHolder.getUserFromRequest(request);
        ComponentService.Iface componentClient = thriftClients.makeComponentClient();
        components = componentClient.getSubscribedComponents(user);
        releases = componentClient.getSubscribedReleases(user);
    } catch (TException e) {
        log.error("Could not fetch your subscriptions from backend", e);
    }
    request.setAttribute(PortalConstants.COMPONENT_LIST, CommonUtils.nullToEmptyList(components));
    request.setAttribute(PortalConstants.RELEASE_LIST, CommonUtils.nullToEmptyList(releases));
    super.doView(request, response);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 3 with CommonUtils.nullToEmptyList

use of org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList in project sw360portal by sw360.

the class RecentComponentPortlet method doView.

@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    List<Component> components = null;
    User user = UserCacheHolder.getUserFromRequest(request);
    try {
        components = thriftClients.makeComponentClient().getRecentComponentsSummary(5, user);
    } catch (TException e) {
        log.error("Could not fetch recent components from backend", e);
    }
    request.setAttribute("components", CommonUtils.nullToEmptyList(components));
    super.doView(request, response);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Component(org.eclipse.sw360.datahandler.thrift.components.Component)

Example 4 with CommonUtils.nullToEmptyList

use of org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList 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)

Example 5 with CommonUtils.nullToEmptyList

use of org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList in project sw360portal by sw360.

the class MyComponentsPortlet method doView.

@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    List<Component> components;
    try {
        final User user = UserCacheHolder.getUserFromRequest(request);
        components = thriftClients.makeComponentClient().getMyComponents(user);
    } catch (TException e) {
        log.error("Could not fetch your components from backend", e);
        components = new ArrayList<>();
    }
    request.setAttribute("components", CommonUtils.nullToEmptyList(components));
    super.doView(request, response);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ArrayList(java.util.ArrayList) Component(org.eclipse.sw360.datahandler.thrift.components.Component)

Aggregations

TException (org.apache.thrift.TException)6 User (org.eclipse.sw360.datahandler.thrift.users.User)6 Component (org.eclipse.sw360.datahandler.thrift.components.Component)3 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)3 ArrayList (java.util.ArrayList)1 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)1 Release (org.eclipse.sw360.datahandler.thrift.components.Release)1 ModerationService (org.eclipse.sw360.datahandler.thrift.moderation.ModerationService)1 ModerationPortletUtils (org.eclipse.sw360.portal.portlets.moderation.ModerationPortletUtils)1