Search in sources :

Example 31 with Release._Fields

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

the class ThriftValidate method ensureEccInformationIsSet.

public static Release ensureEccInformationIsSet(Release release) {
    EccInformation eccInformation = release.isSetEccInformation() ? release.getEccInformation() : newDefaultEccInformation();
    if (!eccInformation.isSetEccStatus()) {
        eccInformation.setEccStatus(ECCStatus.OPEN);
    }
    release.setEccInformation(eccInformation);
    return release;
}
Also used : EccInformation(org.eclipse.sw360.datahandler.thrift.components.EccInformation) SW360Utils.newDefaultEccInformation(org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation)

Example 32 with Release._Fields

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

the class ModerationPortlet method renderReleaseModeration.

public void renderReleaseModeration(RenderRequest request, RenderResponse response, ModerationRequest moderationRequest, User user) throws IOException, PortletException, TException {
    Release actual_release = null;
    final boolean requestDocumentDelete = moderationRequest.isRequestDocumentDelete();
    Boolean is_used = false;
    try {
        ComponentService.Iface client = thriftClients.makeComponentClient();
        actual_release = client.getReleaseById(moderationRequest.getDocumentId(), user);
        is_used = client.releaseIsUsed(actual_release.getId());
    } catch (TException e) {
        log.error("Could not retrieve release", e);
    }
    if (actual_release == null) {
        renderNextModeration(request, response, user, "Ignored unretrievable target", thriftClients.makeModerationClient(), moderationRequest);
        return;
    }
    if (refuseToDeleteUsedDocument(request, response, moderationRequest, user, requestDocumentDelete, is_used))
        return;
    prepareRelease(request, user, actual_release);
    request.setAttribute(PortalConstants.ACTUAL_RELEASE, actual_release);
    if (requestDocumentDelete) {
        include("/html/moderation/releases/delete.jsp", request, response);
    } else {
        include("/html/moderation/releases/merge.jsp", request, response);
    }
}
Also used : TException(org.apache.thrift.TException) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 33 with Release._Fields

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

the class ModerationPortlet method renderEditViewForId.

private void renderEditViewForId(RenderRequest request, RenderResponse response, String id) throws IOException, PortletException, TException {
    if (id != null) {
        ModerationRequest moderationRequest = null;
        User user = UserCacheHolder.getUserFromRequest(request);
        try {
            ModerationService.Iface client = thriftClients.makeModerationClient();
            moderationRequest = client.getModerationRequestById(id);
            boolean actionsAllowed = moderationRequest.getModerators().contains(user.getEmail()) && ModerationPortletUtils.isOpenModerationRequest(moderationRequest);
            request.setAttribute(PortalConstants.MODERATION_ACTIONS_ALLOWED, actionsAllowed);
            if (actionsAllowed) {
                SessionMessages.add(request, "request_processed", "You have assigned yourself to this moderation request.");
                client.setInProgress(id, user);
            }
            request.setAttribute(PortalConstants.MODERATION_REQUEST, moderationRequest);
            addModerationBreadcrumb(request, response, moderationRequest);
        } catch (TException e) {
            log.error("Error fetching moderation  details from backend", e);
        }
        if (moderationRequest != null) {
            switch(moderationRequest.getDocumentType()) {
                case COMPONENT:
                    renderComponentModeration(request, response, moderationRequest, user);
                    break;
                case RELEASE:
                    VendorService.Iface vendorClient = thriftClients.makeVendorClient();
                    Release additions = moderationRequest.getReleaseAdditions();
                    if (additions.isSetVendorId()) {
                        additions.setVendor(vendorClient.getByID(additions.getVendorId()));
                    }
                    Release deletions = moderationRequest.getReleaseDeletions();
                    if (deletions.isSetVendorId()) {
                        deletions.setVendor(vendorClient.getByID(deletions.getVendorId()));
                    }
                    renderReleaseModeration(request, response, moderationRequest, user);
                    break;
                case PROJECT:
                    renderProjectModeration(request, response, moderationRequest, user);
                    break;
                case LICENSE:
                    renderLicenseModeration(request, response, moderationRequest, user);
                    break;
                case USER:
                    renderUserModeration(request, response, moderationRequest, user);
                    break;
            }
        }
    }
}
Also used : ModerationService(org.eclipse.sw360.datahandler.thrift.moderation.ModerationService) TException(org.apache.thrift.TException) VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) User(org.eclipse.sw360.datahandler.thrift.users.User) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 34 with Release._Fields

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

the class ProjectPortlet method serveReleasesFromLinkedProjects.

private void serveReleasesFromLinkedProjects(ResourceRequest request, ResourceResponse response, String projectId) throws IOException, PortletException {
    List<Release> searchResult;
    Set<String> releaseIdsFromLinkedProjects = new HashSet<>();
    User user = UserCacheHolder.getUserFromRequest(request);
    try {
        ComponentService.Iface componentClient = thriftClients.makeComponentClient();
        ProjectService.Iface projectClient = thriftClients.makeProjectClient();
        Project project = projectClient.getProjectById(projectId, user);
        Map<String, ProjectRelationship> linkedProjects = CommonUtils.nullToEmptyMap(project.getLinkedProjects());
        for (String linkedProjectId : linkedProjects.keySet()) {
            Project linkedProject = projectClient.getProjectById(linkedProjectId, user);
            if (linkedProject != null) {
                Map<String, ProjectReleaseRelationship> releaseIdToUsage = CommonUtils.nullToEmptyMap(linkedProject.getReleaseIdToUsage());
                releaseIdsFromLinkedProjects.addAll(releaseIdToUsage.keySet());
            }
        }
        if (releaseIdsFromLinkedProjects.size() > 0) {
            searchResult = componentClient.getReleasesById(releaseIdsFromLinkedProjects, user);
        } else {
            searchResult = Collections.emptyList();
        }
    } catch (TException e) {
        log.error("Error searching projects", e);
        searchResult = Collections.emptyList();
    }
    request.setAttribute(PortalConstants.RELEASE_SEARCH, searchResult);
    include("/html/utils/ajax/searchReleasesAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
Also used : WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 35 with Release._Fields

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

the class ProjectPortletUtils method extractContainedAttachments.

/**
 * Walks through a list of project links and extracts all release attachments
 * with their owner. The returned map is a mapping from a release to its
 * attachment content ids.
 *
 * @param projectLinks
 *            list of project links to walk through
 *
 * @return map of releases and their attachment content ids
 */
public static Map<Source, Set<String>> extractContainedAttachments(Collection<ProjectLink> projectLinks) {
    Map<Source, Set<String>> attachments = Maps.newHashMap();
    for (ProjectLink projectLink : projectLinks) {
        for (ReleaseLink releaseLink : projectLink.linkedReleases) {
            Set<String> attachmentIds = attachments.getOrDefault(Source.releaseId(releaseLink.getId()), Sets.newHashSet());
            attachmentIds.addAll(releaseLink.getAttachments().stream().map(a -> a.getAttachmentContentId()).collect(Collectors.toList()));
            attachments.put(Source.releaseId(releaseLink.getId()), attachmentIds);
        }
    }
    return attachments;
}
Also used : ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) ReleaseLink(org.eclipse.sw360.datahandler.thrift.components.ReleaseLink)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)42 TException (org.apache.thrift.TException)38 Test (org.junit.Test)23 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)12 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)11 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 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