How it Works - Project-IT/MySQL-ExCon GitHub Wiki
The Nitty Gritty Details
Exchange Webservices
The way we use the Exchange Webservices (EWS from now on) is as follows.
First, we take the information entered in the HTML fields in the splash page and pass them into the ExCon main class (Called ExCon). This information is used to login to your Outlook Account.
We make sure we create the new table in your SQL Database for our event mapping. That table is the link between your Outlook Events and the events put into the Confluence Team Calendar. As well as the Outlook username of the person who's event it is. This is to make it easy for a sysadmin to check for errors. The table is called OutlookUIDtable.
Parsing the events
We go through each event in your Outlook Calendar in a for loop, the loop first checks if it is an All-Day event because if it is not, the event is ignored.
After the first check we start writing event parameters, this is for the coming SQL query called in EventInserter.
Organizer is the one - logged into Confluence - that added the Event. In the code some unnecessary characters are removed in order for it to be readable by a human.
SubCalID calls a function that figures out which Calendar it is that you are trying to put the events into.
The last check is to see if the event is recurring, the reason is because recurring events in Outlook all share the same Unique Identifier and would be treated as the same event in Confluence. So, checking if the event is recurring enables us to bind it to a Unique ID in the database so that it can be properly displayed in the Team Calendar.
After all the checks have been performed a function called EventMapper is called with all the information and the connection to the database.
Important Functions
In the ExCon Class some other functions are defined below. However, you only need to worry about ConvertTime and ParentID.
Convert Time
This function converts the outlook event time (which is defined in Unix Epoch Time) to normal, managable UTC time.
ParentID
To know what calendar you want to put your events into we go through the database and see if there are any calendar names matching the one you have entered. If you enter an incorrect name, no events will be pushed.
Other Classes
Spread throughout are the Verifiers and Parameter classes, these you do not have to worry about so much - they are really just there to prevent failures that will mess up the database. You do not want to mess up someone else's Database!
EventMapper
Firstly, this is called right before the loop to make sure the table is made or exists. Probably the most algorithm intensive function is the EventMapper. For each event it looks through the database to see if that event already exists and if it does it calls EventUpdater (which is just like EventInserter) and updates known events. If the events are new, they are mapped to the OutlookUIDtable with the email address and the subcalendarID.
EventDeleter
Another complicated function. Basically, it compares the Unique IDs of the events gotten from Outlook in that pass of the synchronization and the Unique IDs already stored in the database. If the database has any IDs left over after this comparison, they are deleted from both tables. This is done at the end of every sync.
AdminConfig & MyPluginServlet
These classes handle the HTML requests that need to be sent to get user inputs. They are based off some old Atlassian tutorials.
InviteesInserter
Makes sure the people associated with the correct event are written correctly into the Database, without it there would be huge errors in the Team Calendar whenever you try to edit or delete an event.
Last Event ID Finder
Returns the highest ID-value of all the events. Since the ID-column of the events is auto-incrementing, it will return the ID of the most recently inserted event
EventInserter & EventUpdater
These classes handle Prepared Statements for Inserting and Updating events. They are called in the EventMapper Class.
Atlassian Plugin.xml
This XML document is what holds everything together. It holds the location for both the Plugin Configuration page and the Navigation Bar Button at the top of the page.