diff --git a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java index 09a746a75..67b76b356 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java +++ b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java @@ -316,11 +316,24 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String start = getFormParameterSafely(postDecoder, "start"); String collectionType = getFormParameterSafely(postDecoder, "collectionType"); String prizeMultiplier = getFormParameterSafely(postDecoder, "prizeMultiplier"); - List formats = getFormMultipleParametersSafely(postDecoder, "format"); - List serieDurations = getFormMultipleParametersSafely(postDecoder, "serieDuration"); - List maxMatches = getFormMultipleParametersSafely(postDecoder, "maxMatches"); + List formats = getFormMultipleParametersSafely(postDecoder, "format[]"); + List serieDurations = getFormMultipleParametersSafely(postDecoder, "serieDuration[]"); + List maxMatches = getFormMultipleParametersSafely(postDecoder, "maxMatches[]"); String name = getFormParameterSafely(postDecoder, "name"); - int cost = Integer.parseInt(getFormParameterSafely(postDecoder, "cost")); + String costStr = getFormParameterSafely(postDecoder, "cost"); + + if(start == null || start.trim().isEmpty() + ||collectionType == null || collectionType.trim().isEmpty() + ||prizeMultiplier == null || prizeMultiplier.trim().isEmpty() + ||name == null || name.trim().isEmpty() + ||costStr == null || costStr.trim().isEmpty()) { + throw new HttpProcessingException(400); + } + + if(formats.size() != serieDurations.size() || formats.size() != maxMatches.size()) + throw new HttpProcessingException(400); + + int cost = Integer.parseInt(costStr); String code = String.valueOf(System.currentTimeMillis()); @@ -353,11 +366,24 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String start = getFormParameterSafely(postDecoder, "start"); String collectionType = getFormParameterSafely(postDecoder, "collectionType"); String prizeMultiplier = getFormParameterSafely(postDecoder, "prizeMultiplier"); - List formats = getFormMultipleParametersSafely(postDecoder, "format"); - List serieDurations = getFormMultipleParametersSafely(postDecoder, "serieDuration"); - List maxMatches = getFormMultipleParametersSafely(postDecoder, "maxMatches"); + List formats = getFormMultipleParametersSafely(postDecoder, "format[]"); + List serieDurations = getFormMultipleParametersSafely(postDecoder, "serieDuration[]"); + List maxMatches = getFormMultipleParametersSafely(postDecoder, "maxMatches[]"); String name = getFormParameterSafely(postDecoder, "name"); - int cost = Integer.parseInt(getFormParameterSafely(postDecoder, "cost")); + String costStr = getFormParameterSafely(postDecoder, "cost"); + + if(start == null || start.trim().isEmpty() + ||collectionType == null || collectionType.trim().isEmpty() + ||prizeMultiplier == null || prizeMultiplier.trim().isEmpty() + ||name == null || name.trim().isEmpty() + ||costStr == null || costStr.trim().isEmpty()) { + throw new HttpProcessingException(400); + } + + if(formats.size() != serieDurations.size() || formats.size() != maxMatches.size()) + throw new HttpProcessingException(400); + + int cost = Integer.parseInt(costStr); StringBuilder sb = new StringBuilder(); sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.size()); @@ -414,7 +440,18 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String serieDuration = getFormParameterSafely(postDecoder, "serieDuration"); String maxMatches = getFormParameterSafely(postDecoder, "maxMatches"); String name = getFormParameterSafely(postDecoder, "name"); - int cost = Integer.parseInt(getFormParameterSafely(postDecoder, "cost")); + String costStr = getFormParameterSafely(postDecoder, "cost"); + + if(format == null || format.trim().isEmpty() + ||start == null || start.trim().isEmpty() + ||serieDuration == null || serieDuration.trim().isEmpty() + ||maxMatches == null || maxMatches.trim().isEmpty() + ||name == null || name.trim().isEmpty() + ||costStr == null || costStr.trim().isEmpty()) { + throw new HttpProcessingException(400); + } + + int cost = Integer.parseInt(costStr); String code = String.valueOf(System.currentTimeMillis()); @@ -444,7 +481,18 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String serieDuration = getFormParameterSafely(postDecoder, "serieDuration"); String maxMatches = getFormParameterSafely(postDecoder, "maxMatches"); String name = getFormParameterSafely(postDecoder, "name"); - int cost = Integer.parseInt(getFormParameterSafely(postDecoder, "cost")); + String costStr = getFormParameterSafely(postDecoder, "cost"); + + if(format == null || format.trim().isEmpty() + ||start == null || start.trim().isEmpty() + ||serieDuration == null || serieDuration.trim().isEmpty() + ||maxMatches == null || maxMatches.trim().isEmpty() + ||name == null || name.trim().isEmpty() + ||costStr == null || costStr.trim().isEmpty()) { + throw new HttpProcessingException(400); + } + + int cost = Integer.parseInt(costStr); String code = String.valueOf(System.currentTimeMillis()); @@ -498,7 +546,18 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String serieDuration = getFormParameterSafely(postDecoder, "serieDuration"); String maxMatches = getFormParameterSafely(postDecoder, "maxMatches"); String name = getFormParameterSafely(postDecoder, "name"); - int cost = Integer.parseInt(getFormParameterSafely(postDecoder, "cost")); + String costStr = getFormParameterSafely(postDecoder, "cost"); + + if(format == null || format.trim().isEmpty() + ||start == null || start.trim().isEmpty() + ||serieDuration == null || serieDuration.trim().isEmpty() + ||maxMatches == null || maxMatches.trim().isEmpty() + ||name == null || name.trim().isEmpty() + ||costStr == null || costStr.trim().isEmpty()) { + throw new HttpProcessingException(400); + } + + int cost = Integer.parseInt(costStr); String code = String.valueOf(System.currentTimeMillis()); @@ -528,7 +587,18 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String serieDuration = getFormParameterSafely(postDecoder, "serieDuration"); String maxMatches = getFormParameterSafely(postDecoder, "maxMatches"); String name = getFormParameterSafely(postDecoder, "name"); - int cost = Integer.parseInt(getFormParameterSafely(postDecoder, "cost")); + String costStr = getFormParameterSafely(postDecoder, "cost"); + + if(format == null || format.trim().isEmpty() + ||start == null || start.trim().isEmpty() + ||serieDuration == null || serieDuration.trim().isEmpty() + ||maxMatches == null || maxMatches.trim().isEmpty() + ||name == null || name.trim().isEmpty() + ||costStr == null || costStr.trim().isEmpty()) { + throw new HttpProcessingException(400); + } + + int cost = Integer.parseInt(costStr); String code = String.valueOf(System.currentTimeMillis()); diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/leagueAdmin.html b/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/leagueAdmin.html index 1b44bc4d2..46e3c9978 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/leagueAdmin.html +++ b/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/leagueAdmin.html @@ -1,242 +1,397 @@ - - - -
-

