com.aelitis.azureus.core.subs.impl
Class SubscriptionImpl

java.lang.Object
  extended by com.aelitis.azureus.core.subs.impl.SubscriptionImpl
All Implemented Interfaces:
Subscription, UtilitiesImpl.PluginSubscription

public class SubscriptionImpl
extends Object
implements Subscription


Nested Class Summary
protected static class SubscriptionImpl.association
           
 
Field Summary
 
Fields inherited from interface com.aelitis.azureus.core.subs.Subscription
ADD_TYPE_CREATE, ADD_TYPE_IMPORT, ADD_TYPE_LOOKUP, AZ_VERSION, VUZE_FILE_COMPONENT_SUBSCRIPTION_KEY
 
Constructor Summary
protected SubscriptionImpl(SubscriptionManagerImpl _manager, Map map)
           
protected SubscriptionImpl(SubscriptionManagerImpl _manager, String _name, boolean _public, boolean _anonymous, Map _singleton_details, String _json_content, int _add_type)
           
protected SubscriptionImpl(SubscriptionManagerImpl _manager, SubscriptionBodyImpl _body, int _add_type, boolean _is_subscribed)
           
 
Method Summary
 void addAssociation(byte[] hash)
           
protected  boolean addAssociationSupport(byte[] hash, boolean internal)
           
 void addListener(SubscriptionListener l)
           
 void addPotentialAssociation(String result_id, String key)
           
protected static int bytesToInt(byte[] bytes)
           
protected  boolean canAutoUpgradeCheck()
           
protected  void checkPublish()
           
 Subscription cloneWithNewEngine(Engine engine)
           
protected  void destroy()
           
protected static void embedEngines(Map map, Engine engine)
           
protected  String embedEngines(String json_in)
           
protected  void engineUpdated(Engine engine)
           
protected  Engine extractEngine(Map json_map, long id)
           
protected  void fireChanged(int reason)
           
protected  void fireDownloaded(boolean was_auto)
           
protected  void fromMap(Map map)
           
protected  void generate(IndentWriter writer)
           
 long getAddTime()
           
 int getAddType()
           
 int getAssociationCount()
           
protected  SubscriptionImpl.association getAssociationForPublish()
           
protected  int getAssociationsRemainingForPublish()
           
 int getAZVersion()
           
 long getCachedPopularity()
           
 String getCategory()
           
 String getCreatorRef()
           
 Engine getEngine()
           
protected  Engine getEngine(boolean local_only)
           
protected  int getFixedRandom()
           
protected  int getHighestUserPromptedVersion()
           
 int getHighestVersion()
           
 SubscriptionHistory getHistory()
           
protected  Map getHistoryConfig()
           
 String getID()
           
 String getJSON()
           
 SubscriptionManager getManager()
           
 String getName()
          Returns local name if set
 String getName(boolean use_local)
           
 String getNameEx()
           
 String getParent()
           
 void getPopularity(SubscriptionPopularityListener listener)
           
protected  byte[] getPrivateKey()
           
protected  Map getPublicationDetails()
           
protected  byte[] getPublicationHash()
           
protected static byte[] getPublicationHash(Map details)
           
protected static int getPublicationSize(Map details)
           
protected static int getPublicationVersion(Map details)
           
 byte[] getPublicKey()
           
protected  boolean getPublished()
           
 String getQueryKey()
           
 String getReferer()
           
 SubscriptionResult[] getResults(boolean include_deleted)
          shortcut to help plugin interface
protected  Map getScheduleConfig()
           
 VuzeFile getSearchTemplateVuzeFile()
           
protected  boolean getServerPublicationOutstanding()
           
protected  boolean getServerPublished()
           
 byte[] getShortID()
           
protected  Map getSingletonDetails()
           
protected  boolean getSingletonPublishAttempted()
           
protected static String getSkeletonJSON(Engine engine, int check_interval_mins)
           
protected static String getSkeletonJSON(Engine engine, String term, String networks, int check_interval_mins)
           
 String getString()
           
 long getTagID()
          Tag UID
 String getURI()
           
 Object getUserData(Object key)
           
protected  int getVerifiedPublicationVersion(Map details)
           
 int getVersion()
           
 VuzeFile getVuzeFile()
           
 boolean hasAssociation(byte[] hash)
           
protected  void init()
           
