jimm.twice.syndicator
Class TwICESyndicator

java.lang.Object
  extended byjimm.twice.ice.IceMachine
      extended byjimm.twice.ice.Syndicator
          extended byjimm.twice.syndicator.TwICESyndicator

public class TwICESyndicator
extends Syndicator

A syndicator that can deal with subscriptions, persistence, and HTTP.

Author:
Jim Menard, jimm@io.com

Field Summary
protected static int INLINE
           
protected  org.apache.axis.MessageContext msgContext
           
protected  java.lang.String pstoreDir
           
protected static int REF
           
protected  jimm.twice.syndicator.SynSubscriber subscriber
           
protected  IceSubscriberPortType subscriberHandle
           
protected static java.lang.String TWICE_CATALOG_NAME
           
 
Fields inherited from class jimm.twice.ice.Syndicator
LOG_FILE_PREFIX, OFFER_SUBSCRIPTION_ID, packageItemId, UNKNOWN_SUBSCRIPTION
 
Fields inherited from class jimm.twice.ice.IceMachine
DEFAULT_LOGGER_PREFIX, domain, loggerPrefix, party, PING_RESPONSE_STRING
 
Constructor Summary
TwICESyndicator()
          Constructor.
 
Method Summary
 Cancellation cancel(Cancel cancelReq)
           
protected  PackageType generateItems(java.lang.String subscriptionId, java.lang.String currentState)
          Generates the ice item(s) and/or item ref(s) that satisfy the specified subscription id and builds a package containing them.
protected  OfferType[] generateOffers(java.lang.String subscriberId)
          Generates the ice-offer(s) that fill a catalog
 PackageType getCatalog(GetPackageType getPackageReq)
           
protected  java.lang.String getCatalogName()
          Returns the name of the catalog sent in response to an get-catalog request.
 PackageType getPackage(GetPackageType getPackageReq)
           
 Packages getPackages(GetPackages getPackagesReq)
           
 StatusType getStatus(GetStatus getStatusReq)
           
 java.lang.String getSubscriberId()
           
 java.lang.String[] getSubscriberIds()
           
 java.lang.String getSubscriberName()
           
protected  java.lang.String getSubscriberURL(java.lang.String subscriberId)
          Returns the URL given to us by the specified subscriber, or null if we've never heard of this subscriber.
 void handlePing()
           
protected  boolean hasSubscriber(java.lang.String subscriberId)
          Returns true if the subscriber id is known to this syndicator.
 boolean isNewSubscriber()
           
 boolean loadSubscriber(java.lang.String subscriberId)
          Creates subscriber and asks it to load its information; returns true if the info already exists in permanent storage.
 void packageConfirmations(PackageConfirmationsType packageConfirmationsReq)
           
 java.lang.String pingSubscriber(java.lang.String pingSubscriberId)
          Pings the subscriber with the specified id and returns the response as a string.
 java.lang.String pushAll()
          Pushes "push" subscriptions to all subscribers.
 java.lang.String pushOfferTo(java.lang.String offerId, java.lang.String subscriberId)
          Pushes all subscriptions to the specified subscriber and offer.
 java.lang.String pushTo(java.lang.String subscriberId)
          Pushes subscriptions to the specified subscriber.
 void removeSubscriber(java.lang.String subscriberId)
          Removes a subscriber from persistent store.
 void setMessageContext(org.apache.axis.MessageContext msgContext)
           
protected  void storeSubscriber()
          Asks the subscriber to store its information.
 SubscriptionType subscribe(Subscribe subscribeReq)
           
 java.util.Iterator subscribers()
          Returns an iterator over the list of subscriber keys (UUIDs).
 java.util.Iterator subscriptions()
           
 
Methods inherited from class jimm.twice.ice.IceMachine
createIceHeader, getDomain, getLocationURL, getName, getParty, getRole, getUuid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INLINE

protected static final int INLINE
See Also:
Constant Field Values

REF

protected static final int REF
See Also:
Constant Field Values

TWICE_CATALOG_NAME

protected static final java.lang.String TWICE_CATALOG_NAME
See Also:
Constant Field Values

subscriber

protected jimm.twice.syndicator.SynSubscriber subscriber

pstoreDir

protected java.lang.String pstoreDir

subscriberHandle

protected IceSubscriberPortType subscriberHandle

msgContext

protected org.apache.axis.MessageContext msgContext
Constructor Detail

TwICESyndicator

public TwICESyndicator()
Constructor.

Method Detail

getSubscriberId

public java.lang.String getSubscriberId()

getSubscriberName

public java.lang.String getSubscriberName()

isNewSubscriber

public boolean isNewSubscriber()

subscriptions

public java.util.Iterator subscriptions()

setMessageContext

public void setMessageContext(org.apache.axis.MessageContext msgContext)

getSubscriberIds

public java.lang.String[] getSubscriberIds()

subscribers

