use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class UserResourceProcessor method process.
@Override
public Resource<User> process(Resource<User> resource) {
try {
User user = resource.getContent();
String userUUID = Base64.getEncoder().encodeToString(user.getEmail().getBytes("utf-8"));
Link selfLink = linkTo(UserController.class).slash("api/users/" + userUUID).withSelfRel();
resource.add(selfLink);
return resource;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class Sw360VulnerabilityService method getVulnerabilityWithReleaseRelationsByExternalId.
public Vulnerability getVulnerabilityWithReleaseRelationsByExternalId(String externalId, User sw360User) {
try {
VulnerabilityService.Iface sw360VulnerabilityClient = getThriftVulnerabilityClient();
final VulnerabilityWithReleaseRelations vulWithRel = sw360VulnerabilityClient.getVulnerabilityWithReleaseRelationsByExternalId(externalId, sw360User);
return vulWithRel.getVulnerability();
} catch (TException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class ComponentTest method before.
@Before
public void before() throws TException {
List<Component> componentList = new ArrayList<>();
Component component = new Component();
component.setName("Component name");
component.setDescription("Component description");
componentList.add(component);
given(this.componentServiceMock.getComponentsForUser(anyObject())).willReturn(componentList);
User user = new User();
user.setId("admin@sw360.org");
user.setEmail("admin@sw360.org");
user.setFullname("John Doe");
given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class Sw360AttachmentService method downloadAttachmentWithContext.
public void downloadAttachmentWithContext(Object context, String attachmentId, HttpServletResponse response, OAuth2Authentication oAuth2Authentication) {
User sw360User = restControllerHelper.getSw360UserFromAuthentication(oAuth2Authentication);
AttachmentContent attachmentContent = getAttachmentContent(attachmentId);
String filename = attachmentContent.getFilename();
String contentType = attachmentContent.getContentType();
try (InputStream attachmentStream = getStreamToAttachments(Collections.singleton(attachmentContent), sw360User, context)) {
response.setContentType(contentType);
response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", filename));
FileCopyUtils.copy(attachmentStream, response.getOutputStream());
} catch (TException | IOException e) {
log.error(e.getMessage());
}
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class Sw360AttachmentService method uploadAttachment.
public Attachment uploadAttachment(MultipartFile file, Attachment newAttachment, User sw360User) throws IOException, TException {
// TODO: shouldn't the fileName be taken from newAttachment?
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
final AttachmentContent attachmentContent = makeAttachmentContent(fileName, contentType);
final AttachmentConnector attachmentConnector = getConnector();
Attachment attachment = new AttachmentFrontendUtils().uploadAttachmentContent(attachmentContent, file.getInputStream(), sw360User);
attachment.setSha1(attachmentConnector.getSha1FromAttachmentContentId(attachmentContent.getId()));
AttachmentType attachmentType = newAttachment.getAttachmentType();
if (attachmentType != null) {
attachment.setAttachmentType(attachmentType);
}
CheckStatus checkStatus = newAttachment.getCheckStatus();
if (checkStatus != null) {
attachment.setCheckStatus(checkStatus);
}
return attachment;
}
Aggregations