use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class ProjectRepository method filterAccessibleProjectsByIds.
@NotNull
private Set<Project> filterAccessibleProjectsByIds(User user, Set<String> searchIds) {
final Set<Project> accessibleProjects = getAccessibleProjects(user);
final Set<Project> output = new HashSet<>();
for (Project accessibleProject : accessibleProjects) {
if (searchIds.contains(accessibleProject.getId()))
output.add(accessibleProject);
}
return output;
}
use of org.eclipse.sw360.datahandler.thrift.users.User 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.users.User 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.users.User 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.users.User 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);
}
Aggregations