001: /*
002: * Copyright (c) 2004-2005, Hewlett-Packard Company and Massachusetts
003: * Institute of Technology. All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are
007: * met:
008: *
009: * - Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * - Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * - Neither the name of the Hewlett-Packard Company nor the name of the
017: * Massachusetts Institute of Technology nor the names of their
018: * contributors may be used to endorse or promote products derived from
019: * this software without specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
022: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
023: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
024: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
025: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
026: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
027: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
028: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
029: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
030: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
031: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
032: * DAMAGE.
033: */
034: package org.dspace.checker;
035:
036: import java.util.Date;
037:
038: /**
039: * <p>
040: * Value Object that holds bitstream information that will be used for checksum
041: * processing.
042: * </p>
043: *
044: * @author Jim Downing
045: * @author Grace Carpenter
046: * @author Nathan Sarr
047: *
048: */
049: public final class BitstreamInfo {
050: /** deleted flag. */
051: private boolean deleted;
052:
053: /** dspace bitstream information */
054: private DSpaceBitstreamInfo dspaceBitstream;
055:
056: /**
057: * Indicates the bitstream info (metdata) was found in the database.
058: *
059: * @todo Is this actually used for anything?
060: */
061: private boolean infoFound;
062:
063: /** indicates the bitstream was found in the database. */
064: private boolean bitstreamFound;
065:
066: /** the check sum value calculated by the algorithm. */
067: private String calculatedChecksum;
068:
069: /** should be processed or not? */
070: private boolean toBeProcessed;
071:
072: /** checksum comparison result code. */
073: private String checksumCheckResult;
074:
075: /** Date the object was created for processing. */
076: private Date processStartDate;
077:
078: /** Date the processing was completed. */
079: private Date processEndDate;
080:
081: /**
082: * Blanked off no-op default constructor.
083: */
084: private BitstreamInfo() {
085: ;
086: }
087:
088: /**
089: * Minimal constructor.
090: *
091: * @param bid
092: * Bitstream identifier
093: */
094: public BitstreamInfo(int bid) {
095: deleted = false;
096:
097: dspaceBitstream = new DSpaceBitstreamInfo(bid);
098:
099: // set default to true since it's the
100: // case for most bitstreams
101: infoFound = true;
102: bitstreamFound = false;
103: calculatedChecksum = null;
104: processEndDate = null;
105: toBeProcessed = false;
106: processStartDate = new Date();
107: }
108:
109: /**
110: * Complete constructor.
111: *
112: * @param del
113: * Deleted
114: * @param storeNo
115: * Bitstream storeNumber
116: * @param sz
117: * Bitstream size
118: * @param bitstrmFmt
119: * Bitstream format
120: * @param bitstrmId
121: * Bitstream id
122: * @param usrFmtDesc
123: * Bitstream format description
124: * @param intrnlId
125: * Bitstream DSpace internal id
126: * @param src
127: * Bitstream source
128: * @param chksumAlgorthm
129: * Algorithm used to check bitstream
130: * @param chksum
131: * Hash digest obtained
132: * @param nm
133: * Name of bitstream
134: * @param procEndDate
135: * When the last bitstream check finished.
136: * @param toBeProc
137: * Whether the bitstream will be checked or skipped
138: * @param procStartDate
139: * When the last bitstream check started.
140: */
141: public BitstreamInfo(boolean del, int storeNo, int sz,
142: String bitstrmFmt, int bitstrmId, String usrFmtDesc,
143: String intrnlId, String src, String chksumAlgorthm,
144: String chksum, String nm, Date procEndDate,
145: boolean toBeProc, Date procStartDate) {
146: dspaceBitstream = new DSpaceBitstreamInfo(del, storeNo, sz,
147: bitstrmFmt, bitstrmId, usrFmtDesc, intrnlId, src,
148: chksumAlgorthm, chksum, nm, "");
149:
150: this .deleted = del;
151: this .processEndDate = procEndDate;
152: this .toBeProcessed = toBeProc;
153: this .processStartDate = procStartDate;
154: this .infoFound = true;
155: }
156:
157: /**
158: * Get the deleted flag.
159: *
160: * @return true if the bitstream has been deleted
161: */
162: public boolean getDeleted() {
163: return deleted;
164: }
165:
166: /**
167: * Set the deleted flag.
168: *
169: * @param deleted
170: * deleted flag
171: */
172: public void setDeleted(boolean deleted) {
173: this .deleted = deleted;
174: }
175:
176: /**
177: * Get the bitstream store number.
178: *
179: * @return int
180: */
181: public int getStoreNumber() {
182: return dspaceBitstream.getStoreNumber();
183: }
184:
185: /**
186: * Set the store number.
187: *
188: * @param storeNumber
189: * the store number
190: */
191: public void setStoreNumber(int storeNumber) {
192: dspaceBitstream.setStoreNumber(storeNumber);
193: }
194:
195: /**
196: * Get the size.
197: *
198: * @return int
199: */
200: public int getSize() {
201: return dspaceBitstream.getSize();
202: }
203:
204: /**
205: * Set the size.
206: *
207: * @param size
208: * the bitstream size
209: */
210: public void setSize(int size) {
211: dspaceBitstream.setSize(size);
212: }
213:
214: /**
215: * Get the Bitstream Format id.
216: *
217: * @return int
218: */
219: public String getBitstreamFormatId() {
220: return dspaceBitstream.getBitstreamFormatId();
221: }
222:
223: /**
224: * Set the Bitstream Format id.
225: *
226: * @param bitstrmFmt
227: * id of the bitstream format
228: */
229: public void setBitstreamFormatId(String bitstrmFmt) {
230: dspaceBitstream.setBitstreamFormatId(bitstrmFmt);
231: }
232:
233: /**
234: * Get the Bitstream id.
235: *
236: * @return int
237: */
238: public int getBitstreamId() {
239: return dspaceBitstream.getBitstreamId();
240: }
241:
242: /**
243: * Get the user format description.
244: *
245: * @return String
246: */
247: public String getUserFormatDescription() {
248: return dspaceBitstream.getUserFormatDescription();
249: }
250:
251: /**
252: * Set the user format description.
253: *
254: * @param userFormatDescription
255: * the userFormatDescription
256: */
257: public void setUserFormatDescription(String userFormatDescription) {
258: dspaceBitstream.setUserFormatDescription(userFormatDescription);
259: }
260:
261: /**
262: * Get the Internal Id.
263: *
264: * @return String
265: */
266: public String getInternalId() {
267: return dspaceBitstream.getInternalId();
268: }
269:
270: /**
271: * Set the Internal Id.
272: *
273: * @param internalId
274: * the DSpace internal sequence id for the bitstream.
275: */
276: public void setInternalId(String internalId) {
277: dspaceBitstream.setInternalId(internalId);
278: }
279:
280: /**
281: * Get the source.
282: *
283: * @return String
284: */
285: public String getSource() {
286: return dspaceBitstream.getSource();
287: }
288:
289: /**
290: * Set the source.
291: *
292: * @param source
293: * The bitstream source.
294: */
295: public void setSource(String source) {
296: dspaceBitstream.setSource(source);
297: }
298:
299: /**
300: * Get the checksum algorithm.
301: *
302: * @return String
303: */
304: public String getChecksumAlgorithm() {
305: return dspaceBitstream.getChecksumAlgorithm();
306: }
307:
308: /**
309: * Set the checksum algorithm.
310: *
311: * @param checksumAlgorithm
312: * the algorithm used for checking this bitstream
313: */
314: public void setChecksumAlgorithm(String checksumAlgorithm) {
315: dspaceBitstream.setChecksumAlgorithm(checksumAlgorithm);
316: }
317:
318: /**
319: * Get the checksum.
320: *
321: * @return String
322: */
323: public String getStoredChecksum() {
324: return dspaceBitstream.getStoredChecksum();
325: }
326:
327: /**
328: * Set the checksum.
329: *
330: * @param checksum
331: * The last stored checksum for this bitstream.
332: */
333: public void setStoredChecksum(String checksum) {
334: dspaceBitstream.setStoredChecksum(checksum);
335: }
336:
337: /**
338: * Get the name of the bitstream.
339: *
340: * @return String
341: */
342: public String getName() {
343: return dspaceBitstream.getName();
344: }
345:
346: /**
347: * Set the name of the bitstream.
348: *
349: * @param nm
350: * The name of this bitstream.
351: */
352: public void setName(String nm) {
353: dspaceBitstream.setName(nm);
354: }
355:
356: /**
357: * calculatedChecksum accessor.
358: *
359: * @return Returns the calculatedChecksum.
360: */
361: public String getCalculatedChecksum() {
362: return calculatedChecksum;
363: }
364:
365: /**
366: * calculatedChecksum accessor.
367: *
368: * @param calculatedChecksum
369: * The calculatedChecksum to set.
370: */
371: public void setCalculatedChecksum(String calculatedChecksum) {
372: this .calculatedChecksum = calculatedChecksum;
373: }
374:
375: /**
376: * infoFound accessor.
377: *
378: * @return Returns infoFound.
379: */
380: public boolean getInfoFound() {
381: return this .infoFound;
382: }
383:
384: /**
385: * infoFound accessor.
386: *
387: * @param found
388: * sets infoFound.
389: */
390: public void setInfoFound(boolean found) {
391: this .infoFound = found;
392: }
393:
394: /**
395: * bitstreamFound accessor.
396: *
397: * @return Returns bitstreamFound.
398: */
399: public boolean getBitstreamFound() {
400: return this .bitstreamFound;
401: }
402:
403: /**
404: * sets bitstreamFound.
405: *
406: * @param found
407: * value of bitstreamFound to set.
408: */
409: public void setBitstreamFound(boolean found) {
410: this .bitstreamFound = found;
411: }
412:
413: /**
414: * Identity entirely dependent upon <code>bitstreamId</code>.
415: *
416: * @see java.lang.Object#equals(java.lang.Object)
417: */
418: public boolean equals(Object o) {
419: if (this == o) {
420: return true;
421: }
422:
423: if (!(o instanceof BitstreamInfo)) {
424: return false;
425: }
426:
427: BitstreamInfo other = (BitstreamInfo) o;
428:
429: return (this .getBitstreamId() == other.getBitstreamId());
430: }
431:
432: /**
433: * HashCode method uses <code>bitstreamId</code> as hashing function.
434: *
435: * @see java.lang.Object#hashCode()
436: */
437: public int hashCode() {
438: return getBitstreamId();
439: }
440:
441: /**
442: * Describes this BitstreamInfo.
443: *
444: * @see java.lang.Object#toString()
445: */
446: public String toString() {
447: return new StringBuffer("ChecksumInformation for id ").append(
448: getBitstreamId()).toString();
449: }
450:
451: /**
452: * Sets toBeProcessed.
453: *
454: * @param toBeProcessed
455: * flag from most_recent_checksum table
456: */
457: public void setToBeProcessed(boolean toBeProcessed) {
458: this .toBeProcessed = toBeProcessed;
459: }
460:
461: /**
462: * Gets toBeProcessed.
463: *
464: * @return value of toBeProcessed flag (from most_recent_checksum table)
465: */
466: public boolean getToBeProcessed() {
467: return this .toBeProcessed;
468: }
469:
470: /**
471: * Gets checksumCheckResult.
472: *
473: * @return result code for comparison of previous and current checksums
474: */
475: public String getChecksumCheckResult() {
476: return this .checksumCheckResult;
477: }
478:
479: /**
480: * Sets checksumCheckResult.
481: *
482: * @param resultCode
483: * for comparison of previous and current checksums
484: */
485: public void setChecksumCheckResult(String resultCode) {
486: this .checksumCheckResult = resultCode;
487: }
488:
489: /**
490: * The start date and time this bitstream is being processed.
491: *
492: * @return date
493: */
494: public Date getProcessStartDate() {
495: return this .processStartDate;
496: }
497:
498: /**
499: * The date and time the processing started for this bitstream.
500: *
501: * @param startDate
502: * date to set.
503: */
504: public void setProcessStartDate(Date startDate) {
505: this .processStartDate = startDate;
506: }
507:
508: /**
509: * The date and time this bitstream is finished being processed.
510: *
511: * @return date
512: */
513: public Date getProcessEndDate() {
514: return this .processEndDate;
515: }
516:
517: /**
518: * The date and time this bitstream is finished being processed.
519: *
520: * @param endDate
521: * the date to set.
522: */
523: public void setProcessEndDate(Date endDate) {
524: this.processEndDate = endDate;
525: }
526: }
|