protected static byte[] intToBytes(int version)
           
 boolean isAnonymous()
           
 boolean isAutoDownloadSupported()
           
 boolean isMine()
           
 boolean isPublic()
           
protected  boolean isRemoved()
           
 boolean isSearchTemplate()
           
 boolean isSearchTemplateImportable()
           
 boolean isShareable()
           
 boolean isSingleton()
           
 boolean isSubscribed()
           
 boolean isUpdateable()
           
protected  void log(String str)
           
protected  void log(String str, Throwable e)
           
 void remove()
           
 void removeListener(SubscriptionListener l)
           
 void requestAttention()
           
 void reset()
           
 void resetHighestVersion()
           
protected  void setCachedPopularity(long pop)
           
 void setCategory(String _category)
           
 void setCreatorRef(String ref)
           
 boolean setDetails(String _name, boolean _is_public, String _json)
           
protected  void setHighestUserPromptedVersion(int v)
           
 boolean setJSON(String _json)
           
 void setLocalName(String str)
           
 void setName(String _name)
           
 void setParent(String _parent)
           
 void setPublic(boolean _is_public)
           
protected  void setPublished(boolean b)
           
protected  void setServerPublicationOutstanding()
           
protected  void setServerPublished()
           
protected  void setSingletonPublishAttempted()
           
 void setSubscribed(boolean s)
           
 void setTagID(long _tag_id)
           
 void setUserData(Object key, Object data)
           
protected  void syncFromBody(SubscriptionBodyImpl body)
           
protected  void syncToBody(SubscriptionBodyImpl body)
           
protected  Map toMap()
           
protected  void updateHistoryConfig(Map _history_map, int reason)
           
protected  void upgrade(SubscriptionBodyImpl body)
           
protected  boolean verifyPublicationDetails(Map details)
           
