Search in sources :

Example 91 with User

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

the class FossologyAwarePortlet method serveGetSendableReleases.

protected void serveGetSendableReleases(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    String projectId = request.getParameter(PROJECT_ID);
    User user = UserCacheHolder.getUserFromRequest(request);
    try {
        putReleasesAndProjectIntoRequest(request, projectId, user);
        include("/html/projects/ajax/sendableTable.jsp", request, response, PortletRequest.RESOURCE_PHASE);
    } catch (TException e) {
        log.error("Problem with project client", e);
        throw new PortletException(e);
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) PortletException(javax.portlet.PortletException)

Example 92 with User

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

the class LinkedReleasesAndProjectsAwarePortlet method serveLoadLinkedProjectsRows.

protected void serveLoadLinkedProjectsRows(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    final User user = UserCacheHolder.getUserFromRequest(request);
    String branchId = request.getParameter(PARENT_BRANCH_ID);
    request.setAttribute(PARENT_BRANCH_ID, branchId);
    if (branchId != null) {
        String id = branchId.split("_")[0];
        try {
            ProjectService.Iface client = thriftClients.makeProjectClient();
            Project project = client.getProjectById(id, user);
            List<ProjectLink> mappedProjectLinks = createLinkedProjects(project, user);
            request.setAttribute(PROJECT_LIST, mappedProjectLinks);
        } catch (TException e) {
            log.error("Error getting projects!", e);
            throw new PortletException("cannot get projects", e);
        }
    } else {
        List<ProjectLink> mappedProjectLinks = createLinkedProjects(new Project(), user);
        request.setAttribute(PROJECT_LIST, mappedProjectLinks);
    }
    request.setAttribute(PortalConstants.PARENT_SCOPE_GROUP_ID, request.getParameter(PortalConstants.PARENT_SCOPE_GROUP_ID));
    include("/html/utils/ajax/linkedProjectsRows.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
Also used : TException(org.apache.thrift.TException) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) User(org.eclipse.sw360.datahandler.thrift.users.User) ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) PortletException(javax.portlet.PortletException) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService)

Example 93 with User

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

the class AttachmentVacuum method cleanUpAttachments.

private RequestSummary cleanUpAttachments(ResourceRequest request) throws TException {
    final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
    final AttachmentService.Iface attachmentClient = thriftClients.makeAttachmentClient();
    final Set<String> usedAttachmentIds = componentClient.getUsedAttachmentContentIds();
    final User userFromRequest = UserCacheHolder.getUserFromRequest(request);
    return attachmentClient.vacuumAttachmentDB(userFromRequest, usedAttachmentIds);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) AttachmentService(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentService)

Example 94 with User

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

the class ComponentUploadPortlet method updateComponentAttachments.

@UsedAsLiferayAction
public void updateComponentAttachments(ActionRequest request, ActionResponse response) throws PortletException, IOException, TException {
    List<CSVRecord> attachmentRecords = getCSVFromRequest(request, "file");
    FluentIterable<ComponentAttachmentCSVRecord> compCSVRecords = convertCSVRecordsToComponentAttachmentCSVRecords(attachmentRecords);
    log.trace("read records <" + Joiner.on("\n").join(compCSVRecords) + ">");
    final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
    final AttachmentService.Iface attachmentClient = thriftClients.makeAttachmentClient();
    User user = UserCacheHolder.getUserFromRequest(request);
    final RequestSummary requestSummary = writeAttachmentsToDatabase(compCSVRecords, user, componentClient, attachmentClient);
    renderRequestSummary(request, response, requestSummary);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) CSVRecord(org.apache.commons.csv.CSVRecord) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary) AttachmentService(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentService) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 95 with User

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

the class ModerationDatabaseHandler method createRequest.

public RequestStatus createRequest(Component component, User user, Boolean isDeleteRequest) {
    Component dbcomponent;
    try {
        dbcomponent = componentDatabaseHandler.getComponent(component.getId(), user);
    } catch (SW360Exception e) {
        log.error("Could not get original component from database. Could not generate moderation request.", e);
        return RequestStatus.FAILURE;
    }
    // Define moderators
    Set<String> moderators = new HashSet<>();
    CommonUtils.add(moderators, dbcomponent.getCreatedBy());
    try {
        String department = getDepartmentByUserEmail(component.getCreatedBy());
        CommonUtils.addAll(moderators, getUsersAtLeast(UserGroup.CLEARING_ADMIN, department));
    } catch (TException e) {
        log.error("Could not get user from database. Clearing admins not added as moderators, since department is missing.");
    }
    CommonUtils.addAll(moderators, getUsersAtLeast(UserGroup.ADMIN));
    ModerationRequest request = createStubRequest(user, isDeleteRequest, component.getId(), moderators);
    // Set meta-data
    request.setDocumentType(DocumentType.COMPONENT);
    request.setDocumentName(SW360Utils.printName(dbcomponent));
    // Fill the request
    ModerationRequestGenerator generator = new ComponentModerationRequestGenerator();
    request = generator.setAdditionsAndDeletions(request, component, dbcomponent);
    if (component.isSetComponentType()) {
        request.setComponentType(component.getComponentType());
    }
    addOrUpdate(request, user);
    return RequestStatus.SENT_TO_MODERATOR;
}
Also used : TException(org.apache.thrift.TException) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) Component(org.eclipse.sw360.datahandler.thrift.components.Component) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

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