use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class CompareTodos method renderTodoRow.
private static void renderTodoRow(StringBuilder display, Todo todo) {
display.append("<tr>");
for (Todo._Fields field : RELEVANT_FIELDS) {
FieldMetaData fieldMetaData = Todo.metaDataMap.get(field);
Object fieldValue = todo.getFieldValue(field);
if (field.equals(Todo._Fields.OBLIGATIONS) && fieldValue != null) {
fieldValue = ((List<Obligation>) fieldValue).stream().map(Obligation::getName).collect(Collectors.toList());
}
display.append(String.format("<td>%s</td>", getDisplayString(fieldMetaData.valueMetaData.type, fieldValue)));
}
display.append("</tr>");
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class LinkedReleaseRenderer method renderReleaseLinkList.
public <T> void renderReleaseLinkList(StringBuilder display, Map<String, T> releaseRelationshipMap, Set<String> releaseIds, String msg) {
if (releaseIds.isEmpty())
return;
StringBuilder candidate = new StringBuilder();
try {
ComponentService.Iface componentClient = new ThriftClients().makeComponentClient();
for (Release release : componentClient.getReleasesById(releaseIds, user)) {
candidate.append(String.format("<tr><td>%s</td><td>%s</td></tr>", release.getName(), releaseRelationshipMap.get(release.getId())));
}
} catch (TException ignored) {
}
String tableContent = candidate.toString();
if (!tableContent.isEmpty()) {
display.append(String.format("<table class=\"%s\" id=\"%s%s\" >", tableClasses, idPrefix, msg));
display.append(String.format("<thead><tr><th colspan=\"2\">%s</th></tr><tr><th>Release name</th><th>Release relationship</th></tr></thead><tbody>", msg));
display.append(tableContent);
display.append("</tbody></table>");
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ComponentPortlet method serveNewTableRowLinkedRelease.
private void serveNewTableRowLinkedRelease(ResourceRequest request, ResourceResponse response, String[] linkedIds) throws IOException, PortletException {
final User user = UserCacheHolder.getUserFromRequest(request);
List<ReleaseLink> linkedReleases = new ArrayList<>();
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
for (Release release : client.getReleasesById(new HashSet<>(Arrays.asList(linkedIds)), user)) {
final Vendor vendor = release.getVendor();
final String vendorName = vendor != null ? vendor.getShortname() : "";
ReleaseLink linkedRelease = new ReleaseLink(release.getId(), vendorName, release.getName(), release.getVersion(), SW360Utils.printFullname(release), !nullToEmptyMap(release.getReleaseIdToRelationship()).isEmpty());
linkedRelease.setReleaseRelationship(ReleaseRelationship.CONTAINED);
linkedReleases.add(linkedRelease);
}
} catch (TException e) {
log.error("Error getting releases!", e);
throw new PortletException("cannot get releases " + Arrays.toString(linkedIds), e);
}
request.setAttribute(RELEASE_LIST, linkedReleases);
include("/html/utils/ajax/linkedReleasesRelationAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ComponentPortlet method prepareReleaseDetailView.
private void prepareReleaseDetailView(RenderRequest request, RenderResponse response) throws PortletException {
String id = request.getParameter(COMPONENT_ID);
String releaseId = request.getParameter(RELEASE_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
if (isNullOrEmpty(id) && isNullOrEmpty(releaseId)) {
throw new PortletException("Component or Release ID not set!");
}
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
Component component;
Release release = null;
if (!isNullOrEmpty(releaseId)) {
release = client.getReleaseById(releaseId, user);
request.setAttribute(RELEASE_ID, releaseId);
request.setAttribute(RELEASE, release);
request.setAttribute(DOCUMENT_ID, releaseId);
request.setAttribute(DOCUMENT_TYPE, SW360Constants.TYPE_RELEASE);
setAttachmentsInRequest(request, release.getAttachments());
setUsingDocs(request, releaseId, user, client);
putDirectlyLinkedReleaseRelationsInRequest(request, release);
if (isNullOrEmpty(id)) {
id = release.getComponentId();
}
putVulnerabilitiesInRequestRelease(request, releaseId, user);
request.setAttribute(VULNERABILITY_VERIFICATION_EDITABLE, PermissionUtils.isUserAtLeast(UserGroup.SECURITY_ADMIN, user));
}
component = client.getComponentById(id, user);
request.setAttribute(COMPONENT, component);
addComponentBreadcrumb(request, response, component);
if (release != null) {
addReleaseBreadcrumb(request, response, release);
}
} 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._Fields in project sw360portal by sw360.
the class ComponentPortlet method updateRelease.
@UsedAsLiferayAction
public void updateRelease(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(COMPONENT_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
if (id != null) {
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
Component component = client.getComponentById(id, user);
Release release;
String releaseId = request.getParameter(RELEASE_ID);
if (releaseId != null) {
release = client.getReleaseByIdForEdit(releaseId, user);
ComponentPortletUtils.updateReleaseFromRequest(request, release);
String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
RequestStatus requestStatus = client.updateRelease(release, user);
setSessionMessage(request, requestStatus, "Release", "update", printName(release));
cleanUploadHistory(user.getEmail(), releaseId);
response.setRenderParameter(PAGENAME, PAGENAME_RELEASE_DETAIL);
response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
response.setRenderParameter(RELEASE_ID, request.getParameter(RELEASE_ID));
} else {
release = new Release();
release.setComponentId(component.getId());
release.setClearingState(ClearingState.NEW_CLEARING);
ComponentPortletUtils.updateReleaseFromRequest(request, release);
AddDocumentRequestSummary summary = client.addRelease(release, user);
AddDocumentRequestStatus status = summary.getRequestStatus();
switch(status) {
case SUCCESS:
response.setRenderParameter(RELEASE_ID, summary.getId());
String successMsg = "Release " + printName(release) + " added successfully";
SessionMessages.add(request, "request_processed", successMsg);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT_RELEASE);
break;
case DUPLICATE:
setSW360SessionError(request, ErrorMessages.RELEASE_DUPLICATE);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT_RELEASE);
prepareRequestForReleaseEditAfterDuplicateError(request, release);
break;
default:
setSW360SessionError(request, ErrorMessages.RELEASE_NOT_ADDED);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
}
response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
}
} catch (TException e) {
log.error("Error fetching release from backend!", e);
}
}
}
Aggregations