protected  void versionUpdated(SubscriptionBodyImpl body, boolean json_changed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubscriptionImpl

protected SubscriptionImpl(SubscriptionManagerImpl _manager,
                           String _name,
                           boolean _public,
                           boolean _anonymous,
                           Map _singleton_details,
                           String _json_content,
                           int _add_type)
                    throws SubscriptionException
Throws:
SubscriptionException

SubscriptionImpl

protected SubscriptionImpl(SubscriptionManagerImpl _manager,
                           Map map)
                    throws IOException
Throws:
IOException

SubscriptionImpl

protected SubscriptionImpl(SubscriptionManagerImpl _manager,
                           SubscriptionBodyImpl _body,
                           int _add_type,
                           boolean _is_subscribed)
                    throws SubscriptionException
Throws:
SubscriptionException
Method Detail

intToBytes

protected static byte[] intToBytes(int version)

bytesToInt

protected static int bytesToInt(byte[] bytes)

getSkeletonJSON

protected static String getSkeletonJSON(Engine engine,
                                        int check_interval_mins)

getSkeletonJSON

protected static String getSkeletonJSON(Engine engine,
                                        String term,
                                        String networks,
                                        int check_interval_mins)

syncFromBody

protected void syncFromBody(SubscriptionBodyImpl body)
                     throws SubscriptionException
Throws:
SubscriptionException

syncToBody

protected void syncToBody(SubscriptionBodyImpl body)
                   throws SubscriptionException
Throws:
SubscriptionException

toMap

protected Map toMap()
             throws IOException
Throws:
IOException

fromMap

protected void fromMap(Map map)
                throws IOException
Throws:
IOException

getScheduleConfig

protected Map getScheduleConfig()

getHistoryConfig

protected Map getHistoryConfig()

updateHistoryConfig

protected void updateHistoryConfig(Map _history_map,
                                   int reason)

upgrade

protected void upgrade(SubscriptionBodyImpl body)
                throws SubscriptionException
Throws:
SubscriptionException

init

protected void init()

isSingleton

public boolean isSingleton()

isShareable

public boolean isShareable()
Specified by:
isShareable in interface Subscription

isSearchTemplate

public boolean isSearchTemplate()
Specified by:
isSearchTemplate in interface Subscription
Specified by:
isSearchTemplate in interface UtilitiesImpl.PluginSubscription

getSingletonDetails

protected Map getSingletonDetails()

getSingletonPublishAttempted

protected boolean getSingletonPublishAttempted()

setSingletonPublishAttempted

protected void setSingletonPublishAttempted()

getName

public String getName()
Description copied from interface: Subscription
Returns local name if set

Specified by:
getName in interface Subscription
Specified by:
getName in interface UtilitiesImpl.PluginSubscription

getName

public String getName(boolean use_local)
Specified by:
getName in interface Subscription

getURI

public String getURI()
Specified by:
getURI in interface Subscription

requestAttention

public void requestAttention()
Specified by:
requestAttention in interface Subscription

setLocalName

public void setLocalName(String str)
Specified by:
setLocalName in interface Subscription

setName

public void setName(String _name)
             throws SubscriptionException
Specified by:
setName in interface Subscription
Throws:
SubscriptionException

getNameEx

public String getNameEx()
Specified by:
getNameEx in interface Subscription

getQueryKey

public String getQueryKey()
Specified by:
getQueryKey in interface Subscription

getAddTime

public long getAddTime()
Specified by:
getAddTime in interface Subscription

getAddType

public int getAddType()
Specified by:
getAddType in interface Subscription

isPublic

public boolean isPublic()
Specified by:
isPublic in interface Subscription

isAnonymous

public boolean isAnonymous()
Specified by:
isAnonymous in interface Subscription

setPublic

public void setPublic(boolean _is_public)
               throws SubscriptionException
Specified by:
setPublic in interface Subscription
Throws:
SubscriptionException

getServerPublicationOutstanding

protected boolean getServerPublicationOutstanding()

setServerPublicationOutstanding

protected void setServerPublicationOutstanding()

setServerPublished

protected void setServerPublished()

getServerPublished

protected boolean getServerPublished()

getJSON

public String getJSON()
               throws SubscriptionException
Specified by:
getJSON in interface Subscription
Throws:
SubscriptionException

setJSON

public boolean setJSON(String _json)
                throws SubscriptionException
Specified by:
setJSON in interface Subscription
Throws:
SubscriptionException

embedEngines

protected String embedEngines(String json_in)

embedEngines

protected static void embedEngines(Map map,
                                   Engine engine)

extractEngine

protected Engine extractEngine(Map json_map,
                               long id)

cloneWithNewEngine

public Subscription cloneWithNewEngine(Engine engine)
                                throws SubscriptionException
Specified by:
cloneWithNewEngine in interface Subscription
Throws:
SubscriptionException

getEngine

public Engine getEngine()
                 throws SubscriptionException
Specified by:
getEngine in interface Subscription
Throws:
SubscriptionException

getEngine

protected Engine getEngine(boolean local_only)
                    throws SubscriptionException
Throws:
SubscriptionException

engineUpdated

protected void engineUpdated(Engine engine)

setDetails

public boolean setDetails(String _name,
                          boolean _is_public,
                          String _json)
                   throws SubscriptionException
Specified by:
setDetails in interface Subscription
Throws:
SubscriptionException

versionUpdated

protected void versionUpdated(SubscriptionBodyImpl body,
                              boolean json_changed)

getPublicKey

public byte[] getPublicKey()
Specified by:
getPublicKey in interface Subscription

getShortID

public byte[] getShortID()

getID

public String getID()
Specified by:
getID in interface Subscription
Specified by:
getID in interface UtilitiesImpl.PluginSubscription

getPrivateKey

protected byte[] getPrivateKey()

getFixedRandom

protected int getFixedRandom()

getVersion

public int getVersion()
Specified by:
getVersion in interface Subscription

getAZVersion

public int getAZVersion()
Specified by:
getAZVersion in interface Subscription

setHighestUserPromptedVersion

protected void setHighestUserPromptedVersion(int v)

getHighestUserPromptedVersion

protected int getHighestUserPromptedVersion()

getHighestVersion

public int getHighestVersion()
Specified by:
getHighestVersion in interface Subscription

resetHighestVersion

public void resetHighestVersion()
Specified by:
resetHighestVersion in interface Subscription

isMine

public boolean isMine()
Specified by:
isMine in interface Subscription

isUpdateable

public boolean isUpdateable()
Specified by:
isUpdateable in interface Subscription

isSubscribed

public boolean isSubscribed()
Specified by:
isSubscribed in interface Subscription

setSubscribed

public void setSubscribed(boolean s)
Specified by:
setSubscribed in interface Subscription

isAutoDownloadSupported

public boolean isAutoDownloadSupported()
Specified by:
isAutoDownloadSupported in interface Subscription

getPopularity

public void getPopularity(SubscriptionPopularityListener listener)
                   throws SubscriptionException
Specified by:
getPopularity in interface Subscription
Throws:
SubscriptionException

getCachedPopularity

public long getCachedPopularity()
Specified by:
getCachedPopularity in interface Subscription

setCachedPopularity

protected void setCachedPopularity(long pop)

getReferer

public String getReferer()
Specified by:
getReferer in interface Subscription

checkPublish

protected void checkPublish()

canAutoUpgradeCheck

protected boolean canAutoUpgradeCheck()

addAssociation

public void addAssociation(byte[] hash)
Specified by:
addAssociation in interface Subscription

addAssociationSupport

protected boolean addAssociationSupport(byte[] hash,
                                        boolean internal)

hasAssociation

public boolean hasAssociation(byte[] hash)
Specified by:
hasAssociation in interface Subscription

addPotentialAssociation

public void addPotentialAssociation(String result_id,
                                    String key)
Specified by:
addPotentialAssociation in interface Subscription

getAssociationCount

public int getAssociationCount()
Specified by:
getAssociationCount in interface Subscription

getAssociationForPublish

protected SubscriptionImpl.association getAssociationForPublish()

getAssociationsRemainingForPublish

protected int getAssociationsRemainingForPublish()

getPublished

protected boolean getPublished()

setPublished

protected void setPublished(boolean b)

getVerifiedPublicationVersion

protected int getVerifiedPublicationVersion(Map details)

getPublicationVersion

protected static int getPublicationVersion(Map details)

getPublicationHash

protected byte[] getPublicationHash()

getPublicationHash

protected static byte[] getPublicationHash(Map details)

getPublicationSize

protected static int getPublicationSize(Map details)

getPublicationDetails

protected Map getPublicationDetails()

verifyPublicationDetails

protected boolean verifyPublicationDetails(Map details)

setCreatorRef

public void setCreatorRef(String ref)
Specified by:
setCreatorRef in interface Subscription

getCreatorRef

public String getCreatorRef()
Specified by:
getCreatorRef in interface Subscription

setCategory

public void setCategory(String _category)
Specified by:
setCategory in interface Subscription

getCategory

public String getCategory()
Specified by:
getCategory in interface Subscription

setTagID

public void setTagID(long _tag_id)
Specified by:
setTagID in interface Subscription

getTagID

public long getTagID()
Description copied from interface: Subscription
Tag UID

Specified by:
getTagID in interface Subscription

getParent

public String getParent()
Specified by:
getParent in interface Subscription

setParent

public void setParent(String _parent)
Specified by:
setParent in interface Subscription

fireChanged

protected void fireChanged(int reason)

fireDownloaded

protected void fireDownloaded(boolean was_auto)

addListener

public void addListener(SubscriptionListener l)
Specified by:
addListener in interface Subscription

removeListener

public void removeListener(SubscriptionListener l)
Specified by:
removeListener in interface Subscription

getHistory

public SubscriptionHistory getHistory()
Specified by:
getHistory in interface Subscription

getManager

public SubscriptionManager getManager()
Specified by:
getManager in interface Subscription

getVuzeFile

public VuzeFile getVuzeFile()
                     throws SubscriptionException
Specified by:
getVuzeFile in interface Subscription
Throws:
SubscriptionException

getSearchTemplateVuzeFile

public VuzeFile getSearchTemplateVuzeFile()
Specified by:
getSearchTemplateVuzeFile in interface Subscription

isSearchTemplateImportable

public boolean isSearchTemplateImportable()
Specified by:
isSearchTemplateImportable in interface Subscription

destroy

protected void destroy()

reset

public void reset()
Specified by:
reset in interface Subscription

remove

public void remove()
Specified by:
remove in interface Subscription

isRemoved

protected boolean isRemoved()

getResults

public SubscriptionResult[] getResults(boolean include_deleted)
Description copied from interface: Subscription
shortcut to help plugin interface

Specified by:
getResults in interface Subscription
Specified by:
getResults in interface UtilitiesImpl.PluginSubscription

setUserData

public void setUserData(Object key,
                        Object data)
Specified by:
setUserData in interface Subscription

getUserData

public Object getUserData(Object key)
Specified by:
getUserData in interface Subscription

log

protected void log(String str)

log

protected void log(String str,
                   Throwable e)

getString

public String getString()
Specified by:
getString in interface Subscription

generate

protected void generate(IndentWriter writer)