/**
* File ./src/main/java/de/lemo/dms/processing/Question.java
* Lemo-Data-Management-Server for learning analytics.
* Copyright (C) 2015
* Leonard Kappe, Andreas Pursian, Sebastian Schwarzrock, Boris Wenzlaff
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
/**
* File ./main/java/de/lemo/dms/processing/Question.java
* Date 2013-01-24
* Project Lemo Learning Analytics
*/
package de.lemo.dms.processing;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.apache.log4j.Logger;
import de.lemo.dms.service.responses.BadRequestException;
/**
* Base class for questions, sets default JSON response type.
*
* @author Leonard Kappe
*/
@Produces(MediaType.APPLICATION_JSON)
public abstract class Question {
protected final Logger logger = Logger.getLogger(this.getClass());
protected void validateTimestamps(Long startTime, Long endTime) {
if (startTime == null) {
throw new BadRequestException("Missing start time parameter.");
}
if (endTime == null) {
throw new BadRequestException("Missing end time parameter.");
}
if (startTime >= endTime) {
throw new BadRequestException("Invalid start time: start time exceeds end time.");
}
}
protected void validateTimestamps(Long startTime, Long endTime, Long resolution) {
validateTimestamps(startTime, endTime);
if (resolution == null) {
throw new BadRequestException("Missing resolution parameter.");
}
if (resolution <= 0) {
throw new BadRequestException("Invalid resolution: resolution is a negative value.");
}
}
}