use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class CompareAttachments method renderCompareAttachment.
private void renderCompareAttachment(StringBuilder display, Attachment old, Attachment deleted, Attachment added) {
if (old.equals(added))
return;
display.append(String.format("<table class=\"%s\" id=\"%schanges%s\" >", tableClasses, idPrefix, old.getAttachmentContentId()));
display.append(String.format("<thead><tr><th colspan=\"4\"> Changes for Attachment %s </th></tr>", old.getFilename()));
display.append(String.format("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL));
for (Attachment._Fields field : RELEVANT_FIELDS) {
FieldMetaData fieldMetaData = Attachment.metaDataMap.get(field);
displaySimpleFieldOrSet(display, old, added, deleted, field, fieldMetaData, Release._Fields.ATTACHMENTS.getFieldName());
}
display.append("</tbody></table>");
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class BulkReleaseEdit method doView.
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
final User user = UserCacheHolder.getUserFromRequest(request);
ComponentService.Iface client = thriftClients.makeComponentClient();
try {
final List<Release> releaseSummary = client.getReleaseSummary(user);
request.setAttribute(RELEASE_LIST, releaseSummary);
} catch (TException e) {
log.error("Could not fetch releases from backend", e);
request.setAttribute(RELEASE_LIST, Collections.emptyList());
}
// Proceed with page rendering
super.doView(request, response);
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ComponentPortletUtils method subscribeRelease.
public static RequestStatus subscribeRelease(ResourceRequest request, Logger log) {
String id = request.getParameter(PortalConstants.RELEASE_ID);
if (id != null) {
try {
ComponentService.Iface client = new ThriftClients().makeComponentClient();
User user = UserCacheHolder.getUserFromRequest(request);
return client.subscribeRelease(id, user);
} catch (TException e) {
log.error("Could not subscribe to release", e);
}
}
return RequestStatus.FAILURE;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ComponentPortletUtils method deleteVendor.
public static RequestStatus deleteVendor(PortletRequest request, Logger log) {
String vendorId = request.getParameter(PortalConstants.VENDOR_ID);
if (vendorId != null) {
try {
User user = UserCacheHolder.getUserFromRequest(request);
ThriftClients thriftClients = new ThriftClients();
ComponentService.Iface componentClient = thriftClients.makeComponentClient();
VendorService.Iface client = thriftClients.makeVendorClient();
RequestStatus global_status = RequestStatus.SUCCESS;
List<Release> releases = componentClient.getReleasesFromVendorId(vendorId, user);
boolean mayWriteToAllReleases = true;
for (Release release : releases) {
Map<RequestedAction, Boolean> permissions = release.getPermissions();
mayWriteToAllReleases &= permissions.get(RequestedAction.WRITE);
}
if (!mayWriteToAllReleases) {
return RequestStatus.FAILURE;
}
for (Release release : releases) {
release.unsetVendorId();
RequestStatus local_status = componentClient.updateRelease(release, user);
if (local_status != RequestStatus.SUCCESS)
global_status = local_status;
}
if (global_status == RequestStatus.SUCCESS) {
return client.deleteVendor(vendorId, user);
} else {
return global_status;
}
} catch (TException e) {
log.error("Could not delete release from DB", e);
}
}
return RequestStatus.FAILURE;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class MySubscriptionsPortlet method doView.
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
List<Component> components = null;
List<Release> releases = null;
try {
final User user = UserCacheHolder.getUserFromRequest(request);
ComponentService.Iface componentClient = thriftClients.makeComponentClient();
components = componentClient.getSubscribedComponents(user);
releases = componentClient.getSubscribedReleases(user);
} catch (TException e) {
log.error("Could not fetch your subscriptions from backend", e);
}
request.setAttribute(PortalConstants.COMPONENT_LIST, CommonUtils.nullToEmptyList(components));
request.setAttribute(PortalConstants.RELEASE_LIST, CommonUtils.nullToEmptyList(releases));
super.doView(request, response);
}
Aggregations