org.dspace.content.Bitstream.getBundles()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.dspace.content.Bitstream.getBundles()方法的一些代码示例,展示了Bitstream.getBundles()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitstream.getBundles()方法的具体详情如下:
包路径:org.dspace.content.Bitstream
类名称:Bitstream
方法名:getBundles

Bitstream.getBundles介绍

[英]Get the bundles this bitstream appears in
[中]获取此位流出现在其中的捆绑包

代码示例

代码示例来源:origin: DSpace/DSpace

/**
 * Is allowed manage (create, remove, edit) bitstream's policies in the
 * current context?
 *
 * @param context   the DSpace Context Object
 * @param bitstream the bitstream that the policy refer to
 * @throws AuthorizeException if authorization error
 *                            if the current context (current user) is not allowed to
 *                            manage the bitstream's policies
 * @throws SQLException       if database error
 *                            if a db error occur
 */
public static void authorizeManageBitstreamPolicy(Context context,
                         Bitstream bitstream) throws AuthorizeException, SQLException {
  Bundle bundle = bitstream.getBundles().get(0);
  authorizeManageBundlePolicy(context, bundle);
}

代码示例来源:origin: DSpace/DSpace

private Date getLastModified(Context context, Bitstream bitstream)
  throws SQLException {
  Date lm = null;
  List<Bundle> bundles = bitstream.getBundles();
  for (Bundle bundle : bundles) {
    List<Item> items = bundle.getItems();
    for (Item item : items) {
      Date possible = item.getLastModified();
      if (lm == null) {
        lm = possible;
      } else if (possible.getTime() > lm.getTime()) {
        lm = possible;
      }
    }
  }
  if (lm == null) {
    return new Date();
  }
  return lm;
}

代码示例来源:origin: DSpace/DSpace

/**
 * Tests bitstreams for containment in an ORIGINAL bundle
 *
 * @param bitstream Bitstream
 * @return true if the bitstream is in the ORIGINAL bundle
 * @throws BitstreamFilterException if filter error
 */
@Override
public boolean accept(Bitstream bitstream)
  throws BitstreamFilterException {
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle bundle : bundles) {
      if (bundle.getName().equals("ORIGINAL")) {
        return true;
      }
    }
  } catch (SQLException e) {
    throw new BitstreamFilterException(e);
  }
  return false;
}

代码示例来源:origin: DSpace/DSpace

/**
 * Tests bitstream for membership in specified bundles (ORIGINAL, TEXT, THUMBNAIL)
 *
 * @param bitstream Bitstream
 * @return true if bitstream is in specified bundles
 * @throws BitstreamFilterException if error
 */
@Override
public boolean accept(Bitstream bitstream)
  throws BitstreamFilterException {
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle b : bundles) {
      for (String bn : bundlesToEmpty) {
        if (b.getName().equals(bn)) {
          return true;
        }
      }
    }
  } catch (SQLException e) {
    throw new BitstreamFilterException(e);
  }
  return false;
}

代码示例来源:origin: DSpace/DSpace

/**
 * Filter bitstream based on bundle name found in properties file
 *
 * @param bitstream Bitstream
 * @return whether bitstream is in bundle
 * @throws BitstreamFilterException if filter error
 */
@Override
public boolean accept(Bitstream bitstream)
  throws BitstreamFilterException {
  if (bundleName == null) {
    bundleName = props.getProperty("bundle");
    if (bundleName == null) {
      throw new BitstreamFilterException("Property 'bundle' not found.");
    }
  }
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle b : bundles) {
      if (b.getName().equals(bundleName)) {
        return true;
      }
    }
  } catch (SQLException e) {
    throw new BitstreamFilterException(e);
  }
  return false;
}

代码示例来源:origin: DSpace/DSpace

@Override
public DSpaceObject getParentObject(Context context, Bitstream bitstream) throws SQLException {
  List<Bundle> bundles = bitstream.getBundles();
  if (CollectionUtils.isNotEmpty(bundles)) {
    // the ADMIN action is not allowed on Bundle object so skip to the item
    Item item = (Item) bundleService.getParentObject(context, bundles.iterator().next());
    if (item != null) {
      return item;
    } else {
      return null;
    }
  } else if (bitstream.getCommunity() != null) {
    return bitstream.getCommunity();
  } else if (bitstream.getCollection() != null) {
    return bitstream.getCollection();
  }
  return null;
}

代码示例来源:origin: DSpace/DSpace

public void removeBitstream(Context context, Item item, Bitstream bitstream,
              boolean keep)
  throws SQLException, AuthorizeException, IOException {
  Bundle exempt = null;
  if (keep) {
    exempt = this.archiveBitstream(context, item, bitstream);
  }
  Iterator<Bundle> bundles = bitstream.getBundles()
                    .iterator();
  while (bundles.hasNext()) {
    Bundle bundle = bundles.next();
    if (exempt != null &&
      bundle.getID() != exempt.getID()) {
      bundles.remove();
      bundleService
        .removeBitstream(context, bundle,
                 bitstream);
    }
  }
  // there is nowhere in the metadata to say when this file was moved, so we
  // are going to drop it into the description
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
  String desc = bitstream.getDescription();
  String newDesc = "[Deleted on: " + sdf.format(new Date()) + "] ";
  if (desc != null) {
    newDesc += desc;
  }
  bitstream.setDescription(context, newDesc);
  bitstreamService.update(context, bitstream);
}

代码示例来源:origin: DSpace/DSpace