public java.util.Iterator subscribers()
Returns an iterator over the list of subscriber keys (UUIDs).

Returns:
an iterator over the list of subscriber ids

hasSubscriber

protected boolean hasSubscriber(java.lang.String subscriberId)
Returns true if the subscriber id is known to this syndicator.

Specified by:
hasSubscriber in class Syndicator
Parameters:
subscriberId - a subscriber's UUID

getSubscriberURL

protected java.lang.String getSubscriberURL(java.lang.String subscriberId)
Returns the URL given to us by the specified subscriber, or null if we've never heard of this subscriber.

Specified by:
getSubscriberURL in class Syndicator
Parameters:
subscriberId - a subscriber's UUID
Returns:
a URL string or null

removeSubscriber

public void removeSubscriber(java.lang.String subscriberId)
Removes a subscriber from persistent store. If this is the current subscriber, removes it from memory as well.

This method is only used for unit testing right now.

Parameters:
subscriberId - the subscriber to remove

pingSubscriber

public java.lang.String pingSubscriber(java.lang.String pingSubscriberId)
Pings the subscriber with the specified id and returns the response as a string.

Returns:
the ping response, ready for HTML display

generateItems

protected PackageType generateItems(java.lang.String subscriptionId,
                                    java.lang.String currentState)
                             throws StatusCode
Description copied from class: Syndicator
Generates the ice item(s) and/or item ref(s) that satisfy the specified subscription id and builds a package containing them.

Specified by:
generateItems in class Syndicator
Parameters:
subscriptionId - the subscription id
currentState - the sender's subscription's current state
Returns:
the ICE package containing the items
Throws:
StatusCode

getCatalogName

protected java.lang.String getCatalogName()
Description copied from class: Syndicator
Returns the name of the catalog sent in response to an get-catalog request.

Specified by:
getCatalogName in class Syndicator
Returns:
a value for the name attribute

generateOffers

protected OfferType[] generateOffers(java.lang.String subscriberId)
                              throws StatusCode
Description copied from class: Syndicator
Generates the ice-offer(s) that fill a catalog

Specified by:
generateOffers in class Syndicator
Parameters:
subscriberId - the subscriber's UUID
Returns:
array of offers
Throws:
StatusCode

getCatalog

public PackageType getCatalog(GetPackageType getPackageReq)
                       throws StatusCode
Throws:
StatusCode

getPackages

public Packages getPackages(GetPackages getPackagesReq)
                     throws StatusCode
Specified by:
getPackages in class Syndicator
Throws:
StatusCode

getPackage

public PackageType getPackage(GetPackageType getPackageReq)
                       throws StatusCode
Specified by:
getPackage in class Syndicator
Throws:
StatusCode

getStatus

public StatusType getStatus(GetStatus getStatusReq)
                     throws StatusCode
Specified by:
getStatus in class Syndicator
Throws:
StatusCode

packageConfirmations

public void packageConfirmations(PackageConfirmationsType packageConfirmationsReq)
                          throws StatusCode
Specified by:
packageConfirmations in class Syndicator
Throws:
StatusCode

handlePing

public void handlePing()
                throws StatusCode
Specified by:
handlePing in class Syndicator
Throws:
StatusCode

subscribe

public SubscriptionType subscribe(Subscribe subscribeReq)
                           throws SubscriptionFault
Specified by:
subscribe in class Syndicator
Throws:
SubscriptionFault

cancel

public Cancellation cancel(Cancel cancelReq)
                    throws StatusCode
Specified by:
cancel in class Syndicator
Throws:
StatusCode

pushAll

public java.lang.String pushAll()
Pushes "push" subscriptions to all subscribers. Returns a concatenation of all the status strings.

Returns:
a honking big collection of status messages

pushTo

public java.lang.String pushTo(java.lang.String subscriberId)
Pushes subscriptions to the specified subscriber. Returns a status string. We know the subscriber already exists because this method is called either by the Web page menu.jsp that has a list of good subscriber ids or by unit test code.

This method only pushes the subscriptions whose mode is "push".

Parameters:
subscriberId - the subscriber id
Returns:
a status message

pushOfferTo

public java.lang.String pushOfferTo(java.lang.String offerId,
                                    java.lang.String subscriberId)
Pushes all subscriptions to the specified subscriber and offer. Either the subscriber ID or the offer ID can be null. Returns a status string.

This method only pushes the subscriptions whose mode is "push".

Parameters:
subscriberId - the subscriber id
offerId - the offer id
Returns:
a status message

loadSubscriber

public boolean loadSubscriber(java.lang.String subscriberId)
Creates subscriber and asks it to load its information; returns true if the info already exists in permanent storage. If subscriber does not already exist, returns false. Always sets our subscriber to the one that was created and (possibly) loaded.

Parameters:
subscriberId - the subscriber's UUID
Returns:
true if the subscriber's info already existed in our permanent store

storeSubscriber

protected void storeSubscriber()
Asks the subscriber to store its information.