public FilesCDNContainer getCDNContainerInfo(String container) throws IOException, FilesNotFoundException, HttpException, FilesException
{
if (isLoggedin()) {
if (isValidContainerName(container))
{
HttpHead method = null;
try {
method= new HttpHead(getCdnManagementURL()+"/"+sanitizeForURI(container));
method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
method.setHeader(FilesConstants.X_AUTH_TOKEN, authToken);
FilesResponse response = new FilesResponse(client.execute(method));
if (response.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
method.abort();
if(login()) {
method= new HttpHead(getCdnManagementURL()+"/"+sanitizeForURI(container));
method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
method.setHeader(FilesConstants.X_AUTH_TOKEN, authToken);
response = new FilesResponse(client.execute(method));
}
else {
throw new FilesAuthorizationException("Re-login failed", response.getResponseHeaders(), response.getStatusLine());
}
}
if (response.getStatusCode() == HttpStatus.SC_NO_CONTENT)
{
FilesCDNContainer result = new FilesCDNContainer(response.getCdnUrl());
result.setName(container);
result.setSSLURL(response.getCdnSslUrl());
result.setStreamingURL(response.getCdnStreamingUrl());
for (Header hdr : response.getResponseHeaders()) {
String name = hdr.getName().toLowerCase();
if ("x-cdn-enabled".equals(name)) {
result.setEnabled(Boolean.valueOf(hdr.getValue()));
}
else if ("x-log-retention".equals(name)) {
result.setRetainLogs(Boolean.valueOf(hdr.getValue()));
}
else if ("x-ttl".equals(name)) {
result.setTtl(Integer.parseInt(hdr.getValue()));
}
else if ("x-referrer-acl".equals(name)) {
result.setReferrerACL(hdr.getValue());
}
else if ("x-user-agent-acl".equals(name)) {
result.setUserAgentACL(hdr.getValue());
}
}
return result;
}
else if (response.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
logger.warn("Unauthorized access");
throw new FilesAuthorizationException("User not Authorized!",response.getResponseHeaders(), response.getStatusLine());
}
else if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
throw new FilesNotFoundException("Container is not CDN enabled",response.getResponseHeaders(), response.getStatusLine());
}
else {
throw new FilesException("Unexpected result from server: ", response.getResponseHeaders(), response.getStatusLine());
}
}
finally {
if (method != null) {
method.abort();
}
}
}
else
{