Package org.jlab.jlog
Class LogEntry
java.lang.Object
org.jlab.jlog.LogEntry
An electronic log book log entry.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttachment
(String filepath) Add a file attachment with an empty caption and a hastily guessed mime type.void
addAttachment
(String filepath, String caption) Add a file attachment with the specified caption and a hastily guessed mime type.void
addAttachment
(String filepath, String caption, String mimeType) Add a file attachment with the specified caption and mime type.void
addEntryMakers
(String entrymakers) Add a comma-separated list of entry makers to the log entry.void
addEntryMakers
(String[] entrymakers) Add an array of entry makers to the log entry.void
addLogboks
(String[] books) Add an array of log books to this log entry.void
addLogbooks
(String books) Add a comma-separated list of log books to this log entry.void
addReference
(Reference ref) Add a reference to this log entry.void
Add a comma-separated list of tags to the log entry.void
Add an array of tags to the log entry.void
Remove the file attachments.void
Remove the references from the log entry.Return the file attachments.Return the author username.getBody()
Return the body.Get the path to the PEM-encoded client certificate.Return the created date/time.String[]
Return the array of email addresses.Return the comma-separated list of email addresses.String[]
Return the entry makers as an array.Return the entry makers as comma-separated-values.String[]
Return the log books as an array.Return the log books as comma-separated-values.static LogEntry
getLogEntry
(long lognumber, String reason) Factory method to obtain an existing LogEntry for viewing or revising.Return the log number or null if none assigned.Get the problem report information.Return the references.String[]
getTags()
Return the tags as an array.Return the tags as comma-separated-values.getTitle()
Return the title.getXML()
Return the XML.boolean
isSticky()
Return true if sticky, false if not.static void
The entrypoint if this library is invoked as a command line application.void
Set the body to the specified plain text content.void
setBody
(String content, Body.ContentType type) Set the body to the specified content and content type.void
void
setClientCertificatePath
(String certificatePath, boolean updateAuthor) Set the path to the PEM-encoded client certificate.void
setEmailNotify
(String addresses) Set the comma-separated list of email addresses used for notification.void
setEmailNotify
(String[] addresses) Set the array of email addresses used for notification.void
setEntryMakers
(String entrymakers) Replace the entry makers with the specified comma-separated-values.void
setEntryMakers
(String[] entrymakers) Replace the entry makers with the specified array.void
setLogbooks
(String books) Replace the existing log books with the specified comma-separated-values.void
setLogbooks
(String[] books) Replace the existing log books with the specified array.void
setProblemReport
(ProblemReport report) Set the problem report information.void
setSticky
(boolean sticky) Set the sticky value of this log entry.void
Replace the existing tags with the specified comma-separated-values.void
Replace the existing tags with the specified array of tags.void
Set the title to a new value.long
submit()
Submit the log item using the queue mechanism as a fallback and return the log number.long
Submit the log item using only direct submission to the server using the client certificate named .elogcert in the user's home directory and return the log number.Return the LogException which prevented direct submission to the server on the most recent attempt, or null if none.
-
Constructor Details
-
LogEntry
Construct a new LogEntry with the specified title and log books designation.- Parameters:
title
- The titlebooks
- A comma-separated list of log books- Throws:
LogRuntimeException
- If unable to construct a new LogEntry
-
LogEntry
public LogEntry(String filePath) throws SchemaUnavailableException, MalformedXMLException, InvalidXMLException, LogIOException, AttachmentSizeException, LogRuntimeException Construct a new LogEntry from the specified XML file.- Parameters:
filePath
- The path to the XML file- Throws:
SchemaUnavailableException
- If the XML schema is unavailableMalformedXMLException
- If the XML is malformedInvalidXMLException
- If the XML is invalidLogIOException
- If unable to construct due to IOAttachmentSizeException
- If attachments cross a size limitLogRuntimeException
- If unable to construct
-
-
Method Details
-
setProblemReport
Set the problem report information. Use null to clear it.- Parameters:
report
- The problem report information.
-
getProblemReport
Get the problem report information.- Returns:
- The problem report information or null if none
-
getLogEntry
public static LogEntry getLogEntry(long lognumber, String reason) throws SchemaUnavailableException, MalformedXMLException, InvalidXMLException, LogIOException, AttachmentSizeException, LogRuntimeException Factory method to obtain an existing LogEntry for viewing or revising. If the intention is for viewing provide null for the reason.- Parameters:
lognumber
- The log number.reason
- The reason for the revision- Returns:
- The LogEntry
- Throws:
SchemaUnavailableException
- If the XML schema is unavailableMalformedXMLException
- If the XML is malformedInvalidXMLException
- If the XML is invalidLogIOException
- If unable to construct due to IOAttachmentSizeException
- If attachments cross a size limitLogRuntimeException
- If unable to construct
-
addLogboks
Add an array of log books to this log entry. See the Overview for a list of valid logbooks.- Parameters:
books
- The log books- Throws:
LogRuntimeException
- If unable to add log books
-
addLogbooks
Add a comma-separated list of log books to this log entry. See the Overview for a list of valid logbooks.- Parameters:
books
- The log books- Throws:
LogRuntimeException
- If unable to add log books
-
setLogbooks
Replace the existing log books with the specified array. See the Overview for a list of valid logbooks.- Parameters:
books
- The log books- Throws:
LogRuntimeException
- If unable to set log books
-
setLogbooks
Replace the existing log books with the specified comma-separated-values. See the Overview for a list of valid logbooks.- Parameters:
books
- The log books- Throws:
LogRuntimeException
- If unable to set the log books
-
getLogbooksCSV
Return the log books as comma-separated-values.- Returns:
- The log books
- Throws:
LogRuntimeException
- If unable to return the log books
-
getLogbooks
Return the log books as an array.- Returns:
- The log books
- Throws:
LogRuntimeException
- If unable to return the log books
-
addTags
Add an array of tags to the log entry. See the Overview for a list of valid tags.- Parameters:
tags
- The tags- Throws:
LogRuntimeException
- If unable to add tags
-
addTags
Add a comma-separated list of tags to the log entry. See the Overview for a list of valid tags.- Parameters:
tags
- The tags- Throws:
LogRuntimeException
- If unable to add tags
-
setTags
Replace the existing tags with the specified array of tags. See the Overview for a list of valid tags.- Parameters:
tags
- The tags- Throws:
LogRuntimeException
- If unable to set tags
-
setTags
Replace the existing tags with the specified comma-separated-values. See the Overview for a list of valid tags.- Parameters:
tags
- The tags- Throws:
LogRuntimeException
- If unable to set the tags
-
getTagsCSV
Return the tags as comma-separated-values.- Returns:
- The tags
- Throws:
LogRuntimeException
- If unable to return the tags
-
getTags
Return the tags as an array.- Returns:
- The tags
- Throws:
LogRuntimeException
- If unable to get the tags
-
addReference
Add a reference to this log entry. See the Overview for a list of valid reference types.- Parameters:
ref
- The reference- Throws:
LogRuntimeException
- If unable to add a reference
-
getReferences
Return the references.- Returns:
- The references
- Throws:
LogRuntimeException
- If unable to get the references
-
deleteReferences
Remove the references from the log entry.- Throws:
LogRuntimeException
- If unable to remove the references
-
setTitle
Set the title to a new value.- Parameters:
title
- The new title- Throws:
LogRuntimeException
- If unable to set the title
-
getTitle
Return the title.- Returns:
- The title
- Throws:
LogRuntimeException
- If unable to get the title
-
addEntryMakers
Add an array of entry makers to the log entry.- Parameters:
entrymakers
- The entry makers- Throws:
LogRuntimeException
- If unable to add entry makers
-
addEntryMakers
Add a comma-separated list of entry makers to the log entry.- Parameters:
entrymakers
- The entry makers- Throws:
LogRuntimeException
- If unable to add entry makers
-
setEntryMakers
Replace the entry makers with the specified array.- Parameters:
entrymakers
- the entry makers- Throws:
LogRuntimeException
- If unable to set the entry makers
-
setEntryMakers
Replace the entry makers with the specified comma-separated-values.- Parameters:
entrymakers
- The entry makers- Throws:
LogRuntimeException
- If unable to set the entry makers
-
getEntryMakersCSV
Return the entry makers as comma-separated-values.- Returns:
- The entry makers
- Throws:
LogRuntimeException
- If unable to get the entry makers
-
getEntryMakers
Return the entry makers as an array.- Returns:
- The entry makers
- Throws:
LogRuntimeException
- If unable to get the entry makers
-
setSticky
Set the sticky value of this log entry.- Parameters:
sticky
- true if sticky, false if not- Throws:
LogRuntimeException
- If unable to set the sticky value
-
isSticky
Return true if sticky, false if not.- Returns:
- true if sticky, false if not
- Throws:
LogRuntimeException
- If unable to get the sticky value
-
setBody
Set the body to the specified plain text content.- Parameters:
content
- The content- Throws:
LogRuntimeException
- If unable to set the body
-
setBody
Set the body to the specified content and content type.- Parameters:
content
- The contenttype
- the type- Throws:
LogRuntimeException
- If unable to set the body
-
setBody
- Throws:
LogRuntimeException
-
main
The entrypoint if this library is invoked as a command line application.- Parameters:
args
- The command line arguments- Throws:
Exception
- If something goes wrong
-
addAttachment
public void addAttachment(String filepath) throws AttachmentSizeException, LogIOException, LogRuntimeException Add a file attachment with an empty caption and a hastily guessed mime type. The mime type is guessed by using the readily available java.net.URLConnection file name map, which simply looks at file extension and compares with the very limited lookup file at:[JRE_HOME]\lib\content-types.properties
- Parameters:
filepath
- The file path- Throws:
AttachmentSizeException
- If the attachment crosses a size limitLogIOException
- If unable to add the attachment due to IOLogRuntimeException
- If unable to add the attachment
-
addAttachment
public void addAttachment(String filepath, String caption) throws AttachmentSizeException, LogIOException, LogRuntimeException Add a file attachment with the specified caption and a hastily guessed mime type. The mime type is guessed by using the readily available java.net.URLConnection file name map, which simply looks at file extension and compares with the very limited lookup file at:[JRE_HOME]\lib\content-types.properties
- Parameters:
filepath
- The file pathcaption
- The caption- Throws:
AttachmentSizeException
- If the attachment crosses a size limitLogIOException
- If unable to add the attachment due to IOLogRuntimeException
- If unable to add the attachment
-
addAttachment
public void addAttachment(String filepath, String caption, String mimeType) throws AttachmentSizeException, LogIOException, LogRuntimeException Add a file attachment with the specified caption and mime type.- Parameters:
filepath
- The file pathcaption
- The captionmimeType
- The mime type- Throws:
AttachmentSizeException
- If the attachment crosses a size limitLogIOException
- If unable to add the attachment due to IOLogRuntimeException
- If unable to add the attachment
-
getAttachments
Return the file attachments.- Returns:
- The attachments
- Throws:
LogRuntimeException
- If unable to return the attachments
-
deleteAttachments
Remove the file attachments.- Throws:
LogRuntimeException
- If unable to remove the file attachments
-
setEmailNotify
Set the comma-separated list of email addresses used for notification.- Parameters:
addresses
- The email addresses- Throws:
LogRuntimeException
- If unable to set the email addresses
-
setEmailNotify
Set the array of email addresses used for notification.- Parameters:
addresses
- The email addresses- Throws:
LogRuntimeException
- If unable to set the email addresses
-
getEmailNotifyCSV
Return the comma-separated list of email addresses.- Returns:
- The email addresses
- Throws:
LogRuntimeException
- If unable to get the email addresses
-
getEmailNotify
Return the array of email addresses.- Returns:
- The email addresses
- Throws:
LogRuntimeException
- If unable to get the email addresses
-
getAuthor
Return the author username.- Returns:
- The author username
- Throws:
LogRuntimeException
- If unable to get the author username
-
getLogNumber
Return the log number or null if none assigned.- Returns:
- The log number or null
- Throws:
LogRuntimeException
- If unable to get the log number
-
getCreated
Return the created date/time.- Returns:
- The created date/time
- Throws:
LogRuntimeException
- If unable to get the created date/time
-
getBody
Return the body.- Returns:
- The body
- Throws:
LogRuntimeException
- If unable to get the body
-
getXML
Return the XML.- Returns:
- The XML
- Throws:
LogRuntimeException
- If unable to get the XML
-
getClientCertificatePath
Get the path to the PEM-encoded client certificate.- Returns:
- certificatePath The path to the PEM-encoded client certificate
-
setClientCertificatePath
public void setClientCertificatePath(String certificatePath, boolean updateAuthor) throws LogException Set the path to the PEM-encoded client certificate.- Parameters:
certificatePath
- The path to the PEM-encoded client certificateupdateAuthor
- If true, the author field is updated to match username in certificate- Throws:
LogException
- If unable to set the certificate path
-
submit
Submit the log item using the queue mechanism as a fallback and return the log number. If the log number is zero then the submission was queued instead of being consumed directly by the server.- Returns:
- The log number, zero means queued
- Throws:
InvalidXMLException
- If unable to submit due to invalid XMLLogIOException
- If unable to submit due to IO
-
submitNow
Submit the log item using only direct submission to the server using the client certificate named .elogcert in the user's home directory and return the log number. If an error occurs during submission then an Exception will be thrown instead of falling back to the queue method.- Returns:
- The log number
- Throws:
LogIOException
- If unable to submit due to IOLogCertificateException
- If unable to submit due to certificateLogRuntimeException
- If unable to submit
-
whyQueued
Return the LogException which prevented direct submission to the server on the most recent attempt, or null if none. This method allows access to the exception which is masked when the submit method is called and returns with a zero value indicating the submission was queued.- Returns:
- The LogException or null
-