mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 12:33:18 +00:00
[DS-3895] Rename Bitstream.getSize() to getSizeBytes().
This commit is contained in:
@@ -547,7 +547,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
// add up the size
|
// add up the size
|
||||||
size += bitstream.getSize();
|
size += bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.add(item.getID());
|
items.add(item.getID());
|
||||||
@@ -574,7 +574,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
// add up the size
|
// add up the size
|
||||||
size += bitstream.getSize();
|
size += bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.add(item.getID());
|
items.add(item.getID());
|
||||||
@@ -593,7 +593,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
// add up the size
|
// add up the size
|
||||||
size += bitstream.getSize();
|
size += bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<UUID> items = new ArrayList<>();
|
ArrayList<UUID> items = new ArrayList<>();
|
||||||
|
@@ -220,7 +220,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String handle = myItem.getHandle();
|
String handle = myItem.getHandle();
|
||||||
List<Bundle> bundles = myBitstream.getBundles();
|
List<Bundle> bundles = myBitstream.getBundles();
|
||||||
long size = myBitstream.getSize();
|
long size = myBitstream.getSizeBytes();
|
||||||
String checksum = myBitstream.getChecksum() + " (" + myBitstream.getChecksumAlgorithm() + ")";
|
String checksum = myBitstream.getChecksum() + " (" + myBitstream.getChecksumAlgorithm() + ")";
|
||||||
int assetstore = myBitstream.getStoreNumber();
|
int assetstore = myBitstream.getStoreNumber();
|
||||||
|
|
||||||
|
@@ -86,7 +86,7 @@ public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
|||||||
if (priority1 > priority2) {
|
if (priority1 > priority2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (priority1 == priority2) {
|
} else if (priority1 == priority2) {
|
||||||
if (b1.getSize() <= b2.getSize()) {
|
if (b1.getSizeBytes() <= b2.getSizeBytes()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -366,7 +366,7 @@ public class SyndicationFeed {
|
|||||||
if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
|
if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
|
||||||
SyndEnclosure enc = new SyndEnclosureImpl();
|
SyndEnclosure enc = new SyndEnclosureImpl();
|
||||||
enc.setType(bit.getFormat(context).getMIMEType());
|
enc.setType(bit.getFormat(context).getMIMEType());
|
||||||
enc.setLength(bit.getSize());
|
enc.setLength(bit.getSizeBytes());
|
||||||
enc.setUrl(urlOfBitstream(request, bit));
|
enc.setUrl(urlOfBitstream(request, bit));
|
||||||
enclosures.add(enc);
|
enclosures.add(enc);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -92,7 +92,7 @@ public class ResultsLogger implements ChecksumResultsCollector {
|
|||||||
LOG.info(msg("internal-id") + ": " + bitstream.getInternalId());
|
LOG.info(msg("internal-id") + ": " + bitstream.getInternalId());
|
||||||
LOG.info(msg("name") + ": " + bitstream.getName());
|
LOG.info(msg("name") + ": " + bitstream.getName());
|
||||||
LOG.info(msg("store-number") + ": " + bitstream.getStoreNumber());
|
LOG.info(msg("store-number") + ": " + bitstream.getStoreNumber());
|
||||||
LOG.info(msg("size") + ": " + bitstream.getSize());
|
LOG.info(msg("size") + ": " + bitstream.getSizeBytes());
|
||||||
LOG.info(msg("bitstream-format") + ": " + (bitstream.getFormat(context) != null ? bitstream.getFormat(context)
|
LOG.info(msg("bitstream-format") + ": " + (bitstream.getFormat(context) != null ? bitstream.getFormat(context)
|
||||||
.getID() : "-1"));
|
.getID() : "-1"));
|
||||||
LOG.info(msg("user-format-description") + ": "
|
LOG.info(msg("user-format-description") + ": "
|
||||||
|
@@ -306,7 +306,7 @@ public class SimpleReporterServiceImpl implements SimpleReporterService {
|
|||||||
info.getInternalId()).append("\n");
|
info.getInternalId()).append("\n");
|
||||||
buf.append(msg("name")).append(" = ").append(info.getName())
|
buf.append(msg("name")).append(" = ").append(info.getName())
|
||||||
.append("\n");
|
.append("\n");
|
||||||
buf.append(msg("size")).append(" = ").append(info.getSize())
|
buf.append(msg("size")).append(" = ").append(info.getSizeBytes())
|
||||||
.append("\n");
|
.append("\n");
|
||||||
buf.append(msg("source")).append(" = ").append(info.getSource())
|
buf.append(msg("source")).append(" = ").append(info.getSource())
|
||||||
.append("\n");
|
.append("\n");
|
||||||
|
@@ -212,7 +212,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
*
|
*
|
||||||
* @return the size in bytes
|
* @return the size in bytes
|
||||||
*/
|
*/
|
||||||
public long getSize() {
|
public long getSizeBytes() {
|
||||||
return sizeBytes;
|
return sizeBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -233,7 +233,7 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
// Add sizes and checksums of bitstreams
|
// Add sizes and checksums of bitstreams
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
myMessage.append(bitstream.getName()).append(": ")
|
myMessage.append(bitstream.getName()).append(": ")
|
||||||
.append(bitstream.getSize()).append(" bytes, checksum: ")
|
.append(bitstream.getSizeBytes()).append(" bytes, checksum: ")
|
||||||
.append(bitstream.getChecksum()).append(" (")
|
.append(bitstream.getChecksum()).append(" (")
|
||||||
.append(bitstream.getChecksumAlgorithm()).append(")\n");
|
.append(bitstream.getChecksumAlgorithm()).append(")\n");
|
||||||
}
|
}
|
||||||
|
@@ -236,7 +236,7 @@ public class OREDisseminationCrosswalk
|
|||||||
bs.getName()) + "?sequence=" + bs.getSequenceID());
|
bs.getName()) + "?sequence=" + bs.getSequenceID());
|
||||||
arLink.setAttribute("title", bs.getName());
|
arLink.setAttribute("title", bs.getName());
|
||||||
arLink.setAttribute("type", bs.getFormat(context).getMIMEType());
|
arLink.setAttribute("type", bs.getFormat(context).getMIMEType());
|
||||||
arLink.setAttribute("length", Long.toString(bs.getSize()));
|
arLink.setAttribute("length", Long.toString(bs.getSizeBytes()));
|
||||||
|
|
||||||
aggregation.addContent(arLink);
|
aggregation.addContent(arLink);
|
||||||
|
|
||||||
|
@@ -108,9 +108,9 @@ public class PREMISCrosswalk
|
|||||||
if (ssize != null) {
|
if (ssize != null) {
|
||||||
try {
|
try {
|
||||||
int size = Integer.parseInt(ssize);
|
int size = Integer.parseInt(ssize);
|
||||||
if (bitstream.getSize() != size) {
|
if (bitstream.getSizeBytes() != size) {
|
||||||
throw new MetadataValidationException(
|
throw new MetadataValidationException(
|
||||||
"Bitstream size (" + String.valueOf(bitstream.getSize()) +
|
"Bitstream size (" + String.valueOf(bitstream.getSizeBytes()) +
|
||||||
") does not match size in PREMIS (" + ssize + "), rejecting it.");
|
") does not match size in PREMIS (" + ssize + "), rejecting it.");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ne) {
|
} catch (NumberFormatException ne) {
|
||||||
@@ -274,7 +274,7 @@ public class PREMISCrosswalk
|
|||||||
|
|
||||||
// size
|
// size
|
||||||
Element size = new Element("size", PREMIS_NS);
|
Element size = new Element("size", PREMIS_NS);
|
||||||
size.setText(String.valueOf(bitstream.getSize()));
|
size.setText(String.valueOf(bitstream.getSizeBytes()));
|
||||||
ochar.addContent(size);
|
ochar.addContent(size);
|
||||||
|
|
||||||
// Punt and set formatName to the MIME type; the best we can
|
// Punt and set formatName to the MIME type; the best we can
|
||||||
|
@@ -53,7 +53,6 @@ import edu.harvard.hul.ois.mets.helper.MetsException;
|
|||||||
import edu.harvard.hul.ois.mets.helper.MetsValidator;
|
import edu.harvard.hul.ois.mets.helper.MetsValidator;
|
||||||
import edu.harvard.hul.ois.mets.helper.MetsWriter;
|
import edu.harvard.hul.ois.mets.helper.MetsWriter;
|
||||||
import edu.harvard.hul.ois.mets.helper.PreformedXML;
|
import edu.harvard.hul.ois.mets.helper.PreformedXML;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.app.util.Util;
|
import org.dspace.app.util.Util;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||||
@@ -86,6 +85,8 @@ import org.jdom.Element;
|
|||||||
import org.jdom.Namespace;
|
import org.jdom.Namespace;
|
||||||
import org.jdom.output.Format;
|
import org.jdom.output.Format;
|
||||||
import org.jdom.output.XMLOutputter;
|
import org.jdom.output.XMLOutputter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for disseminator of
|
* Base class for disseminator of
|
||||||
@@ -124,7 +125,7 @@ public abstract class AbstractMETSDisseminator
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(AbstractMETSDisseminator.class);
|
private static final Logger log = LoggerFactory.getLogger(AbstractMETSDisseminator.class);
|
||||||
|
|
||||||
// JDOM xml output writer - indented format for readability.
|
// JDOM xml output writer - indented format for readability.
|
||||||
protected static XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
|
protected static XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
|
||||||
@@ -442,7 +443,7 @@ public abstract class AbstractMETSDisseminator
|
|||||||
log.debug(new StringBuilder().append("Writing CONTENT stream of bitstream(")
|
log.debug(new StringBuilder().append("Writing CONTENT stream of bitstream(")
|
||||||
.append(bitstream.getID()).append(") to Zip: ")
|
.append(bitstream.getID()).append(") to Zip: ")
|
||||||
.append(zname).append(", size=")
|
.append(zname).append(", size=")
|
||||||
.append(bitstream.getSize()).toString());
|
.append(bitstream.getSizeBytes()).toString());
|
||||||
}
|
}
|
||||||
if (lmTime != 0) {
|
if (lmTime != 0) {
|
||||||
ze.setTime(lmTime);
|
ze.setTime(lmTime);
|
||||||
@@ -451,7 +452,7 @@ public abstract class AbstractMETSDisseminator
|
|||||||
// contents are unchanged
|
// contents are unchanged
|
||||||
ze.setTime(DEFAULT_MODIFIED_DATE);
|
ze.setTime(DEFAULT_MODIFIED_DATE);
|
||||||
}
|
}
|
||||||
ze.setSize(auth ? bitstream.getSize() : 0);
|
ze.setSize(auth ? bitstream.getSizeBytes() : 0);
|
||||||
zip.putNextEntry(ze);
|
zip.putNextEntry(ze);
|
||||||
if (auth) {
|
if (auth) {
|
||||||
InputStream input = bitstreamService.retrieve(context, bitstream);
|
InputStream input = bitstreamService.retrieve(context, bitstream);
|
||||||
@@ -483,10 +484,12 @@ public abstract class AbstractMETSDisseminator
|
|||||||
String zname = makeBitstreamURL(context, logoBs, params);
|
String zname = makeBitstreamURL(context, logoBs, params);
|
||||||
ZipEntry ze = new ZipEntry(zname);
|
ZipEntry ze = new ZipEntry(zname);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Writing CONTENT stream of bitstream(" + String
|
log.debug("Writing CONTENT stream of bitstream({}) to Zip: {}, size={}",
|
||||||
.valueOf(logoBs.getID()) + ") to Zip: " + zname + ", size=" + String.valueOf(logoBs.getSize()));
|
String.valueOf(logoBs.getID()),
|
||||||
|
zname,
|
||||||
|
String.valueOf(logoBs.getSizeBytes()));
|
||||||
}
|
}
|
||||||
ze.setSize(logoBs.getSize());
|
ze.setSize(logoBs.getSizeBytes());
|
||||||
//Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged
|
//Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged
|
||||||
ze.setTime(DEFAULT_MODIFIED_DATE);
|
ze.setTime(DEFAULT_MODIFIED_DATE);
|
||||||
zip.putNextEntry(ze);
|
zip.putNextEntry(ze);
|
||||||
@@ -921,7 +924,7 @@ public abstract class AbstractMETSDisseminator
|
|||||||
}
|
}
|
||||||
file.setGROUPID(groupID);
|
file.setGROUPID(groupID);
|
||||||
file.setMIMETYPE(bitstream.getFormat(context).getMIMEType());
|
file.setMIMETYPE(bitstream.getFormat(context).getMIMEType());
|
||||||
file.setSIZE(auth ? bitstream.getSize() : 0);
|
file.setSIZE(auth ? bitstream.getSizeBytes() : 0);
|
||||||
|
|
||||||
// Translate checksum and type to METS
|
// Translate checksum and type to METS
|
||||||
String csType = bitstream.getChecksumAlgorithm();
|
String csType = bitstream.getChecksumAlgorithm();
|
||||||
@@ -1077,7 +1080,7 @@ public abstract class AbstractMETSDisseminator
|
|||||||
String fileID = gensym("logo");
|
String fileID = gensym("logo");
|
||||||
file.setID(fileID);
|
file.setID(fileID);
|
||||||
file.setMIMETYPE(logoBs.getFormat(context).getMIMEType());
|
file.setMIMETYPE(logoBs.getFormat(context).getMIMEType());
|
||||||
file.setSIZE(logoBs.getSize());
|
file.setSIZE(logoBs.getSizeBytes());
|
||||||
|
|
||||||
// Translate checksum and type to METS
|
// Translate checksum and type to METS
|
||||||
String csType = logoBs.getChecksumAlgorithm();
|
String csType = logoBs.getChecksumAlgorithm();
|
||||||
|
@@ -116,7 +116,7 @@ public class BitstreamsIntoMetadata extends AbstractCurationTask {
|
|||||||
protected void addMetadata(Item item, Bitstream bitstream, String type) throws SQLException {
|
protected void addMetadata(Item item, Bitstream bitstream, String type) throws SQLException {
|
||||||
String value = bitstream.getFormat(Curator.curationContext()).getMIMEType() + "##";
|
String value = bitstream.getFormat(Curator.curationContext()).getMIMEType() + "##";
|
||||||
value += bitstream.getName() + "##";
|
value += bitstream.getName() + "##";
|
||||||
value += bitstream.getSize() + "##";
|
value += bitstream.getSizeBytes() + "##";
|
||||||
value += item.getHandle() + "##";
|
value += item.getHandle() + "##";
|
||||||
value += bitstream.getSequenceID() + "##";
|
value += bitstream.getSequenceID() + "##";
|
||||||
value += bitstream.getChecksum() + "##";
|
value += bitstream.getChecksum() + "##";
|
||||||
|
@@ -168,7 +168,7 @@ public class FullTextContentStreams extends ContentStreamBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getSize() {
|
public long getSize() {
|
||||||
return bitstream.getSize();
|
return bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStream() throws SQLException, IOException, AuthorizeException {
|
public InputStream getInputStream() throws SQLException, IOException, AuthorizeException {
|
||||||
|
@@ -381,7 +381,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
|||||||
log.info("Copying bitstream:" + bitstream
|
log.info("Copying bitstream:" + bitstream
|
||||||
.getID() + " from assetstore[" + assetstoreSource + "] to assetstore[" + assetstoreDestination + "] " +
|
.getID() + " from assetstore[" + assetstoreSource + "] to assetstore[" + assetstoreDestination + "] " +
|
||||||
"Name:" + bitstream
|
"Name:" + bitstream
|
||||||
.getName() + ", SizeBytes:" + bitstream.getSize());
|
.getName() + ", SizeBytes:" + bitstream.getSizeBytes());
|
||||||
|
|
||||||
InputStream inputStream = retrieve(context, bitstream);
|
InputStream inputStream = retrieve(context, bitstream);
|
||||||
stores.get(assetstoreDestination).put(bitstream, inputStream);
|
stores.get(assetstoreDestination).put(bitstream, inputStream);
|
||||||
|
@@ -94,9 +94,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("application/pdf");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("application/pdf");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/pdf");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/pdf");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/pdf");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/pdf");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -136,9 +136,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -157,9 +157,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("application/pdf");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("application/pdf");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/pdf");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/pdf");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/pdf");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/pdf");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -181,9 +181,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("unknown");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("unknown");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(400));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(400));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -203,9 +203,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("unknown");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("unknown");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("unknown");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("unknown");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("unknown");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("unknown");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -242,9 +242,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNoMimeType() throws Exception {
|
public void testNoMimeType() throws Exception {
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -295,9 +295,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -318,9 +318,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -342,9 +342,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -362,9 +362,9 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("audio/x-wav");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("audio/x-wav");
|
||||||
when(bitstream1.getSize()).thenReturn(Long.valueOf(300));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
when(bitstream2.getSize()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSize()).thenReturn(Long.valueOf(100));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
|
@@ -292,12 +292,12 @@ public class BitstreamTest extends AbstractDSpaceObjectTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of getSize method, of class Bitstream.
|
* Test of getSizeBytes method, of class Bitstream.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetSize() {
|
public void testGetSize() {
|
||||||
long size = 238413; // yuck, hardcoded!
|
long size = 238413; // yuck, hardcoded!
|
||||||
assertThat("testGetSize 0", bs.getSize(), equalTo(size));
|
assertThat("testGetSize 0", bs.getSizeBytes(), equalTo(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -225,11 +225,11 @@ public class InstallItemTest extends AbstractUnitTest {
|
|||||||
// Create provenance description
|
// Create provenance description
|
||||||
String testMessage = "No. of bitstreams: 2\n";
|
String testMessage = "No. of bitstreams: 2\n";
|
||||||
testMessage += "one: "
|
testMessage += "one: "
|
||||||
+ one.getSize() + " bytes, checksum: "
|
+ one.getSizeBytes() + " bytes, checksum: "
|
||||||
+ one.getChecksum() + " ("
|
+ one.getChecksum() + " ("
|
||||||
+ one.getChecksumAlgorithm() + ")\n";
|
+ one.getChecksumAlgorithm() + ")\n";
|
||||||
testMessage += "two: "
|
testMessage += "two: "
|
||||||
+ two.getSize() + " bytes, checksum: "
|
+ two.getSizeBytes() + " bytes, checksum: "
|
||||||
+ two.getChecksum() + " ("
|
+ two.getChecksum() + " ("
|
||||||
+ two.getChecksumAlgorithm() + ")\n";
|
+ two.getChecksumAlgorithm() + ")\n";
|
||||||
|
|
||||||
|
@@ -72,9 +72,9 @@ public class FullTextContentStreamsTest {
|
|||||||
when(textBitstream2.getName()).thenReturn("Full Text 2");
|
when(textBitstream2.getName()).thenReturn("Full Text 2");
|
||||||
when(textBitstream3.getName()).thenReturn("Full Text 3");
|
when(textBitstream3.getName()).thenReturn("Full Text 3");
|
||||||
|
|
||||||
when(textBitstream1.getSize()).thenReturn(1L);
|
when(textBitstream1.getSizeBytes()).thenReturn(1L);
|
||||||
when(textBitstream2.getSize()).thenReturn(2L);
|
when(textBitstream2.getSizeBytes()).thenReturn(2L);
|
||||||
when(textBitstream3.getSize()).thenReturn(3L);
|
when(textBitstream3.getSizeBytes()).thenReturn(3L);
|
||||||
|
|
||||||
when(bitstreamService.retrieve(null, textBitstream1))
|
when(bitstreamService.retrieve(null, textBitstream1))
|
||||||
.thenReturn(new ByteArrayInputStream("This is text 1".getBytes(Charsets.UTF_8)));
|
.thenReturn(new ByteArrayInputStream("This is text 1".getBytes(Charsets.UTF_8)));
|
||||||
|
@@ -230,7 +230,7 @@ public class ItemUtils {
|
|||||||
createValue("format", bit.getFormat(context)
|
createValue("format", bit.getFormat(context)
|
||||||
.getMIMEType()));
|
.getMIMEType()));
|
||||||
bitstream.getField().add(
|
bitstream.getField().add(
|
||||||
createValue("size", "" + bit.getSize()));
|
createValue("size", "" + bit.getSizeBytes()));
|
||||||
bitstream.getField().add(createValue("url", url));
|
bitstream.getField().add(createValue("url", url));
|
||||||
bitstream.getField().add(
|
bitstream.getField().add(
|
||||||
createValue("checksum", cks));
|
createValue("checksum", cks));
|
||||||
|
@@ -77,7 +77,7 @@ public class Bitstream extends DSpaceObject {
|
|||||||
|
|
||||||
description = bitstream.getDescription();
|
description = bitstream.getDescription();
|
||||||
format = bitstreamService.getFormatDescription(context, bitstream);
|
format = bitstreamService.getFormatDescription(context, bitstream);
|
||||||
sizeBytes = bitstream.getSize();
|
sizeBytes = bitstream.getSizeBytes();
|
||||||
String path = new DSpace().getRequestService().getCurrentRequest().getHttpServletRequest().getContextPath();
|
String path = new DSpace().getRequestService().getCurrentRequest().getHttpServletRequest().getContextPath();
|
||||||
retrieveLink = path + "/bitstreams/" + bitstream.getID() + "/retrieve";
|
retrieveLink = path + "/bitstreams/" + bitstream.getID() + "/retrieve";
|
||||||
mimeType = bitstreamService.getFormat(context, bitstream).getMIMEType();
|
mimeType = bitstreamService.getFormat(context, bitstream).getMIMEType();
|
||||||
|
@@ -137,7 +137,7 @@ public class ItemFilterUtil {
|
|||||||
for (Bitstream bit : bundle.getBitstreams()) {
|
for (Bitstream bit : bundle.getBitstreams()) {
|
||||||
for (String mime : mimeList) {
|
for (String mime : mimeList) {
|
||||||
if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
|
if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
|
||||||
if (bit.getSize() < size) {
|
if (bit.getSizeBytes() < size) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ public class ItemFilterUtil {
|
|||||||
for (Bitstream bit : bundle.getBitstreams()) {
|
for (Bitstream bit : bundle.getBitstreams()) {
|
||||||
for (String mime : mimeList) {
|
for (String mime : mimeList) {
|
||||||
if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
|
if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
|
||||||
if (bit.getSize() > size) {
|
if (bit.getSizeBytes() > size) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -139,7 +139,7 @@ public class BitstreamContentRestController {
|
|||||||
if (citationDocumentService.isCitationEnabledForBitstream(bit, context)) {
|
if (citationDocumentService.isCitationEnabledForBitstream(bit, context)) {
|
||||||
return generateBitstreamWithCitation(context, bit);
|
return generateBitstreamWithCitation(context, bit);
|
||||||
} else {
|
} else {
|
||||||
return Pair.of(bitstreamService.retrieve(context, bit),bit.getSize());
|
return Pair.of(bitstreamService.retrieve(context, bit),bit.getSizeBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ public class BitstreamConverter
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
b.setFormat(format);
|
b.setFormat(format);
|
||||||
b.setSizeBytes(obj.getSize());
|
b.setSizeBytes(obj.getSizeBytes());
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -138,7 +138,7 @@ public class SubmissionService {
|
|||||||
checksum.setCheckSumAlgorithm(source.getChecksumAlgorithm());
|
checksum.setCheckSumAlgorithm(source.getChecksumAlgorithm());
|
||||||
checksum.setValue(source.getChecksum());
|
checksum.setValue(source.getChecksum());
|
||||||
data.setCheckSum(checksum);
|
data.setCheckSum(checksum);
|
||||||
data.setSizeBytes(source.getSize());
|
data.setSizeBytes(source.getSizeBytes());
|
||||||
data.setUrl(configurationService.getProperty("dspace.url") + "/api/" + BitstreamRest.CATEGORY + "/" + English
|
data.setUrl(configurationService.getProperty("dspace.url") + "/api/" + BitstreamRest.CATEGORY + "/" + English
|
||||||
.plural(BitstreamRest.NAME) + "/" + source.getID() + "/content");
|
.plural(BitstreamRest.NAME) + "/" + source.getID() + "/content");
|
||||||
return data;
|
return data;
|
||||||
|
@@ -34,7 +34,7 @@ public class BitstreamMatcher {
|
|||||||
BitstreamMetadataMatcher.matchTitle(bitstream.getName()),
|
BitstreamMetadataMatcher.matchTitle(bitstream.getName()),
|
||||||
BitstreamMetadataMatcher.matchDescription(bitstream.getDescription())
|
BitstreamMetadataMatcher.matchDescription(bitstream.getDescription())
|
||||||
)),
|
)),
|
||||||
hasJsonPath("$.sizeBytes", is((int) bitstream.getSize())),
|
hasJsonPath("$.sizeBytes", is((int) bitstream.getSizeBytes())),
|
||||||
hasJsonPath("$.checkSum", matchChecksum()),
|
hasJsonPath("$.checkSum", matchChecksum()),
|
||||||
hasJsonPath("$._embedded.format", matchFormat()),
|
hasJsonPath("$._embedded.format", matchFormat()),
|
||||||
//Check links
|
//Check links
|
||||||
|
@@ -53,7 +53,8 @@ public class CollectionMatcher {
|
|||||||
hasJsonPath("$._embedded.logo", Matchers.not(Matchers.empty()))
|
hasJsonPath("$._embedded.logo", Matchers.not(Matchers.empty()))
|
||||||
) :
|
) :
|
||||||
allOf(
|
allOf(
|
||||||
hasJsonPath("$._embedded.logo", BitstreamMatcher.matchBitstreamEntry(logo.getID(), logo.getSize()))
|
hasJsonPath("$._embedded.logo",
|
||||||
|
BitstreamMatcher.matchBitstreamEntry(logo.getID(), logo.getSizeBytes()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user