Skip to content

Environment Set up

Ben Read edited this page Jan 25, 2015 · 67 revisions

Environment Set-up

Netbeans IDE

Netbeans is used as our development environment. Download the 'all' version with the Glassfish web application server included.

Additional configuration

Checkstyle

The Checkstyle plugin shows code warnings when the Java code does not adhere to our coding standards.

To install:

To configure:

  • Under the menu Tools->Options, select the Miscellaneous option tab and then the Checkstyle tab
  • Check the Enable Custom Configuration checkbox
  • Set the config file to the checkstyle.xml file found at the root of the ROMS project

Code Templates

The organisation and licence (MIT) are built into the maven configuration; Netbeans picks these up automatically, albeit in a buggy way. Apart from that, the encouragement is not to leave your name at the top of the file (default behavior) since that information is available in the VCS.

MySql

  • Download the MySql Community Server from http://dev.mysql.com/downloads/mysql/ and install it.
    • Create a root user, with your password of choice
  • Create the ROMS database by
    • Open a command window (or terminal window for *nix users)
    • Run the database user creation script using: mysql --user root --password < \path\to\rbc1b\roms\database\000.sql and enter the root password.
    • Run the database schema creation script using: mysql --user root --password < \path\to\rbc1b\roms\database\001.sql and enter the root password.
    • Optionally populate some dummy data using mysql --user root --password < \path\to\rbc1b\roms\database\001-dummy.sql and enter the root password.

Database Cleanup

Databases are periodically updated by developers to enable more functionality to work with ROMS and to add new dummy content.

When databases are updated they need to be updated on your local environment. to do this you need to locate the files on your hard drive. You can do this in NetBeans by going to FILES > ROMS > Database and right-clicking, then Properties.

In the Properties panel you'll see a path to the database. Click on the button with three dots (...) to copy the path, which looks something like /Users/you/NetBeansProjects/ROMS/database/000.sql.

First, log in to Mysql by typing mysql -u root -p , press Enter and type your MySQL password.

Then, open a Terminal or Command Prompt window and type Source and paste the path. Do this for each database. The databases need to be updated in a specific order as below:

  1. 001
  2. 001-dummy
  3. 002
  4. 003
  5. 003-dummy
  6. 003-cleanup
  7. 004
  8. 004-dummy
  9. 005

Glassfish

