Search in sources :

Example 11 with RequestSummary

use of org.eclipse.sw360.datahandler.thrift.RequestSummary in project sw360portal by sw360.

the class ComponentImportUtils method updateComponents.

private static RequestSummary updateComponents(Iterable<ComponentCSVRecord> compCSVRecords, ComponentService.Iface componentClient, User user) throws TException {
    Set<String> componentNames = new HashSet<>();
    for (Component component : componentClient.getComponentSummaryForExport()) {
        componentNames.add(component.getName());
    }
    Set<Component> toBeUpdated = new HashSet<>();
    for (ComponentCSVRecord componentCSVRecord : compCSVRecords) {
        if (componentCSVRecord.isSetComponent()) {
            String componentName = componentCSVRecord.getComponentName();
            if (componentNames.add(componentName)) {
                Component component = componentCSVRecord.getComponent();
                toBeUpdated.add(component);
            }
        }
    }
    return componentClient.updateComponents(toBeUpdated, user);
}
Also used : Component(org.eclipse.sw360.datahandler.thrift.components.Component)

Example 12 with RequestSummary

use of org.eclipse.sw360.datahandler.thrift.RequestSummary in project sw360portal by sw360.

the class AttachmentHandlerTest method testVacuum_OnlyAdminCanRun.

@Test
public void testVacuum_OnlyAdminCanRun() throws Exception {
    final RequestSummary requestSummary = handler.vacuumAttachmentDB(new User("a", "a", "a").setUserGroup(UserGroup.USER), ImmutableSet.of("A1", "A2"));
    assertThat(requestSummary.requestStatus, is(RequestStatus.FAILURE));
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary)

Example 13 with RequestSummary

use of org.eclipse.sw360.datahandler.thrift.RequestSummary in project sw360portal by sw360.

the class AttachmentHandlerTest method testVacuum_UnusedIdIsDeleted.

@Test
public void testVacuum_UnusedIdIsDeleted() throws Exception {
    final RequestSummary requestSummary = handler.vacuumAttachmentDB(new User("a", "a", "a").setUserGroup(UserGroup.ADMIN), ImmutableSet.of("A1"));
    assertThat(requestSummary.requestStatus, is(RequestStatus.SUCCESS));
    assertThat(requestSummary.totalElements, is(2));
    assertThat(requestSummary.totalAffectedElements, is(1));
    final AttachmentContent a1 = handler.getAttachmentContent("A1");
    assertNotNull(a1);
    exception.expect(SW360Exception.class);
    final AttachmentContent a2 = handler.getAttachmentContent("A2");
    assert (a2 == null);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) AttachmentContent(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary)

Example 14 with RequestSummary

use of org.eclipse.sw360.datahandler.thrift.RequestSummary in project sw360portal by sw360.

the class DatabaseSanitation method deleteAllLicenseInformation.

private void deleteAllLicenseInformation(ResourceRequest request, ResourceResponse response) {
    User user = UserCacheHolder.getUserFromRequest(request);
    LicenseService.Iface licenseClient = thriftClients.makeLicenseClient();
    try {
        RequestSummary requestSummary = licenseClient.deleteAllLicenseInformation(user);
        renderRequestSummary(request, response, requestSummary);
    } catch (TException te) {
        log.error("Got TException when trying to delete all license information.", te);
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) LicenseService(org.eclipse.sw360.datahandler.thrift.licenses.LicenseService) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary)

Example 15 with RequestSummary

use of org.eclipse.sw360.datahandler.thrift.RequestSummary in project sw360portal by sw360.

the class AttachmentVacuum method serveResource.

@Override
public void serveResource(ResourceRequest request, ResourceResponse response) throws IOException, PortletException {
    String action = request.getParameter(PortalConstants.ACTION);
    if (PortalConstants.CLEANUP.equals(action)) {
        try {
            final RequestSummary requestSummary = cleanUpAttachments(request);
            renderRequestSummary(request, response, requestSummary);
        } catch (TException e) {
            log.error("Something went wrong with the cleanup", e);
        }
    }
}
Also used : TException(org.apache.thrift.TException) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary)

Aggregations

RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)17 User (org.eclipse.sw360.datahandler.thrift.users.User)11 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)4 Component (org.eclipse.sw360.datahandler.thrift.components.Component)4 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)4 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)4 CSVRecord (org.apache.commons.csv.CSVRecord)3 TException (org.apache.thrift.TException)3 AttachmentService (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentService)3 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 LicenseService (org.eclipse.sw360.datahandler.thrift.licenses.LicenseService)2 DocumentOperationResult (org.ektorp.DocumentOperationResult)2 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)1 DatabaseRepository (org.eclipse.sw360.datahandler.couchdb.DatabaseRepository)1 PermissionUtils (org.eclipse.sw360.datahandler.permissions.PermissionUtils)1 ReleaseRelationship (org.eclipse.sw360.datahandler.thrift.ReleaseRelationship)1 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)1