Package com.biglybt.core.subs.impl
Class SubscriptionImpl
- java.lang.Object
-
- com.biglybt.core.subs.impl.SubscriptionImpl
-
- All Implemented Interfaces:
Subscription
,DataSourceResolver.ExportableDataSource
,UtilitiesImpl.PluginSubscription
public class SubscriptionImpl extends java.lang.Object implements Subscription, DataSourceResolver.ExportableDataSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SubscriptionImpl.association
-
Field Summary
Fields Modifier and Type Field Description private long
add_time
private int
add_type
private java.util.List<SubscriptionImpl.association>
associations
private int
az_version
private java.lang.String
category
private java.lang.String
creator_ref
private boolean
destroyed
private int
fixed_random
private byte[]
hash
private int
highest_prompted_version
private SubscriptionHistoryImpl
history
private java.util.Map
history_map
private java.lang.String
id
private boolean
is_anonymous
private boolean
is_public
private boolean
is_subscribed
private long
last_auto_upgrade_check
private CopyOnWriteList
listeners
private java.lang.String
local_name
private LightWeightSeed
lws
private int
lws_skip_check
private SubscriptionManagerImpl
manager
private static int
MAX_ASSOCIATIONS
private static int
MIN_RECENT_ASSOC_TO_RETAIN
private java.lang.String
name
private java.lang.String
name_ex
private java.lang.String
parent
private long
popularity
private byte[]
private_key
private byte[]
public_key
private boolean
published
private java.lang.String
referer
private java.util.Map
schedule_map
private boolean
server_publication_outstanding
private boolean
server_published
private byte[]
short_id
private byte[]
sig
private int
sig_data_size
private java.util.Map
singleton_details
private boolean
singleton_sp_attempted
private long
tag_id
private java.util.Map
user_data
private java.util.Map
verify_cache_details
private boolean
verify_cache_result
private int
version
private int
view_options
-
Fields inherited from interface com.biglybt.core.subs.Subscription
ADD_TYPE_CREATE, ADD_TYPE_IMPORT, ADD_TYPE_LOOKUP, AZ_VERSION, VO_FULL, VO_HIDE_HEADER, VUZE_FILE_COMPONENT_SUBSCRIPTION_KEY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SubscriptionImpl(SubscriptionManagerImpl _manager, SubscriptionBodyImpl _body, int _add_type, boolean _is_subscribed)
protected
SubscriptionImpl(SubscriptionManagerImpl _manager, java.lang.String _name, boolean _public, boolean _anonymous, java.util.Map _singleton_details, java.lang.String _json_content, int _add_type)
protected
SubscriptionImpl(SubscriptionManagerImpl _manager, java.util.Map map)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAssociation(byte[] hash)
protected boolean
addAssociationSupport(byte[] hash, boolean internal)
void
addListener(SubscriptionListener l)
void
addPotentialAssociation(java.lang.String result_id, java.lang.String key)
protected static int
bytesToInt(byte[] bytes)
protected boolean
canAutoUpgradeCheck()
protected void
checkPublish()
Subscription
cloneWithNewEngine(Engine engine)
protected void
destroy()
protected java.lang.String
embedEngines(java.lang.String json_in)
protected static void
embedEngines(java.util.Map map, Engine engine)
protected void
engineUpdated(Engine engine)
DataSourceResolver.ExportedDataSource
exportDataSource()
protected Engine
extractEngine(java.util.Map json_map, long id)
protected void
fireChanged(int reason)
protected void
fireDownloaded()
protected void
fromMap(java.util.Map map)
protected void
generate(IndentWriter writer)
long
getAddTime()
int
getAddType()
int
getAssociationCount()
protected SubscriptionImpl.association
getAssociationForPublish()
protected int
getAssociationsRemainingForPublish()
int
getAZVersion()
long
getCachedPopularity()
java.lang.String
getCategory()
java.lang.String
getCreatorRef()
Engine
getEngine()
protected Engine
getEngine(boolean local_only)
SubscriptionResultFilter
getFilters()
protected int
getFixedRandom()
protected int
getHighestUserPromptedVersion()
int
getHighestVersion()
SubscriptionHistory
getHistory()
protected java.util.Map
getHistoryConfig()
java.lang.String
getID()
java.lang.String
getJSON()
SubscriptionManager
getManager()
java.lang.String
getName()
Returns local name if setjava.lang.String
getName(boolean use_local)
java.lang.String
getNameEx()
java.lang.String
getParent()
void
getPopularity(SubscriptionPopularityListener listener)
protected byte[]
getPrivateKey()
protected java.util.Map
getPublicationDetails()
protected byte[]
getPublicationHash()
protected static byte[]
getPublicationHash(java.util.Map details)
protected static int
getPublicationSize(java.util.Map details)
protected static int
getPublicationVersion(java.util.Map details)
byte[]
getPublicKey()
protected boolean
getPublished()
java.lang.String
getQueryKey()
java.lang.String
getReferer()
SubscriptionResult[]
getResults(boolean include_deleted)
shortcut to help plugin interfaceprotected java.util.Map
getScheduleConfig()
VuzeFile
getSearchTemplateVuzeFile()
protected boolean
getServerPublicationOutstanding()
protected boolean
getServerPublished()
byte[]
getShortID()
protected java.util.Map
getSingletonDetails()
protected boolean
getSingletonPublishAttempted()
protected static java.lang.String
getSkeletonJSON(Engine engine, int check_interval_mins)
protected static java.lang.String
getSkeletonJSON(Engine engine, java.lang.String term, java.lang.String networks, int check_interval_mins)
java.lang.String
getString()
long
getTagID()
Tag UIDjava.lang.String
getURI()
java.lang.Object
getUserData(java.lang.Object key)
protected int
getVerifiedPublicationVersion(java.util.Map details)
int
getVersion()
int
getViewOptions()
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(java.lang.String str)
protected void
log(java.lang.String str, java.lang.Throwable e)
void
remove()
void
removeListener(SubscriptionListener l)
void
requestAttention()
void
reset()
void
resetHighestVersion()
protected void
setCachedPopularity(long pop)
void
setCategory(java.lang.String _category)
void
setCreatorRef(java.lang.String ref)
boolean
setDetails(java.lang.String _name, boolean _is_public, java.lang.String _json)
protected void
setHighestUserPromptedVersion(int v)
boolean
setJSON(java.lang.String _json)
void
setLocalName(java.lang.String str)
void
setName(java.lang.String _name)
void
setParent(java.lang.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(java.lang.Object key, java.lang.Object data)
void
setViewOptions(int _options)
protected void
syncFromBody(SubscriptionBodyImpl body)
protected void
syncToBody(SubscriptionBodyImpl body)
protected java.util.Map
toMap()
protected void
updateHistoryConfig(java.util.Map _history_map, int reason)
protected void
upgrade(SubscriptionBodyImpl body)
protected boolean
verifyPublicationDetails(java.util.Map details)
protected void
versionUpdated(SubscriptionBodyImpl body, boolean json_changed)
-
-
-
Field Detail
-
MAX_ASSOCIATIONS
private static final int MAX_ASSOCIATIONS
-
MIN_RECENT_ASSOC_TO_RETAIN
private static final int MIN_RECENT_ASSOC_TO_RETAIN
- See Also:
- Constant Field Values
-
manager
private SubscriptionManagerImpl manager
-
public_key
private byte[] public_key
-
private_key
private byte[] private_key
-
name
private java.lang.String name
-
name_ex
private java.lang.String name_ex
-
version
private int version
-
az_version
private int az_version
-
is_public
private boolean is_public
-
is_anonymous
private boolean is_anonymous
-
singleton_details
private java.util.Map singleton_details
-
hash
private byte[] hash
-
sig
private byte[] sig
-
sig_data_size
private int sig_data_size
-
add_type
private int add_type
-
add_time
private long add_time
-
is_subscribed
private boolean is_subscribed
-
highest_prompted_version
private int highest_prompted_version
-
short_id
private byte[] short_id
-
id
private java.lang.String id
-
associations
private java.util.List<SubscriptionImpl.association> associations
-
fixed_random
private int fixed_random
-
popularity
private long popularity
-
last_auto_upgrade_check
private long last_auto_upgrade_check
-
published
private boolean published
-
server_published
private boolean server_published
-
server_publication_outstanding
private boolean server_publication_outstanding
-
singleton_sp_attempted
private boolean singleton_sp_attempted
-
local_name
private java.lang.String local_name
-
lws
private LightWeightSeed lws
-
lws_skip_check
private int lws_skip_check
-
destroyed
private boolean destroyed
-
history_map
private java.util.Map history_map
-
schedule_map
private java.util.Map schedule_map
-
user_data
private java.util.Map user_data
-
history
private final SubscriptionHistoryImpl history
-
referer
private java.lang.String referer
-
listeners
private CopyOnWriteList listeners
-
verify_cache_details
private java.util.Map verify_cache_details
-
verify_cache_result
private boolean verify_cache_result
-
creator_ref
private java.lang.String creator_ref
-
category
private java.lang.String category
-
tag_id
private long tag_id
-
view_options
private int view_options
-
parent
private java.lang.String parent
-
-
Constructor Detail
-
SubscriptionImpl
protected SubscriptionImpl(SubscriptionManagerImpl _manager, java.lang.String _name, boolean _public, boolean _anonymous, java.util.Map _singleton_details, java.lang.String _json_content, int _add_type) throws SubscriptionException
- Throws:
SubscriptionException
-
SubscriptionImpl
protected SubscriptionImpl(SubscriptionManagerImpl _manager, java.util.Map map) throws java.io.IOException
- Throws:
java.io.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 java.lang.String getSkeletonJSON(Engine engine, int check_interval_mins)
-
getSkeletonJSON
protected static java.lang.String getSkeletonJSON(Engine engine, java.lang.String term, java.lang.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 java.util.Map toMap() throws java.io.IOException
- Throws:
java.io.IOException
-
fromMap
protected void fromMap(java.util.Map map) throws java.io.IOException
- Throws:
java.io.IOException
-
exportDataSource
public DataSourceResolver.ExportedDataSource exportDataSource()
- Specified by:
exportDataSource
in interfaceDataSourceResolver.ExportableDataSource
-
getScheduleConfig
protected java.util.Map getScheduleConfig()
-
getHistoryConfig
protected java.util.Map getHistoryConfig()
-
updateHistoryConfig
protected void updateHistoryConfig(java.util.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 interfaceSubscription
-
isSearchTemplate
public boolean isSearchTemplate()
- Specified by:
isSearchTemplate
in interfaceSubscription
- Specified by:
isSearchTemplate
in interfaceUtilitiesImpl.PluginSubscription
-
getSingletonDetails
protected java.util.Map getSingletonDetails()
-
getSingletonPublishAttempted
protected boolean getSingletonPublishAttempted()
-
setSingletonPublishAttempted
protected void setSingletonPublishAttempted()
-
getName
public java.lang.String getName()
Description copied from interface:Subscription
Returns local name if set- Specified by:
getName
in interfaceSubscription
- Specified by:
getName
in interfaceUtilitiesImpl.PluginSubscription
-
getName
public java.lang.String getName(boolean use_local)
- Specified by:
getName
in interfaceSubscription
-
getURI
public java.lang.String getURI()
- Specified by:
getURI
in interfaceSubscription
-
requestAttention
public void requestAttention()
- Specified by:
requestAttention
in interfaceSubscription
-
setLocalName
public void setLocalName(java.lang.String str)
- Specified by:
setLocalName
in interfaceSubscription
-
setName
public void setName(java.lang.String _name) throws SubscriptionException
- Specified by:
setName
in interfaceSubscription
- Throws:
SubscriptionException
-
getNameEx
public java.lang.String getNameEx()
- Specified by:
getNameEx
in interfaceSubscription
-
getQueryKey
public java.lang.String getQueryKey()
- Specified by:
getQueryKey
in interfaceSubscription
-
getAddTime
public long getAddTime()
- Specified by:
getAddTime
in interfaceSubscription
-
getAddType
public int getAddType()
- Specified by:
getAddType
in interfaceSubscription
-
isPublic
public boolean isPublic()
- Specified by:
isPublic
in interfaceSubscription
-
isAnonymous
public boolean isAnonymous()
- Specified by:
isAnonymous
in interfaceSubscription
-
setPublic
public void setPublic(boolean _is_public) throws SubscriptionException
- Specified by:
setPublic
in interfaceSubscription
- Throws:
SubscriptionException
-
getServerPublicationOutstanding
protected boolean getServerPublicationOutstanding()
-
setServerPublicationOutstanding
protected void setServerPublicationOutstanding()
-
setServerPublished
protected void setServerPublished()
-
getServerPublished
protected boolean getServerPublished()
-
getJSON
public java.lang.String getJSON() throws SubscriptionException
- Specified by:
getJSON
in interfaceSubscription
- Throws:
SubscriptionException
-
setJSON
public boolean setJSON(java.lang.String _json) throws SubscriptionException
- Specified by:
setJSON
in interfaceSubscription
- Throws:
SubscriptionException
-
embedEngines
protected java.lang.String embedEngines(java.lang.String json_in)
-
embedEngines
protected static void embedEngines(java.util.Map map, Engine engine)
-
extractEngine
protected Engine extractEngine(java.util.Map json_map, long id)
-
cloneWithNewEngine
public Subscription cloneWithNewEngine(Engine engine) throws SubscriptionException
- Specified by:
cloneWithNewEngine
in interfaceSubscription
- Throws:
SubscriptionException
-
getEngine
public Engine getEngine() throws SubscriptionException
- Specified by:
getEngine
in interfaceSubscription
- Throws:
SubscriptionException
-
getEngine
protected Engine getEngine(boolean local_only) throws SubscriptionException
- Throws:
SubscriptionException
-
engineUpdated
protected void engineUpdated(Engine engine)
-
setDetails
public boolean setDetails(java.lang.String _name, boolean _is_public, java.lang.String _json) throws SubscriptionException
- Specified by:
setDetails
in interfaceSubscription
- Throws:
SubscriptionException
-
versionUpdated
protected void versionUpdated(SubscriptionBodyImpl body, boolean json_changed)
-
getPublicKey
public byte[] getPublicKey()
- Specified by:
getPublicKey
in interfaceSubscription
-
getShortID
public byte[] getShortID()
-
getID
public java.lang.String getID()
- Specified by:
getID
in interfaceSubscription
- Specified by:
getID
in interfaceUtilitiesImpl.PluginSubscription
-
getPrivateKey
protected byte[] getPrivateKey()
-
getFixedRandom
protected int getFixedRandom()
-
getVersion
public int getVersion()
- Specified by:
getVersion
in interfaceSubscription
-
getAZVersion
public int getAZVersion()
- Specified by:
getAZVersion
in interfaceSubscription
-
setHighestUserPromptedVersion
protected void setHighestUserPromptedVersion(int v)
-
getHighestUserPromptedVersion
protected int getHighestUserPromptedVersion()
-
getHighestVersion
public int getHighestVersion()
- Specified by:
getHighestVersion
in interfaceSubscription
-
resetHighestVersion
public void resetHighestVersion()
- Specified by:
resetHighestVersion
in interfaceSubscription
-
isMine
public boolean isMine()
- Specified by:
isMine
in interfaceSubscription
-
isUpdateable
public boolean isUpdateable()
- Specified by:
isUpdateable
in interfaceSubscription
-
isSubscribed
public boolean isSubscribed()
- Specified by:
isSubscribed
in interfaceSubscription
-
setSubscribed
public void setSubscribed(boolean s)
- Specified by:
setSubscribed
in interfaceSubscription
-
isAutoDownloadSupported
public boolean isAutoDownloadSupported()
- Specified by:
isAutoDownloadSupported
in interfaceSubscription
-
getPopularity
public void getPopularity(SubscriptionPopularityListener listener) throws SubscriptionException
- Specified by:
getPopularity
in interfaceSubscription
- Throws:
SubscriptionException
-
getCachedPopularity
public long getCachedPopularity()
- Specified by:
getCachedPopularity
in interfaceSubscription
-
setCachedPopularity
protected void setCachedPopularity(long pop)
-
getReferer
public java.lang.String getReferer()
- Specified by:
getReferer
in interfaceSubscription
-
checkPublish
protected void checkPublish()
-
canAutoUpgradeCheck
protected boolean canAutoUpgradeCheck()
-
addAssociation
public void addAssociation(byte[] hash)
- Specified by:
addAssociation
in interfaceSubscription
-
addAssociationSupport
protected boolean addAssociationSupport(byte[] hash, boolean internal)
-
hasAssociation
public boolean hasAssociation(byte[] hash)
- Specified by:
hasAssociation
in interfaceSubscription
-
addPotentialAssociation
public void addPotentialAssociation(java.lang.String result_id, java.lang.String key)
- Specified by:
addPotentialAssociation
in interfaceSubscription
-
getAssociationCount
public int getAssociationCount()
- Specified by:
getAssociationCount
in interfaceSubscription
-
getAssociationForPublish
protected SubscriptionImpl.association getAssociationForPublish()
-
getAssociationsRemainingForPublish
protected int getAssociationsRemainingForPublish()
-
getPublished
protected boolean getPublished()
-
setPublished
protected void setPublished(boolean b)
-
getVerifiedPublicationVersion
protected int getVerifiedPublicationVersion(java.util.Map details)
-
getPublicationVersion
protected static int getPublicationVersion(java.util.Map details)
-
getPublicationHash
protected byte[] getPublicationHash()
-
getPublicationHash
protected static byte[] getPublicationHash(java.util.Map details)
-
getPublicationSize
protected static int getPublicationSize(java.util.Map details)
-
getPublicationDetails
protected java.util.Map getPublicationDetails()
-
verifyPublicationDetails
protected boolean verifyPublicationDetails(java.util.Map details)
-
setCreatorRef
public void setCreatorRef(java.lang.String ref)
- Specified by:
setCreatorRef
in interfaceSubscription
-
getCreatorRef
public java.lang.String getCreatorRef()
- Specified by:
getCreatorRef
in interfaceSubscription
-
setCategory
public void setCategory(java.lang.String _category)
- Specified by:
setCategory
in interfaceSubscription
-
getCategory
public java.lang.String getCategory()
- Specified by:
getCategory
in interfaceSubscription
-
setTagID
public void setTagID(long _tag_id)
- Specified by:
setTagID
in interfaceSubscription
-
getTagID
public long getTagID()
Description copied from interface:Subscription
Tag UID- Specified by:
getTagID
in interfaceSubscription
-
getViewOptions
public int getViewOptions()
- Specified by:
getViewOptions
in interfaceSubscription
-
setViewOptions
public void setViewOptions(int _options)
- Specified by:
setViewOptions
in interfaceSubscription
-
getParent
public java.lang.String getParent()
- Specified by:
getParent
in interfaceSubscription
-
setParent
public void setParent(java.lang.String _parent)
- Specified by:
setParent
in interfaceSubscription
-
fireChanged
protected void fireChanged(int reason)
-
fireDownloaded
protected void fireDownloaded()
-
addListener
public void addListener(SubscriptionListener l)
- Specified by:
addListener
in interfaceSubscription
-
removeListener
public void removeListener(SubscriptionListener l)
- Specified by:
removeListener
in interfaceSubscription
-
getHistory
public SubscriptionHistory getHistory()
- Specified by:
getHistory
in interfaceSubscription
-
getManager
public SubscriptionManager getManager()
- Specified by:
getManager
in interfaceSubscription
-
getVuzeFile
public VuzeFile getVuzeFile() throws SubscriptionException
- Specified by:
getVuzeFile
in interfaceSubscription
- Throws:
SubscriptionException
-
getSearchTemplateVuzeFile
public VuzeFile getSearchTemplateVuzeFile()
- Specified by:
getSearchTemplateVuzeFile
in interfaceSubscription
-
isSearchTemplateImportable
public boolean isSearchTemplateImportable()
- Specified by:
isSearchTemplateImportable
in interfaceSubscription
-
destroy
protected void destroy()
-
reset
public void reset()
- Specified by:
reset
in interfaceSubscription
-
remove
public void remove()
- Specified by:
remove
in interfaceSubscription
-
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 interfaceSubscription
- Specified by:
getResults
in interfaceUtilitiesImpl.PluginSubscription
-
getFilters
public SubscriptionResultFilter getFilters() throws SubscriptionException
- Specified by:
getFilters
in interfaceSubscription
- Throws:
SubscriptionException
-
setUserData
public void setUserData(java.lang.Object key, java.lang.Object data)
- Specified by:
setUserData
in interfaceSubscription
-
getUserData
public java.lang.Object getUserData(java.lang.Object key)
- Specified by:
getUserData
in interfaceSubscription
-
log
protected void log(java.lang.String str)
-
log
protected void log(java.lang.String str, java.lang.Throwable e)
-
getString
public java.lang.String getString()
- Specified by:
getString
in interfaceSubscription
-
generate
protected void generate(IndentWriter writer)
-
-