public class DSpaceValidity extends Object implements org.apache.excalibur.source.SourceValidity
The basic idea is that, each time a DSpace object is rendered by a Cocoon component, the object and everything about it that makes it unique should be reflected in the validity object for the component. By following this principle, if the object has been updated externally then the cache will be invalidated.
This DSpaceValidity object makes this processes easier by abstracting out the processes of determining what is unique about a DSpace object. A class is expected to create a new DSpaceValidity object and add() to it all DSpaceObjects that are rendered by the component. This validity object will serialize all those objects to a string, take a hash of the string and compare the hash of the string for any updates.
| Modifier and Type | Field and Description |
|---|---|
protected long |
assumedValidityDelay
The length of time that a cache is assumed to be valid
|
protected long |
assumedValidityTime
The time when the validity is no longer assumed to be valid
|
protected CollectionService |
collectionService |
protected CommunityService |
communityService |
protected boolean |
completed
Simple flag to note if the object has been completed.
|
protected long |
hash
A hash of the validityKey taken after completion
|
protected ItemService |
itemService |
protected StringBuffer |
validityKey
The validityKey while it is being build, once it is completed.
|
| Constructor and Description |
|---|
DSpaceValidity() |
DSpaceValidity(String initialValidityKey)
Create a new DSpace validity object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Context context,
DSpaceObject dso)
Add a DSpace object to the validity.
|
void |
add(String nonDSpaceObject)
Add a non-DSpaceObject to the validity, the object should be
serialized into a string form.
|
DSpaceValidity |
complete()
Complete this validity object.
|
int |
isValid()
Determine if the cache is still valid
|
int |
isValid(org.apache.excalibur.source.SourceValidity otherObject)
Determine if the cache is still valid based
upon the other validity object.
|
void |
setAssumedValidityDelay(long milliseconds)
Set the time delay for how long this cache will be assumed
to be valid.
|
void |
setAssumedValidityDelay(String delay)
Set the time delay for how long this cache will be assumed to be valid.
|
protected StringBuffer validityKey
protected boolean completed
protected long hash
protected long assumedValidityTime
protected long assumedValidityDelay
protected transient CommunityService communityService
protected transient CollectionService collectionService
protected transient ItemService itemService
public DSpaceValidity(String initialValidityKey)
initialValidityKey - The initial stringpublic DSpaceValidity()
public DSpaceValidity complete()
public void setAssumedValidityDelay(long milliseconds)
milliseconds - The delay time in millieseconds.public void setAssumedValidityDelay(String delay)
This method takes a string which is parsed for the delay time. The string
must be of the following form: "<integer> <scale>" where scale is days,
hours, minutes, or seconds.
Examples: "1 day" or "12 hours" or "1 hour" or "30 minutes"
delay - The delay time in a variable scale.setAssumedValidityDelay(long)public void add(Context context, DSpaceObject dso) throws SQLException
Communities -> logo bitstream
Collection -> logo bitstream
Item -> bundles -> bitstream
Bundles -> bitstreams
EPeople -> groups
context - session context.dso - The object to add to the validity.SQLException - passed through.public void add(String nonDSpaceObject) throws SQLException
nonDSpaceObject - The non-DSpace object to add to the validity.SQLException - passed through.public int isValid()
isValid in interface org.apache.excalibur.source.SourceValiditySourceValidity.VALID,
SourceValidity.UNKNOWN,
or SourceValidity.INVALID.public int isValid(org.apache.excalibur.source.SourceValidity otherObject)
isValid in interface org.apache.excalibur.source.SourceValidityotherObject - The other validity object.SourceValidity.VALID
or SourceValidity.INVALID.Copyright © 2016 DuraSpace. All rights reserved.