Package io.github.mastodonContentMover
Class Post
java.lang.Object
io.github.mastodonContentMover.Post
Holds in an XML-persistable object all the data associated with a Mastodon status,
using
MediaFile
objects to store metadata
associated with media files.
- Since:
- 0.01.00
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
Post
(String postId, String mastodonId, PostArchive pa) Loads thePost
object with the specified archiveId in the specifiedPostArchive
from file if it is available, or creates a newPost
object if no data is found for that archiveId on the filesystem within the given data directory for the specifiedPostArchive
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addMastodonId
(String mi) protected void
protected String
protected long
Obtains as a primitivelong
the number of a count of favourites for the status represented by thisPost
object.protected String
protected String
protected String
Returns the most recent Mastodon instance id used for thisPost
on the instance specified as a parameter.protected String[]
getMedia()
protected long
Obtains as a primitivelong
the number of times the Mastodon status represented by thisPost
object was reblogged.protected String
protected String
Retrieves the value of the Mastodonspoiler_text
field stored for thisPost
object.protected String
getText()
Retrieves the plain text that comprises the body of the Mastodon status thisPost
object represents.protected String
protected boolean
hasMastodonId
(String mi) protected boolean
hasMedia()
Indicates whether thisPost
object has any media attachments.protected boolean
protected boolean
protected boolean
Obtains a primitiveboolean
value that indicates whether the Mastodon status represented by thisPost
object is bookmarked by the account used to save it to the archive.protected boolean
Obtains a primitiveboolean
value that indicates whether the Mastodon status represented by thisPost
object is favourited by the account used to save it to the archive.protected boolean
isPinned()
Obtains a primitiveboolean
value that indicates whether the Mastodon status represented by thisPost
object is pinned by the account used to save it to the archive.protected boolean
Obtains as a primitiveboolean
value the sensitivity of the Mastodon status represented by thisPost
object.protected void
Halts the saving to file of changes to thisPost
object as and when they are made, until this behaviour is restored with .protected void
Resumes the saving to file of changes to thisPost
object as and when they are made, and saves its current state to file.protected void
setFavouritesCount
(long fc) Stores as a primitivelong
the number of favourites for the Mastodon status represented by thisPost
object, and saves the change to file if persistance has not been paused.protected void
setInReplyToArchiveId
(String irtai) protected void
setIsBookmarked
(boolean ib) Stores as a primitiveboolean
whether the Mastodon status represented by thisPost
object is bookmarked by the account used to save it to the archive, and saves the change to file if persistance has not been paused.protected void
setIsFavourited
(boolean ifav) Stores as a primitiveboolean
whether the Mastodon status represented by thisPost
object is favourited by the account used to save it to the archive, and saves the change to file if persistance has not been paused.protected void
setIsPinned
(boolean ip) Stores as a primitiveboolean
whether the Mastodon status represented by thisPost
object is pinned by the account used to save it to the archive, and saves the change to file if persistance has not been paused.protected void
setIsSensitive
(boolean is) Stores as a primitiveboolean
value the sensitivity of the Mastodon status represented by thisPost
object, and saves the change to file if persistance has not been paused.protected void
protected void
setReblogsCount
(long rc) Stores as a primitivelong
the number of times the Mastodon status represented by thisPost
object was reblogged, and saves the change to file if persistance has not been paused.protected void
setReblogUrl
(String ru) protected void
setSpoilerText
(String st) Stores the value of the Mastodonspoiler_text
field in thisPost
object, and saves the change to file if persistance has not been paused.protected void
Stores the Mastodon StatusSource, which is the plain text used to compose the status, to thisPost
object, and saves the change to file if persistance has not been paused.protected void
-
Constructor Details
-
Post
protected Post(String postId, String mastodonId, PostArchive pa) throws jakarta.xml.bind.JAXBException, IOException Loads thePost
object with the specified archiveId in the specifiedPostArchive
from file if it is available, or creates a newPost
object if no data is found for that archiveId on the filesystem within the given data directory for the specifiedPostArchive
.
Currently themastodonId
parameter can be null, but it would be better if a separate constructor was made without themastodonId
parameter. This constructor could then call that constructor and perform the processing required for themastodonId
specified after receiving thePost
object from that constructor (including registering it with the archive). Then parameters would never need to be null. Also the postId parameter would really be better if it was named archiveId. (TODO)
Would also be good to mention in this doc info when this is likely to be called (TODO)- Parameters:
postId
- the MastodonContentMover internal archiveId for this postmastodonId
- the id for this post on a specific Mastodon instancepa
- thePostArchive
from which to load thePost
object- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)IllegalStateException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
-
Method Details
-
getArchiveId
Gives the MastodonContentMover internal id for thisPost
object, based on the creation date of the Mastodon post that was first downloaded and from which thisPost
object, in this archive, was first created.
For example, if you create an archive from "instance #1", use that archive to populate "instance #2", then create a fresh archive from "instance #2", the date that will be used for this comparison will be the date you used your initial archive to populate "instance #2" (not the date you first created the post on "instance #1").- Returns:
- the archiveId of this
Post
object - Since:
- 0.01.00
-
getLatestMastodonId
Returns the most recent Mastodon instance id used for thisPost
on the instance specified as a parameter.- Parameters:
i
- the instance address or hostname, specified as aString
- Returns:
- the most recent Mastodon instance id, comprised of the address or hostname for that
instance and the internal id for this post on that instance, that was
retrieved when reposting this
Post
from this archive to the instance specified. - Since:
- 0.01.00
- See Also:
-
addMastodonId
Associates with thisPost
object a new mastodonIdString
value, comprised of the Mastodon instance hostname/address concatenated with the id used for the status on that instance, and saves the change to file if persistance has not been paused.- Parameters:
mi
- a Mastodon instance hostname/address concatenated with a separator and the id used for the status on that instance- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
hasMastodonId
Checks whether the specified mastodonIdString
value, comprised of a Mastodon instance hostname/address concatenated with the id used for the status on that instance, is already among those associated with thisPost
object.- Parameters:
mi
- a Mastodon instance hostname/address concatenated with a separator and the id used for the status on that instance- Since:
- 0.01.05
-
getMastodonIds
Obtains an ordered primitiveString
array of all the mastodonId values associated with thisPost
object, each comprised of a Mastodon instance hostname/address concatenated with the id used for the status on that instance.
The array is ordered according to the sequence in which thisPost
object was reposted to each Mastodon instance. The same Mastodon instance may appear more than once in the list (although presumably not with the same id - if that has happened it probably means something has gone wrong, as the alternative of the same status having been assigned the same numeric id by the same instance on two separate occasions is highly unlikely - TODO: check for duplicates on adding?)- Returns:
- an array of
String
objects each containing a Mastodon instance hostname/address concatenated with a separator and the id used for the status on that instance - Since:
- 0.01.00
- See Also:
-
pausePersistence
protected void pausePersistence()Halts the saving to file of changes to thisPost
object as and when they are made, until this behaviour is restored with .- Since:
- 0.01.00
-
resumePersistence
Resumes the saving to file of changes to thisPost
object as and when they are made, and saves its current state to file.- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
-
setText
Stores the Mastodon StatusSource, which is the plain text used to compose the status, to thisPost
object, and saves the change to file if persistance has not been paused.- Parameters:
pt
- the plain text that comprises the body of this post- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
-
getText
Retrieves the plain text that comprises the body of the Mastodon status thisPost
object represents.- Returns:
- the body text of this
Post
object in plain text - Since:
- 0.01.00
-
setSpoilerText
Stores the value of the Mastodonspoiler_text
field in thisPost
object, and saves the change to file if persistance has not been paused.- Parameters:
st
- the text used to apply a spoiler or content warning on this post, also known elsewhere on ActivityPub as a summary- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getSpoilerText
- Returns:
- the text used to apply a spoiler or content warning on this post, also
known elsewhere on ActivityPub as a summary
- Since:
- 0.01.00
- See Also:
-
setVisibility
Stores as aString
value the visibility of the Mastodon status represented by thisPost
object, and saves the change to file if persistance has not been paused.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.
At time of writing, values are:
- public = Visible to everyone, shown in public timelines.
- unlisted = Visible to public, but not included in public timelines.
- private = Visible to followers only, and to any mentioned users.
- direct = Visible only to mentioned users.
- Parameters:
v
- the visibility of the status represented by thisPost
object- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getVisibility
Obtains as aString
value the visibility of the Mastodon status represented by thisPost
object.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.
At time of writing, values are:
- public = Visible to everyone, shown in public timelines.
- unlisted = Visible to public, but not included in public timelines.
- private = Visible to followers only, and to any mentioned users.
- direct = Visible only to mentioned users.
- Returns:
- the visibility of the status represented by this
Post
object - Since:
- 0.01.00
- See Also:
-
setIsSensitive
Stores as a primitiveboolean
value the sensitivity of the Mastodon status represented by thisPost
object, and saves the change to file if persistance has not been paused.- Parameters:
is
-true
for statuses that should be concealed beneath a spoiler or content warning, orfalse
where that is not the case- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isSensitive
protected boolean isSensitive()Obtains as a primitiveboolean
value the sensitivity of the Mastodon status represented by thisPost
object.- Returns:
true
for statuses that should be concealed beneath a spoiler or content warning, orfalse
where that is not the case- Since:
- 0.01.00
- See Also:
-
setInReplyToArchiveId
protected void setInReplyToArchiveId(String irtai) throws jakarta.xml.bind.JAXBException, IOException Stores the MastodonContentMover internal archiveId for aPost
object to which thisPost
object is a reply, and saves the change to file if persistance has not been paused.
This tool only links self-replies in this way, not replies to statuses by other users.- Parameters:
irtai
- thearchiveId
for aPost
object to which thisPost
object is a reply- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getInReplyToArchiveId
Obtains the MastodonContentMover internal archiveId for aPost
object to which thisPost
object is a reply.
This tool only links self-replies in this way, not replies to statuses by other users. -
setReblogUrl
Stores as aString
the URL of a Mastodon status that was reblogged in the status thisPost
object represents, and saves the change to file if persistance has not been paused.- Parameters:
ru
- the url of a Mastodon status reblogged in thisPost
object- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getReblogUrl
Obtains as aString
the URL of a Mastodon status that was reblogged in the status thisPost
object represents.
In order to repost this reblogged status, it is necessary to search for this URL on the Mastodon instance where thisPost
object is being reposted, using "resolve=true", to get the status id on that instance. (This is not implemented yet - TODO!)- Returns:
- the url of a Mastodon status reblogged in this
Post
object - Since:
- 0.01.00
- See Also:
-
setLanguage
Stores as aString
value an ISO 639 Part 1 two-letter language code for the Mastodon status represented by thisPost
object, and saves the change to file if persistance has not been paused.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.- Parameters:
l
- an ISO 639 Part 1 two-letter language code for the status represented by thisPost
object- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getLanguage
Obtains as aString
value an ISO 639 Part 1 two-letter language code for the Mastodon status represented by thisPost
object.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.- Returns:
- an ISO 639 Part 1 two-letter language code for the status represented by
this
Post
object - Since:
- 0.01.00
- See Also:
-
setIsFavourited
Stores as a primitiveboolean
whether the Mastodon status represented by thisPost
object is favourited by the account used to save it to the archive, and saves the change to file if persistance has not been paused.
This field may later be used to determine whether a status created when thisPost
is reposted should be favourited again, based also on the parameters specified when the tool is run. (TODO)- Parameters:
ifav
-true
for statuses that have been favourited by the account used to save it to the archive, orfalse
otherwise- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isFavourited
protected boolean isFavourited()Obtains a primitiveboolean
value that indicates whether the Mastodon status represented by thisPost
object is favourited by the account used to save it to the archive.
This field may later be used to determine whether a status created when thisPost
is reposted should be favourited again, based also on the parameters specified when the tool is run. (TODO)- Returns:
true
for statuses that have been favourited by the account used to save it to the archive, orfalse
otherwise- Since:
- 0.01.00
- See Also:
-
setIsBookmarked
Stores as a primitiveboolean
whether the Mastodon status represented by thisPost
object is bookmarked by the account used to save it to the archive, and saves the change to file if persistance has not been paused.
This field is used to determine whether a status created when thisPost
is reposted should be bookmarked again, based also on the parameters specified when the tool is run.- Parameters:
ib
-true
for statuses that have been bookmarked by the account used to save it to the archive, orfalse
otherwise- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isBookmarked
protected boolean isBookmarked()Obtains a primitiveboolean
value that indicates whether the Mastodon status represented by thisPost
object is bookmarked by the account used to save it to the archive.
This field is used to determine whether a status created when thisPost
is reposted should be bookmarked again, based also on the parameters specified when the tool is run.- Returns:
true
for statuses that have been bookmarked by the account used to save it to the archive, orfalse
otherwise- Since:
- 0.01.00
- See Also:
-
setIsPinned
Stores as a primitiveboolean
whether the Mastodon status represented by thisPost
object is pinned by the account used to save it to the archive, and saves the change to file if persistance has not been paused.
This field is used to determine whether a status created when thisPost
is reposted should be pinned again, based also on the parameters specified when the tool is run.- Parameters:
ip
-true
for statuses that have been pinned by the account used to save it to the archive, orfalse
otherwise- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isPinned
protected boolean isPinned()Obtains a primitiveboolean
value that indicates whether the Mastodon status represented by thisPost
object is pinned by the account used to save it to the archive.
This field is used to determine whether a status created when thisPost
is reposted should be pinned again, based also on the parameters specified when the tool is run.- Returns:
true
for statuses that have been pinned by the account used to save it to the archive, orfalse
otherwise- Since:
- 0.01.00
- See Also:
-
setFavouritesCount
Stores as a primitivelong
the number of favourites for the Mastodon status represented by thisPost
object, and saves the change to file if persistance has not been paused.
This field may later be used to determine whether or not to repost thisPost
object, based on a threshold specified when the tool is run. (TODO)- Parameters:
fc
- the number of favourites for the Mastodon status represented by thisPost
object when it was saved to the archive- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getFavouritesCount
protected long getFavouritesCount()Obtains as a primitivelong
the number of a count of favourites for the status represented by thisPost
object.
This may later be used to determine whether or not to repost thisPost
object, based on a threshold specified when the tool is run. (TODO)- Returns:
- the count of favourites for the Mastodon status represented by this
Post
object when it was saved to the archive - Since:
- 0.01.00
- See Also:
-
setReblogsCount
Stores as a primitivelong
the number of times the Mastodon status represented by thisPost
object was reblogged, and saves the change to file if persistance has not been paused.
This field may later be used to determine whether or not to repost thisPost
object, based on a threshold specified when the tool is run. (TODO)- Parameters:
rc
- the number of times the Mastodon status represented by thisPost
object had been reblogged when it was saved to the archive- Throws:
jakarta.xml.bind.JAXBException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getReblogsCount
protected long getReblogsCount()Obtains as a primitivelong
the number of times the Mastodon status represented by thisPost
object was reblogged.
This may later be used to determine whether or not to repost thisPost
object, based on a threshold specified when the tool is run. (TODO)- Returns:
- the number of times the Mastodon status represented by this
Post
object had been reblogged when it was saved to the archive - Since:
- 0.01.00
- See Also:
-
addMedia
protected void addMedia(String u, String mmt, String tu, String at, float x, float y) throws FileNotFoundException, MalformedURLException, IOException Saves media from a URL and attaches it to thisPost
object, together with its thumbnail (when it is a video) and other metadata used by Mastodon, as aMediaFile
object.- Parameters:
u
- the URL for the media filemmt
- the media type as specified by/for Mastodontu
- the URL of the thumbnail for this mediaat
- the "alt text" or description of this mediax
- the x-coordinate of the Mastodon focal point for this mediay
- the y-coordinate of the Mastodon focal point for this media- Throws:
FileNotFoundException
- (TODO: add more info here on when this happens)MalformedURLException
- (TODO: add more info here on when this happens)IOException
- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
hasMedia
protected boolean hasMedia()- Returns:
true
if thisPost
object has any media attachments, orfalse
otherwise- Since:
- 0.01.00
-
getMedia
Obtains media attached to thisPost
object, as aList
ofMediaFile
objects.
A read-only, deep-cloned version *should* be returned here; right now the objects returned are the actual data objects held within thisPost
object, when there is no need to modify them programmatically. This should be fixed *asap* as inadvertent changes to the data within could then be persisted and the archive may be damaged (TODO: make MediaFile cloneable then do a deep copy of the array list here) -
isAfter
Determines whether thisPost
object was created (so far as the tool is aware) after the given date and time, specified as an ISO 8601 compliantString
.
This relies on the archiveId of the post, which in turn is based on the creation date of the Mastodon post that was first downloaded and from which thisPost
object, in this archive, was first created.
Handling of dates and their conversion into archiveIds is done byPostArchive
-
isBefore
Determines whether thisPost
object was created (so far as the tool is aware) before the given date and time, specified as an ISO 8601 compliantString
.
This relies on the archiveId of the post, which in turn is based on the creation date of the Mastodon post that was first downloaded and from which thisPost
object, in this archive, was first created.
Handling of dates and their conversion into archiveIds is done byPostArchive
-