.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);
/** * 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); } }
@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); }
@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; }
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());
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) {
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());
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();
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();
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
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);
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());
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());
(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();
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");
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);
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();
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());