LicenseUtils { public static void grantLicense(Context context, Item item, String licenseText) throws SQLException, IOException, AuthorizeException { byte[] licenseBytes = licenseText.getBytes("UTF-8"); ByteArrayInputStream bais = new ByteArrayInputStream(licenseBytes); Bitstream b = itemService.createSingleBitstream(context, bais, item, "LICENSE"); b.setName(context, "license.txt"); b.setSource(context, "Written by org.dspace.content.LicenseUtils"); BitstreamFormat bf = bitstreamFormat.findByShortDescription(context, "License"); b.setFormat(bf); bitstreamService.update(context, b); }  static String getLicenseText(Locale locale, Collection collection,
            Item item, EPerson eperson, Map<String, Object> additionalInfo); static String getLicenseText(Locale locale, Collection collection,
            Item item, EPerson eperson); static void grantLicense(Context context, Item item,
            String licenseText);  }
@Test public void testGrantLicense() throws Exception { context.turnOffAuthorisationSystem(); Collection collection = collectionService.create(context, owningCommunity); Item item = installItemService.installItem(context, workspaceItemService.create(context, collection, false)); String defaultLicense = licenseService.getDefaultSubmissionLicense(); LicenseUtils.grantLicense(context, item, defaultLicense); StringWriter writer = new StringWriter(); IOUtils.copy(bitstreamService.retrieve(context, itemService.getBundles(item, "LICENSE").get(0).getBitstreams().get(0)), writer); String license = writer.toString(); assertThat("testGrantLicense 0",license, equalTo(defaultLicense)); context.restoreAuthSystemState(); }