// Add tag
if (tag != null) {
headers.put("x-emc-tags", unicodeEnabled ? encodeUtf8(tag) : tag);
} else {
throw new EsuException("Tag cannot be null");
}
// Process options
if( options != null ) {
if( options.isIncludeMetadata() ) {
headers.put( "x-emc-include-meta", "1" );
if( options.getSystemMetadata() != null ) {
headers.put( "x-emc-system-tags",
join( options.getSystemMetadata(), "," ) );
}
if( options.getUserMetadata() != null ) {
headers.put( "x-emc-user-tags",
join( options.getUserMetadata(), "," ) );
}
}
if( options.getLimit() > 0 ) {
headers.put( "x-emc-limit", ""+options.getLimit() );
}
if( options.getToken() != null ) {
headers.put( "x-emc-token", options.getToken() );
}
}
// Add date
headers.put("Date", getDateHeader());
// Sign request
signRequest("GET", resource, null, headers);
configureRequest( con, "GET", headers );
con.connect();
// Check response
try {
if (con.getResponseCode() > 299) {
handleError(con);
}
} catch( EsuException e ) {
if( e.getAtmosCode() == 1003 ) {
return Collections.emptyList();
}
throw e;
}
// Get object id list from response
byte[] response = readResponse(con, null);
l4j.debug("Response: " + new String(response, "UTF-8"));
con.disconnect();
if( options != null ) {
// Update the token for listing more results. If there are no
// more results, the header will not be set and the token will
// be cleared in the options object.
options.setToken( con.getHeaderField("x-emc-token") );
} else {
if( con.getHeaderField( "x-emc-token" ) != null ) {
l4j.warn( "Result set truncated. Use ListOptions to " +
"retrieve token for next page of results." );
}
}
return parseObjectListWithMetadata(response);
} catch (MalformedURLException e) {
throw new EsuException("Invalid URL", e);
} catch (IOException e) {
throw new EsuException("Error connecting to server", e);
} catch (GeneralSecurityException e) {
throw new EsuException("Error computing request signature", e);
} catch (URISyntaxException e) {
throw new EsuException("Invalid URL", e);
}
}