Skip to content

Commit

Permalink
Requested pit '{}' is older than the Repository Creation Time '{}'
Browse files Browse the repository at this point in the history
  • Loading branch information
robertblust committed Mar 10, 2015
1 parent 1992269 commit aa015ef
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
package ch.flatland.cdo.service.repoaccess.internal

import ch.flatland.cdo.service.repoaccess.SessionFactory
import ch.flatland.cdo.util.DateConverter
import ch.flatland.cdo.util.FlatlandException
import ch.flatland.cdo.util.Request
import ch.flatland.cdo.util.Response
import ch.flatland.cdo.util.View
import java.util.Date
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import org.eclipse.emf.cdo.view.CDOView
Expand All @@ -29,6 +31,7 @@ class Get {
val extension Request = new Request
val extension Response = new Response
val extension View = new View
val extension DateConverter = new DateConverter

def void run(HttpServletRequest req, HttpServletResponse resp) {
logger.debug("Run for '{}'", req.userId)
Expand All @@ -40,7 +43,15 @@ class Get {
try {
if(req.pointInTime != null) {
try {
val session = SessionFactory.getCDOSession(req)
val creationTime = session.repositoryInfo.creationTime
val pit = Long.parseLong(req.pointInTime)
if (pit < creationTime) {
throw new FlatlandException(SC_BAD_REQUEST, "Requested pit '{}' is older than the Repository Creation Time '{}'", new Date(pit).formatDate, new Date(creationTime).formatDate)
}
view = SessionFactory.getCDOSession(req).openView(Long.parseLong(req.pointInTime))
} catch (FlatlandException fle) {
throw fle
} catch(Exception e) {
throw new FlatlandException(SC_NOT_FOUND, "{} not found", req.pathInfo)
}
Expand Down

0 comments on commit aa015ef

Please sign in to comment.