use of org.eclipse.sw360.datahandler.thrift.attachments.CheckStatus 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;
}
use of org.eclipse.sw360.datahandler.thrift.attachments.CheckStatus in project sw360portal by sw360.
the class PortletUtilsTest method setAttachmentCheckStatus.
protected static void setAttachmentCheckStatus(PortletRequest request, CheckStatus... statuses) {
List<String> stringTypes = Lists.newArrayList();
for (CheckStatus status : statuses) {
stringTypes.add("" + status.getValue());
}
Mockito.when(request.getParameterValues(Release._Fields.ATTACHMENTS.toString() + Attachment._Fields.CHECK_STATUS.toString())).thenReturn(stringTypes.toArray(new String[] {}));
}
Aggregations