Search in sources :

Example 76 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class DisplayUserGroup method doTag.

public void doTag() throws JspException, IOException {
    User user;
    if (!Strings.isNullOrEmpty(email)) {
        user = UserCacheHolder.getUserFromEmail(email);
    } else {
        user = UserCacheHolder.EMPTY_USER;
    }
    getJspContext().getOut().print(escapeHtml(user.getDepartment()));
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 77 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class UserPortlet method getCurrentUser.

private User getCurrentUser(PortletRequest request) throws SW360Exception {
    User user;
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    if (themeDisplay.isSignedIn())
        user = themeDisplay.getUser();
    else {
        throw new SW360Exception("Broken portlet!");
    }
    return user;
}
Also used : User(com.liferay.portal.model.User) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

Example 78 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class UserPortlet method getUsersFromCSV.

private List<UserCSV> getUsersFromCSV(List<CSVRecord> records) {
    List<UserCSV> users = new ArrayList<>();
    for (CSVRecord record : records) {
        try {
            UserCSV user = new UserCSV(record);
            users.add(user);
        } catch (IndexOutOfBoundsException e) {
            log.error("Broken csv record");
        }
    }
    return users;
}
Also used : UserCSV(org.eclipse.sw360.portal.users.UserCSV) CSVRecord(org.apache.commons.csv.CSVRecord)

Example 79 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class ComponentPortlet method exportExcel.

private void exportExcel(ResourceRequest request, ResourceResponse response) {
    final User user = UserCacheHolder.getUserFromRequest(request);
    try {
        boolean extendedByReleases = Boolean.valueOf(request.getParameter(PortalConstants.EXTENDED_EXCEL_EXPORT));
        List<Component> components = getFilteredComponentList(request);
        ComponentExporter exporter = new ComponentExporter(thriftClients.makeComponentClient(), components, user, extendedByReleases);
        PortletResponseUtil.sendFile(request, response, "Components.xlsx", exporter.makeExcelExport(components), CONTENT_TYPE_OPENXML_SPREADSHEET);
    } catch (IOException | SW360Exception e) {
        log.error("An error occurred while generating the Excel export", e);
        response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
    }
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentExporter(org.eclipse.sw360.exporter.ComponentExporter) IOException(java.io.IOException)

Example 80 with User

use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.

the class ComponentPortlet method serveNewTableRowLinkedRelease.

private void serveNewTableRowLinkedRelease(ResourceRequest request, ResourceResponse response, String[] linkedIds) throws IOException, PortletException {
    final User user = UserCacheHolder.getUserFromRequest(request);
    List<ReleaseLink> linkedReleases = new ArrayList<>();
    try {
        ComponentService.Iface client = thriftClients.makeComponentClient();
        for (Release release : client.getReleasesById(new HashSet<>(Arrays.asList(linkedIds)), user)) {
            final Vendor vendor = release.getVendor();
            final String vendorName = vendor != null ? vendor.getShortname() : "";
            ReleaseLink linkedRelease = new ReleaseLink(release.getId(), vendorName, release.getName(), release.getVersion(), SW360Utils.printFullname(release), !nullToEmptyMap(release.getReleaseIdToRelationship()).isEmpty());
            linkedRelease.setReleaseRelationship(ReleaseRelationship.CONTAINED);
            linkedReleases.add(linkedRelease);
        }
    } catch (TException e) {
        log.error("Error getting releases!", e);
        throw new PortletException("cannot get releases " + Arrays.toString(linkedIds), e);
    }
    request.setAttribute(RELEASE_LIST, linkedReleases);
    include("/html/utils/ajax/linkedReleasesRelationAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Aggregations

User (org.eclipse.sw360.datahandler.thrift.users.User)169 TException (org.apache.thrift.TException)100 Release (org.eclipse.sw360.datahandler.thrift.components.Release)58 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)44 Test (org.junit.Test)30 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)27 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)26 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)20 ResponseEntity (org.springframework.http.ResponseEntity)20 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)19 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)18 IOException (java.io.IOException)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)16 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)16 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)13 RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)12 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)12 Before (org.junit.Before)12 ArrayList (java.util.ArrayList)11