.. Netfiles API documentation

Synchronization Concepts
========================

As a response to the ``checkIdentity`` call you will receive a list of projects as described there.

The interesting attribute there is ``modificationDate``, which every HW Object has. The date & time stored
in this attribute shows the date & time of the last modification *below this point* since your last login.

Contrary to prior belief, this is of not much help.

In order to synchronize (for offline use), you need to store the date+time of last synchronization somewhere.

Next time you log-in to Netfiles-server, you will need to send a :doc:`Get Changed Files <../calls/showchangedfiles>` - call
and check for the response there. The ``period`` parameter needs to contain the date+time of your last login (last login
from your offline-apps' perspective, not the server's perspective).

You may then receive a list of items (files, folders or both - depending on your ``scope``).

Deleted Files / Folders
-----------------------

Obviously you will not get any information about deleted files & folders. But you will be (indirectly) informed about them
because the former parent of the deleted item will have changed.

If the deleted items was directly below the dataroom (root-directory), then the dataroom will have changed (``/projectfiles``).

Otherwise, the former parent will be listed as changed.

In this case, you have to load the children of the parent in question and remove any item that doesn't exist anymore. The reason why it doesn't exist may actually be that access was removed (in which case, it is for all purposes, deleted - for you).

Moved Files / Folders
---------------------

If a file / folder was moved from one parent to another parent, both parents will be shown as *changed* (one has a child removed and the other one has a child added). Additionally, the item that was moved is also shown as *changed* (it has a different parent now).

File Content Changed
--------------------

The file in question is shown as *changed*. If you are caching the contents, you will need to reload the content, or, at the least, delete the locally cached version of the content.

File/Folder Attribute Changed
-----------------------------

If any attribute has changed, then the file/folder in question will be shown as *changed*. 

The problem is differentiating between an *Attribute Change* and *Child Change* in case of folders: we can't!

New Files / Folders
-------------------

New files/folders can be retrieved using the :doc:`Get New Files <../calls/shownewfiles>` - call.

In these cases, just check the ``path`` attribute of the item in question to identify where to put it in your hierarchy.

    **IMPORTANT**: It is important to understand that just getting the *changed files* since a certain date is not enough if you want to synchronize 
    for offline usage. If *new* files/folders were added *after* that date, they will **not** be returned as *changed* because they did 
    not exist prior to their creation date/time.

    Thus, you must get the list of *changed* files/folders as well as *new* files/folders - otherwise your synchronization will fail.

