Newer
Older
marking / src / main / java / dao / MarkingProperties.java
package dao;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.swing.JOptionPane;

/**
 *
 * @author mark
 */
@SuppressWarnings("StaticNonFinalUsedInInitialization")
public class MarkingProperties {

	private static Properties properties = null;

	static {
		if (properties == null) {

			properties = new Properties();
			try {
				// production
				properties.load(new FileInputStream("marking.properties"));
			} catch (IOException ex1) {
				try {
					// development
					properties.load(MarkingProperties.class.getResourceAsStream("/marking.properties"));
				} catch (IOException ex2) {
					JOptionPane.showMessageDialog(null, "marking.properties not found!");
				}
			}
		}
	}

	public static String jdbcUri() {
		return properties.getProperty("jdbc.url").trim();
	}

	public static String reportPath() {
		return properties.getProperty("report.dir").trim();
	}

	public static String attachmentEmailName() {
		return properties.getProperty("attachment.email.name").trim();
	}

	public static String attachmentFilePrefix() {
		return properties.getProperty("attachment.file.prefix").trim();
	}

	public static String assessmentDescription() {
		return properties.getProperty("assessment.description").trim();
	}

	public static Boolean isEmailEnabled() {
		return properties.getProperty("enable.email").trim().equalsIgnoreCase("true");
	}

	public static String xidType() {
		return properties.getProperty("submission.key.type").trim();
	}

	public static String smtpHost() {
		return properties.getProperty("smtp.host").trim();
	}

	public static Boolean isTls() {
		return properties.getProperty("smtp.tls").trim().equalsIgnoreCase("true");
	}

	public static String smtpUserName() {
		return properties.getProperty("smtp.user.name").trim();
	}

	public static String markerName() {
		return properties.getProperty("marker.name").trim();
	}

	public static String markerEmail() {
		return properties.getProperty("marker.email").trim();
	}

	public static Integer smtpPort() {
		return Integer.valueOf(properties.getProperty("smtp.port").trim());
	}

	public static Integer emailDelay() {
		return Integer.valueOf(properties.getProperty("email.delay").trim());
	}

	public static Boolean reportShowMax() {
		return properties.getProperty("report.showmax").trim().equalsIgnoreCase("true");
	}

	public static String reportTitle() {
		return properties.getProperty("report.title").trim();
	}

	public static String reportFooter() {
		return properties.getProperty("report.footer").trim();
	}

	public static String paperCode() {
		return properties.getProperty("paper.code").trim();
	}

}