Search in sources :

Example 36 with Release._Fields

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>");
}
Also used : FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) Attachment(org.eclipse.sw360.datahandler.thrift.attachments.Attachment)

Example 37 with Release._Fields

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);
}
Also used : 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 38 with Release._Fields

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;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 39 with Release._Fields

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;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) RequestedAction(org.eclipse.sw360.datahandler.thrift.users.RequestedAction) VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService)

Example 40 with Release._Fields

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);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

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