<?xml version="1.0"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->

<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">

  <New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>mail/Session</Arg>
    <Arg>
      <New class="org.mortbay.naming.factories.MailSessionReference">
        <Set name="user"></Set>
        <Set name="password"></Set>
        <Set name="properties">
          <New class="java.util.Properties">
            <Put name="mail.smtp.host">localhost</Put>
            <Put name="mail.smtp.port">25</Put>
          </New>
        </Set>
      </New>
    </Arg>
  </New>

<!-- START SNIPPET: setting-up-mysql
 In order to use this jetty-env, you need to setup your mysql locally.

 1) Connect to mysql

    $ mysql -u root -p

    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 62
    Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql>

 2) Create the databases.

    mysql> create database archiva;
    Query OK, 1 row affected (0.00 sec)

    mysql> create database redback;
    Query OK, 1 row affected (0.00 sec)

 3) Create the archiva user / permissions to (archiva and redback) tables.

    mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX
        ->     ON archiva.*
        ->     TO 'archiva'@'localhost'
        ->     IDENTIFIED BY 'sa';
    Query OK, 0 rows affected (0.00 sec)

    mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX
        ->     ON redback.*
        ->     TO 'archiva'@'localhost'
        ->     IDENTIFIED BY 'sa';
    Query OK, 0 rows affected (0.00 sec)

    mysql> 

 4) Quit from mysql command shell, and verify the user creation.

    $ mysql -u archiva -p sa
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 77
    Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> use archiva;
    Database changed
    mysql> use redback;
    Database changed
    mysql> use mysql;
    ERROR 1044 (42000): Access denied for user 'archiva'@'localhost' to database 'mysql'
    mysql> 

 5) Done with mysql server setup.  To use this jetty-env.xml use the following command line.

    $ mvn -Pmysql clean jetty:run

END SNIPPET: setting-up-mysql
    -->

  <!-- Archiva database -->
  <New id="archiva" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>jdbc/archiva</Arg>
    <Arg>
      <New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <Set name="serverName">localhost</Set>
        <Set name="databaseName">archiva</Set>
        <Set name="user">archiva</Set>
        <Set name="password">sa</Set>
      </New>
    </Arg>
  </New>

  <New id="archivaShutdown" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>jdbc/archivaShutdown</Arg>
    <Arg>
      <New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <!-- <Set name="url">jdbc:mysql://localhost/archiva</Set> -->
        <Set name="serverName">localhost</Set>
        <Set name="databaseName">archiva</Set>
        <Set name="user">archiva</Set>
        <Set name="password">sa</Set>
      </New>
    </Arg>
  </New>

  <!-- users / Security Database -->
  <New id="users" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>jdbc/users</Arg>
    <Arg>
      <New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <!-- <Set name="url">jdbc:mysql://localhost/redback</Set> -->
        <Set name="serverName">localhost</Set>
        <Set name="databaseName">redback</Set>
        <Set name="user">archiva</Set>
        <Set name="password">sa</Set>
      </New>
    </Arg>
  </New>

  <New id="usersShutdown" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>jdbc/usersShutdown</Arg>
    <Arg>
      <New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <Set name="url">jdbc:mysql://localhost/redback</Set>
        <Set name="user">archiva</Set>
        <Set name="password">sa</Set>
      </New>
    </Arg>
  </New>

</Configure>

