if (!CreativeCommons.isEnabled()) { return; }    Bundle[] bundles = item.getBundles(CC_BUNDLE_NAME);  if ((bundles.length > 0) && (bundles[0] != null)) { item.removeBundle(bundles[0]); }  Bundle bundle = item.createBundle(CC_BUNDLE_NAME);
Bundle bundle = getCcBundle(item);
    public static void setLicense(Context context, Item item,            String cc_license_url) throws SQLException, IOException,            AuthorizeException    {        // only if CC is enabled        if (!CreativeCommons.isEnabled())        {            return;        }        // create the CC bundle if it doesn't exist        // If it does, remove it and create a new one.        Bundle[] bundles = item.getBundles(CC_BUNDLE_NAME);        if ((bundles.length > 0) && (bundles[0] != null))        {            item.removeBundle(bundles[0]);        }        Bundle bundle = item.createBundle(CC_BUNDLE_NAME);        // get some more information        String license_text = fetchLicenseText(cc_license_url);        String license_rdf = fetchLicenseRDF(cc_license_url);        // here we need to transform the license_rdf into a document_rdf        // first we find the beginning of "<License"        int license_start = license_rdf.indexOf("<License");        // the 10 is the length of the license closing tag.        int license_end = license_rdf.indexOf("</License>") + 10;        String document_rdf = "<rdf:RDF xmlns=\"http://web.resource.org/cc/\"\n"                + "   xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"                + "   xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n"                + "<Work rdf:about=\"\">\n"                + "<license rdf:resource=\""                + cc_license_url                + "\">\n"                + "</Work>\n\n"                + license_rdf.substring(license_start, license_end)                + "\n\n</rdf:RDF>";        // set the format        BitstreamFormat bs_format = BitstreamFormat.findByShortDescription(                context, "License");        // set the URL bitstream        setBitstreamFromBytes(item, bundle, BSN_LICENSE_URL, bs_format,                cc_license_url.getBytes());        // set the license text bitstream        setBitstreamFromBytes(item, bundle, BSN_LICENSE_TEXT, bs_format,                license_text.getBytes());        // set the RDF bitstream        setBitstreamFromBytes(item, bundle, BSN_LICENSE_RDF, bs_format,                document_rdf.getBytes());    }