League

+

Add Sealed League

+ +
+ Name:
+ Cost (in silver):
+ Start (YYYYMMDD):
+ Format: +
+ Series duration in days:
+ Maximum matches in series:
+ + + Ready. +
-

Add sealed league

-
- Name:
- Cost (in silver):
- Start (YYYYMMDD):
- Format: -
- Series duration in days:
- Maximum matches in series:
- - -
+

Add Solo-Draft League

+
+ Name:
+ Cost (in silver):
+ Start (YYYYMMDD):
+ Format: +
+ Series duration in days:
+ Maximum matches in series:
+ + + + + + Ready. +
-

Add solo-draft league

+

Add Constructed League

-
- Name:
- Cost (in silver):
- Start (YYYYMMDD):
- Format: -
- Series duration in days:
- Maximum matches in series:
- - -
+
+ Name:
+ Cost (in silver):
+ Start (YYYYMMDD):
+ Prize multiplier (e.g. 0.7):
+ Collection: +
-

Add constructed league

+
+
+ Series definition:
+ Format: +
+ Series duration in days:
+ Maximum matches in series:
-
- Name:
- Cost (in silver):
- Start (YYYYMMDD):
- Prize multiplier (e.g. 0.7):
- Collection: -
- -
-
- Series definition:
- Format: -
- Series duration in days:
- Maximum matches in series:
-
-
- - - -
+
+
+ + + + + + Ready. +
diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/userAdmin.html b/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/userAdmin.html index 631e88975..67daeb6e2 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/userAdmin.html +++ b/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/userAdmin.html @@ -54,86 +54,3 @@ - - \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js index d32aa6d52..014c0877a 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js +++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js @@ -873,6 +873,124 @@ var GempLotrCommunication = Class.extend({ }); }, + previewSealedLeague:function (format, start, serieDuration, maxMatches, name, cost, callback, errorMap) { + $.ajax({ + type:"POST", + url:this.url + "/admin/previewSealedLeague", + cache:false, + data:{ + format:format, + start:start, + serieDuration:serieDuration, + maxMatches:maxMatches, + name:name, + cost:cost + }, + success:this.deliveryCheck(callback), + error:this.errorCheck(errorMap), + dataType:"xml" + }); + }, + + addSealedLeague:function (format, start, serieDuration, maxMatches, name, cost, callback, errorMap) { + $.ajax({ + type:"POST", + url:this.url + "/admin/addSealedLeague", + cache:false, + data:{ + format:format, + start:start, + serieDuration:serieDuration, + maxMatches:maxMatches, + name:name, + cost:cost + }, + success:this.deliveryCheck(callback), + error:this.errorCheck(errorMap), + dataType:"html" + }); + }, + + previewSoloDraftLeague:function (format, start, serieDuration, maxMatches, name, cost, callback, errorMap) { + $.ajax({ + type:"POST", + url:this.url + "/admin/previewSoloDraftLeague", + cache:false, + data:{ + format:format, + start:start, + serieDuration:serieDuration, + maxMatches:maxMatches, + name:name, + cost:cost + }, + success:this.deliveryCheck(callback), + error:this.errorCheck(errorMap), + dataType:"xml" + }); + }, + + addSoloDraftLeague:function (format, start, serieDuration, maxMatches, name, cost, callback, errorMap) { + $.ajax({ + type:"POST", + url:this.url + "/admin/addSoloDraftLeague", + cache:false, + data:{ + format:format, + start:start, + serieDuration:serieDuration, + maxMatches:maxMatches, + name:name, + cost:cost + }, + success:this.deliveryCheck(callback), + error:this.errorCheck(errorMap), + dataType:"html" + }); + }, + + previewConstructedLeague:function (start, collectionType, prizeMultiplier, name, cost, formats, serieDurations, maxMatches, callback, errorMap) { + $.ajax({ + type:"POST", + url:this.url + "/admin/previewConstructedLeague", + cache:false, + data:{ + start:start, + collectionType:collectionType, + prizeMultiplier:prizeMultiplier, + name:name, + cost:cost, + format:formats, + serieDuration:serieDurations, + maxMatches:maxMatches + }, + success:this.deliveryCheck(callback), + error:this.errorCheck(errorMap), + dataType:"xml" + }); + }, + + addConstructedLeague:function (start, collectionType, prizeMultiplier, name, cost, formats, serieDurations, maxMatches, callback, errorMap) { + $.ajax({ + type:"POST", + url:this.url + "/admin/addConstructedLeague", + cache:false, + data:{ + start:start, + collectionType:collectionType, + prizeMultiplier:prizeMultiplier, + name:name, + cost:cost, + format:formats, + serieDuration:serieDurations, + maxMatches:maxMatches + }, + success:this.deliveryCheck(callback), + error:this.errorCheck(errorMap), + dataType:"html" + }); + }, + //NEVER EVER EVER use this for actual authentication