Source:
private Bitstream processBitstreamCreation(Context context, Item item, InputStream fileInputStream, String properties, String originalFilename) throws AuthorizeException, IOException, SQLException { Bitstream bitstream = null; if (StringUtils.isNotBlank(properties)) { ObjectMapper mapper = new ObjectMapper(); BitstreamPropertiesRest bitstreamPropertiesRest = null; try { bitstreamPropertiesRest = mapper.readValue(properties, BitstreamPropertiesRest.class); } catch (Exception e) { throw new UnprocessableEntityException("The properties parameter was incorrect: " + properties); } String bundleName = bitstreamPropertiesRest.getBundleName(); if (StringUtils.isBlank(bundleName)) { throw new UnprocessableEntityException("Properties without a bundleName is not allowed"); } bitstream = itemService.createSingleBitstream(context, fileInputStream, item, bundleName); if (bitstreamPropertiesRest.getMetadata() != null) { metadataConverter.setMetadata(context, bitstream, bitstreamPropertiesRest.getMetadata()); } String name = bitstreamPropertiesRest.getName(); if (StringUtils.isNotBlank(name)) { bitstream.setName(context, name); } else { bitstream.setName(context, originalFilename); } Integer sequenceId = bitstreamPropertiesRest.getSequenceId(); if (sequenceId != null) { try { bitstreamService.setSequenceId(context, bitstream, item, sequenceId); } catch (IllegalArgumentException e) { throw new UnprocessableEntityException(e.getMessage(), e); } } } else { bitstream = itemService.createSingleBitstream(context, fileInputStream, item); bitstream.setName(context, originalFilename); } BitstreamFormat bitstreamFormat = bitstreamFormatService.guessFormat(context, bitstream); bitstreamService.setFormat(context, bitstream, bitstreamFormat); bitstreamService.update(context, bitstream); return bitstream; }

Target:
private Bitstream processBitstreamCreation(Context context, Item item, InputStream fileInputStream, String properties, String originalFilename) throws AuthorizeException, IOException, SQLException { Bitstream bitstream = null; if (StringUtils.isNotBlank(properties)) { ObjectMapper mapper = new ObjectMapper(); BitstreamRest bitstreamRest = null; try { bitstreamRest = mapper.readValue(properties, BitstreamRest.class); } catch (Exception e) { throw new UnprocessableEntityException("The properties parameter was incorrect: " + properties); } String bundleName = bitstreamRest.getBundleName(); if (StringUtils.isBlank(bundleName)) { throw new UnprocessableEntityException("Properties without a bundleName is not allowed"); } bitstream = itemService.createSingleBitstream(context, fileInputStream, item, bundleName); if (bitstreamRest.getMetadata() != null) { metadataConverter.setMetadata(context, bitstream, bitstreamRest.getMetadata()); } String name = bitstreamRest.getName(); if (StringUtils.isNotBlank(name)) { bitstream.setName(context, name); } else { bitstream.setName(context, originalFilename); } } else { bitstream = itemService.createSingleBitstream(context, fileInputStream, item); bitstream.setName(context, originalFilename); } BitstreamFormat bitstreamFormat = bitstreamFormatService.guessFormat(context, bitstream); bitstreamService.setFormat(context, bitstream, bitstreamFormat); bitstreamService.update(context, bitstream); return bitstream; }