Search in sources :

Example 96 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class CveSearchHandler method updateForRelease.

private VulnerabilityUpdateStatus updateForRelease(Release release) {
    Optional<List<CveSearchData>> cveSearchDatas = cveSearchWrapper.searchForRelease(release);
    if (!cveSearchDatas.isPresent()) {
        return new VulnerabilityUpdateStatus().setRequestStatus(RequestStatus.FAILURE);
    }
    CveSearchDataTranslator cveSearchDataTranslator = new CveSearchDataTranslator();
    List<CveSearchDataTranslator.VulnerabilityWithRelation> translated = cveSearchDatas.get().stream().map(cveSearchDataTranslator).map(vulnerabilityWithRelation -> {
        vulnerabilityWithRelation.relation.setReleaseId(release.getId());
        return vulnerabilityWithRelation;
    }).collect(Collectors.toList());
    VulnerabilityUpdateStatus updateStatus = getEmptyVulnerabilityUpdateStatus();
    for (CveSearchDataTranslator.VulnerabilityWithRelation vulnerabilityWithRelation : translated) {
        updateStatus = vulnerabilityConnector.addOrUpdate(vulnerabilityWithRelation.vulnerability, vulnerabilityWithRelation.relation, updateStatus);
    }
    return updateStatus;
}
Also used : VulnerabilityConnector(org.eclipse.sw360.cvesearch.datasink.VulnerabilityConnector) java.util(java.util) CveSearchData(org.eclipse.sw360.cvesearch.datasource.CveSearchData) CveSearchService(org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) CveSearchWrapper(org.eclipse.sw360.cvesearch.datasource.CveSearchWrapper) TException(org.apache.thrift.TException) IOException(java.io.IOException) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) Collectors(java.util.stream.Collectors) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UpdateType(org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) Logger(org.apache.log4j.Logger) CveSearchDataTranslator(org.eclipse.sw360.cvesearch.entitytranslation.CveSearchDataTranslator) VulnerabilityUtils(org.eclipse.sw360.cvesearch.helper.VulnerabilityUtils) CveSearchApiImpl(org.eclipse.sw360.cvesearch.datasource.CveSearchApiImpl) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) CveSearchDataTranslator(org.eclipse.sw360.cvesearch.entitytranslation.CveSearchDataTranslator)

Example 97 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ProjectDatabaseHandler method getReleaseClearingStatuses.

