Hi all,
I'm looking for a way to reset the REST cache in a custom application with the following code in java, but it seems that it needs a cookie stored for the browser and the result after executing is the login page again.. if anyone knows or has done something similar please any suggestions are welcome.
public Boolean cleanRestCache(String adminRestCacheUrl, String clearRestCacheUrl, String adminUserName, String adminPassword)
{
Boolean bOK = false;
try
{
// Construct data
String data = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(adminUserName, "UTF-8");
data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(adminPassword, "UTF-8");
data += "&" + URLEncoder.encode("redirect", "UTF-8") + "=" + URLEncoder.encode(clearRestCacheUrl, "UTF-8");
/*String data = "username=arcgismanager&password=arcgismanager&redirect=http%3A%2F%2F08cpc0301%3A8399%2Farcgis%2Frest%2Fadmin%2Fcache%2Fclear";*/
// Send data
URL url = new URL(adminRestCacheUrl); URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String answer = "";
while ((line = rd.readLine()) != null)
{
answer += line;
}
wr.close();
rd.close();
System.out.println(answer);
bOK = true;
}
catch(Exception ex)
{
System.out.println("Problems cleanning API Rest Cache");
ex.printStackTrace();
bOK = false;
}
return bOK;
}
TIA