Class SubscriptionImpl
- java.lang.Object
-
- org.bedework.synch.db.DbItem<SubscriptionImpl>
-
- org.bedework.synch.db.SubscriptionImpl
-
- All Implemented Interfaces:
Serializable,Comparable<SubscriptionImpl>,Subscription
public class SubscriptionImpl extends DbItem<SubscriptionImpl> implements Subscription
Represents a subscription for the synch engine.A subscription has 2 connections, one for each end of the subscription. We will refer to these as endA and endB.
Each connection has a kind which is a name used to retrieve a connector from the synch engine. The retrieved connector implements the Connector interface. This connector object can then be used to retrieve a ConnectionInst implementation which uses information stored in a serializable object to obtain connection specific properties such as id and password.
These properties are obtained by presenting the user with a list of required properties and then encrypting and storing the response. The serialized result is stored as a field in the subscription.
Connections are either polling or notify. Polling means that the host will be polled to see if anything has changed. Notify means that the subscription will be activated when the system is notified of a change.
Connections are also resynch only - that is the far end does not support fetching of individual items but must be completely resynched each time, or the support the full synch feature set.
Resynch connections support relatively simple protocols or file synch.
The full feature connections are used for bedework, Exchange etc.
Skip Lists
A skip list allows the diffing process to skip properties that are not to be considered, for example lastmod. We create a skip list from 3 lists;- one for each end of the subscription. This marks properties used exclusively by that end, for example x-properties.
- One for the middle which might skip properties we want to ignore such as alarms
An empty list means exactly that, no skip properties. A null list means the default diff skip list - probably more useful.
- Author:
- Mike Douglass
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SubscriptionImpl()null constructor for hibernateSubscriptionImpl(String subscriptionId)Constructor to create a new subscription.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanchanged()intcompareTo(SubscriptionImpl that)booleangetDeleted()org.bedework.synch.wsmessages.SynchDirectionTypegetDirection()Which way?ConnectorgetEndAConn()SubscriptionConnectorInfogetEndAConnectorInfo()ConnectorInstancegetEndAConnInst()ConnectorgetEndBConn()SubscriptionConnectorInfogetEndBConnectorInfo()ConnectorInstancegetEndBConnInst()intgetErrorCt()SubscriptionInfogetInfo()StringgetLastRefresh()org.bedework.synch.wsmessages.SynchMasterTypegetMaster()booleangetMissingTarget()SubscriptiongetOutstandingSubscription()An outstanding request that requires an unsubscribe to complete firstStringgetOwner()OwnerStringgetSubscriptionId()Our generated subscriptionId.inthashCode()DatenextRefresh()Get a next refresh date based on the last refresh valuebooleanpolling()longrefreshDelay()voidresetChanged()reset the changed flag.voidsetDeleted(boolean val)True if subscription deletedvoidsetDirection(org.bedework.synch.wsmessages.SynchDirectionType val)Which way?voidsetEndAConn(Connector val)voidsetEndAConnectorInfo(SubscriptionConnectorInfo val)Info for the endA connector.voidsetEndAConnInst(ConnectorInstance val)voidsetEndBConn(Connector val)voidsetEndBConnectorInfo(SubscriptionConnectorInfo val)Info for the endB connector.voidsetEndBConnInst(ConnectorInstance val)voidsetErrorCt(int val)int consecutive errorsvoidsetInfo(SubscriptionInfo val)Info for the subscription.voidsetLastRefresh(String val)A UTC dtstamp valuevoidsetMaster(org.bedework.synch.wsmessages.SynchMasterType val)Which end is master?voidsetMissingTarget(boolean val)True if either target is missingvoidsetOutstandingSubscription(Subscription val)An outstanding request that requires an unsubscribe to complete firstvoidsetOwner(String val)The owner.voidsetSubscriptionId(String val)Our generated subscriptionId.StringtoString()protected org.bedework.util.misc.ToStringtoStringSegment(org.bedework.util.misc.ToString ts)Add our stuff to the StringBuildervoidupdateLastRefresh()Set the lastRefresh from the current time
-
-
-
Constructor Detail
-
SubscriptionImpl
public SubscriptionImpl()
null constructor for hibernate
-
SubscriptionImpl
public SubscriptionImpl(String subscriptionId)
Constructor to create a new subscription.- Parameters:
subscriptionId- - null means generate one
-
-
Method Detail
-
setSubscriptionId
public void setSubscriptionId(String val)
Our generated subscriptionId.- Specified by:
setSubscriptionIdin interfaceSubscription- Parameters:
val- String
-
getSubscriptionId
public String getSubscriptionId()
Our generated subscriptionId.- Specified by:
getSubscriptionIdin interfaceSubscription- Returns:
- String
-
setLastRefresh
public void setLastRefresh(String val)
A UTC dtstamp value- Specified by:
setLastRefreshin interfaceSubscription- Parameters:
val-
-
getLastRefresh
public String getLastRefresh()
- Specified by:
getLastRefreshin interfaceSubscription- Returns:
- String lastRefresh
-
setErrorCt
public void setErrorCt(int val)
int consecutive errors- Specified by:
setErrorCtin interfaceSubscription- Parameters:
val-
-
getErrorCt
public int getErrorCt()
- Specified by:
getErrorCtin interfaceSubscription- Returns:
- int consecutive errors
-
setMissingTarget
public void setMissingTarget(boolean val)
True if either target is missing- Specified by:
setMissingTargetin interfaceSubscription- Parameters:
val-
-
getMissingTarget
public boolean getMissingTarget()
- Specified by:
getMissingTargetin interfaceSubscription- Returns:
- True if either target is missing
-
setOwner
public void setOwner(String val)
The owner. This is the (verified) account that set up the subscription. It is either the authenticated user or provided by a proxy that has verified the account. The owner is only needed for subcribing, unsubscribing and display of and updates to the subscription itself.Interactions with the end points use information contained within the subscription.
- Specified by:
setOwnerin interfaceSubscription- Parameters:
val- String
-
getOwner
public String getOwner()
Owner- Specified by:
getOwnerin interfaceSubscription- Returns:
- String
-
setEndAConnectorInfo
public void setEndAConnectorInfo(SubscriptionConnectorInfo val)
Info for the endA connector.- Specified by:
setEndAConnectorInfoin interfaceSubscription- Parameters:
val- SubscriptionConnectorInfo
-
getEndAConnectorInfo
public SubscriptionConnectorInfo getEndAConnectorInfo()
- Specified by:
getEndAConnectorInfoin interfaceSubscription- Returns:
- SubscriptionConnectorInfo
-
setEndBConnectorInfo
public void setEndBConnectorInfo(SubscriptionConnectorInfo val)
Info for the endB connector.- Specified by:
setEndBConnectorInfoin interfaceSubscription- Parameters:
val- SubscriptionConnectorInfo
-
getEndBConnectorInfo
public SubscriptionConnectorInfo getEndBConnectorInfo()
- Specified by:
getEndBConnectorInfoin interfaceSubscription- Returns:
- SubscriptionConnectorInfo
-
setInfo
public void setInfo(SubscriptionInfo val)
Info for the subscription.- Specified by:
setInfoin interfaceSubscription- Parameters:
val- SubscriptionInfo
-
getInfo
public SubscriptionInfo getInfo()
- Specified by:
getInfoin interfaceSubscription- Returns:
- SubscriptionInfo
-
setDirection
public void setDirection(org.bedework.synch.wsmessages.SynchDirectionType val)
Which way?- Specified by:
setDirectionin interfaceSubscription- Parameters:
val-
-
getDirection
public org.bedework.synch.wsmessages.SynchDirectionType getDirection()
Which way?- Specified by:
getDirectionin interfaceSubscription- Returns:
- direction
-
setMaster
public void setMaster(org.bedework.synch.wsmessages.SynchMasterType val)
Which end is master?- Specified by:
setMasterin interfaceSubscription- Parameters:
val-
-
getMaster
public org.bedework.synch.wsmessages.SynchMasterType getMaster()
- Specified by:
getMasterin interfaceSubscription- Returns:
- who's master
-
setOutstandingSubscription
public void setOutstandingSubscription(Subscription val)
An outstanding request that requires an unsubscribe to complete first- Specified by:
setOutstandingSubscriptionin interfaceSubscription- Parameters:
val- Subscription
-
getOutstandingSubscription
public Subscription getOutstandingSubscription()
An outstanding request that requires an unsubscribe to complete first- Specified by:
getOutstandingSubscriptionin interfaceSubscription- Returns:
- Subscription
-
setDeleted
public void setDeleted(boolean val)
True if subscription deleted- Specified by:
setDeletedin interfaceSubscription- Parameters:
val-
-
getDeleted
public boolean getDeleted()
- Specified by:
getDeletedin interfaceSubscription- Returns:
- True if deleted
-
setEndAConn
public void setEndAConn(Connector val)
- Specified by:
setEndAConnin interfaceSubscription- Parameters:
val- a connection
-
getEndAConn
public Connector getEndAConn()
- Specified by:
getEndAConnin interfaceSubscription- Returns:
- a connection or null
-
setEndBConn
public void setEndBConn(Connector val)
- Specified by:
setEndBConnin interfaceSubscription- Parameters:
val- a connection
-
getEndBConn
public Connector getEndBConn()
- Specified by:
getEndBConnin interfaceSubscription- Returns:
- a connection or null
-
setEndAConnInst
public void setEndAConnInst(ConnectorInstance val)
- Specified by:
setEndAConnInstin interfaceSubscription- Parameters:
val- a connection instance
-
getEndAConnInst
public ConnectorInstance getEndAConnInst()
- Specified by:
getEndAConnInstin interfaceSubscription- Returns:
- a connection instance or null
-
setEndBConnInst
public void setEndBConnInst(ConnectorInstance val)
- Specified by:
setEndBConnInstin interfaceSubscription- Parameters:
val- a connection instance
-
getEndBConnInst
public ConnectorInstance getEndBConnInst()
- Specified by:
getEndBConnInstin interfaceSubscription- Returns:
- a connection instance or null
-
changed
public boolean changed()
- Specified by:
changedin interfaceSubscription- Returns:
- true if any connector info changed
-
resetChanged
public void resetChanged()
reset the changed flag.- Specified by:
resetChangedin interfaceSubscription
-
polling
public boolean polling()
- Specified by:
pollingin interfaceSubscription- Returns:
- true if this has to be put on a poll queue
-
refreshDelay
public long refreshDelay() throws SynchException- Specified by:
refreshDelayin interfaceSubscription- Returns:
- the delay in millisecs.
- Throws:
SynchException
-
updateLastRefresh
public void updateLastRefresh()
Set the lastRefresh from the current time- Specified by:
updateLastRefreshin interfaceSubscription
-
nextRefresh
public Date nextRefresh() throws SynchException
Get a next refresh date based on the last refresh value- Specified by:
nextRefreshin interfaceSubscription- Returns:
- date value incremented by delay.
- Throws:
SynchException
-
toStringSegment
protected org.bedework.util.misc.ToString toStringSegment(org.bedework.util.misc.ToString ts)
Add our stuff to the StringBuilder- Overrides:
toStringSegmentin classDbItem<SubscriptionImpl>- Parameters:
ts- ToString builder for result
-
hashCode
public int hashCode()
- Overrides:
hashCodein classDbItem<SubscriptionImpl>
-
compareTo
public int compareTo(SubscriptionImpl that)
- Specified by:
compareToin interfaceComparable<SubscriptionImpl>- Overrides:
compareToin classDbItem<SubscriptionImpl>
-
-