syncloud.google.docs.model.Feed Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of syncloud-google-docs Show documentation
Show all versions of syncloud-google-docs Show documentation
Google Docs Syncloud Starage Adapter
The newest version!
package syncloud.google.docs.model;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.xml.atom.AtomContent;
import com.google.api.client.util.Key;
import syncloud.core.log.Logger;
import syncloud.google.docs.DocumentIterator;
import syncloud.google.docs.RequestExecutor;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Feed {
private static Logger logger = Logger.getLogger(Feed.class);
private static RequestExecutor requestExecutor = new RequestExecutor();
@Key("openSearch:totalResults")
public int totalResults;
@Key("link")
public List links;
@Key("entry")
public List docs = new ArrayList();
public Link getLink(LinkRel linkRel) {
return Link.find(links, linkRel);
}
public static Feed first100Entries(HttpRequestFactory requestFactory, DocsUrl url) throws IOException {
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse response = requestExecutor.executeNonSensitive(request);
return response.parseAs(Feed.class);
}
public static Iterable allEntries(final HttpRequestFactory requestFactory, final DocsUrl url) throws IOException {
return new Iterable() {
@Override
public Iterator iterator() {
return new DocumentIterator(requestFactory, url);
}
};
}
public static Entry executeGet(HttpRequestFactory requestFactory, DocsUrl url, Class feedClass) throws IOException {
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse response = requestExecutor.executeNonSensitive(request);
return response.parseAs(feedClass);
}
public static InputStream executeGetContent(HttpRequestFactory requestFactory, DocsUrl url) throws IOException {
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse response = requestExecutor.executeNonSensitive(request);
return response.getContent();
}
public static DocumentListEntry executePost(HttpRequestFactory requestFactory, DocsUrl url, AtomContent content) throws IOException {
HttpRequest request = requestFactory.buildPostRequest(url, content);
HttpResponse response = requestExecutor.executeSensitive(request);
return response.parseAs(DocumentListEntry.class);
}
public static void executeDelete(HttpRequestFactory requestFactory, DocsUrl url, String etag, boolean matchAll) throws IOException {
HttpRequest request = requestFactory.buildDeleteRequest(url);
if (matchAll)
request.getHeaders().setIfMatch("*");
else
request.getHeaders().setIfMatch(etag);
HttpResponse response = requestExecutor.executeNonSensitive(request);
response.ignore();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy