@Override public Bitstream getFirstBitstream(Item item, String bundleName) throws SQLException { List<Bundle> bundles = itemService.getBundles(item, bundleName); if (CollectionUtils.isNotEmpty(bundles)) { List<Bitstream> bitstreams = bundles.get(0).getBitstreams(); if (CollectionUtils.isNotEmpty(bitstreams)) { return bitstreams.get(0); } } return null; }
@Override public void removeLicense(Context context, Item item) throws SQLException, IOException, AuthorizeException { // remove CC license bundle if one exists List<Bundle> bundles = itemService.getBundles(item, CC_BUNDLE_NAME); if ((bundles.size() > 0) && (bundles.get(0) != null)) { itemService.removeBundle(context, item, bundles.get(0)); } }
protected Bundle getCcBundle(Context context, Item item) throws SQLException, AuthorizeException, IOException { List<Bundle> bundles = itemService.getBundles(item, CC_BUNDLE_NAME); if ((bundles.size() > 0) && (bundles.get(0) != null)) { itemService.removeBundle(context, item, bundles.get(0)); } return bundleService.create(context, item, CC_BUNDLE_NAME); }
@Override public boolean hasLicense(Context context, Item item) throws SQLException, IOException { // try to find CC license bundle List<Bundle> bundles = itemService.getBundles(item, CC_BUNDLE_NAME); if (bundles.size() == 0) { return false; } // verify it has correct contents try { if ((getLicenseURL(context, item) == null)) { return false; } } catch (AuthorizeException ae) { return false; } return true; }
@Override public Bitstream getBitstreamByName(Item item, String bundleName, String bitstreamName) throws SQLException { List<Bundle> bundles = itemService.getBundles(item, bundleName); for (int i = 0; i < bundles.size(); i++) { Bundle bundle = bundles.get(i); List<Bitstream> bitstreams = bundle.getBitstreams(); for (int j = 0; j < bitstreams.size(); j++) { Bitstream bitstream = bitstreams.get(j); if (StringUtils.equals(bitstream.getName(), bitstreamName)) { return bitstream; } } } return null; }
/** * This helper method retrieves the bytes of a bitstream for an item under * the CC bundle, with the given bitstream name * * @param item parent item * @param bitstream_name bitstream name to set * @return the bitstream * @throws IOException A general class of exceptions produced by failed or interrupted I/O operations. * @throws SQLException An exception that provides information on a database access error or other errors. * @throws AuthorizeException Exception indicating the current user of the context does not have permission * to perform a particular action. */ protected Bitstream getBitstream(Item item, String bitstream_name) throws SQLException, IOException, AuthorizeException { Bundle cc_bundle = null; // look for the CC bundle try { List<Bundle> bundles = itemService.getBundles(item, CC_BUNDLE_NAME); if ((bundles != null) && (bundles.size() > 0)) { cc_bundle = bundles.get(0); } else { return null; } } catch (Exception exc) { // this exception catching is a bit generic, // but basically it happens if there is no CC bundle return null; } return bundleService.getBitstreamByName(cc_bundle, bitstream_name); }
@Override public boolean filterItem(Context context, Item myItem) throws Exception { // get 'original' bundles List<Bundle> myBundles = itemService.getBundles(myItem, "ORIGINAL"); boolean done = false; for (Bundle myBundle : myBundles) { // now look at all of the bitstreams List<Bitstream> myBitstreams = myBundle.getBitstreams(); for (Bitstream myBitstream : myBitstreams) { done |= filterBitstream(context, myItem, myBitstream); } } return done; }
private List<String> getFileFormats(Item item) { List<String> formats = new ArrayList<>(); try { for (Bundle b : itemService.getBundles(item, "ORIGINAL")) { for (Bitstream bs : b.getBitstreams()) { if (!formats.contains(bs.getFormat(context).getMIMEType())) { formats.add(bs.getFormat(context).getMIMEType()); } } } } catch (SQLException ex) { log.error(ex.getMessage(), ex); } return formats; }
@Override public boolean preProcessBitstream(Context c, Item item, Bitstream source, boolean verbose) throws Exception { String nsrc = source.getName(); for (Bundle b : itemService.getBundles(item, "THUMBNAIL")) { for (Bitstream bit : b.getBitstreams()) { String n = bit.getName();
/** * Find bitstream by its Name, looking in specific named bundle. * * @param item - dspace item whose bundles to search. * @param bsName - name of bitstream to match. * @param bnName - bundle name to match, or null for all. * @return the format found or null if none found. * @throws SQLException if database error */ public static Bitstream getBitstreamByName(Item item, String bsName, String bnName) throws SQLException { List<Bundle> bundles; if (bnName == null) { bundles = item.getBundles(); } else { bundles = itemService.getBundles(item, bnName); } for (Bundle bundle : bundles) { List<Bitstream> bitstreams = bundle.getBitstreams(); for (Bitstream bitstream : bitstreams) { if (bsName.equals(bitstream.getName())) { return bitstream; } } } return null; }
List<Bundle> bundles = itemService.getBundles(item, "CC-LICENSE");
List<Bundle> bundles = itemService.getBundles(i, newBundleName); Bundle targetBundle = null;
originalBundle = itemService.getBundles(item, "ORIGINAL").get(0); } catch (IndexOutOfBoundsException ex) { originalBundle = null;
List<Bundle> bundles = itemService.getBundles(item, Constants.LICENSE_BUNDLE_NAME); for (Bundle bundle : bundles) {
List<Bundle> bundles = itemService.getBundles(item, Constants.LICENSE_BUNDLE_NAME); if (CollectionUtils.isEmpty(bundles)) { lb = bundleService.create(context, item, Constants.LICENSE_BUNDLE_NAME);
Bitstream bestSoFar = null; List<Bundle> contentBundles = itemService.getBundles(item, "ORIGINAL"); for (Bundle bundle : contentBundles) { List<Bitstream> bitstreams = bundle.getBitstreams();
throws SQLException { List<Bundle> bundles = itemService.getBundles(item, "ORIGINAL"); if (bundles.size() == 0) { ItemMarkingInfo markInfo = new ItemMarkingInfo();
List<Bundle> license = itemService.getBundles(i, Constants.LICENSE_BUNDLE_NAME); List<Bundle> license = itemService.getBundles(i, CreativeCommonsService.CC_BUNDLE_NAME); List<Bundle> license = itemService.getBundles(i, CreativeCommonsService.CC_BUNDLE_NAME);
bundles = item.getBundles(); } else { bundles = itemService.getBundles(item, bnName);
Bundle bundle = itemService.getBundles(item, "ORIGINAL").get(0); results = new ArrayList<String>(); for (Bitstream bitstream : bundle.getBitstreams()) {