return collection;
}
public Resource get(String path) throws RegistryException {
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse;
String encodedPath;
// If the request is to fetch all comments for a given path, then encode ":" as well to
// avoid confusion with versioned paths.
if (path.endsWith(RegistryConstants.URL_SEPARATOR + APPConstants.PARAMETER_COMMENTS)) {
encodedPath = encodeURL(path);
if (encodedPath.indexOf(";version:") > -1) {
int index = encodedPath.lastIndexOf(";version:");
encodedPath = encodedPath.substring(0, index).replace(":", "%3A") +
encodedPath.substring(index);
} else {
encodedPath = encodedPath.replace(":", "%3A");
}
} else {
encodedPath = encodeURL(path);
}
if (!cache.isResourceCached(path)) {
clientResponse =
abderaClient.get(baseURI + "/atom" + encodedPath, getAuthorization());
} else {
clientResponse =
abderaClient.get(baseURI + "/atom" + encodedPath,
getAuthorizationForCaching(path));
}
if (clientResponse.getType() == Response.ResponseType.CLIENT_ERROR ||
clientResponse.getType() == Response.ResponseType.SERVER_ERROR) {
if (clientResponse.getStatus() == 404) {
abderaClient.teardown();
throw new ResourceNotFoundException(path);
}
abderaClient.teardown();
throw new RegistryException(clientResponse.getStatusText());
}
if (clientResponse.getStatus() == 304) {
abderaClient.teardown();
/*do caching here */
log.debug(
"Cached resource returned since no modification has been done on the resource");
return cache.getCachedResource(path);
}
String eTag = clientResponse.getHeader("ETag");
Element introspection = clientResponse.getDocument().getRoot();
ResourceImpl resource;
if (introspection instanceof Feed) {
// This is a collection
Feed feed = (Feed) introspection;
String state = feed.getSimpleExtension(new QName(APPConstants.NAMESPACE, "state"));