本文整理汇总了Java中com.google.gdata.client.sites.SitesService类的典型用法代码示例。如果您正苦于以下问题:Java SitesService类的具体用法?Java SitesService怎么用?Java SitesService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SitesService类属于com.google.gdata.client.sites包,在下文中一共展示了SitesService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importSite
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Override
public void importSite(String host, @Nullable String domain, String webspace,
boolean importRevisions, SitesService sitesService, File rootDirectory,
ProgressListener progressListener) {
URL feedUrl = UrlUtils.getFeedUrl(host, domain, webspace);
URL siteUrl = UrlUtils.getSiteUrl(host, domain, webspace);
progressListener.setStatus("Scanning directory.");
int numPages = getNumPages(rootDirectory);
List<BasePageEntry<?>> ancestors = Lists.newLinkedList();
for (File subDirectory : rootDirectory.listFiles()) {
if (subDirectory.isDirectory()
&& !subDirectory.getName().startsWith("_")) {
importPage(subDirectory, importRevisions, ancestors, feedUrl, siteUrl,
sitesService, progressListener, numPages);
}
}
progressListener.setProgress(1.0);
progressListener.setStatus("Import complete.");
}
示例2: importPage
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
private void importPage(File pageDirectory, boolean importRevisions,
List<BasePageEntry<?>> ancestors, URL feedUrl, URL siteUrl,
SitesService sitesService, ProgressListener progressListener, int numPages) {
File file = new File(pageDirectory, "index.html");
if (file.isFile()) {
progressListener.setStatus("Importing page: " + pageDirectory.getName());
BasePageEntry<?> page = pageImporter.importPage(pageDirectory,
importRevisions, ancestors, feedUrl, siteUrl, sitesService);
progressListener.setProgress(progressListener.getProgress() + 1.0/numPages);
if (page != null) {
List<BasePageEntry<?>> newAncestors = Lists.newLinkedList(ancestors);
newAncestors.add(page);
for (File subDirectory : pageDirectory.listFiles()) {
if (subDirectory.isDirectory()
&& !subDirectory.getName().startsWith("_")) {
importPage(subDirectory, importRevisions, newAncestors, feedUrl,
siteUrl, sitesService, progressListener, numPages);
}
}
}
}
}
示例3: getEntries
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<BaseContentEntry<?>> getEntries(Query query,
SitesService sitesService) throws IOException, ServiceException {
checkNotNull(query, "query");
checkNotNull(sitesService, "sitesService");
List<BaseContentEntry> baseEntries =
sitesService.getFeed(query, ContentFeed.class).getEntries();
List<BaseContentEntry<?>> adaptedEntries = Lists.newLinkedList();
for (BaseContentEntry entry : baseEntries) {
BaseContentEntry<?> adaptedEntry =
(BaseContentEntry<?>) entry.getAdaptedEntry();
if (adaptedEntry == null) {
adaptedEntries.add(entry);
} else {
adaptedEntries.add(adaptedEntry);
}
}
return adaptedEntries;
}
示例4: getEntries
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
public List<BaseContentEntry<?>> getEntries(Query query, SitesService sitesService)
throws ServiceException, IOException {
int fromIndex = query.getStartIndex() - 1;
int max = Math.min(maxResultsPerRequest, query.getMaxResults());
int toIndex = Math.min(fromIndex + max, entries.size());
if (fromIndex > toIndex) {
return new ArrayList<BaseContentEntry<?>>();
}
List<BaseContentEntry<?>> response = entries.subList(fromIndex, toIndex);
if (response.contains(serviceExceptionEntry)) {
throw new ServiceException("Error");
}
if (response.contains(ioExceptionEntry)) {
throw new IOException("Error");
}
return response;
}
示例5: before
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Before
public void before() throws MalformedURLException {
context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
linkConverter = context.mock(AbsoluteLinkConverter.class);
appendableFactory = context.mock(AppendableFactory.class);
attachmentDownloader = new FakeDownloader();
entryStore = context.mock(EntryStore.class);
entryStoreFactory = context.mock(EntryStoreFactory.class);
feedProvider = context.mock(FeedProvider.class);
pageExporter = context.mock(PageExporter.class);
progressListener = context.mock(ProgressListener.class);
revisionsExporter = context.mock(RevisionsExporter.class);
siteExporter = new SiteExporterImpl(linkConverter, appendableFactory,
attachmentDownloader, entryStoreFactory, feedProvider, pageExporter,
revisionsExporter);
sitesService = new SitesService("");
entries = Sets.newHashSet();
feedUrl = new URL("https://host/feeds/content/domain/webspace");
}
示例6: importPage
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Override
public BasePageEntry<?> importPage(
BasePageEntry<?> page,
List<BasePageEntry<?>> ancestors,
URL feedUrl,
URL siteUrl,
SitesService sitesService) {
BasePageEntry<?> returnedEntry;
if (ancestors.isEmpty()) {
returnedEntry = (BasePageEntry<?>) entryUploader.uploadEntry(
page, ancestors, feedUrl, sitesService);
} else {
BasePageEntry<?> parent = ancestors.get(ancestors.size() - 1);
returnedEntry = (BasePageEntry<?>) entryUpdater.updateEntry(
parent, page, sitesService);
EntryUtils.setParent(returnedEntry, parent);
}
ancestors.add(returnedEntry);
return returnedEntry;
}
示例7: DumpWriterImpl
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
DumpWriterImpl(
ProgressListener progressListener,
WikiConfigurationInterface configuration,
File imagesDirectory,
PageImporter pageImporter,
URL feedUrl,
URL siteUrl,
SitesService sitesService) {
this.progressListener = progressListener;
this.configuration = configuration;
this.imagesDirectory = imagesDirectory;
this.pageImporter = pageImporter;
this.feedUrl = feedUrl;
this.siteUrl = siteUrl;
this.sitesService = sitesService;
compiler = new Compiler(configuration);
}
示例8: SitesHelper
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
/**
* Constructor
*
* @param applicationName The name of the application.
* @param domain The Site's Google Apps domain or "site".
* @param siteName The webspace name of the Site.
* @param logging Whether to enable HTTP requests to stdout
*/
public SitesHelper(String applicationName, String domain, String siteName,
boolean logging) {
if (logging) {
turnOnLogging(false);
}
this.domain = domain;
this.siteName = siteName;
this.service = new SitesService(applicationName);
registerMediaTypes();
}
示例9: importRevisions
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Override
public BasePageEntry<?> importRevisions(File directory,
List<BasePageEntry<?>> ancestors, URL feedUrl, URL siteUrl,
SitesService sitesService) {
File revisionsDirectory = new File(directory, "_revisions");
int num = 1;
BasePageEntry<?> revision = null;
while (new File(revisionsDirectory, num + ".html").isFile()) {
BasePageEntry<?> page = getPageEntry(new File(revisionsDirectory,
num + ".html"));
if (page != null) {
page.setPageName(new PageName(directory.getName()));
if (!ancestors.isEmpty()) {
EntryUtils.setParent(page, ancestors.get(ancestors.size() - 1));
}
linkConverter.convertLinks(page, ancestors, siteUrl, true);
if (revision == null) {
revision = (BasePageEntry<?>) entryUploader
.uploadEntry(page, ancestors, feedUrl, sitesService);
} else {
revision = (BasePageEntry<?>) entryUpdater
.updateEntry(revision, page, sitesService);
}
}
num++;
}
return revision;
}
示例10: ContinuousContentFeed
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
/**
* Creates a new instance of {@code ContinuousContentFeed} for the given
* entry provider, feed URL, and number of entries to request per query.
*
* <p>This {@code ContinuousContentFeed} will contain all of the valid entries
* in the feed at {@code feedUrl}.</p>
*/
ContinuousContentFeed(URL feedUrl, EntryProvider entryProvider,
SitesService sitesService, int resultsPerRequest) {
this.entryProvider = checkNotNull(entryProvider);
this.feedUrl = checkNotNull(feedUrl);
this.sitesService = checkNotNull(sitesService);
checkArgument(resultsPerRequest > 0);
this.resultsPerRequest = resultsPerRequest;
}
示例11: downloadAttachment
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
private void downloadAttachment(AttachmentEntry attachment,
File rootDirectory, EntryStore entryStore, SitesService sitesService) {
BasePageEntry<?> parent = entryStore.getParent(attachment.getId());
if (parent != null) {
File relativePath = getPath(parent, entryStore);
if (relativePath != null) {
File folder = new File(rootDirectory, relativePath.getPath());
folder.mkdirs();
File file = new File(folder, attachment.getTitle().getPlainText());
attachmentDownloader.download(attachment, file, sitesService);
}
}
}
示例12: before
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Before
public void before() throws MalformedURLException {
context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
sitesService = context.mock(SitesService.class);
entryInserter = context.mock(EntryInserter.class);
entryProvider = context.mock(EntryProvider.class);
entryUpdater = context.mock(EntryUpdater.class);
feedUrl = new URL("http://sites.google.com/feeds/content/site/test");
entryUploader = new EntryUploaderImpl(entryInserter, entryProvider,
entryUpdater);
}
示例13: importAttachment
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Override
public BaseContentEntry<?> importAttachment(
BaseContentEntry<?> attachment,
List<BasePageEntry<?>> ancestors,
URL feedUrl,
SitesService sitesService) {
if (!ancestors.isEmpty()) {
BasePageEntry<?> parent = ancestors.get(ancestors.size() - 1);
EntryUtils.setParent(attachment, parent);
}
return entryUploader.uploadEntry(
attachment, ancestors, feedUrl, sitesService);
}
示例14: uploadEntry
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Override
public BaseContentEntry<?> uploadEntry(BaseContentEntry<?> entry,
List<BasePageEntry<?>> ancestors, URL feedUrl, SitesService sitesService) {
checkNotNull(entry);
checkNotNull(ancestors);
checkNotNull(feedUrl);
checkNotNull(sitesService);
BaseContentEntry<?> returnedEntry = null;
if (entry.getId() != null) {
if (entry.getId().startsWith(feedUrl.toExternalForm() + "/")) {
returnedEntry = getEntryById(entry, sitesService);
} else {
entry.setId(null);
}
}
if (returnedEntry == null) {
if (isPage(entry) ||
getType(entry) == ATTACHMENT ||
getType(entry) == WEB_ATTACHMENT) {
returnedEntry = getEntryByPath(entry, ancestors, feedUrl, sitesService);
} else if (getType(entry) == COMMENT) {
// TODO(gk5885): remove extra cast for
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
if (commentExists((CommentEntry) (BaseContentEntry) entry, feedUrl, sitesService)) {
return entry;
}
} else if (getType(entry) == LIST_ITEM) {
// TODO(gk5885): remove extra cast for
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
if (listItemExists((ListItemEntry) (BaseContentEntry) entry, feedUrl, sitesService)) {
return entry;
}
}
}
if (returnedEntry == null) {
return entryInserter.insertEntry(entry, feedUrl, sitesService);
} else {
return entryUpdater.updateEntry(returnedEntry, entry,
sitesService);
}
}
示例15: importPage
import com.google.gdata.client.sites.SitesService; //导入依赖的package包/类
@Override
public BasePageEntry<?> importPage(File directory, boolean importRevisions,
List<BasePageEntry<?>> ancestors, URL feedUrl, URL siteUrl,
SitesService sitesService) {
checkNotNull(directory);
File file = new File(directory, "index.html");
if (!file.isFile()) {
LOGGER.log(Level.WARNING, "No valid file in directory: " + directory);
return null;
}
List<BaseContentEntry<?>> entries = pageParser.parsePage(file);
BasePageEntry<?> page = getFirstPageEntry(entries);
if (page == null) {
LOGGER.log(Level.WARNING, "No valid page entry!");
return null;
}
page.setPageName(new PageName(directory.getName()));
linkConverter.convertLinks(page, ancestors, siteUrl, false);
if (!ancestors.isEmpty()) {
EntryUtils.setParent(page, ancestors.get(ancestors.size() - 1));
}
BasePageEntry<?> returnedEntry = null;
if (importRevisions && new File(directory, "_revisions").isDirectory()) {
returnedEntry = revisionsImporter.importRevisions(
directory, ancestors, feedUrl, siteUrl, sitesService);
}
if (returnedEntry == null) {
returnedEntry = (BasePageEntry<?>) entryUploader.uploadEntry(
page, ancestors, feedUrl, sitesService);
} else {
returnedEntry = (BasePageEntry<?>) entryUpdater.updateEntry(
returnedEntry, page, sitesService);
}
List<BasePageEntry<?>> newAncestors = Lists.newLinkedList(ancestors);
newAncestors.add(returnedEntry);
for (BaseContentEntry<?> child : getNonPageEntries(entries)) {
if (getType(child) == ATTACHMENT) {
if (child.getContent() != null) {
String src = ((OutOfLineContent) child.getContent()).getUri();
File attachmentFile = new File(directory, src);
MediaSource mediaSource = new MediaFileSource(attachmentFile,
"application/octet-stream");
child.setContent((Content) null);
child.setMediaSource(mediaSource);
} else {
System.out.println(child.getTitle().getPlainText());
}
}
EntryUtils.setParent(child, returnedEntry);
entryUploader.uploadEntry(child, newAncestors, feedUrl, sitesService);
}
return returnedEntry;
}