Skip to content

sebasalons/eyeos-u1db

 
 

Repository files navigation

Tutorial eyeOS 2.5 OpenSource & CloudSpaces

Table contents

eyeOS 2.5 installation on Ubuntu

Requeriments

  • Apache HTTP Server

    # apt-get install apache2
    # apache2 -version

    Type in the navegation bar of the browser http://localhost, and you'll see apache2 page (It works!)

  • Mysql

    # apt-get install mysql-server mysql-client
    # mysql --version

    Remember the password of database's administrator ('root'), because it'll be requested during the eyeOS 2.5 installation.

  • Php

    # apt-get install php5 php5-mysql libapache2-mod-php5 php5-gd php5-mcrypt php5-sqlite php-db php5-curl php-pear php5-dev
    # php5 --version

    Configure the php.ini.

    # cd /etc/php5/apache2/
    # nano php.ini

    Change the next parameters:

    • error_reporting = E_ALL & ~E_NOTICE

    • display_errors = Off

    • max_execution_time = 30

    • max_input_time = 60

    • memory_limit = 128M

    • post_max_size = 200M

    • upload_max_filesize = 100M

    • allow_url_fopen = On

    • disable_functions =

    • safe_mode = Off

    • short_open_tag = On

    • magic_quotes_runtime = Off

    • file_uploads = On

  • Java

    # apt-get install python-software-properties
    # add-apt-repository ppa:webupd8team/java
    # apt-get update
    # apt-get install oracle-java7-installer
    # update-alternatives --config java
    # java -version

  • OpenOffice

    # apt-get install openoffice.org

  • Python

    # apt-get install python-support python-simplejson python-uno recoll zip unzip libimage-exiftool-perl
    # pip install requests requests_oauthlib

  • Curl SSL

    If you don't have SSL certificate get it by typing:
    # wget http://curl.haxx.se/ca/cacert.pem

    Open the php.ini and introduce the path where the certificate to make requests to secure url is located.
    # cd /etc/php5/apache2/
    # nano php.ini
    ....
    curl.cainfo='/root/cacert.pem'

  • Uploadprogress

    # apt-get install make
    # pecl install uploadprogress

    # nano /etc/php5/apache2/php.ini (Add the last two lines) .

  • Sendmail

    # apt-get install sendmail
    # nano /etc/hosts (Add localhost.localdomain to IP 127.0.0.1)

    # sendmailconfig (Confirmar todas las preguntas)

  • Apache

    Configure mod-rewrite in apache:

    # a2enmod rewrite

    # nano /etc/apache2/sites-available/default

    Change into <Directory /var/www/> the parameter AllowOverride to All

    Restart the apache service

    # /etc/init.d/apache2 restart

eyeOS installation

Download the code into /var/www

# cd /var/www/
# git clone https://github.com/cloudspaces/eyeos-u1db eyeos

Change the eyeos directory's permissions

# chown -R www-data.www-data eyeos
# chmod -R 755 eyeos

Add to DocumentRoot the eyeos directory:

# nano /etc/apache2/sites-available/default

# service apache2 restart

Install python-u1db package:

# cd eyeos/eyeos/packages/
# dpkg -i python-u1db_0.1.4-0ubuntu1_all.deb

If you have dependency problems during package installation follow the next steps:

# apt-get install python-u1db
# apt-get -f install
# dpkg -i python-u1db_0.1.4-0ubuntu1_all.deb

Get into mysql and create the schema 'eyeos'. As showed bellow:

# mysql -uroot -p<password>
> create database eyeos;