Glassfish is our web application server. We need to configure our database connection using JDBC though [JNDI] (http://www.javaworld.com/jw-01-2000/jw-01-howto.html).

MySQL & Glassfish Setup

  1. Download the MySQL JDBC Connector (bin.jar file) from the [MySql website] (http://dev.mysql.com/downloads/connector/j/). Unzip the contents.
  2. Copy the bin.jar file into the glassfish lib folder. You can find the glass fish installation folder by: in Netbeans, click in the services tab, under servers->glassfish server. Right click->properties and read the domains folder.
  3. Make sure the glass fish server is running. (servers->glassfish server, right click->start).
  4. Go into your Glassfish Administration Console in your browser: localhost:4848.
  5. On the left side of the Admin Console under Common Tasks: Choose Resources->JDBC->Connection Pools. In the main panel, click New.
  6. The name of the JDBC connection Pool is: mysqlpool. The Resource Type: javax.sql.DataSource (from the Drop-down menu) and the Database Vendor: MySql. After this, click: Next.
  7. Check the 'Ping Enabled' check-box.
  8. Set Additional Properties as follows as name-value pairs:
    • URL: jdbc:mysql://localhost:3306/ROMS
    • User: Username that you set for your MySQL server instance, e.g. root
    • Password: Password of the username given in the 'User' property above.
    • DatabaseName: ROMS
  9. Click the Finish->Ping. Hope it's successful!
  10. On the left of Admin Console: Resources->JDBC->JDBC Resources.
  11. Click New in main panel.
  12. 'JNDI Name' name option: jdbc/_roms
  13. Set 'Pool Name' to mysqlpool. Click OK to finish.

Email support

  1. Click on the JavaMail Sessions on the left-side of the admin console and then click on New….
  2. Set the following Properties to the corresponding values:
    • JNDI Name: mail/EdificeMail
    • Mail Host: smtp.gmail.com
    • Default User: Use the gmail account
    • Default Sender Address: < Same as default user above>
    • Description:
    • Status: Enabled
    • Store Protocol: imap
    • Store Protocol class: com.sun.mail.imap.IMAPSTore
    • Transport Protocol: smtp
    • Transport Protocol Class: com.sun.mail.smtp.SMTPTransport
  3. Add the additional properties by clicking on the "Add Property" button. These are name-value pairs:
    • mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
    • mail.smtp.password: the password for the gmail account
    • mail.smtp.auth: true
    • mail.smtp.socketFactory.fallback: false
    • mail.smtp.port: 465
    • mail.smtp.socketFactory.port: 465

Image directory support

Like the previous two subsections, image support in Edifice is carried out by use of a JNDI lookup of the directory in which the JPEG images are stored. To do this, please follow these steps:

  1. Create a folder or directory somewhere on your computer where you can store these images. You can choose to create a folder or directory (e.g. volunteer_images) within your GlassFish folder. But, please make a note of it's absolute path.
  2. Log into the GlassFish Admin console (localhost:4848).
  3. On the left-hand side of the admin console, Choose Resources->JNDI->Custom JNDI.
  4. Click the New button to create a new JNDI resource.
  5. Set the following properties to the corresponding values:
    • JDNI Name: jndi/_images_directories
    • Resource Type: java.util.Properties
    • Factory class: (Should pre-fill itself once the Resource Type has been set) org.glassfish.resources.custom.factory.PropertiesFactory
    • Status: Set to Enabled.
  6. In the Additional Properties table at the bottom, click Add Property and set the following values:
    • Name: volunteer.images.directory

    • Value: Type in the absolute path to your images folder from your root. e.g. if your images folder was in /opt/glassfish3/glassfish/domains/domain1/volunteer_images then you must type: /opt/glassfish3/glassfish/domains/domain1/volunteer_images/ as the value. NOTE: The directory must end with a forward slash / if you are using a Linux or a Mac, *or a backslash * if you are using a Windows machine. e.g.

      Typical Linux: /usr/local/glassfish3/glassfish/domains/domain1/volunteer_images/

      Typical Mac: /Applications/NetBeans/glassfish-3.1.2.2/glassfish/domains/domain1/volunteer_images/

      Typical Windows: C:\Users\RodneyMackay\glassfish3\glassfish\domains\domain1\volunteer_images\

  7. Hit the Save button.
  8. Restart your GlassFish server.

System Properties Settings

Certain properties need to be defined using JNDI that the application server can use to lookup. These properties are defined below.

To set-up the JNDI Custom Resource, using the GlassFish administration console:

  1. Navigate to JNDI -> Custom Resource page.

  2. Click on the new button and define the following:

    • JNDI Name: jndi/_edifice_property
    • Resource Type: java.util.Properties
    • Status: Enabled
    • Click on the "Add Property" to add the properties described below.

The following Properties are used in the application:

edifice.url

Description: This is the URL used to access the server. The reason for this is that the GlassFish server only listens on localhost. Using HTTP Request object to retrieve the URL will result in "http://localhost:8080" or whatever the GlassFish server listens on. On local, i.e. your, development server, you can leave it out. On external dev/production servers, it needs to be set to "https://edifice.rbc-lhc.org.uk:9443" for development server and "https://edifice.rbc-lhc.org.uk" for production server.

Example: http://localhost:8080

security.salt

Description: This is the initial security salt used to create security tokens/hash. If this is left out, a default security salt is used. However, this should be set on both development and production server, and should be different, random and changed on a regular interval.

Example: sdlkfjitu8bndlkjdfs901 but please do not use this on any development or production servers.