use of org.eclipse.sw360.datahandler.thrift.components.Release 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;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release 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);
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release 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;
}
}
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release 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);
}
use of org.eclipse.sw360.datahandler.thrift.components.Release 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;
}
Aggregations