Open into the browser the eyeOS configuration screen (http://localhost/install)

Select 'Install eyeOS 2 on my server'

The error "SQLite extension not installed" can be ignored.

Once all requirements are listed, go on with the installation selecting 'Continue with the installation'.

Introduce user and password of mysql database's administrator (root), and in addition, the eyeOS platform root user's password.

Once configured the database and eyeOS user, go on with the installation selecting 'Continue with the installation'.

After the installation is finished select 'Go to my new eyeOS' to see the eyeOS 2.5 platform's login screen.

The url of StackSync resources requests can be configured in the file settings.php

# cd /var/www/eyeos/
# nano settings.php

serverU1DB installation

Follow the steps explained in the Readme.md file, located in /var/www/eyeos/serverU1DB. The serverU1DB can be installed in the same machine than eyeOS or in another independent machine.

If installed in another independent machine the directories /var/www/eyeos/serverU1DB and /var/www/eyeos/eyeos/package must be copied in that machine.

Persistence

eyeOS Calendar and the comments tool of the file manager store data in a U1DB database.

U1DB is a database API to sync JSON documents that was created by Canonical. It lets applications store documents and synchronize them between machines and devices. U1DB is designed to work anywhere, acting as a storage backup for native platform data. This means it can be implemented on any platform, from different languages, providing backup and sync services between platforms.

The U1DB API contains three sections: document storage/retrieval, querying and synchronization. A short description of their operation is given below.

Storage/recovering documents

U1DB stores documents, basically any information that can be expressed in JSON.

created_doc_from_json(json,doc_id=None)

Creates a document from JSON data.

Optionally the doc id can be specified. This id must not exist in the database. If the database specifies a maximum document size and the document exceeds this size, a DocumentTooBig exception is triggered.

Parameters:
  • json – JSON data
  • doc-id – Optional document id
Return: Document

put_doc(doc)

Updates documents. If the database specifies a maximum document size and the document exceeds this size, a DocumentTooBig exception is triggered.

Parameters: doc – Document with new contents
Return: new_doc_rev - New revision id for the document.
The document object will also be updated

set_json(json)

Updates document's JSON data.

Parameters: json – JSON data

delete_doc(doc)

Flags a document as deleted.

Parameters: doc – Document to delete

Queries

Querying in U1DB is done using indexes. To retrieve certain documents from the database according to specific criteria, first you must create an index and then query this index.

create_index(index_name,*index_expressions)

Creates an index that will be used to perform queries in the database. No exceptions are triggered if you try to create an existing index. However, an exception is triggered if you try to create an index that changes the index_expressions of a previously created index.

Parameters:
  • index_name – Unique index id
  • index_expressions – Keys used in future queries


Examples: “nameKey” o “nameKey.nameSubKey”

get_from_index(index_name,*key_values)

Returns the documents containing the keys specified. The same number of values as keys defined in the index must be specified.

Parameters:
  • index_name – Name of the index queried
  • key_values – Values to search.
    if an index has 3 fields, you will get get_from_index(index1,val1,val2,val3)
Return: List of documents

Synchronization

U1DB is a syncable database. Any U1DB database can be synced with a U1DB server. Most U1DB installations can be run as server.

Syncing the server and the client updates both sides so that they contain the same data. Data is saved in local U1DBs, whether online-offline, and then synchronized when online.

sync(url,creds=None,autocreate=True)

Syncs documents with a remote replica via a URL.

Parameters:
  • url – URL of the remote replica with which it will be synchronized
  • creds – (Optional). Credentials to authorize the operation with the server. For example, use credentials to identify via OAuth:
             {
                'oauth': {
                                  ‘consumer_key’: ..., ‘consumer_secret’: ...,
                                  ‘token_key’: ..., ‘token_secret’: ...
                               }
                }
  • autocreate – If the value is True, the database is created if it doesn’t exist. If the value is False, synchronization will not be performed if the database doesn’t exist.
Return: local_gen_before_sync – A local gen key to control synchronization. This is useful with the whats_changed function, if an application needs to know the documents changed during synchronization.

Implementation of Oauth into eyeOS calendar

To sync eyeOS Calendar and the comments tool applications, authentication must be done with the server using the OAuth protocol.

The OAuth server provides access to a unique protected resource, the U1DB server.

The eyeOS platform implements the Credentials.py script, which contains the APIs required for communicating with the OAuth server.

The communication dialog is as follows:

Step 1:

API getRequestToken() gets the consumer key and consumer secret from the settings (see Annex 1.2). It then makes a call to the OAuth server using the “request_token” URL.

The OAuth server retrieves the consumer key from the database and compares it with the consumer key received. If the keys do not match, it returns an error; otherwise, it performs a new search in the database using the consumer key to get the request token.

The OAuth server responds to the eyeOS call, returning the request token and access verifier to request the access token.

The eyeOS platform stores the request token and the verifier in the session variables so that it does not have to repeat the process in subsequent steps.

Step 2:

API getAccesToken(token,verifier) makes a call to the OAuth server through the “access_token” URL.

The OAuth server retrieves the consumer key and request token from the database and compares them with those received from getAccessToken(). If they do not match, it returns an error; otherwise, it performs a new search in the database with the consumer key and request token to get the access token. If no data is obtained or the data obtained has expired, a new access token must be generated and stored in the database, which means that previous tokens will no longer have access.

The OAuth server responds to the eyeOS call, returning the access token.

Step 3:

API protocol(params) calls the OAuth server via the U1DB synchronization API.

The OAuth server retrieves the access token from the database using the consumer and token received. If they do not match, it returns an error; otherwise, it syncs with the U1DB server.

Step 1 only applies where a request token has not been requested during the eyeOS user session.

Authentication implemented in both applications is requested for each resource request. The request process flow is illustrated in the following diagram:

Persistence OAuth Manager and Persistence OAuth API persistence functions are described in more detail, respectively:

Persistence OAuth Manager

callProcessCredentials()

Gets credentials of the eyeOS consumer.

Script call: No parameters
Return: Token object or in the event of error null
Example:
{
   "oauth":{
                     "token_key":"access1234",
                     "token_secret":"access_secret",
                     "consumer_key":"key1234",
                     "consumer_secret":"secret1234",
                  }
}

Persistence OAuth API

The configuration file of OAuth API is found at “/var/www/eyeos/eyeos/extern/u1db/” and is called “settings.py”. This file must be modified in the following values:

Server IP address where the Oauth server is active
Port Port where the Oauth server is active
urls
CALLBACK_URL Replace IP and port with the values stablished in the previous parameters (server and port)
consumer
key Included when mongodb was configured in the Oauth server installation
secret Included when mongodb was configured in the Oauth server installation

getRequestToken()

Gets the request token of the eyeOS consumer.

Url: Use REQUEST_TOKEN_URL of the configuration file.
Method: GET
Signature: Plaintext
Parameters: No parameters
Return: Key and secret of the request token or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{“oauth_token” : “token1234”, “oauth_secret” : “secret1234”} {“error” : “401”, “description” : “Authorization required”}

getAccessToken(token,verifier)

Gets the access token of the eyeOS consumer from the request token and verifier received.

Url: Use ACCESS_TOKEN_URL of the configuration file.
Method: GET
Signature: Plaintext
Parameters: token – OauthToken object. Includes key and secret values of the request token
verifier – Word by which the user is authenticated
Return: Key and secret of the access token or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{
   "credentials":{
                              "token_key":"access1234",
                              "token_secret":"access_secret",
                              "consumer_key":"key1234",
                              "consumer_secret":"secret1234",
                           },
   "request_token":{"key":"token1111","secret":"secret2222"},
   "verifier":"verifier"
}
{"error" : "401", "description" : "Authorization required"}

Implementation of U1DB into eyeOS calendar

EyeOS storages the user's calendars and events into U1DB synchronized database.

Calendar and event sync processes are performed when eyeOS Calendar is opened.

Calendars are synced every 20 seconds. If any changes are detected, the calendar list is refreshed and the waiting time is reset.

Events are synced every 10 seconds. If any changes are detected, the events of the period shown on screen are refreshed and the waiting time is reset.

Persistence in implemented in eyeOS according to the diagram below:

The user performs an action on the calendar, such as adds an event to a specific calendar. The Manager uses the insertEvent function to retrieve the user’s credentials. These values are sent to the API together with the data of the new event. The API is responsible for requesting the resource from the U1DB server using the insertEvent function.

If everything is correct, the U1DB server updates the server database and subsequently notifies other clients of the change. The API receives confirmation of the change and applies it to the client U1DB database. Once the updates have been made, it notifies the Manager, which modifies the local calendar tables and updates the eyeOS interface.

The insertEvent functions of the Calendar Manager and the Calendar API, as well as the other actions performed by the calendar. Now are described in more detail, respectively.

Calendar Manager

The Calendar Manager API consists of a uniform structure in the script call:

Parameters:
  • type – Name of the Python API function
  • lista – Parameters of the previous function
  • credentials – Credentials for identification during the synchronization process

The functions are listed and described below.

synchronizeCalendars(user)

Requests credentials of the eyeOS consumer.

Parameters: user – Contains the id and name of the eyeOS user
Script call: Example:
{
    "type":"selectCalendar" ,
    "lista":[{
                   "type":"calendar",
                   "user_eyeos": "eyeos"
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: List of calendars

insertCalendars(user,calendar)

Creates a new calendar.

Parameters:
  • user – User name
  • calendar – An object that contains name, description, and timezone
Script call: Example:
{
    "type":"insertCalendar" ,
    "lista":[{
                   "type":"calendar",
                   "user_eyeos": "eyeos"
                   "name": "personal"
                   "status": "NEW"
                   "description": "personal calendar"
                   "timezone": 0
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: True or in case of error null

deleteCalendars(user,calendar)

Deletes an existing calendar.

Parameters:
  • user – User name
  • calendar – Calendar name
Script call: Example:
{
    "type":"deleteCalendar" ,
    "lista":[{
                   "type":"calendar",
                   "user_eyeos": "eyeos"
                   "name": "personal"
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: True or in the event of error null

synchronizeCalendar(calendarId,user)

Synchronizes all the events of the specified calendar of the user connected to the eyeOS platform.

Parameters:
  • calendarId – Id of the eyeOS calendar
  • user – User name
Script call: Example:
{
    "type":"selectEvent" ,
    "lista":[{
                   "type":"event",
                   "user_eyeos": "eyeos"
                   "name": "personal"
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: List of events

createEvent(event)

Creates a new event

Parameters: event – Contains the U1DB structure of the event
Script call: Example:
{
    "type":"insertEvent" ,
    "lista":[{
                   "type":"event",
                   "user_eyeos": "eyeos"
                   "calendar": "personal"
                   "status": "NEW"
                   "isallday": "0"
                   "timestart": "201419160000"
                   "timeend": "201419170000"
                   "repetition": "None"
                   "finaltype": "1"
                   "finalvalue": "0"
                   "subject": "Visita Médico"
                   "location": "Barcelona"
                   "description": "Llevar justificante"
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: True or in the event of error null

deleteEvent(event)

Deletes an existing event.

Parameters: event – Contains the U1DB structure of the event
Script call: Example:
{
    "type":"deleteEvent" ,
    "lista":[{
                   "type":"event",
                   "user_eyeos": "eyeos"
                   "calendar": "personal"
                   "status": "DELETED"
                   "isallday": "0"
                   "timestart": "201419160000"
                   "timeend": "201419170000"
                   "repetition": "None"
                   "finaltype": "1"
                   "finalvalue": "0"
                   "subject": "Visita Médico"
                   "location": "Barcelona"
                   "description": "Llevar justificante"
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: True or in the event of error null

updateEvent(event)

Updates an existing event.

Parameters: event – Contains the U1DB structure of the event
Script call: Example:
{
    "type":"updateEvent" ,
    "lista":[{
                   "type":"event",
                   "user_eyeos": "eyeos"
                   "calendar": "personal"
                   "status": "CHANGED"
                   "isallday": "0"
                   "timestart": "201419160000"
                   "timeend": "201419170000"
                   "repetition": "None"
                   "finaltype": "1"
                   "finalvalue": "0"
                   "subject": "Visita Médico"
                   "location": "Barcelona"
                   "description": "Llevar justificante"
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: True or in the event of error null

Calendar API

To display the calendars correctly in the eyeOS platform, the structure of the calendars and the events, as well as their indexes, must be respected:

  • calendar: type and user_eyeos.
  • events: type, user_eyeos and calendar.

The functions are listed and described below.

selectCalendar(data)

Get all calendars of the user.

Parameters: data – Contains the type and the user.
Example: {“type”:”calendar”,”user_eyeos”:”eyeos”}
Return: Vector with all the calendars, in JSON format
Example:
[{
   “type”:”calendar”,
   ”user_eyeos”:”eyeos”,
   ”name”:”personal”,
   ”description”:”personal calendar”,
   ”timezone”: 0,
   ”status”:”NEW”
}]

insertCalendar(lista)

Inserts the new calendar generated by the user in eyeOS.

Parameters: lista – Contains a vector of the calendars to be inserted.
Example:
[{
   “type”:”calendar”,
   ”user_eyeos”:”eyeos”,
   ”name”:”personal”,
   ”description”:”personal calendar”,
   ”timezone”:0,
   ”status”:”NEW”
}]
Return: 'true' or exception in the event of error

deleteCalendar(lista)

Identifies the status of the calendar to be deleted (STATUS=”DELETED”) of a specific eyeOS user.

Parameters: lista – Contains a vector of the calendars to be deleted.
Example:
[{
   “type”:”calendar”,
   ”user_eyeos”:”eyeos”,
   ”name”:”personal”
}]
Return: 'true' or exception in the event of error

selectEvent(type,user,calendarId)

Gets all the events of the calendar belonging to the specified user.

Parameters:
  • type – “event” fixed flag
  • user – eyeOS user
  • calendarId – Calendar name
Return: Vector with all the calendar events, in JSON format
Example:
[{
   “type”:”event”,
   ”user_eyeos”:”eyeos”,
   ”calendar”:”personal”,
   ”status”:”NEW”,
   “isallday”: “0”,
   “timestart”: “201419160000”,
   “timeend”:”201419170000”,
   “repetition”: “None”,
   “finaltype”: “1”,
   “finalvalue”: “0”,
   “subject”: “Visita Médico”,
   “location”: “Barcelona”,
   “description”: “Llevar justificante”
}]

insertEvent(lista)

Inserts a new event in the calendar of the specified user.

Parameters: lista – Contains a vector of the events to be inserted.
Example:
[{
   “type”:”event”,
   ”user_eyeos”:”eyeos”,
   ”calendar”:”personal”,
   ”status”:”NEW”,
   “isallday”: “0”,
   “timestart”: “201419160000”,
   “timeend”:”201419170000”,
   “repetition”: “None”,
   “finaltype”: “1”,
   “finalvalue”: “0”,
   “subject”: “Visita Médico”,
   “location”: “Barcelona”,
   “description”: “Llevar justificante”
}]
Return: 'true' or exception in the event of error

deleteEvent(lista)

Identifies the status of the event of a calendar to be deleted for a specific eyeOS user.

Parameters: lista – Contains an array with the events identified as deleted.
Example:
[{
   “type”:”event”,
   ”user_eyeos”:”eyeos”,
   ”calendar”:”personal”,
   ”status”:DELETED,
   “isallday”: “0”,
   “timestart”: “201419160000”,
   “timeend”:”201419170000”,
   “repetition”: “None”,
   “finaltype”: “1”,
   “finalvalue”: “0”,
   “subject”: “Visita Médico”,
   “location”: “Barcelona”,
   “description”: “Llevar justificante”
}]
Return: 'true' or exception in the event of error

updateEvent(lista)

Changes the data of an event in the existing calendar of a specific eyeOS user.

Parameters: lista – Contains a vector of the events to be updated.
Example:
[{
   “type”:”event”,
   ”user_eyeos”:”eyeos”,
   ”calendar”:”personal”,
   ”status”:CHANGED,
   “isallday”: “0”,
   “timestart”: “201419160000”,
   “timeend”:”201419170000”,
   “repetition”: “None”,
   “finaltype”: “1”,
   “finalvalue”: “0”,
   “subject”: “Examen”,
   “location”: “Tarragona”,
   “description”: “Llevar libro”
}]
Return: 'true' or exception in the event of error

Collaborative tool between eyeOS and StackSync

The comments tool is only valid in the user’s Personal Cloud because it is a collaboration resource between StackSync and eyeOS.

The user accesses the comments tool when they select a Personal Cloud file or directory in the file manager and then clicks the “Comments” tab in the right toolbar (social bar).

The comments tool lists all comments inserted for a specific element, both those from the element’s owner and from other users who have been given privileges to access the element.

The data given in a list comment is:

  • name of the user who made the comment
  • creation date/time
  • text entered

Example:

User stacksync2
Date / time 04/07/2014 13:02
Text Welcome 3

Other actions that can be performed include insert new comments with the “New” option or delete existing comments with the “Delete” option. The delete option is restricted; only comments made by the user in question can be deleted. Users cannot delete comments made by others.

The comments list is not refreshed, as there is no background process that enables new comments to be displayed automatically.

Persistence is implemented in the eyeOS comments tool according to the diagram below:

The user performs an action, such as inserts a new comment in the list. The Manager using the createComment function retrieves the user’s credentials. These values are sent to the API together with the data of the new comment. The API is responsible for requesting the resource from the U1DB server using the createComment function.

If everything is correct, the U1DB server updates the server database and subsequently notifies other clients of the change. The API receives confirmation of the change and applies it to the client U1DB database. Once the updates have been made, it notifies the Manager, which will update the eyeOS interface.

The createComment functions of the Comment Manager and the Comment API, as well as the other actions performed by the comments tool. Now are described in more detail, respectively:

Comment Manager

The Comment Manager API consists of a uniform structure in the script call:

Parameters:
  • type – Name of the Python API function
  • lista – Parameters of the previous function
  • credentials – Credentials for identification during the synchronization process

The functions are listed and described below.

getComments(id)

Gets all the comments of a StackSync element.

Parameters: id – Id of the StackSync element
Script call: Example:
{
    "type":"get" ,
    "metadata":[{
                   "id":"124578",
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: Array containing all comments, in JSON format or, in the event of error, returns an error structure:
- error: Error number
Example:
[{
   “id”:”1245789”,
   ”user”:”eyeos”,
   ”time_created”:”20140702124055”,
   ”status”:”NEW”,
   ”text”: ”Comment 1” }]
[{“error”:-1,”description”:”Error getComments”}]

createComment(id,user,text)

Links a new comment to a specific StackSync element.

Parameters: id – Id of the StackSync element
user – Name of the user inserting a comment
text – Text of the comment
Script call: Example:
{
    "type":"create" ,
    "metadata":[{
                   "id":"124578",
                   "user":"eyeos",
                   "text":"Comment 1",
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: Metadata of the comment, in JSON format or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
[{
   “id”:”1245789”,
   ”user”:”eyeos”,
   ”time_created”:”20140702124944”,
   ”status”:”NEW”,
   ”text”: ”Comment 1” }]
{“error”:-1,”description”:”Error create comment”}

deleteComments(id,user,time_created)

Deletes a comment of a specific StackSync element.

Parameters: id – Id of the StackSync element
user – Name of the user inserting a comment
time_created – Date and time when the comment was created. YYYYmmddHHMMSS format
Script call: Example:
{
    "type":"delete" ,
    "metadata":[{
                   "id":"124578",
                   "user":"eyeos",
                   "time_created":"20140702124944",
               }]
    "credentials":{
                   ”oauth”:{
                                    “consumer_key”:”eyeos”,
                                    “consumer_secret”:”eyeosABC”,
                                    “token_key”:”eyeostoken”,
                                    “token_secret”:”eyeosDEF”
                                 }
                           }
}
Return: Result structure:
- status: 'OK' if correct or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{“status”: “OK”}
{
       “status”: “KO”,
       “error”: -1
}

Comment API

getComments(id)

Gets all comments of a specific StackSync element.

Parameters: id – Id of the StackSync element
Return: Vector containing all comments, in JSON format or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
[{
   “id”:”1245789”,
   ”user”:”eyeos”,
   ”time_created”:”20140702124944”,
   ”status”:”NEW”,
   ”text”: ”Comment 1” }]
[{“error”:-1,”description”:”Error getComments”}]

createComment(id,user,text,time_created)

Links a new comment to a specific StackSync element.

Parameters: id – Id of the StackSync element
user – Name of the user inserting a comment
text – Text of the comment
time_created – Date and time when the comment was created. YYYYmmddHHMMSS format (Optional)
Return: Metadata of the comment, in JSON format or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
[{
   “id”:”1245789”,
   ”user”:”eyeos”,
   ”time_created”:”20140702124055”,
   ”status”:”NEW”,
   ”text”: ”Comment 1” }]
{“error”:-1,”description”:”Error create comment”}

deleteComment(id,user,time_created)

Deletes a comment from a specific StackSync element.

Parameters: id – Id of the StackSync element
user – Name of the user inserting a comment
time_created – Date and time when the comment was created. YYYYmmddHHMMSS format (Optional)
Return: Result structure:
- status: 'OK' if correct or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{“status”: “OK”}
{
       “status”: “KO”,
       “error”: -1
}
        </td>
    </tr>
</table>

Implementation of StackSync API into eyeOS

Within the eyeOS Personal Web Desktop, one of the key features of the platform is file management. eyeOS includes a web file manager developed in JavaScript, HTML and CSS that enables users to manage all their files directly from their browser, but with an experience similar to a file manager of any desktop operating system, such as Microsoft Windows™ or GNU/Linux.

By integrating Personal Cloud services in the eyeOS platform, users can use eyeOS’ web file manager and all its features with their Personal Cloud files. For example, users can display online their documents saved in their Personal Cloud, create directories, move files, share documents, etc.

Users access the files in their Personal Cloud using the StackSync directory. To get the file and directory structure of Personal Cloud, a call is made to StackSync’s API. This call returns metadata with all the structural information of the files and directories, which eyeOS uses to generate a local replica.

The files and directories are created without content. When the user selects an element and performs an operation on it, i.e. opens, moves or copies it, the element's contents are downloaded. By doing this, the system is not overloaded unnecessarily by retrieving information that the user will not use at that moment. If the content of a file or directory has already been retrieved and there are no changes, it will not be updated.

The file manager can retrieve previous versions of a file. It shows a list of all the available versions of the file, letting the user retrieve the contents of the desired version.

If the user makes changes to a previous version, when those changes are saved, a new version is created in Personal Cloud.

The contents of the current directory are synced with the Personal Cloud directory in a background process, which sends queries every 10 seconds to check whether there are any changes. If there are any changes, the current structure is updated.

###Authentication

The eyeOS platform uses OAuth authentication in order to interact with the user’s protected data stored in Personal Cloud. OAuth is an authorization protocol that enables the user (resource owner) to authorize eyeOS to access the resources on their behalf without giving eyeOS their authentication credentials i.e. user name and password.

When the eyeOS user accesses the file manager for the first time, a newly developed plugin is used to get a security token with which the keys required for interacting with user data stored in Personal Cloud can be obtained. The Access Token and Token Secret keys are stored in the ‘token’ table of the relational database management system (RDBMS) based on MySQL. These keys are linked with the user who has logged into the platform, meaning the system can determine the access token for a given user who attempts to use the service at any stage.

The communication dialog is as follows:

Step 1:

Request from StackSync the consumer key and secret token that identifies eyeOS as the CloudSpaces resource consumer.This communication is done via email.

Step 2:

Get the request token and provide StackSync with the redirect URL to eyeOS once the user grants authorization. StackSync responds to the previous request by giving a valid request token and an authorization URL.

Step 3:

Redirect the user to the authorization URL where the user grants eyeOS access to their private space. Once StackSync verifies the user, it redirects the user to the eyeOS URL provided in the previous step.

Step 4:

Get the access token and token secret from StackSync, with which eyeOS will identify itself when accessing the user’s private space in CloudSpaces.

Authentication is implemented in eyeOS according to the diagram below:

The OAuth Manager and OAuth API functions now are described, respectively:

OAuth Manager

getRequestToken()

Gets the request token of the eyeOS consumer.

Script call: No parameters
Return: Object token or in case of error null
Example:
{
 "key": "token1234",
 "secret": "secret1234"
}

getAccessToken(token)

Get the access token of eyeOS consumer from the request token.

Parameters: token – Contains the request token and user authorization
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "verifier":"userVerifier"
}
Return: Token object or in the event of error, null
Example:
{
 "key": "access1234",
 "secret": "access1234"
}

OAuth API

The configuration file of the OAuth API is found at “/var/www/eyeos/eyeos/extern/u1db/” and is called “settings.py”.

getRequestToken(oauth)

Gets the request token of the eyeOS consumer.

Url: Use REQUEST_TOKEN_URL of the configuration file.
Method: GET
Signature: Plaintext
Parameters: oauth – OauthRequest object. Contains the values of the consumer key, consumer secret and CALLBACK_URL of the configuration file
Return: Key and secret of the request token or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"oauth_token":"token1234","oauth_token_secret":"secret1234"}
{"error":401, "description": "Authorization required."}

getAccessToken(oauth)

Gets the access token of the eyeOS consumer from the request token stored.

Url: Use ACCESS_TOKEN_URL of the configuration file.
Method: GET
Signature: Plaintext
Parameters: oauth – OauthRequest object. Includes the values of consumer key and consumer secret of the configuration file. And also the request token and verifier received from StackSync.
Return: Key and secret of the access token or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"oauth_token":"token1234","oauth_token_secret":"secret1234"}
{"error":401, "description": "Authorization required."}

If the user has not previously granted eyeOS access to their CloudSpaces private space, when they access the file manager, the authentication process is initiated, as shown in the following screens:

  • The user is asked if they want to grant eyeOS access to their protected data.

  • If the user selects “No”, the eyeOS file structure is shown without the StackSync directory, which contains the user’s protected data in CloudSpaces.

  • If the user selects “Yes” in the first screen of the process, communication is established with StackSync to get the access token.

  • A new browser window is pops up in which the user is redirected to the authorization URL received from StackSync. Here the user authorizes eyeOS to access their private space.

  • Once access has been authorized, StackSync redirects the user to the URL provided by eyeOS on requesting the request token. This page notifies the user that the process has been completed successfully and that they can return to the eyeOS desktop.

  • The access token for the current eyeOS user is saved. From this moment, the user can access their protected data from the StackSync directory without having to authenticate again.

During the authentication process, various exceptions may be triggered, which interrupt the process to get the access token. These errors are described below:

  • Communication error. This may occur on sending or receiving data from StackSync.

  • Timeout exceeded for receiving the user’s authorization to access their private space. eyeOS establishes a timeout of 1 minute. The process to request the request token can be restarted or interrupted.

  • Access denied as an invalid access token was sent to StackSync. The access token does not expire and is stored permanently in eyeOS. This error occurs when the users deletes the access token from the StackSync portal.

Storage

To integrate the Personal Cloud storage service within eyeOS, the Storage Manager and the Storage API have been created. The Storage API communicates with the StackSync API v2, which manages all the requests made from the file manager.

Storage is implemented in eyeOS according to the diagram below:

The user performs an action in the file manager, such as opening a directory. The Storage Manager using the getMetadata function retrieves the user’s access token and id for the directory in StackSync. These values are sent to the API, which is responsible for requesting the resource from StackSync using the getMetadata function. The file structure of the directory is retrieved and stored in the database, and the Manager is notified of the new structure, which will update the eyeOS interface.

The getMetadata functions of the Storage Manager and the Storage API, as well as the other actions performed by the file manager. Now are described in more detail, respectively:

Storage Manager

getMetadata(token,id,path,user)

Gets metadata for the current element. Generates its file structure and/or directories in eyeOS.

Parameters: token – Includes key and secret of the access token
id – Id number of the element in StackSync
path – eyeOS path
user – eyeOS user identifier
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"get",
                          "file":false,
                          "id":155241412,
                          "contents":true
                         }
}
Return: Metadatas or, in the event of error, returns an error structure:
- error: Error number
Example:
{"filename":"clients",
  "id":155241412,
  "status":"NEW",
  "version":1,
  "parent_id":"null",
  "user":"eyeos",
  “modified_at”: "2013-03-08 10:36:41.997",
  "is_root":false,
  "is_folder":true,
  "contents":[{
                        "filename":"Client1.pdf",
                        "id":32565632156,
                        "size":775412,
                        "mimetype":"application/pdf",
                        "status":"NEW",
                        "version":1,
                        "parent_id":155241412,
                        "user":"eyeos",
                        "modified_at":"2013-03-08 10:36:41.997",
                        "is_root":false,
                        "is_folder":false,
                     }]",
} {"error":401}

getSkel(token,file,id,metadatas,path,pathAbsolute,pathEyeos)

Recursively gets metadata depending on the current element. This function is used in the copy and move action in eyeOS.

Parameters: token – Includes key and secret of the access token
file – True, if it is a file or False, if it is a directory
id – Id number of the element in StackSync
metadatas – Accumulative vector of metadata
path – Relative path of the current element
pathAbsolute – eyeOS path
pathEyeos – eyeOS path, only used when the destination of the action is outside Personal Cloud
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"get",
                          "file":false,
                          "id":155241412,
                          "contents":true
                         }
}
Return: Vector of metadata or, in the event of error, returns an error structure:
- error: Error number
Example:
[{"filename":"Client1.pdf",
  "id":32565632156,
  "size":775412,
  "mimetype":"application/pdf",
  "status":"NEW",
  "version":1,
  "parent_id":155241412,
  "user":"eyeos",
  "modified_at": "2013-03-08 10:36:41.997",
  "is_root":false,
  "is_folder":false},
 {"filename":"clients",
  "id":155241412,
  "status":"NEW",
  "version":1,
  "parent_id":"null",
  "user":"eyeos",
  “modified_at”: "2013-03-08 10:36:41.997",
  "is_root":false,
  "is_folder":true}]
{"error":401}

createMetadata(token,user,file,name,parent_id,path,pathAbsolute)

Creates a new file or directory.

Parameters: token – Includes key and secret of the access token
user – eyeOS user identifier
file – True, if it is a file or False, if it is a directory
name – Name of the element
parent_id – Id of the destination directory
path – Relative path of the current element
pathAbsolute – Absolute path. Required when the element is a file
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"create",
                          "file":true,
                          "filename":"Client.pdf",
                          "parent_id":254885,
                          "path":"/home/eyeos/Documents/Client.pdf"
                         }
}
Return: Metadata or, in the event of error, returns an error structure:
- error: Error number
Example:
{"filename":"Client.pdf",
  "id":32565632111,
  "size":775412,
  "mimetype":"application/pdf",
  "status":"NEW",
  "version":1,
  "parent_id":254885,
  "user":"eyeos",
  “modified_at”: "2013-03-08 10:36:41.997",
  "is_root":false,
  "is_folder":false}
{"error":401}

downloadMetadata(token,id,path,user,isTmp=false)

Downloads the content of a file.

Parameters: token – Includes key and secret of the access token
id – Id number of the file in Stacksync
path – Absolute path
user – eyeOS user identifier
isTmp – When False, updates the file versions table. When True, no update is performed
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"download",
                          "id":32565632111,
                          "path":"/home/eyeos/Documents/Client.pdf"
                         }
}
Return: Result structure:
- status: 'OK' if correct or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{"status":"OK"}
{"status":"KO","error":-1}

deleteMetadata(token,file,id,user,path)

Deletes an existing file or directory.

Parameters: token – Includes key and secret of the access token
file – True, if it is a file or False, if it is a directory
id – Id number of the element in Stacksync
user – eyeOS useridentifier
user – Absolute path
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"delete",
                          "file":true,
                          "id":32565632111
                         }
}
Return: Result structure:
- status: 'OK' if correct or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{"status":"OK"}
{"status":"KO","error":-1}

renameMetadata(token,file,id,name,path,user,parent)

Renames a file or directory.

Parameters: token – Includes key and secret of the access token
file – True, if it is a file or False, if it is a directory
id – Id number of the element in Stacksync
name – New name of the element
path – Relative path of the current element
user – eyeOS user identifier
parent – Id of the destination directory (Optional)
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"update",
                          "file":true,
                          "id":32565632156,
                          "filename":"Client2.pdf",
                          "parent_id":155241412
                         }
}
Return: Result structure:
- status: 'OK' if correct or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{"status":"OK"}
{"status":"KO","error":-1}

moveMetadata(token,file,id,pathOrig,pathDest,user,parent,filenameOld,filenameNew)

Moves a file or directory.

Parameters: token – Includes key and secret of the access token
file – True, if it is a file or False, if it is a directory
id – Id number of the element in Stacksync
pathOrig – eyeOS source path
pathDest – eyeOS destination path
user – eyeOS user identifier
parent – Id of the destination directory
filenameOld – Name of the element of the source path
filenameNew – Name of the element of the destination path if different from the source path (Optional)
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"update",
                          "file":true,
                          "id":32565632156,
                          "filename":"Client2.pdf",
                          "parent_id":0
                         }
}
Return: Result structure:
- status: 'OK' if correct case or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{"status":"OK"}
{"status":"KO","error":-1}

listVersions(token,id,user)

Gets a list of versions for a specific file.

Parameters: token – Includes key and secret of the access token
id – Id number of the file in Stacksync
user – eyeOS user identifier
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"listVersions",
                          "id":32565632156,
                         }
}
Return: Result structure:
- status: 'OK' if correct case or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{"status":"OK"}
{"status":"KO","error":-1}

getFileVersionData(token,id,version,path,user)

Downloads the contents of a specific version of an existing file.

Parameters: token – Includes key and secret of the access token
id – Id number of the file in Stacksync
version – Version to be downloaded
path – Absolute path
user – eyeOS user identifier
Script call: Example:
{
 "token":{
                   "key":"token1234",
                   "secret":"secret1234",
                 },
 "metadata":{
                          "type":"getFileVersion",
                          "id":32565632156,
                          "version":2,
                          "path":"\/documents\/clients\/Winter2012.jpg",
                         }
}
Return: Result structure:
- status: 'OK' if correct case or 'KO' in the event of error
- error: Error number. Only exists in the event of error
Example:
{"status":"OK"}
{"status":"KO","error":-1}

Storage API

The configuration file of Storage API is found at“/var/www/eyeos/eyeos/extern/u1db/” and is called “settings.py”.

The “Stacksync” key components of the configuration file are:

urls
REQUEST_TOKEN_URL StakcSync API where the request token is requested
ACCES_TOKEN_URL StackSync API to request the access token
CALLBACK_URL Redirect to eyeOS once the user grants access to their private space
RESOURCE_URL StackSync API to access the user's protected resources
Consumer
KEY Provided by StackSync to identify eyeOS
SECRET Provided by StackSync to identify eyeOS

getMetadata(oauth,file,id,contents)

Gets metadata of a directory and/or files.

Url: Use RESOURCE_URL of the configuration file.
Method: GET
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of the consumer key and secret of the configuration file. And also the access token
file – True, if it is a file or False, if it is a directory
id – Id number of the element (directory or file)
contents – True, lists dependent metadata of the element identified by 'id', or none, the list is not activated. This is used when 'id' is a directory. (Optional)
Return: Metadata of the element/s or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"filename":"clients",
 "id":9873615,
 "status":"NEW",
 "version":1,
 "parent_id":”null”,
 "user":"eyeos",
 "modified_at":"2013-03-08 10:36:41.997",
 “is_root”: false,
 "is_folder":true,
 "contents":[{
                          "filename":"Client1.pdf",
                          "id":32565632156,
                          "size":775412,
                          "mimetype":"application/pdf",
                          "status":"NEW",
                          "version":1,
                          "parent_id":-348534824681,
                          "user":"eyeos",
                          "modified_at":"2013-03-08 10:36:41.997",
                          "is_root":false,
                          "is_folder":false
                       }]
}
{"error":403, "description": "Forbidden ."}

updateMetadata(oauth,file,id,name,parent)

Updates metadata of the element for rename and move actions.

Url: Use RESOURCE_URL of the configuration file.
Method: PUT
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of consumer key and secret of the configuration file. And also the access token
file – True, if it is a file or False, of it is a directory
id – Id number of the element (directory or file)
name – Name of the element
parent – Id of the destination directory (Optional)
Return: Metadata of the element or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"status": "CHANGED",
 "is_folder": false,
 "user": "eyeos",
 "modified_at": "2013-03-08 10:36:41.997",
 "id": 32565632156,
 "size": 775412,
 "mimetype": "application/pdf",
 "filename": "Client1.pdf",
 "parent_id": 789456,
 “is_root”: false,
 "version": 3}
{"error":403, "description": "Forbidden ."}

createMetadata(oauth,file,name,parent,path)

Creates a new element (file or directory)

Url: Use RESOURCE_URL of the configuration file.
Method: POST
Signature: HMAC-SHA1
Parameters: oauth – OAuthRequest object. Includes the values of the consumer key and secret of the configuration file. And also the access token.
file – True, if it is a file or False, if it is a directory
name – Name of the element
parent – Id of the destination directory (Optional)
path – Absolute path of the file(Optional)
Return: Metadata of the element or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"status": "NEW",
 "is_folder": false,
 "user": "eyeos",
 "modified_at": "2013-03-08 10:36:41.997",
 "id": 32565632155,
 "size": 775412,
 "mimetype": "application/pdf",
 "filename": "Client.pdf",
 "parent_id": 789456,
 “is_root”: false,
 "version": 1}
{"error":403, "description": "Forbidden ."}

uploadFile(oauth,id,path)

Uploads the content of an existing file.

Url: Use RESOURCE_URL of the configuration file.
Method: PUT
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of consumer key and secret of the configuration file. And also the access token
id – Id number of file
path – Absolute path of the file (Optional)
Return: True or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"error":403, "description": "Forbidden ."}

downloadFile(oauth,id,path)

Downloads the content of an existing file.

Url: Use RESOURCE_URL of the configuration file.
Method: GET
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of the consumer key and secret of the configuration file. And also the access token
id – Id number of the file
path – Absolute path of the file (Optional)
Return: True or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"error":403, "description": "Forbidden ."}

deleteMetadata(oauth,file,id)

Deletes an element (file or directory)

Url: Use RESOURCE_URL of the configuration file.
Method: DELETE
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of the consumer key and secret of the configuration file. And also the access token.
file – True, if it is a file or False, if it is a directory
Id – Id number of the element (directory or file)
Return: Metadata of the element or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"status": "DELETED",
 "is_folder": false,
 "user": "eyeos",
 "modified_at": "2013-03-08 10:36:41.997",
 "id": 32565632156,
 "size": 775412,
 "mimetype": "application/pdf",
 "filename": "Client1.pdf",
 "parent_id": 789456,
 “is_root”: false,
 "version": 3}
{"error":403, "description": "Forbidden ."}

getFileVersions(oauth,id)

Gets the version list for a specific file.

Url: Use RESOURCE_URL of the configuration file.
Method: GET
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of consumer key and secret of the configuration file. And also the access token.
Id – Id number of the file
Return: Metadata or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"status": "CHANGED",
 "is_folder": false,
 "chunks": [],
 "id": "155",
 "mimetype": "text/plain",
 "versions": [
                          {"status":"CHANGED",
                          "is_folder": false,
                          "chunks": [],
                          "id": "155",
                          "size": 61,
                          "mimetype": "text/plain",
                          "checksum": 2499810342,
                          "modified_at": "2014-06-20 10:11:11.031",
                          "filename":"welcome.txt",
                          "parent_id":"null",
                          "version":"2"},
                          {"status":"NEW",
                          "is_folder": false,
                          "chunks": [],
                          "id": "155",
                          "size": 59,
                          "mimetype": "text/plain",
                          "checksum": 2499810342,
                          "modified_at": "2014-06-20 10:11:11.031",
                          "filename":"welcome.txt",
                          "parent_id":"null",
                          "version":"1"}],
 "checksum": 2499810342,
 "modified_at": "2014-06-20 10:11:11.031",
 "filename": "welcome.txt",
 "parent_id": "null",
 "version":2}
{"error":403, "description": "Forbidden ."}

getFileVersionData(oauth,id,version,path)

Downloads the contents of a specific version of an existing file.

Url: Use RESOURCE_URL of the configuration file.
Method: GET
Signature: HMAC-SHA1
Parameters: oauth – OauthRequest object. Includes the values of consumer key and secret of the configuration file. And also the access token.
id – Id number of the file
version – Version to be downloaded
path – Absolute path of the file
Return: True or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"error":403, "description": "Forbidden ."}

Implementation of Share API into eyeOS

To share folders and their contents among users of the same or different Personal Clouds, the Share tool is implemented in the file manager.

The user can access the tool by selecting a Personal Cloud directory and then clicking the “Activity” tab in the right toolbar (social bar).

This tab lists all users that can access and manage the active directory. Furthermore it indicates who is the owner of the directory.

Where the directory is not shared, only the directory owner is displayed.

If the user wants to share or add more users to the sharing list, they must right click on the directory to open a contextual menu and then select the “Share” option. When they select this option, a form appears in which they need to enter the email addresses of the people with whom they want to share the directory. Once the form has been completed, the data is sent to StackSync. If the operation is done successfully, the form closes. When the user accesses the “Activity” tab of the directory again, they will see the new users added to the list.

The list of users sharing the directory is not refreshed, as there is no background process that enables new users to be displayed automatically.

Directory sharing is implemented in eyeOS according to the diagram below:

The user performs an action in the file manager, such as lists the users who have access to the directory. The Manager using the getListUsersShare function retrieves the user’s access token and the id of the directory in StackSync. These values are sent to the API, which is responsible for requesting the resource from StackSync using the getListUsersShare function. It receives the list of users and then it notifies the Manager, which will update the eyeOS interface.

The getListUsersShare of the Share Manager and the Share API, as well as the other actions performed by the Share tool. Now are described in more detail, respectively:

Share Manager

getListUsersShare(token,id)

Gets all users with access to a StackSync directory.

Parameters: token – Includes key and secret of the access token
id – Id of the StackSync element
Script call: Example:
{
    "token":{
                     "key":"token1234",
                     "secret":"secret1234",
                  }
    "metadata":{
                            "type":"listUsersShare",
                            "id":32565632156,
                        }
}
Return: List of users or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
[
   {“name”:”tester1”,
   ”email”:”tester1@test.com”,
   ”modified_at”:”2014-04-11 10:02:33.432”,
   ”is_owner”:true},
   {“name”:”tester2”,
   ”email”:”tester2@test.com”,
   ”modified_at”:”2014-05-30 19:39:21.044”,
   ”is_owner”:false},
   {“name”:”tester3”,
   ”email”:”tester3@test.com”,
   ”modified_at”:”2014-06-06 15:42:41.852”,
   ”is_owner”:false},
]
{“error”:401,”description”:”Error list members”}

shareFolder(token,id,list)

Shares a directory with another user.

Parameters: token – Includes key and secret of the access token
id – Id of the StackSync element
list – Users’ email addresses
Script call: Example:
{
    "token":{
                     "key":"token1234",
                     "secret":"secret1234",
                  }
    "metadata":{
                            "type":"shareFolder",
                            "id":32565632156,
                            "list":[
                                        "tester1@test.com",
                                        "tester2@test.com",
                                        "tester3@test.com"
                                     ]
                        }
}
Return: Result structure:
- status: ‘OK’ if correct or ‘KO’ in the event of error
- error: Error number. Only exists in the event of error
Example:
{“status”:”OK” }
{“status”:”KO”, “error”: -1}

Share API

The configuration file of Share API is found at “/var/www/eyeos/eyeos/extern/u1db/” and is called “settings.py”.

getListUsersShare(oauth,id)

Gets all users with access to a StackSync directory.

Url: Use RESOURCE_URL of the configuration file.
Method: GET
Signature: HMAC-SHA1
Parameters:
  • oauth – OauthRequest object. Includes the values of the consumer key and secret of the configuration file. And also the access token
  • id – Id of the StackSync element
Return: List of users or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
[
   {“name”:”tester1”,
   ”email”:”tester1@test.com”,
   ”modified_at”:”2014-04-11 10:02:33.432”,
   ”is_owner”:true},
   {“name”:”tester2”,
   ”email”:”tester2@test.com”,
   ”modified_at”:”2014-05-30 19:39:21.044”,
   ”is_owner”:false},
   {“name”:”tester3”,
   ”email”:”tester3@test.com”,
   ”modified_at”:”2014-06-06 15:42:41.852”,
   ”is_owner”:false},
]
{“error”:401,”description”:”Error list members”}

shareFolder(oauth,id,list)

Shares a directory with another user.

Url: Use RESOURCE_URL of the configuration file.
Method: POST
Signature: HMAC-SHA1
Parameters:
  • oauth – OauthRequest object. Includes the values of the consumer key and secret of the configuration file. And also the access token
  • id – Id of the StackSync element
  • list – List of users
Return: True or, in the event of error, returns an error structure:
- error: Error number
- description: Error description
Example:
{"error":403, "description": "Forbidden ."}

About

No description, website, or topics provided.

Resources

License

AGPL-3.0, AGPL-3.0 licenses found

Licenses found

AGPL-3.0
LICENSE
AGPL-3.0
Copying

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 57.7%
  • JavaScript 22.8%
  • SourcePawn 7.3%
  • HTML 6.3%
  • TeX 3.2%
  • Python 1.4%
  • Other 1.3%