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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations