\subsection{Artifact-Server}
The Artifact-Server contains the entire business logic of the system.
The server provides a RESTful interface with a XML-based protocol to the
webclient. Technically the server is a standalone java process serving the
REST interface.

\subsubsection*{Installation}
\label{ref:artifact-server-install}

Running the server with its own user\footnote{Remark: A group with the
same name is created automatically.}: 
\begin{lstlisting}
  adduser artifacts
\end{lstlisting}

Setup and configuring logging:
\begin{lstlisting}
  cd /var/log
  mkdir artifacts
  chmod 770 artifacts
  chmod g+s artifacts
\end{lstlisting}

The log level can be adjusted in the file \verb+ conf/log4j.properties+.
Further information can be found there.

Integrate software of artifact-server into filesystem:
\begin{lstlisting}
  cd /opt
  tar xfvj /root/artifact-server-$VERSION.tar.bz2
  ln -s artifact-server-$VERSION artifact-server
  cd artifact-server
\end{lstlisting}

Setting the access rights:
\begin{lstlisting}
   bin/setup.sh
\end{lstlisting}

Configure connection to database:
\begin{lstlisting}
  cd /opt/artefact-server
  vim conf/arcsdeconnectionpool.properties
  
  # in conf/arcsdeconnectionpool.properties do:
  server=xyz.server.com
  username=guest
  credentials=XYZ
  port=5151
  database=esri_sde
\end{lstlisting}

Configure address for finding the WMS-Server:
\begin{lstlisting}
  cd /opt/artefact-server/
  vim conf/conf.xml
  # adapt the address in the element
  # artifact-database/gnv/mapserver/server. This is
  # the string the server uses to provide an address of the mapserver to enduser.
  e.g. http://SERVER/cgi-bin/gnv-wrapper
\end{lstlisting}

The artifact server can export and import projects of the user's
parameterizations. In order to protect the server against invalid files,
configure a secret for signing artifacts.

{\em Hint: If the secret is changed, all files that were created before
are not valid anymore.}

\begin{lstlisting}
  # generate a randomized string, e.g.
  cd /opt/artefact-server/
  pwgen -s 30
  # populate the tag artifact-database/export-secret
\end{lstlisting}

Adapt TCP-port of artefact-server, if the default has to be changed
(default:8181):
\begin{lstlisting}
  cd /opt/artefact-server
  vim conf/conf.xml
  
  # in conf/conf.xml edit the element artifact-database/rest-server/port
\end{lstlisting}

Integrate artifact-server in startup-process of operating system:
\begin{lstlisting}
  cp -i /opt/artefact-server/bin/debian/artifact-server /etc/init.d/
  chmod +x /etc/init.d/artifact-server
  update-rc.d artifact-server defaults
\end{lstlisting}

The server can be started and stopped via
\begin{lstlisting}
  /etc/init.d/artifact-server {start | stop}
\end{lstlisting}

The installation of the artifact-server is finished. It can be tested
now.

\subsubsection*{Test of the Installation}
\label{ref:artifact-server-testing}
  Start the server:
  \begin{lstlisting}
  /etc/init.d/artefact-server start
  \end{lstlisting}
  
  1. Operating System: Check if the process of the server called "App"
  is running:
  \begin{lstlisting}
  jps
  
  # Example with list of java processes:
  19252
  19509 Jps
  19441 App

  cat /var/run/artefact-server
  \end{lstlisting}

  Task: Compare the running process numbers.

  2. Network: Check if the artefact-server opens a TCP-port (default: 8181)
  \begin{lstlisting}
  netstat -nltp
  
  # Check for an entry like:
  tcp        0      0 127.0.0.1:8181          0.0.0.0:*  LISTEN 18648/java
  \end{lstlisting}

  3. Artefact-Server ready for communication with client?
  \begin{lstlisting}
  curl "http://localhost:8181/factories" | xmllint --format -
  \end{lstlisting}
  
  Task: Check for a XML-document describing possible expert information
  systems (FIS)
