filesInputStream = new URL(autoUpdaterFilesQuery).openStream();
versionsInputStream = new URL(autoUpdaterVersionsQuery).openStream();
BufferedReader filesReader = new BufferedReader(new InputStreamReader(filesInputStream, Charset.forName("UTF-8")));
BufferedReader versionsReader = new BufferedReader(new InputStreamReader(versionsInputStream, Charset.forName("UTF-8")));
String filesText = UtilMethods.getStringFromReader(filesReader);
JSONObject filesJSON = new JSONObject(filesText);
String versionsText = UtilMethods.getStringFromReader(versionsReader);
JSONObject versionsJSON = new JSONObject(versionsText);
JSONArray majorArr = versionsJSON.getJSONArray("contentlets");
JSONArray minorArr = filesJSON.getJSONArray("contentlets");
if(minorArr.size()>0){
String versionsFilesQuery = "http://dotcms.com/JSONContent/?type=json&q="+
URLEncoder.encode("+Parent_Versions-Child_Files:"+minorArr.getJSONObject(0).getString("identifier")+" +deleted:false +live:true","UTF-8")+
"&limit=1&orderBy=AutoupdaterFiles.releasedDate%20desc";
versionsFilesQueryIs = new URL(versionsFilesQuery).openStream();
BufferedReader versionsFilesReader = new BufferedReader(new InputStreamReader(versionsFilesQueryIs, Charset.forName("UTF-8")));
String versionsFilesText = UtilMethods.getStringFromReader(versionsFilesReader);
JSONObject versionsFilesJSON = new JSONObject(versionsFilesText);
JSONArray versionsFilesArr = versionsFilesJSON.getJSONArray("contentlets");
if(versionsFilesArr.size()>0){
if(versionsFilesQueryIs!=null){
versionsFilesQueryIs.close();
}
versionsFilesQuery = "http://dotcms.com/JSONContent/?type=json&q="+
URLEncoder.encode("+Parent_Versions-Child_Files:"+versionsFilesArr.getJSONObject(0).getString("identifier")+" -AutoupdaterFiles.minor:autoupdater_* +AutoupdaterFiles.released:true +deleted:false +working:true", "UTF-8")+
"&limit=1&orderBy=AutoupdaterFiles.releasedDate%20desc";
versionsFilesQueryIs = new URL(versionsFilesQuery).openStream();
versionsFilesReader = new BufferedReader(new InputStreamReader(versionsFilesQueryIs, Charset.forName("UTF-8")));
versionsFilesText = UtilMethods.getStringFromReader(versionsFilesReader);
versionsFilesJSON = new JSONObject(versionsFilesText);
versionsFilesArr = versionsFilesJSON.getJSONArray("contentlets");
minor = versionsFilesArr.getJSONObject(0).getString("minor");
}
}
if(majorArr.size()>0){
for(int i=0;i<majorArr.size();i++){
if(versionsFilesQueryIs!=null){
versionsFilesQueryIs.close();
}
major = majorArr.getJSONObject(i).getString("major");
String majorIdentifier = majorArr.getJSONObject(i).getString("identifier");
String versionsFilesQuery = "http://dotcms.com/JSONContent/?type=json&q="+
URLEncoder.encode("+Parent_Versions-Child_Files:"+majorIdentifier+" +AutoupdaterFiles.released:true -AutoupdaterFiles.minor:autoupdater_* +deleted:false +live:true","UTF-8")+
"&limit=1&orderBy=AutoupdaterFiles.releasedDate%20desc";
versionsFilesQueryIs = new URL(versionsFilesQuery).openStream();
BufferedReader versionsFilesReader = new BufferedReader(new InputStreamReader(versionsFilesQueryIs, Charset.forName("UTF-8")));
String versionsFilesText = UtilMethods.getStringFromReader(versionsFilesReader);
JSONObject versionsFilesJSON = new JSONObject(versionsFilesText);
JSONArray versionsFilesArr = versionsFilesJSON.getJSONArray("contentlets");
if(versionsFilesArr.size()>0){
break;
}else{
major = "";
}