Search in sources :

Example 1 with CheckStatus

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;
}
Also used : AttachmentFrontendUtils(org.eclipse.sw360.commonIO.AttachmentFrontendUtils) AttachmentConnector(org.eclipse.sw360.datahandler.couchdb.AttachmentConnector)

Example 2 with CheckStatus

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[] {}));
}
Also used : CheckStatus(org.eclipse.sw360.datahandler.thrift.attachments.CheckStatus)

Aggregations

AttachmentFrontendUtils (org.eclipse.sw360.commonIO.AttachmentFrontendUtils)1 AttachmentConnector (org.eclipse.sw360.datahandler.couchdb.AttachmentConnector)1 CheckStatus (org.eclipse.sw360.datahandler.thrift.attachments.CheckStatus)1