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;
}
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;
}
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;
}
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);
}
}
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);
}
}
Aggregations