本文整理了Java中org.dspace.content.Bitstream
类的一些代码示例,展示了Bitstream
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitstream
类的具体详情如下:
包路径:org.dspace.content.Bitstream
类名称:Bitstream
[英]Class representing bitstreams stored in the DSpace system.
When modifying the bitstream metadata, changes are not reflected in the database until update
is called. Note that you cannot alter the contents of a bitstream; you need to create a new bitstream.
[中]类,表示存储在DSpace系统中的位流。
修改位流元数据时,在调用update
之前,更改不会反映在数据库中。请注意,您不能更改位流的内容;您需要创建一个新的位流。
代码示例来源:origin: DSpace/DSpace
.getBytes()));
newBitstream.setName(context, bitstream.getName());
newBitstream.setDescription(context, bitstream.getDescription());
newBitstream.setFormat(context, bitstream.getFormat(context));
newBitstream.setSource(context, bitstream.getSource());
newBitstream.setUserFormatDescription(context, bitstream
.getUserFormatDescription());
bitstreamService.update(context, newBitstream);
代码示例来源:origin: DSpace/DSpace
/**
* Add the bitstream metadata to the item
*
* @param item The item
* @param bitstream The bitstream
* @param type The type of bitstream
* @throws SQLException An exception that provides information on a database access error or other errors.
*/
protected void addMetadata(Item item, Bitstream bitstream, String type) throws SQLException {
String value = bitstream.getFormat(Curator.curationContext()).getMIMEType() + "##";
value += bitstream.getName() + "##";
value += bitstream.getSizeBytes() + "##";
value += item.getHandle() + "##";
value += bitstream.getSequenceID() + "##";
value += bitstream.getChecksum() + "##";
if (bitstream.getDescription() != null) {
value += bitstream.getDescription();
}
itemService.addMetadata(Curator.curationContext(), item, "dc", "format", type, "en", value);
}
}
代码示例来源: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
@Override
public int hashCode() {
int hash = 5;
hash += 73 * hash + getType();
hash += 73 * hash + getID().hashCode();
return hash;
}
代码示例来源:origin: DSpace/DSpace
public String getActionableBitstreamUrl(Bitstream bitstream)
throws DSpaceSwordException {
return this.getSwordBaseUrl() + "/edit-media/bitstream/" +
bitstream.getID() + "/" + bitstream.getName();
}
代码示例来源: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: org.dspace/dspace-xmlui-api
validityKey.append(bitstream.getID());
validityKey.append(bitstream.getSequenceID());
validityKey.append(bitstream.getName());
validityKey.append(bitstream.getSource());
validityKey.append(bitstream.getDescription());
validityKey.append(bitstream.getChecksum());
validityKey.append(bitstream.getChecksumAlgorithm());
validityKey.append(bitstream.getSize());
validityKey.append(bitstream.getUserFormatDescription());
validityKey.append(bitstream.getFormat().getDescription());
代码示例来源:origin: DSpace/DSpace
String sid = String.valueOf(bitstream.getSequenceID());
String baseUrl = ConfigurationManager.getProperty("dspace.url");
String handle = null;
List<Bundle> bn = bitstream.getBundles();
if (bn.size() > 0) {
List<Item> bi = bn.get(0).getItems();
String bsName = bitstream.getName();
if (bsName == null) {
List<String> ext = bitstream.getFormat(context).getExtensions();
bsName = "bitstream_" + sid + (ext.size() > 0 ? ext.get(0) : "");
String cks = bitstream.getChecksum();
String cka = bitstream.getChecksumAlgorithm();
if (cks != null && cka != null) {
Element fixity = new Element("fixity", PREMIS_NS);
size.setText(String.valueOf(bitstream.getSizeBytes()));
ochar.addContent(size);
Element formatDes = new Element("formatDesignation", PREMIS_NS);
Element formatName = new Element("formatName", PREMIS_NS);
formatName.setText(bitstream.getFormat(context).getMIMEType());
formatDes.addContent(formatName);
format.addContent(formatDes);
String oname = bitstream.getName();
if (oname == null) {
代码示例来源:origin: DSpace/DSpace
buf.append("------------------------------------------------ \n");
buf.append(msg("format-id")).append(" = ").append(
info.getFormat(context).getID()).append("\n");
buf.append(msg("deleted")).append(" = ").append(info.isDeleted())
.append("\n");
buf.append(msg("bitstream-id")).append(" = ").append(
info.getID()).append("\n");
buf.append(msg("checksum-algorithm")).append(" = ").append(
info.getChecksumAlgorithm()).append("\n");
buf.append(msg("internal-id")).append(" = ").append(
info.getInternalId()).append("\n");
buf.append(msg("name")).append(" = ").append(info.getName())
.append("\n");
buf.append(msg("size")).append(" = ").append(info.getSizeBytes())
.append("\n");
buf.append(msg("source")).append(" = ").append(info.getSource())
.append("\n");
buf.append(msg("checksum")).append(" = ").append(
info.getChecksum()).append("\n");
buf.append(msg("store-number")).append(" = ").append(
info.getStoreNumber()).append("\n");
buf.append(msg("description")).append(" = ").append(
info.getUserFormatDescription()).append("\n");
buf.append("----------------------------------------------- \n\n");
osw.write(buf.toString());
代码示例来源:origin: DSpace/DSpace
throws DSpaceSwordException {
try {
List<Bundle> bundles = bitstream.getBundles();
Bundle parent = null;
if (!bundles.isEmpty()) {
bitstream.getSequenceID() + "/" + bitstream.getName();
} else {
bsLink = bsLink + "/retrieve/" + bitstream.getID() + "/" +
bitstream.getName();
代码示例来源:origin: org.dspace/dspace-xmlui-api
result.setContinue(false);
Bitstream bitstream = Bitstream.find(context, bitstreamID);
BitstreamFormat currentFormat = bitstream.getFormat();
bitstream.setDescription(description);
bitstream.setName(bitstreamName);
Bundle[] bundles = bitstream.getBundles();
if (bundles != null && bundles.length > 0)
if (newFormat != null)
bitstream.setFormat(newFormat);
bitstream.setUserFormatDescription(userFormat);
bitstream.update();
context.commit();
代码示例来源:origin: DSpace/DSpace
if (bitstream.getBundles() != null && !bitstream.getBundles().isEmpty()) {
if (bitstreamService.getParentObject(context, bitstream).getType() == Constants.ITEM) {
bundleName = bitstream.getBundles().get(0).getName();
description = bitstream.getDescription();
format = bitstreamService.getFormatDescription(context, bitstream);
sizeBytes = bitstream.getSizeBytes();
String path = new DSpace().getRequestService().getCurrentRequest().getHttpServletRequest().getContextPath();
retrieveLink = path + "/bitstreams/" + bitstream.getID() + "/retrieve";
mimeType = bitstreamService.getFormat(context, bitstream).getMIMEType();
sequenceId = bitstream.getSequenceID();
CheckSum checkSum = new CheckSum();
checkSum.setCheckSumAlgorith(bitstream.getChecksumAlgorithm());
checkSum.setValue(bitstream.getChecksum());
this.setCheckSum(checkSum);
List<Bundle> bundles = bitstream.getBundles();
for (Bundle bundle : bundles) {
List<org.dspace.authorize.ResourcePolicy> bitstreamsPolicies = bundleService
代码示例来源:origin: DSpace/DSpace
try {
int size = Integer.parseInt(ssize);
if (bitstream.getSizeBytes() != size) {
throw new MetadataValidationException(
"Bitstream size (" + String.valueOf(bitstream.getSizeBytes()) +
") does not match size in PREMIS (" + ssize + "), rejecting it.");
String alg = fixity.getChildTextTrim("messageDigestAlgorithm", PREMIS_NS);
String md = fixity.getChildTextTrim("messageDigest", PREMIS_NS);
String b_alg = bitstream.getChecksumAlgorithm();
String b_md = bitstream.getChecksum();
if (StringUtils.equals(alg, b_alg)) {
if (StringUtils.equals(md, b_md)) {
log.debug("Bitstream checksum agrees with PREMIS: " + bitstream.getName());
} else {
throw new MetadataValidationException(
"Bitstream " + alg + " Checksum does not match value in PREMIS (" + b_md + " != "
+ md + "), for bitstream: " + bitstream
.getName());
log.warn("Cannot test checksum on bitstream=" + bitstream.getName() +
", algorithm in PREMIS is different: " + alg);
bitstream.setName(context, bsName);
log.debug(
"Changing bitstream id=" + String.valueOf(bitstream.getID()) + "name and source to: " + bsName);
bitstream.setFormat(context, bf);
代码示例来源:origin: DSpace/DSpace
List<Bitstream> bitstreams = b.getBitstreams();
for (Bitstream bsm : bitstreams) {
if (bsm.getName().equals(ce.filename)) {
throw new IllegalArgumentException("Duplicate bundle + filename cannot be added: "
+ b.getName() + " + " + bsm.getName());
bs.setName(context, ce.filename);
bs.setDescription(context, ce.description);
itarch.addUndoDeleteContents(bs.getID());
代码示例来源:origin: org.dspace/dspace-xmlui-api
Bitstream bitstream = Bitstream.find(context, bitstreamID);
BitstreamFormat currentFormat = bitstream.getFormat();
BitstreamFormat[] bitstreamFormats = AuthorizeManager.isAdmin(context) ?
BitstreamFormat.findAll(context) :
Bundle[] bundles = bitstream.getBundles();
if (bundles != null && bundles.length > 0)
String fileUrl = contextPath + "/bitstream/id/" +bitstream.getID() + "/" + bitstream.getName();
String fileName = bitstream.getName();
description.setLabel(T_description_label);
description.setHelp(T_description_help);
description.setValue(bitstream.getDescription());
userFormat.setLabel(T_user_label);
userFormat.setHelp(T_user_help);
userFormat.setValue(bitstream.getUserFormatDescription());
代码示例来源:origin: DSpace/DSpace
(pluginName != null ? FILTER_PLUGIN_SEPARATOR + pluginName : ""));
if (fmts.contains(myBitstream.getFormat(context).getShortDescription())) {
try {
List<Bundle> bundles = myBitstream.getBundles();
long size = myBitstream.getSizeBytes();
String checksum = myBitstream.getChecksum() + " (" + myBitstream.getChecksumAlgorithm() + ")";
int assetstore = myBitstream.getStoreNumber();
if (mimeTypes != null) {
for (String mimeType : mimeTypes) {
if (mimeType.equalsIgnoreCase(myBitstream.getFormat(context).getMIMEType())) {
applyFilter = true;
if (descriptions != null) {
for (String desc : descriptions) {
if (desc.equalsIgnoreCase(myBitstream.getFormat(context).getShortDescription())) {
applyFilter = true;
if (extensions != null) {
for (String ext : extensions) {
List<String> formatExtensions = myBitstream.getFormat(context).getExtensions();
if (formatExtensions != null && formatExtensions.contains(ext)) {
applyFilter = true;
+ myBitstream.getID() + " " + e);
e.printStackTrace();
代码示例来源:origin: DSpace/DSpace
if (displayMap.containsKey(bitstream.getName())) {
bundleService.removeBitstream(context, dBundle, displayMap.get(bitstream.getName()));
citedBitstream.setName(context, bitstream.getName());
bitstreamService.setFormat(context, citedBitstream, bitstream.getFormat(Curator.curationContext()));
citedBitstream.setDescription(context, bitstream.getDescription());
+ citedBitstream.getName()
+ " to the " + CitationPage.DISPLAY_BUNDLE_NAME + " bundle.\n");
代码示例来源:origin: DSpace/DSpace
dspaceBitstream.setSource(context, "DSpace REST API");
dspaceBitstream.setFormat(context, bitstreamFormatService.findUnknown(context));
} else {
bitstreamService.setFormat(context, dspaceBitstream, bitstreamFormatService
dspaceBitstream.setName(context, name);
dspaceBitstream.setDescription(context, description);
bundles = dspaceBitstream.getBundles();
for (Bundle dspaceBundle : bundles) {
List<org.dspace.authorize.ResourcePolicy> bitstreamsPolicies = bundleService
.ResourcePolicy>();
for (org.dspace.authorize.ResourcePolicy policy : bitstreamsPolicies) {
if (policy.getdSpaceObject().getID().equals(dspaceBitstream.getID())) {
policiesToRemove.add(policy);
dspaceBitstream = bitstreamService.find(context, dspaceBitstream.getID());
bitstream = new Bitstream(dspaceBitstream, servletContext, "", context);
代码示例来源:origin: org.dspace/dspace-xmlui-api
if (owningCollection != null)
Bundle bnd = bitstream.getBundles()[0];
bnd.inheritCollectionDefaultPolicies(owningCollection);
bitstream.setName(name);
bitstream.setSource(filePart.getUploadName());
bitstream.setDescription(request.getParameter("description"));
bitstream.setFormat(format);
bitstream.update();
item.update();
代码示例来源:origin: org.dspace/dspace-xmlui-api
BitstreamFormat currentFormat = bitstream.getFormat();
BitstreamFormat guessedFormat = FormatIdentifier.guessFormat(context, bitstream);
BitstreamFormat[] bitstreamFormats = BitstreamFormat.findNonInternal(context);
String fileUrl = contextPath + "/bitstream/item/" + itemID + "/" + bitstream.getName();
String fileName = bitstream.getName();
description.setLabel(T_description);
description.setHelp(T_description_help);
description.setValue(bitstream.getDescription());
userFormat.setLabel(T_format_user);
userFormat.setHelp(T_format_user_help);
userFormat.setValue(bitstream.getUserFormatDescription());
div.addHidden("bitstream_id").setValue(bitstream.getID());
内容来源于网络,如有侵权,请联系作者删除!