Worked out building and developing instructions
1 parent e0c0b31 commit b7ef23a6b6f5cca083f289b81cd0216dd7c67068
@Kimberlee I. Model Kimberlee I. Model authored on 24 Aug 2019
Showing 6 changed files
View
13
README.md 0 → 100644
# Kimee's Blog
 
This repository houses the code for Kimee's blog and website.
It's written using Java EE, primarily JSP, with a number of DAOs.
 
To build follow the [building instructions](docs/building.md).
 
To install follow the [installation instructions](docs/installation.md).
 
## License
 
It is licensed under the Apache 2.0 [license](license.txt).
View
119
docs/building.md 0 → 100644
# Building Instructions
 
Building this requires [maven](https://maven.apache.org/), [tomcat](https://tomcat.apache.org/), and [MariaDB](https://mariadb.org/).
Consult your Operating System Distribution's manual for installation instructions.
It also uses [git](https://git-scm.com/) for source control.
 
## Database Configuration
 
For developer testing, the project's ``context.xml`` is setup to expect a schema called ``blog`` with the following configuration:
 
- Connection URL: localhost:3306/blog
- Username: blogger
- Password: bloggingit
 
These credentials should be given minimal permissions to the rest of the database.
While possible to do so, it is recommended not to use these credentials in a production system.
Simply create a production user and edit ``context.xml`` after deploying to use different credentials.
See [installation](installation.md).
 
These SQL commands will create the ``blog`` schema with the credentials as listed. this makes code-test-debug cycles easy, at minimal risk to the rest of the database.
 
```
CREATE SCHEMA blog;
USE SCHEMA blog;
SOURCE src/main/sql/setup.sql;
GRANT SELECT, INSERT, UPDATE, DELETE ON blog.* TO 'blogger'@'host' IDENTIFIED BY 'bloggingit';
```
 
The project uses an additional schema called 'blogtest' for running unit tests.
The unit tests also have a testing user hard coded in, to facilitate testing queries.
The following credentials are used:
 
- Connection URL: localhost:3306/blogtest
- Username: blogtester
- Password: bloggingit
 
To install the schema in your database and create the ``blogtester`` user, run the following queries.
The project will automatically recreate the tables before each test run.
 
```
CREATE SCHEMA blogtest;
USE blogtest;
GRANT SELECT, INSERT, UPDATE, DELETE ON blog.* TO 'blogtester'@'host' IDENTIFIED BY 'testingit';
```
 
Lastly the project requires a user account with full permissions to destroy and recreate the ``blogtest`` schema.
Run this query to create one, changing the username and password.
 
```
GRANT ALL PERMISSIONS ON blogtest.* TO 'username'@'localhost' IDENTIFIED BY 'password';
```
 
This allows maven build to destroy and recreate the ``blogtest`` schema.
 
Since this user has all permissions it is necessary to use unique credentials and protect them.
In Maven this can be done by hiding per-machine credentials in the ``.m2/settings.xml`` file.
Edit the file ``~/.m2/settings.xml`` to have the following.
Ensure the id is set to ``localhost-mariadb-tester`` so that the POM accesses the correct server.
 
```
<servers>
<server>
<id>localhost-mariadb-tester</id>
<username>username</username>
<password>password</password>
</server>
</servers>
```
 
## Tomcat Configuration
 
There are two tomcat configuration items: the MariaDB JDBC driver jar, and the manager interface login.
 
To configure the MariaDB driver change directory to ``${tomcat}/lib/`` (where ${tomcat} is the installation location of tomcat) and run the following maven command.
 
```
cd ${tomcat}/lib/
mvn dependency:copy -Dartifact=org.mariadb.jdbc:mariadb-java-client:2.4.2:jar -DoutputDirectory=./
```
 
To grant the project permission to deploy the blog.war application, you will need to edit ``${tomcat}/conf/tomcat-users.xml``.
Make sure you have the following lines. Changing passwords to protect your development environment.
 
```
<!-- manager-gui is optional, but convenient if you want to deploy by hand -->
<role rolename="manager-gui" />
<role rolename="manager-script" />
<user username="username" password="password" roles="manager-gui, manager-script" />
 
```
 
Again you should protect your server by hiding these credentials on the per-machine ``~/.m2/settings.xml`` file.
Make sure that this time the ``id`` is given as ``localhost-tomcat``.
 
```
<servers>
<server>
<id>localhost-tomcat</id>
<username>username</username>
<password>password</password>
</server>
</servers>
```
 
Now you should be ready to start developing.
To build the project, as usual run
 
```
mvn package
```
 
And to deploy, redeploy, or undeploy the project WAR file to the development tomcat instance, run the following commands.
 
```
mvn tomcat7:deploy
mvn tomcat7:redeploy
mvn tomcat7:undeploy
```
View
2
■■■
docs/installation.md
- INSERT
- UPDATE
- DELETE
 
To create such an account run the following statement, changing username, host to your web server's hostname or IP address and password to a unique password.
To create such an account run the following statement, changing username, host to the hostname or IP address of your database server and password to a unique password.
 
```
GRANT SELECT, INSERT, UPDATE, DELETE ON blog TO 'username'@'host' IDENTIFIED BY 'password';
```
View
pom.xml
View
src/main/webapp/style.css
View
src/test/java/kim/redbow/web/blog/TestUtil.java