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);
}
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));
}
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);
}
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);
}
}
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);
}
}
}
Aggregations