throws DSpaceSWORDException {
try {
  List<Bundle> bundles = bitstream.getBundles();
  Bundle parent = null;
  if (!bundles.isEmpty()) {

代码示例来源:origin: DSpace/DSpace

public void deleteBitstream(Context context, Bitstream bitstream)
  throws SwordError, DSpaceSwordException {
  // this is equivalent to asking whether the media resource in the item can be deleted
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle bundle : bundles) {
      // is the bitstream in the ORIGINAL bundle?  If not, it can't be worked on
      if (!Constants.CONTENT_BUNDLE_NAME
        .equals(bundle.getName())) {
        throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED,
                   "The file is not in a bundle which can be modified");
      }
      List<Item> items = bundle.getItems();
      for (Item item : items) {
        this.deleteMediaResource(context, item);
      }
    }
  } catch (SQLException e) {
    throw new DSpaceSwordException(e);
  }
}

代码示例来源:origin: DSpace/DSpace

public void replaceBitstream(Context context, Bitstream bitstream)
  throws SwordError, DSpaceSwordException {
  // this is equivalent to asking whether the media resource in the item can be deleted
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle bundle : bundles) {
      // is the bitstream in the ORIGINAL bundle?  If not, it can't be worked on
      if (!Constants.CONTENT_BUNDLE_NAME
        .equals(bundle.getName())) {
        throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED,
                   "The file is not in a bundle which can be modified");
      }
      List<Item> items = bundle.getItems();
      for (Item item : items) {
        this.replaceResourceContent(context, item);
      }
    }
  } catch (SQLException e) {
    throw new DSpaceSwordException(e);
  }
}

代码示例来源:origin: DSpace/DSpace

public void deleteBitstream(Context context, Bitstream bitstream)
  throws SwordError, DSpaceSwordException {
  // this is equivalent to asking whether the media resource in the item can be deleted
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle bundle : bundles) {
      // is the bitstream in the ORIGINAL bundle?  If not, it can't be worked on
      if (!Constants.CONTENT_BUNDLE_NAME
        .equals(bundle.getName())) {
        throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED,
                   "The file is not in a bundle which can be modified");
      }
      List<Item> items = bundle.getItems();
      for (Item item : items) {
        this.deleteMediaResource(context, item);
      }
    }
  } catch (SQLException e) {
    throw new DSpaceSwordException(e);
  }
}

代码示例来源:origin: DSpace/DSpace

public void undoDeposit(DepositResult result) throws DSpaceSWORDException {
    try {
      SWORDContext sc = swordService.getSwordContext();
      BundleService bundleService = ContentServiceFactory.getInstance()
                                .getBundleService();

      // obtain the bitstream's owning bundles and remove the bitstream
      // from them.  This will ensure that the bitstream is physically
      // removed from the disk.
      Bitstream bs = result.getBitstream();
      Iterator<Bundle> bundles = bs.getBundles().iterator();
      while (bundles.hasNext()) {
        Bundle bundle = bundles.next();
        bundles.remove();
        bundleService.removeBitstream(sc.getContext(), bundle, bs);
        bundleService.update(sc.getContext(), bundle);
      }

      swordService.message("Removing temporary files from disk");

      // abort the context, so no database changes are written
      sc.abort();
      swordService.message("Database changes aborted");
    } catch (IOException | AuthorizeException | SQLException e) {
      throw new DSpaceSWORDException(e);
    }
  }
}

代码示例来源:origin: DSpace/DSpace

return;
List<Bundle> bundles = bitstream.getBundles();
for (Bundle b : bundles) {
  List<Item> items = b.getItems();

代码示例来源:origin: DSpace/DSpace

@Override
public void delete(Context context, Bitstream bitstream) throws SQLException, AuthorizeException {
  // changed to a check on delete
  // Check authorisation
  authorizeService.authorizeAction(context, bitstream, Constants.DELETE);
  log.info(LogManager.getHeader(context, "delete_bitstream",
                 "bitstream_id=" + bitstream.getID()));
  context.addEvent(new Event(Event.DELETE, Constants.BITSTREAM, bitstream.getID(),
                String.valueOf(bitstream.getSequenceID()), getIdentifiers(context, bitstream)));
  // Remove bitstream itself
  bitstream.setDeleted(true);
  update(context, bitstream);
  //Remove our bitstream from all our bundles
  final List<Bundle> bundles = bitstream.getBundles();
  for (Bundle bundle : bundles) {
    bundle.removeBitstream(bitstream);
  }
  //Remove all bundles from the bitstream object, clearing the connection in 2 ways
  bundles.clear();
  // Remove policies only after the bitstream has been updated (otherwise the current user has not WRITE rights)
  authorizeService.removeAllPolicies(context, bitstream);
}

代码示例来源:origin: DSpace/DSpace

List<Bundle> bundles = bitstream.getBundles();
for (Bundle bundle : bundles) {

代码示例来源:origin: DSpace/DSpace

if (bitstream.getBundles().size() <= 1) {
} else {
  bundle.removeBitstream(bitstream);
  bitstream.getBundles().remove(bundle);

代码示例来源:origin: DSpace/DSpace

List<Bundle> bundles = bit.getBundles();
for (Bundle bundle : bundles) {
  doc1.addField("bundleName", bundle.getName());

代码示例来源:origin: DSpace/DSpace

List<Bundle> bundles = bit.getBundles();
for (Bundle bundle : bundles) {
  doc1.addField("bundleName", bundle.getName());

代码示例来源:origin: DSpace/DSpace

bitstream.getBundles().add(bundle);

代码示例来源:origin: DSpace/DSpace

List<Bundle> bundles = bitstream.getBundles();
for (Bundle bundle : bundles) {
  List<Item> items = bundle.getItems();

相关文章