當前位置: 首頁>>代碼示例>>Java>>正文


Java BaseContentEntry.addLink方法代碼示例

本文整理匯總了Java中com.google.gdata.data.sites.BaseContentEntry.addLink方法的典型用法代碼示例。如果您正苦於以下問題:Java BaseContentEntry.addLink方法的具體用法?Java BaseContentEntry.addLink怎麽用?Java BaseContentEntry.addLink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gdata.data.sites.BaseContentEntry的用法示例。


在下文中一共展示了BaseContentEntry.addLink方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUpdateById

import com.google.gdata.data.sites.BaseContentEntry; //導入方法依賴的package包/類
@Test
public void testUpdateById() throws IOException, ServiceException {
  final String id = feedUrl.toExternalForm() + "/entry";
  final BaseContentEntry<?> newEntry = new WebPageEntry();
  newEntry.setId(id);
  final BaseContentEntry<?> oldEntry = new WebPageEntry();
  oldEntry.setId(id);
  oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
  final BaseContentEntry<?> returnedEntry = new WebPageEntry();
  returnedEntry.setId(id);
  
  context.checking(new Expectations() {{
    oneOf (sitesService).getEntry(new URL(id), WebPageEntry.class);
      will(returnValue(oldEntry));
    oneOf (entryUpdater).updateEntry(oldEntry, newEntry, sitesService);
      will(returnValue(returnedEntry));
  }});
  
  assertEquals(returnedEntry, entryUploader.uploadEntry(newEntry, 
      new LinkedList<BasePageEntry<?>>(), feedUrl, sitesService));
}
 
開發者ID:sih4sing5hong5,項目名稱:google-sites-liberation,代碼行數:22,代碼來源:EntryUploaderImplTest.java

示例2: setParent

import com.google.gdata.data.sites.BaseContentEntry; //導入方法依賴的package包/類
/**
 * Sets all parent-related fields in the given entry for the given parent. 
 */
public static void setParent(BaseContentEntry<?> entry, 
    BasePageEntry<?> parent) {
  entry.addLink(SitesLink.Rel.PARENT, ILink.Type.ATOM, parent.getId());
  if (getType(entry) == COMMENT) {
    InReplyTo inReplyTo = new InReplyTo();
    inReplyTo.setHref(
        parent.getLink(ILink.Rel.ALTERNATE, "text/html").getHref()); 
    inReplyTo.setRef(parent.getId());
    // TODO(gk5885): remove extra cast for
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
    ((CommentEntry) (BaseContentEntry) entry).setInReplyTo(inReplyTo);
  } else if (getType(entry) == LIST_ITEM) {
    if (getType(parent) != LIST_PAGE) {
      throw new IllegalStateException("List items can only be descendents of " 
          + "list pages!");
    }
    // TODO(gk5885): remove extra casts for
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
    ListItemEntry listItem = (ListItemEntry) (BaseContentEntry) entry;
    ListPageEntry listPage = (ListPageEntry) (BasePageEntry) parent;
    Data data = listPage.getData();
    Map<String, String> names = Maps.newHashMap();
    for (Column column : data.getColumns()) {
      names.put(column.getIndex(), column.getName());
    }
    for (Field field : listItem.getFields()) {
      String name = names.get(field.getIndex());
      field.setName(name);
    }
  }
}
 
開發者ID:sih4sing5hong5,項目名稱:google-sites-liberation,代碼行數:35,代碼來源:EntryUtils.java

示例3: setParentId

import com.google.gdata.data.sites.BaseContentEntry; //導入方法依賴的package包/類
/**
 * Sets the parent link of the given entry to the given id
 */
public static void setParentId(BaseContentEntry<?> entry, String id) {
  entry.addLink(SitesLink.Rel.PARENT, ILink.Type.ATOM, id);
}
 
開發者ID:sih4sing5hong5,項目名稱:google-sites-liberation,代碼行數:7,代碼來源:EntryUtils.java

示例4: testOnePageWithAttachment

import com.google.gdata.data.sites.BaseContentEntry; //導入方法依賴的package包/類
@Test
public void testOnePageWithAttachment() throws IOException {
  final BasePageEntry<?> page = new FileCabinetPageEntry();
  page.setId("1");
  page.setTitle(new PlainTextConstruct("Page 1"));
  page.setPageName(new PageName("Page-1"));
  XmlBlob blob = new XmlBlob();
  blob.setBlob("content");
  page.setContent(new XhtmlTextConstruct(blob));
  final BaseContentEntry<?> attachment = new AttachmentEntry();
  attachment.setId("2");
  attachment.setTitle(new PlainTextConstruct("attach this.wow"));
  attachment.addLink(SitesLink.Rel.PARENT, ILink.Type.ATOM, "1");
  entries.add(page);
  entries.add(attachment);
  final Appendable out = context.mock(Appendable.class);
  
  context.checking(new Expectations() {{
    allowing (entryStoreFactory).newEntryStore(); 
        will(returnValue(entryStore));
    allowing (feedProvider).getEntries(feedUrl, sitesService);
        will(returnValue(entries));
    allowing (entryStore).getEntry("1"); will(returnValue(page));
    allowing (entryStore).getParent("1"); will(returnValue(null));
    allowing (entryStore).getEntry("2"); will(returnValue(attachment));
    allowing (entryStore).getParent("2"); will(returnValue(page));
    allowing (progressListener).setStatus(with(any(String.class)));
    allowing (progressListener).setProgress(with(any(Double.class)));
    oneOf (entryStore).addEntry(page);
    oneOf (entryStore).addEntry(attachment);
    oneOf (appendableFactory).getAppendable(
        new File("path/Page-1/index.html"));
        will(returnValue(out));
    oneOf (linkConverter).convertLinks(page, entryStore, 
        new URL("https://host/a/domain/webspace"), false);
    oneOf (pageExporter).exportPage(page, entryStore, out, false);
  }});
  
  export(false);
  assertTrue(downloaded.get(attachment).equals(
      new File("path/Page-1/attach this.wow")));
}
 
開發者ID:sih4sing5hong5,項目名稱:google-sites-liberation,代碼行數:43,代碼來源:SiteExporterImplTest.java


注:本文中的com.google.gdata.data.sites.BaseContentEntry.addLink方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。