use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class RepositoryUtils method doBulk.
// This works with any repository
public static RequestSummary doBulk(Collection<?> objects, User user, DatabaseRepository<?> repository) {
RequestSummary requestSummary = new RequestSummary();
if (PermissionUtils.isAdmin(user)) {
// Prepare component for database
final List<DocumentOperationResult> documentOperationResults = repository.executeBulk(objects);
requestSummary.setTotalElements(objects.size());
requestSummary.setTotalAffectedElements(objects.size() - documentOperationResults.size());
requestSummary.setRequestStatus(RequestStatus.SUCCESS);
} else {
requestSummary.setRequestStatus(RequestStatus.FAILURE);
}
return requestSummary;
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentRepository method getRecentComponentsSummary.
public List<Component> getRecentComponentsSummary(int limit, User user) {
ViewQuery query = createQuery("byCreatedOn").includeDocs(true).descending(true);
if (limit >= 0) {
query.limit(limit);
}
List<Component> components = db.queryView(query, Component.class);
return makeSummaryWithPermissionsFromFullDocs(SummaryType.SUMMARY, components, user);
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentController method getComponent.
@RequestMapping(value = COMPONENTS_URL + "/{id}", method = RequestMethod.GET)
public ResponseEntity<Resource<Component>> getComponent(@PathVariable("id") String id, OAuth2Authentication oAuth2Authentication) throws TException {
User user = restControllerHelper.getSw360UserFromAuthentication(oAuth2Authentication);
Component sw360Component = componentService.getComponentForUserById(id, user);
HalResource<Component> userHalResource = createHalComponent(sw360Component, user);
return new ResponseEntity<>(userHalResource, HttpStatus.OK);
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentController method downloadAttachmentFromComponent.
@RequestMapping(value = COMPONENTS_URL + "/{componentId}/attachments/{attachmentId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public void downloadAttachmentFromComponent(@PathVariable("componentId") String componentId, @PathVariable("attachmentId") String attachmentId, HttpServletResponse response, OAuth2Authentication oAuth2Authentication) throws TException {
final User sw360User = restControllerHelper.getSw360UserFromAuthentication(oAuth2Authentication);
final Component component = componentService.getComponentForUserById(componentId, sw360User);
attachmentService.downloadAttachmentWithContext(component, attachmentId, response, oAuth2Authentication);
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class Sw360ComponentService method updateComponent.
public RequestStatus updateComponent(Component component, User sw360User) throws TException {
ComponentService.Iface sw360ComponentClient = getThriftComponentClient();
RequestStatus requestStatus = sw360ComponentClient.updateComponent(component, sw360User);
if (requestStatus != RequestStatus.SUCCESS) {
throw new RuntimeException("sw360 component with name '" + component.getName() + " cannot be updated.");
}
return requestStatus;
}
Aggregations