class FossologyUploader {

    public int uploadToFossology(InputStream inputStream, AttachmentContent attachment, String clearingTeam) {
        try {
            final CapturerOutputStream os = new CapturerOutputStream();

            final String attachmentFilename = attachment.getFilename();
            final String id = attachment.getId();

            assertNotEmpty(id);
            assertNotEmpty(clearingTeam);
            assertNotEmpty(attachmentFilename);

            final String command = String.format(FOSSOLOGY_COMMAND_UPLOAD, sanitizeQuotes(id), sanitizeQuotes(clearingTeam), sanitizeQuotes(attachmentFilename));

            final int exitCode = fossologySshConnector.runInFossologyViaSsh(command, inputStream, os);

            String output = os.getContent();
            if (exitCode != 0) {
                log.error("upload to fossology failed: " + output);
                return -1;
            }
            return parseResultUploadId(output);
        } catch (SW360Exception e) {
            log.error("cannot upload file with id " + attachment.getId() + " (" + attachment.getFilename() + ") to fossology", e);
            return -1;
        }
    }

    @Autowired public  FossologyUploader(FossologySshConnector fossologySshConnector);

}