README - icecite
================================================================================
================================================================================

(1) How to do a clean installation of Icecite 

There are mainly 5 components:
    (a) CompleteSearch - an instance of CompleteSearch, that is used to search 
        DBLP.
    (b) MetadataKnowledge - a metadata knowledge server based on DBLP, that is 
        used to enrich metadata extracted from PDF to *full* and *reliable* 
        metadata.
    (c) PdfMachine - a server that is used to find 
         - PDF files for given metadata. 
         - Metadata for given PDF files.
    (d) CouchDb - a database server that is used to store user data, pdf data, 
        metadata, annotations, etc.
    (e) User Interface - The collection of html, css, js files that build the
        user interface.  
________________________________________________________________________________

(1a) How to install/setup CompleteSearch

svn co https://ad-svn.informatik.uni-freiburg.de/completesearch

DIR = ~/completesearch          (The base directory) (TODO: Move this directory into icecite directory).
DB_DIR = $DIR/databases/dblp    (The base directory of dblp parser)
DATA_DIR = $DB_DIR/data         (The data directory with dblp.xml and dblp.dtd)
PARSER = dblp.parser            (The name of parser)
DB=data/dblp                    (The basename of database)
PORT=6201                       (The default port of server)

!! Need to modify $DIR/codebase/server/CompletionServer.cpp: 
Add line '<< "Access-Control-Allow-Origin: *" << "\r\n"' in line 886, 1546 and 1694.!!!

cd $DB_DIR                      (Move to database directory)
ln -s ../../codebase            (Create symbolic link to codebase directory)
ln -s /nfs/raid5/korzen/icecite/completesearch/data/    (Create symbolic link to data directory with dblp.xml and dblp.dtd)
ln -s data/dblp.dtd             (TODO: CompleteSearch doesn't find the dtd-File in data?)
cd codebase/synonymsearch       (Move to synonymsearch in codebase directory)
make                            (Build synonymsearch)
cd $DB_DIR                      
make $PARSER                    (Compile the parser)
make parse sort index DB=$DB    (Parse the database and create index)
make start DB=$DB PORT=$PORT    (Start the server)

To compile the parser, there must be a cpp file ($PARSER).cpp from which the
parser can be created. On parsing the database, a lot of intermediate files will
be created (index files, vocabularies, etc.). Once these files were created, 
the server is ready to be started (the server make use of the created files, 
there is no need to parse the database on every start/restart of the server). 
________________________________________________________________________________

(1b) How to install/setup MetadataKnowledge

Install gtest if it is not available on your machine: https://ad-wiki.informatik.uni-freiburg.de/teaching/ProgrammierenCplusplusSS2014/Gtest

DIR = ~/icecite/metadata-knowledge  (The base directory) (TODO: Move this directory into icecite directory).
DATA_DIR = $DIR/data                (The data directory with dblp.xml and dblp.dtd)
DB=data/dblp                        (The basename of database)
PORT=6200                           (The default port of server)

cd $DIR                             (Move to base directory)
make compile                        (Compile the files)
nohup make start DB=$DB PORT=$PORT >/dev/null 2>&1 & (Start the server)

On starting the server (TODO: Schreiben, dass index-Dateien erstellt werden)
________________________________________________________________________________

(1c) How to install/setup PdfMachine

DIR = ~/icecite/pdf-machine

cd $DIR
mvn -DskipTests install

- Deploy to Tomcat6:
It is enough, to copy the created war file to /var/lib/tomcat6/webapps. Change
the ownership: sudo chown tomcat6:tomcat6 pdf-machine.war.

________________________________________________________________________________

(1d) How to install/setup CouchDb

$PORT  = 6501

(HINT: There are no users created at the moment!)
$ADMIN1 = dev
$ADMIN1_PWD = !dev4AD!
$ADMIN2 = couchdb-user (FIXME: This is the default account for all users. But it's an admin account, because a user must be able to create databases. Try to remove the admin privileges from normal user.)
$ADMIN2_PWD = !couch4users!

- Installation:
sudo apt-get install couchdb

- Configuration:
CONFIG_FILE = /etc/couchdb/local.ini
DATABASE_DIR = /var/lib/couchdb
  
  * Change port and bind_address:
    port=$PORT
    bind_address=0.0.0.0            (to make the database visible externally).

  * Add/delete admins:
    Add/comment line to [admins] section in the format username = password

  * Enable CORS:
    [httpd]
    enable_cors = true
    
    [cors]
    credentials = true
    headers = accept, authorization, content-type, origin, referer
    methods = GET, PUT, POST, HEAD, DELETE
    origins = *

  * Enable SSL (TODO: disabled for the moment):
    Cert-File: /home/korzen/icecite/cert/mycert.pem
    Key-File: /home/korzen/icecite/cert/privkey.pem

- Start/Stop/Restart:
sudo service couchdb start/stop/restart

- Create admin:
Go to $URL_OF_MACHINE:$PORT/_utils/
Click "Fix this in the lower right and type in name and password for admin user. 

- Create user/another admin:
________________________________________________________________________________

(1e) How to install/setup User Interface

- Setting up Apache:

Put all the files into /var/www/icecite(-new)

Define Virtual Host in Apache. Create file "icecite(-new)" in /etc/apache2/sites-available/:

<VirtualHost *:80>
  ServerName icecite(-new).informatik.uni-freiburg.de
  ServerAlias icecite(-new)
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/icecite/

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <Directory /var/www/icecite(-new)/>
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Create symbolic link in /etc/apache2/sites-enabled/:
sudo ln -s ../sites-available/icecite(-new).conf 

Restart Apache:  sudo /etc/init.d/apache2 restart

- Setting up Google Oauth Client IDs:

Go to: https://console.developers.google.com/
Select the Project "Hello OAuth2" in the header.
Click "ZUgangsdaten" in left bar.
Click "Web Client 1" in "OAuth-2.0-Client-IDs"
Add/remove "Autorisierte JavaScript-Quellen"
