1. tbrugz
  2. queryon

Commits

tbrugz  committed a58f776

queryon: added props 'queryon.limit.default' & 'queryon.limit.max'

  • Participants
  • Parent commits 8b29524
  • Branches default

Comments (0)

Files changed (3)

File src/queryon.template.properties

View file
  • Ignore whitespace
 sqldump.datadump.html.append=\n</body></html>
 
 # default query limit
-#queryon.defaultlimit=100
+queryon.limit.default=100
+queryon.limit.max=1000
 
 #####
 

File src/tbrugz/queryon/QueryOn.java

View file
  • Ignore whitespace
 
 	static final String PROPERTIES_RESOURCE = "/queryon.properties";
 	static final String CONN_PROPS_PREFIX = "queryon";
-	static final String PROP_DEFAULT_LIMIT = "queryon.defaultlimit";
+	static final String PROP_DEFAULT_LIMIT = "queryon.limit.default";
+	static final String PROP_MAX_LIMIT = "queryon.limit.max";
 
 	static final String DEFAULT_OUTPUT_SYNTAX = "html";
 	

File src/tbrugz/queryon/RequestSpec.java

View file
  • Ignore whitespace
 		if(offsetStr!=null) { offset = Integer.parseInt(offsetStr); }
 		else { offset = 0; }
 
-		String lengthStr = req.getParameter("limit");
-		if(lengthStr!=null) { limit = Integer.parseInt(lengthStr); }
+		Long maxLimit = Utils.getPropLong(prop, QueryOn.PROP_MAX_LIMIT);
+		String limitStr = req.getParameter("limit");
+		if(limitStr!=null) { 
+			int propLimit = Integer.parseInt(limitStr);
+			if(maxLimit!=null && propLimit>maxLimit) {
+				limit = (int)(long) maxLimit;
+			}
+			else {
+				limit = propLimit;
+			}
+		}
 		else {
-			limit = (int)(long) Utils.getPropLong(prop, QueryOn.PROP_DEFAULT_LIMIT, 1000l);
+			Long defaultLimit = Utils.getPropLong(prop, QueryOn.PROP_DEFAULT_LIMIT);
+			if(defaultLimit!=null) {
+				limit = (int)(long) defaultLimit;
+			}
+			else if(maxLimit!=null) {
+				limit = (int)(long) maxLimit;
+			}
+			else {
+				//limit = (int)(long) Utils.getPropLong(prop, QueryOn.PROP_DEFAULT_LIMIT, 1000l);
+				limit = 0;
+			}
 		}
 		
 		String fields = req.getParameter("fields");