Search in sources :

Example 1 with CommonUtils.isTemporaryTodo

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

the class LicensesPortlet method prepareDetailView.

private void prepareDetailView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    String id = request.getParameter(LICENSE_ID);
    User user = UserCacheHolder.getUserFromRequest(request);
    request.setAttribute(IS_USER_AT_LEAST_CLEARING_ADMIN, PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user) ? "Yes" : "No");
    if (id != null) {
        try {
            LicenseService.Iface client = thriftClients.makeLicenseClient();
            License moderationLicense = client.getByIDWithOwnModerationRequests(id, user.getDepartment(), user);
            List<Todo> allTodos = nullToEmptyList(moderationLicense.getTodos());
            List<Todo> addedTodos = allTodos.stream().filter(CommonUtils::isTemporaryTodo).collect(Collectors.toList());
            List<Todo> currentTodos = allTodos.stream().filter(t -> !CommonUtils.isTemporaryTodo(t)).collect(Collectors.toList());
            request.setAttribute(ADDED_TODOS_FROM_MODERATION_REQUEST, addedTodos);
            request.setAttribute(DB_TODOS_FROM_MODERATION_REQUEST, currentTodos);
            request.setAttribute(MODERATION_LICENSE_DETAIL, moderationLicense);
            License dbLicense = client.getByID(id, user.getDepartment());
            request.setAttribute(KEY_LICENSE_DETAIL, dbLicense);
            List<Obligation> obligations = client.getObligations();
            request.setAttribute(KEY_OBLIGATION_LIST, obligations);
            addLicenseBreadcrumb(request, response, moderationLicense);
        } catch (TException e) {
            log.error("Error fetching license details from backend", e);
            setSW360SessionError(request, ErrorMessages.ERROR_GETTING_LICENSE);
        }
    }
}
Also used : java.util(java.util) User(org.eclipse.sw360.datahandler.thrift.users.User) PortletResponseUtil(com.liferay.portal.kernel.portlet.PortletResponseUtil) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) TMP_TODO_ID_PREFIX(org.eclipse.sw360.datahandler.common.CommonUtils.TMP_TODO_ID_PREFIX) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception) Function(java.util.function.Function) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Strings(com.google.common.base.Strings) Logger(org.apache.log4j.Logger) SessionMessages(com.liferay.portal.kernel.servlet.SessionMessages) CONTENT_TYPE_OPENXML_SPREADSHEET(org.eclipse.sw360.datahandler.common.SW360Constants.CONTENT_TYPE_OPENXML_SPREADSHEET) ThriftEnumUtils(org.eclipse.sw360.datahandler.common.ThriftEnumUtils) Ternary(org.eclipse.sw360.datahandler.thrift.Ternary) javax.portlet(javax.portlet) org.eclipse.sw360.datahandler.thrift.licenses(org.eclipse.sw360.datahandler.thrift.licenses) Sw360Portlet(org.eclipse.sw360.portal.portlets.Sw360Portlet) ImmutableSet(com.google.common.collect.ImmutableSet) UserGroup(org.eclipse.sw360.datahandler.thrift.users.UserGroup) HttpServletResponse(javax.servlet.http.HttpServletResponse) TException(org.apache.thrift.TException) PermissionUtils(org.eclipse.sw360.datahandler.permissions.PermissionUtils) IOException(java.io.IOException) CommonUtils.nullToEmptyList(org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList) Collectors(java.util.stream.Collectors) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) ErrorMessages(org.eclipse.sw360.portal.common.ErrorMessages) EnumUtils(org.apache.commons.lang.enums.EnumUtils) UserCacheHolder(org.eclipse.sw360.portal.users.UserCacheHolder) PortalConstants(org.eclipse.sw360.portal.common.PortalConstants) LicenseExporter(org.eclipse.sw360.exporter.LicenseExporter) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Aggregations

Strings (com.google.common.base.Strings)1 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 PortletResponseUtil (com.liferay.portal.kernel.portlet.PortletResponseUtil)1 SessionMessages (com.liferay.portal.kernel.servlet.SessionMessages)1 IOException (java.io.IOException)1 java.util (java.util)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 javax.portlet (javax.portlet)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 EnumUtils (org.apache.commons.lang.enums.EnumUtils)1 Logger (org.apache.log4j.Logger)1 TException (org.apache.thrift.TException)1 CommonUtils (org.eclipse.sw360.datahandler.common.CommonUtils)1 TMP_TODO_ID_PREFIX (org.eclipse.sw360.datahandler.common.CommonUtils.TMP_TODO_ID_PREFIX)1 CommonUtils.nullToEmptyList (org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyList)1 CONTENT_TYPE_OPENXML_SPREADSHEET (org.eclipse.sw360.datahandler.common.SW360Constants.CONTENT_TYPE_OPENXML_SPREADSHEET)1 ThriftEnumUtils (org.eclipse.sw360.datahandler.common.ThriftEnumUtils)1 PermissionUtils (org.eclipse.sw360.datahandler.permissions.PermissionUtils)1