public List<ReleaseClearingStatusData> getReleaseClearingStatuses(String projectId, User user) throws SW360Exception {
    Project project = getProjectById(projectId, user);
    SetMultimap<String, ProjectWithReleaseRelationTuple> releaseIdsToProject = releaseIdToProjects(project, user);
    List<Release> releasesById = componentDatabaseHandler.getFullReleases(releaseIdsToProject.keySet());
    Map<String, Component> componentsById = ThriftUtils.getIdMap(componentDatabaseHandler.getComponentsShort(releasesById.stream().map(Release::getComponentId).collect(Collectors.toSet())));
    List<ReleaseClearingStatusData> releaseClearingStatuses = new ArrayList<>();
    for (Release release : releasesById) {
        List<String> projectNames = new ArrayList<>();
        List<String> mainlineStates = new ArrayList<>();
        for (ProjectWithReleaseRelationTuple projectWithReleaseRelation : releaseIdsToProject.get(release.getId())) {
            projectNames.add(printName(projectWithReleaseRelation.getProject()));
            mainlineStates.add(ThriftEnumUtils.enumToString(projectWithReleaseRelation.getRelation().getMainlineState()));
            if (projectNames.size() > 3) {
                projectNames.add("...");
                mainlineStates.add("...");
                break;
            }
        }
        releaseClearingStatuses.add(new ReleaseClearingStatusData(release).setProjectNames(joinStrings(projectNames)).setMainlineStates(joinStrings(mainlineStates)).setComponentType(componentsById.get(release.getComponentId()).getComponentType()));
    }
    return releaseClearingStatuses;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ProjectWithReleaseRelationTuple(org.eclipse.sw360.datahandler.thrift.projects.ProjectWithReleaseRelationTuple)

Example 98 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentDatabaseHandler method getReleaseForEdit.

public Release getReleaseForEdit(String id, User user) throws SW360Exception {
    List<ModerationRequest> moderationRequestsForDocumentId = moderator.getModerationRequestsForDocumentId(id);
    Release release = getRelease(id, user);
    DocumentState documentState;
    if (moderationRequestsForDocumentId.isEmpty()) {
        documentState = CommonUtils.getOriginalDocumentState();
    } else {
        final String email = user.getEmail();
        Optional<ModerationRequest> moderationRequestOptional = CommonUtils.getFirstModerationRequestOfUser(moderationRequestsForDocumentId, email);
        if (moderationRequestOptional.isPresent() && isInProgressOrPending(moderationRequestOptional.get())) {
            ModerationRequest moderationRequest = moderationRequestOptional.get();
            release = releaseModerator.updateReleaseFromModerationRequest(release, moderationRequest.getReleaseAdditions(), moderationRequest.getReleaseDeletions());
            documentState = CommonUtils.getModeratedDocumentState(moderationRequest);
        } else {
            documentState = new DocumentState().setIsOriginalDocument(true).setModerationState(moderationRequestsForDocumentId.get(0).getModerationState());
        }
    }
    vendorRepository.fillVendor(release);
    release.setPermissions(makePermission(release, user).getPermissionMap());
    release.setDocumentState(documentState);
    ensureEccInformationIsSet(release);
    return release;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 99 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentPortlet method prepareReleaseEdit.

private void prepareReleaseEdit(RenderRequest request, RenderResponse response) throws PortletException {
    String id = request.getParameter(COMPONENT_ID);
    String releaseId = request.getParameter(RELEASE_ID);
    final User user = UserCacheHolder.getUserFromRequest(request);
    request.setAttribute(DOCUMENT_TYPE, SW360Constants.TYPE_RELEASE);
    if (isNullOrEmpty(id) && isNullOrEmpty(releaseId)) {
        throw new PortletException("Component or Release ID not set!");
    }
    try {
        ComponentService.Iface client = thriftClients.makeComponentClient();
        Release release;
        if (!isNullOrEmpty(releaseId)) {
            release = client.getReleaseByIdForEdit(releaseId, user);
            request.setAttribute(RELEASE, release);
            request.setAttribute(DOCUMENT_ID, releaseId);
            setAttachmentsInRequest(request, release.getAttachments());
            putDirectlyLinkedReleaseRelationsInRequest(request, release);
            Map<RequestedAction, Boolean> permissions = release.getPermissions();
            DocumentState documentState = release.getDocumentState();
            setUsingDocs(request, releaseId, user, client);
            addEditDocumentMessage(request, permissions, documentState);
            if (isNullOrEmpty(id)) {
                id = release.getComponentId();
            }
        } else {
            release = (Release) request.getAttribute(RELEASE);
            if (release == null) {
                release = new Release();
                release.setComponentId(id);
                release.setClearingState(ClearingState.NEW_CLEARING);
                request.setAttribute(RELEASE, release);
                putDirectlyLinkedReleaseRelationsInRequest(request, release);
                setAttachmentsInRequest(request, release.getAttachments());
                setUsingDocs(request, null, user, client);
                SessionMessages.add(request, "request_processed", "New Release");
            }
        }
        Component component = client.getComponentById(id, user);
        addComponentBreadcrumb(request, response, component);
        if (!isNullOrEmpty(release.getId())) {
            // Otherwise the link is meaningless
            addReleaseBreadcrumb(request, response, release);
        }
        request.setAttribute(COMPONENT, component);
        request.setAttribute(IS_USER_AT_LEAST_ECC_ADMIN, PermissionUtils.isUserAtLeast(UserGroup.ECC_ADMIN, user) ? "Yes" : "No");
    } catch (TException e) {
        log.error("Error fetching release from backend!", e);
        setSW360SessionError(request, ErrorMessages.ERROR_GETTING_RELEASE);
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) RequestedAction(org.eclipse.sw360.datahandler.thrift.users.RequestedAction)

Example 100 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentPortlet method fillVendor.

private void fillVendor(Release release) throws TException {
    VendorService.Iface client = thriftClients.makeVendorClient();
    if (release.isSetVendorId()) {
        Vendor vendor = client.getByID(release.getVendorId());
        release.setVendor(vendor);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)39 TException (org.apache.thrift.TException)34 Test (org.junit.Test)22 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Component (org.eclipse.sw360.datahandler.thrift.components.Component)18 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)15 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)11 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)10 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)9 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)9 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)7 Before (org.junit.Before)7 Collectors (java.util.stream.Collectors)6 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)6 FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)6 IOException (java.io.IOException)5 java.util (java.util)5