Implemented redirects for cases where the given regatta ID is invalid

This commit is contained in:
Steffen Schaefer committed 2015-03-17 08:47:25 +01:00
1 parent 0c7db73839
commit a46f85f60b
2 files changed
+26 -4

No files matched your search

@@ -148,20 +148,33 @@ public class EventActivityProxy extends AbstractActivityProxy {
* If not, the place is automatically being adjusted.
*/
private AbstractEventPlace verifyAndAdjustPlace() {
EventContext contextWithoutRegatta = new EventContext(ctx).withRegattaId(null);
// TODO check if regatta ID is valid
if(place instanceof AbstractMultiregattaEventPlace && ctx.getEventDTO().getType() != EventType.MULTI_REGATTA) {
EventContext ctxToUse = new EventContext(ctx).withRegattaId(null);
// Events with a type other than multi regatta only have regatta level pages
if(place instanceof MultiregattaRegattasPlace) {
return new RegattaRacesPlace(ctxToUse);
return new RegattaRacesPlace(contextWithoutRegatta);
}
if(place instanceof MultiregattaMediaPlace) {
return new RegattaMediaPlace(ctxToUse);
return new RegattaMediaPlace(contextWithoutRegatta);
}
// TODO Overview isn't implemented yet
// return new RegattaOverviewPlace(ctxToUse);
return new RegattaRacesPlace(ctxToUse);
return new RegattaRacesPlace(contextWithoutRegatta);
}
if(place instanceof AbstractEventRegattaPlace) {
boolean regattaKnown = ctx.getEventDTO().isRegattaIDKnown(ctx.getRegattaId());
if(ctx.getEventDTO().getType() != EventType.MULTI_REGATTA && ctx.getRegattaId() != null && !regattaKnown) {
// Regatta ID unknown but unnecessary ...
ctx.withRegattaId(null);
} else if(ctx.getEventDTO().getType() == EventType.MULTI_REGATTA && !regattaKnown) {
return new MultiregattaRegattasPlace(contextWithoutRegatta);
}
}
if(place instanceof RegattaMediaPlace && ctx.getEventDTO().getType() == EventType.MULTI_REGATTA) {
// The media page for multi regatta events is on event level only but not on regatta level
return new MultiregattaMediaPlace(new EventContext(ctx).withRegattaId(null));
}
// no adjustment necessary
@@ -148,4 +148,13 @@ public class EventViewDTO extends EventDTO {
public void setHasAnalytics(boolean hasAnalytics) {
this.hasAnalytics = hasAnalytics;
}
public boolean isRegattaIDKnown(String regattaId) {
for (RegattaMetadataDTO regatta : regattas) {
if(regatta.getId().equals(regattaId)) {
return true;
}
}
return false;
}
}