本文整理了Java中org.dspace.content.Bundle.getName()
方法的一些代码示例,展示了Bundle.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getName()
方法的具体详情如下:
包路径:org.dspace.content.Bundle
类名称:Bundle
方法名:getName
[英]Get the name of the bundle
[中]获取捆绑包的名称
代码示例来源:origin: DSpace/DSpace
/**
* Predicate, does this bundle container meta-information. I.e.
* does this bundle contain descriptive metadata or other metadata
* such as license bitstreams? If so we probably don't want to put
* it into the "content" section of a package; hence this predicate.
*
* @param bn -- the bundle
* @return true if this bundle name indicates it is a meta-info bundle.
*/
public static boolean isMetaInfoBundle(Bundle bn) {
return (bn.getName().equals(Constants.LICENSE_BUNDLE_NAME) ||
bn.getName().equals(CreativeCommonsService.CC_BUNDLE_NAME) ||
bn.getName().equals(Constants.METADATA_BUNDLE_NAME));
}
代码示例来源:origin: DSpace/DSpace
@Override
public List<Bundle> getBundles(Item item, String name) throws SQLException {
List<Bundle> matchingBundles = new ArrayList<>();
// now only keep bundles with matching names
List<Bundle> bunds = item.getBundles();
for (Bundle bund : bunds) {
if (name.equals(bund.getName())) {
matchingBundles.add(bund);
}
}
return matchingBundles;
}
代码示例来源:origin: DSpace/DSpace
static boolean hasUnsupportedBundle(Item item, String[] bundleList) {
if (bundleList == null) {
return false;
}
ArrayList<String> bundles = new ArrayList<String>();
for (String bundleName : bundleList) {
bundles.add(bundleName.trim());
}
for (Bundle bundle : item.getBundles()) {
if (!bundles.contains(bundle.getName())) {
return true;
}
}
return false;
}
代码示例来源:origin: DSpace/DSpace
/**
* Get the bundles matching a bundle name (name corresponds roughly to type)
*
* @param name
* name of bundle (ORIGINAL/TEXT/THUMBNAIL)
*
* @return the bundles in an unordered array
*/
public List<Bundle> getBundles(String name) {
List<Bundle> matchingBundles = new ArrayList<Bundle>();
// now only keep bundles with matching names
List<Bundle> bunds = getBundles();
for (Bundle bundle : bunds) {
if (name.equals(bundle.getName())) {
matchingBundles.add(bundle);
}
}
return matchingBundles;
}
代码示例来源:origin: DSpace/DSpace
private String getNumberedName(Item item, String name, int number)
throws SQLException {
String nName = name + "." + Integer.toString(number);
List<Bundle> bundles = item.getBundles();
for (Bundle bundle : bundles) {
if (nName.equals(bundle.getName())) {
return this.getNumberedName(item, name, number + 1);
}
}
return nName;
}
}
代码示例来源:origin: DSpace/DSpace
public void removeBundle(Context context, Item item, String name)
throws SQLException, AuthorizeException, IOException {
boolean keep = ConfigurationManager
.getBooleanProperty("swordv2-server", "versions.keep");
Iterator<Bundle> bundles = item.getBundles().iterator();
while (bundles.hasNext()) {
Bundle b = bundles.next();
if (name.equals(b.getName())) {
bundles.remove();
this.removeBundle(context, item, b, keep);
}
}
}
代码示例来源:origin: DSpace/DSpace
static int countBitstream(BundleName bundleName, Item item) {
int count = 0;
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(bundleName.name())) {
continue;
}
count += bundle.getBitstreams().size();
}
return count;
}
代码示例来源:origin: DSpace/DSpace
static List<String> getBitstreamNames(BundleName bundleName, Item item) {
ArrayList<String> names = new ArrayList<String>();
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(bundleName.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
names.add(bit.getName());
}
}
return names;
}
代码示例来源:origin: DSpace/DSpace
public boolean testItem(Context context, Item item) {
try {
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(BundleName.ORIGINAL.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
if (!authorizeService
.authorizeActionBoolean(getAnonContext(), bit, org.dspace.core.Constants.READ)) {
return true;
}
}
}
} catch (SQLException e) {
ItemFilterDefsPerm.log.warn("SQL Exception testing original bitstream access " + e.getMessage(), e);
}
return false;
}
},
代码示例来源:origin: DSpace/DSpace
public boolean testItem(Context context, Item item) {
try {
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(BundleName.THUMBNAIL.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
if (!authorizeService
.authorizeActionBoolean(getAnonContext(), bit, org.dspace.core.Constants.READ)) {
return true;
}
}
}
} catch (SQLException e) {
ItemFilterDefsPerm.log
.warn("SQL Exception testing thumbnail bitstream access " + e.getMessage(), e);
}
return false;
}
},
代码示例来源:origin: DSpace/DSpace
static int countBitstreamByDesc(BundleName bundleName, Item item, String[] descList) {
int count = 0;
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(bundleName.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
for (String desc : descList) {
String bitDesc = bit.getDescription();
if (bitDesc == null) {
continue;
}
if (bitDesc.equals(desc.trim())) {
count++;
}
}
}
}
return count;
}
代码示例来源:origin: DSpace/DSpace
static int countBitstreamMime(Context context, BundleName bundleName, Item item, String[] mimeList) {
int count = 0;
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(bundleName.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
for (String mime : mimeList) {
try {
if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
count++;
}
} catch (SQLException e) {
log.error("Get format error for bitstream " + bit.getName());
}
}
}
}
return count;
}
代码示例来源:origin: DSpace/DSpace
static int countBitstreamMimeStartsWith(Context context, BundleName bundleName, Item item, String prefix) {
int count = 0;
try {
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(bundleName.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
if (bit.getFormat(context).getMIMEType().startsWith(prefix)) {
count++;
}
}
}
} catch (SQLException e) {
// ignore
}
return count;
}
代码示例来源: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
private void buildFullTextList(Item parentItem) {
// now get full text of any bitstreams in the TEXT bundle
// trundle through the bundles
List<Bundle> myBundles = parentItem.getBundles();
for (Bundle myBundle : emptyIfNull(myBundles)) {
if (StringUtils.equals(FULLTEXT_BUNDLE, myBundle.getName())) {
// a-ha! grab the text out of the bitstreams
List<Bitstream> bitstreams = myBundle.getBitstreams();
for (Bitstream fulltextBitstream : emptyIfNull(bitstreams)) {
fullTextStreams.add(new FullTextBitstream(sourceInfo, fulltextBitstream));
log.debug("Added BitStream: "
+ fulltextBitstream.getStoreNumber() + " "
+ fulltextBitstream.getSequenceID() + " "
+ fulltextBitstream.getName());
}
}
}
}
代码示例来源:origin: DSpace/DSpace
static int countBitstreamLargerThanMaxSize(Context context, BundleName bundleName, Item item, String[] mimeList,
String prop) {
long size = DSpaceServicesFactory.getInstance().getConfigurationService().getLongProperty(prop);
int count = 0;
try {
for (Bundle bundle : item.getBundles()) {
if (!bundle.getName().equals(bundleName.name())) {
continue;
}
for (Bitstream bit : bundle.getBitstreams()) {
for (String mime : mimeList) {
if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
if (bit.getSizeBytes() > size) {
count++;
}
}
}
}
}
} catch (SQLException e) {
// ignore
}
return count;
}
代码示例来源:origin: DSpace/DSpace
protected void deleteBundle(Context context, Item item, Bundle b)
throws AuthorizeException, SQLException, IOException {
// Check authorisation
authorizeService.authorizeAction(context, item, Constants.REMOVE);
bundleService.delete(context, b);
log.info(LogManager.getHeader(context, "remove_bundle", "item_id="
+ item.getID() + ",bundle_id=" + b.getID()));
context
.addEvent(new Event(Event.REMOVE, Constants.ITEM, item.getID(), Constants.BUNDLE, b.getID(), b.getName()));
}
代码示例来源:origin: DSpace/DSpace
@Override
public void removeBundle(Context context, Item item, Bundle bundle)
throws SQLException, AuthorizeException, IOException {
// Check authorisation
authorizeService.authorizeAction(context, item, Constants.REMOVE);
log.info(LogManager.getHeader(context, "remove_bundle", "item_id="
+ item.getID() + ",bundle_id=" + bundle.getID()));
context.addEvent(new Event(Event.REMOVE, Constants.ITEM, item.getID(),
Constants.BUNDLE, bundle.getID(), bundle.getName(), getIdentifiers(context, item)));
bundleService.delete(context, bundle);
}
代码示例来源:origin: DSpace/DSpace
@Override
public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException {
log.info(LogManager.getHeader(context, "delete_bundle", "bundle_id="
+ bundle.getID()));
authorizeService.authorizeAction(context, bundle, Constants.DELETE);
context.addEvent(new Event(Event.DELETE, Constants.BUNDLE, bundle.getID(),
bundle.getName(), getIdentifiers(context, bundle)));
// Remove bitstreams
List<Bitstream> bitstreams = bundle.getBitstreams();
bundle.clearBitstreams();
for (Bitstream bitstream : bitstreams) {
removeBitstream(context, bundle, bitstream);
}
List<Item> items = new LinkedList<>(bundle.getItems());
bundle.getItems().clear();
for (Item item : items) {
item.removeBundle(bundle);
}
// Remove ourself
bundleDAO.delete(context, bundle);
}
代码示例来源:origin: DSpace/DSpace
@Override
public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException {
// Check authorisation
authorizeService.authorizeAction(context, item, Constants.ADD);
log.info(LogManager.getHeader(context, "add_bundle", "item_id="
+ item.getID() + ",bundle_id=" + bundle.getID()));
// Check it's not already there
if (item.getBundles().contains(bundle)) {
// Bundle is already there; no change
return;
}
// now add authorization policies from owning item
// hmm, not very "multiple-inclusion" friendly
authorizeService.inheritPolicies(context, item, bundle);
// Add the bundle to in-memory list
item.addBundle(bundle);
bundle.addItem(item);
context.addEvent(new Event(Event.ADD, Constants.ITEM, item.getID(),
Constants.BUNDLE, bundle.getID(), bundle.getName(),
getIdentifiers(context, item)));
}
内容来源于网络,如有侵权,请联系作者删除!