FilesObjectMetaData metaData;
if (this.isLoggedin())
{
if (isValidContainerName(container) && isValidObjectName(objName))
{
HttpHead method = new HttpHead(getStorageURL()+"/"+sanitizeForURI(container)+"/"+sanitizeForURI(objName));
try {
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();
login();
method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
method.setHeader(FilesConstants.X_AUTH_TOKEN, authToken);
response = new FilesResponse(client.execute(method));
}
if (response.getStatusCode() == HttpStatus.SC_NO_CONTENT ||
response.getStatusCode() == HttpStatus.SC_OK)
{
logger.debug ("Object metadata retreived : "+objName);
String mimeType = response.getContentType();
String lastModified = response.getLastModified();
String eTag = response.getETag();
String contentLength = response.getContentLength();
metaData = new FilesObjectMetaData(mimeType, contentLength, eTag, lastModified);
Header [] headers = response.getResponseHeaders();
HashMap<String,String> headerMap = new HashMap<String,String>();
for (Header h: headers)
{
if ( h.getName().startsWith(FilesConstants.X_OBJECT_META) )
{
headerMap.put(h.getName().substring(FilesConstants.X_OBJECT_META.length()), unencodeURI(h.getValue()));
}
}
if (headerMap.size() > 0)
metaData.setMetaData(headerMap);
return metaData;
}
else if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND)
{
throw new FilesNotFoundException("Container: " + container + " did not have object " + objName,
response.getResponseHeaders(), response.getStatusLine());
}
else {
throw new FilesException("Unexpected Return Code from Server",
response.getResponseHeaders(), response.getStatusLine());
}
}
finally {
method.abort();
}
}
else
{
if (!isValidObjectName(objName)) {