• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Entry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.resteasy.plugins.providers.atom.Entry的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Entry类属于org.jboss.resteasy.plugins.providers.atom包,在下文中一共展示了Entry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: upload

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Override
public BaseArtifactType upload(ArtifactType artifactType, String filePath) throws Exception {
    String atomUrl = getUrl(artifactType);
    Builder clientRequest = getClientRequest(atomUrl);
    
    InputStream is = this.getClass().getResourceAsStream(filePath);
    String text = convertStreamToString(is);
    is.close();

    String fileName = filePath.substring( filePath.lastIndexOf('/') + 1, filePath.length() );
    clientRequest.header("Slug", fileName);

    Response response = clientRequest.post(Entity.entity(text, artifactType.getMimeType()));
    verifyResponse(response, 200);
    Entry entry = response.readEntity(Entry.class);
    verifyEntry(entry);
    return SrampAtomUtils.unwrapSrampArtifact(artifactType, entry);
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:19,代码来源:AtomBinding.java


示例2: unwrapSrampArtifact

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
/**
 * Unwraps a specific {@link BaseArtifactType} from the Atom {@link Entry} containing it.  This
 * method grabs the {@link Artifact} child from the Atom {@link Entry} and then unwraps the
 * {@link BaseArtifactType} from that.
 * @param artifactType the s-ramp artifact type
 * @param entry an Atom {@link Entry}
 * @return a {@link BaseArtifactType}
 */
public static BaseArtifactType unwrapSrampArtifact(ArtifactType artifactType, Entry entry) {
	try {
		Artifact artifact = getArtifactWrapper(entry);
		if (artifact != null) {
		    // Don't trust the extended types - there is some ambiguity there.
		    if (artifactType.isExtendedType()) {
		        artifactType = disambiguateExtendedType(entry, artifactType);
		    }
	        return unwrapSrampArtifact(artifactType, artifact);
		} else {
               return null;
		}
	} catch (JAXBException e) {
		// This is unlikely to happen.
		throw new RuntimeException(e);
	}
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:26,代码来源:SrampAtomUtils.java


示例3: wrapSrampArtifact

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
/**
 * Wraps the given s-ramp artifact in an Atom {@link Entry}.
 * @param artifact
 * @throws URISyntaxException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 * @throws NoSuchMethodException
 * @throws SecurityException
 */
public static Entry wrapSrampArtifact(BaseArtifactType artifact) throws URISyntaxException,
		IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException,
		NoSuchMethodException {
	// TODO leverage the artifact->entry visitors here
	Entry entry = new Entry();
	if (artifact.getUuid() != null)
		entry.setId(new URI(artifact.getUuid()));
	if (artifact.getLastModifiedTimestamp() != null)
		entry.setUpdated(artifact.getLastModifiedTimestamp().toGregorianCalendar().getTime());
	if (artifact.getName() != null)
		entry.setTitle(artifact.getName());
	if (artifact.getCreatedTimestamp() != null)
		entry.setPublished(artifact.getCreatedTimestamp().toGregorianCalendar().getTime());
	if (artifact.getCreatedBy() != null)
		entry.getAuthors().add(new Person(artifact.getCreatedBy()));
	if (artifact.getDescription() != null)
		entry.setSummary(artifact.getDescription());

	Artifact srampArty = new Artifact();
	Method method = Artifact.class.getMethod("set" + artifact.getClass().getSimpleName(), artifact.getClass()); //$NON-NLS-1$
	method.invoke(srampArty, artifact);
	entry.setAnyOtherJAXBObject(srampArty);

	return entry;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:36,代码来源:SrampAtomUtils.java


示例4: wrapStoredQuery

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
public static Entry wrapStoredQuery(StoredQuery storedQuery) throws Exception {
    Entry entry = new Entry();
    entry.setId(new URI("urn:uuid:" + storedQuery.getQueryName())); //$NON-NLS-1$
    entry.setTitle("Stored Query: " + storedQuery.getQueryName()); //$NON-NLS-1$
    
    // TODO: This is really stupid.  Going to push back on this w/ the TC.  The Atom binding spec should simply
    // reuse the core model's StoredQuery.
    StoredQueryData data = new StoredQueryData();
    data.setQueryName(storedQuery.getQueryName());
    data.setQueryString(storedQuery.getQueryExpression());
    data.getPropertyName().addAll(storedQuery.getPropertyName());
    entry.setAnyOtherJAXBObject(data);
    
    Content content = new Content();
    content.setText("Stored Query Entry"); //$NON-NLS-1$
    entry.setContent(content);
    
    Category category = new Category();
    category.setTerm("query"); //$NON-NLS-1$
    category.setLabel("Stored Query Entry"); //$NON-NLS-1$
    category.setScheme(SrampAtomConstants.X_S_RAMP_TYPE_URN);
    entry.getCategories().add(category);
    
    return entry;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:26,代码来源:SrampAtomUtils.java


示例5: disambiguateExtendedType

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
/**
 * Attempts to figure out whether we're dealing with an {@link ExtendedArtifactType} or a
 * {@link ExtendedDocument} by looking for clues in the {@link Entry}.
 * @param entry
 * @param artifactType
 */
protected static ArtifactType disambiguateExtendedType(Entry entry, ArtifactType artifactType) {
    String et = artifactType.getExtendedType();
    boolean convertToDocument = false;
    // Dis-ambiguate the extended types (or try to)
    if (entry.getContent() != null) {
        convertToDocument = true;
    } else {
        Element node = getArtifactWrapperNode(entry);
        if (node != null) {
            String type = getArtifactWrappedElementName(node);
            if (ExtendedDocument.class.getSimpleName().equals(type)) {
                convertToDocument = true;
            }
        }
    }

    if (convertToDocument) {
        artifactType = ArtifactType.valueOf(BaseArtifactEnum.EXTENDED_DOCUMENT);
        artifactType.setExtendedType(et);
    }
    return artifactType;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:29,代码来源:SrampAtomUtils.java


示例6: unwrap

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
/**
 * Unwrap some other jaxb object from its Atom Entry wrapper.
 * @param entry
 * @param clazz
 * @throws JAXBException
 */
@SuppressWarnings("unchecked")
public static <T> T unwrap(Entry entry, Class<T> clazz) throws JAXBException {
    setFinder(entry);
    if (entry.getAnyOtherElement() == null && entry.getAnyOther().isEmpty())
        return null;
	T object = entry.getAnyOtherJAXBObject(clazz);
	if (object == null) {
		for (Object anyOther : entry.getAnyOther()) {
			if (anyOther != null && anyOther.getClass().equals(clazz)) {
				object = (T) anyOther;
				break;
			}
		}
	}
	return object;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:23,代码来源:SrampAtomUtils.java


示例7: markEntryAsConsumed

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
public void markEntryAsConsumed(Entry entry) {
	synchronized (mutex) {
		currentlyConsuming.remove(entry);

		if (currentlyConsuming.isEmpty()) {
			if (entry.getUpdated().after(dateReachedDuringConsumption))
				dateReachedDuringConsumption = entry.getUpdated();
		} else if (oldestDateCurrentlyConsuming().after(dateReachedDuringConsumption)) {
			dateReachedDuringConsumption = oldestDateCurrentlyConsuming();
		}

		if (dateReachedDuringConsumption.after(entry.getUpdated()))
			lastConsumedEntries.removeAll(entry.getUpdated());
		else
			lastConsumedEntries.put(entry.getUpdated(), entry.getId());
	}
}
 
开发者ID:nordinh,项目名称:atom-feed,代码行数:18,代码来源:ConcurrentInMemoryAtomFeedBookmark.java


示例8: initialize

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
public static void initialize() {
	System.out.println("Initializing ActiviteitenFeed consumer");

	new AtomFeedConsumer(new ConcurrentInMemoryAtomFeedBookmark()) {

		@Override
		public String getURL() {
			return "http://localhost:8082/notifications/";
		}

		@Override
		public void consumeEntry(Entry entry) {
			System.out.println("consuming entry " + mapToActiviteitNotificatie(entry));
		}

		@Override
		public int getNoOfConcurrentConsumers() {
			return 5;
		};
	}.start();
}
 
开发者ID:nordinh,项目名称:atom-feed,代码行数:22,代码来源:NotificationsFeedConsumer.java


示例9: getFeed

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@GET
@Produces("application/atom+xml")
public Feed getFeed() throws URISyntaxException {
    Feed feed = new Feed();
    feed.setId(new URI("http://test.com/1"));
    feed.setTitle("WildFly Camel Test Feed");
    feed.setUpdated(new Date());

    Link link = new Link();
    link.setHref(new URI("http://localhost"));
    link.setRel("edit");
    feed.getLinks().add(link);
    feed.getAuthors().add(new Person("WildFly Camel"));

    Entry entry = new Entry();
    entry.setTitle("Hello Kermit");

    Content content = new Content();
    content.setType(MediaType.TEXT_HTML_TYPE);
    content.setText("Greeting Kermit");
    entry.setContent(content);

    feed.getEntries().add(entry);
    return feed;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:AtomFeed.java


示例10: get

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Override
public BaseArtifactType get(String uuid, ArtifactType type, int expectedResponse) throws Exception {
    String atomUrl = getUrl(type) + "/" + uuid;
    Entry entry = getArtifact(atomUrl, expectedResponse);
    if (entry != null) {
        return SrampAtomUtils.unwrapSrampArtifact(entry);
    } else {
        return null;
    }
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:11,代码来源:AtomBinding.java


示例11: queryFullArtifacts

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Override
public List<BaseArtifactType> queryFullArtifacts(String query) throws Exception {
    String path = "/s-ramp?query=" + query;
    List<BaseArtifactType> artifacts = new ArrayList<BaseArtifactType>();
    Feed feed = getFeed(path, 200);
    for (Entry entry : feed.getEntries()) {
        for (Link link : entry.getLinks()) {
            // TODO: Safe assumption for all impls?
            if ("self".equals(link.getRel())) {
                artifacts.add(SrampAtomUtils.unwrapSrampArtifact(getArtifact(link.getHref().toString(), 200)));
            }
        }
    }
    return artifacts;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:16,代码来源:AtomBinding.java


示例12: storedQuery

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Override
public List<BaseArtifactType> storedQuery(String queryName, String pagingParams, int expectedResponse) throws Exception {
    String path = "/s-ramp/query/" + queryName + "/results?" + pagingParams;
    List<BaseArtifactType> artifacts = new ArrayList<BaseArtifactType>();
    Feed feed = getFeed(path, expectedResponse);
    if (feed != null) {
        for (Entry entry : feed.getEntries()) {
            artifacts.add(SrampAtomUtils.unwrapSrampArtifact(entry));
        }
    }
    return artifacts;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:13,代码来源:AtomBinding.java


示例13: create

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Override
public BaseArtifactType create(BaseArtifactType artifact) throws Exception {
    ArtifactType artifactType = ArtifactType.valueOf(artifact);
    String atomUrl = getUrl(artifactType);
    Response response = create(atomUrl, SrampAtomUtils.wrapSrampArtifact(artifact), 200);
    Entry entry = response.readEntity(Entry.class);
    verifyEntry(entry);
    return SrampAtomUtils.unwrapSrampArtifact(artifactType, entry);
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:10,代码来源:AtomBinding.java


示例14: uploadReturnEntry

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
public Entry uploadReturnEntry(BaseArtifactType artifact, String filePath, int expectedResponse) throws Exception {
    ArtifactType artifactType = ArtifactType.valueOf(artifact);
    String atomUrl = getUrl(artifactType);
    Builder clientRequest = getClientRequest(atomUrl);

    MultipartRelatedOutput output = new MultipartRelatedOutput();

    //1. Add first part, the S-RAMP entry
    Entry atomEntry = SrampAtomUtils.wrapSrampArtifact(artifact);

    MediaType mediaType = new MediaType("application", "atom+xml");
    output.addPart(atomEntry, mediaType);

    //2. Add second part, the content
    InputStream is = this.getClass().getResourceAsStream(filePath);
    String text = convertStreamToString(is);
    is.close();
    output.addPart(text, MediaType.valueOf(artifactType.getMimeType()));

    //3. Send the request
    Response response = clientRequest.post(Entity.entity(output, MultipartConstants.MULTIPART_RELATED));
    boolean continueProcessing = verifyResponse(response, expectedResponse);
    if (continueProcessing) {
        Entry entry = response.readEntity(Entry.class);
        verifyEntry(entry);
        return entry;
    } else {
        return null;
    }
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:31,代码来源:AtomBinding.java


示例15: getArtifact

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
private Entry getArtifact(String url, int expectedResponse) {
    Builder clientRequest = getClientRequest(url);
    Response response = clientRequest.get();
    boolean continueProcessing = verifyResponse(response, expectedResponse);
    if (continueProcessing) {
        Entry entry = response.readEntity(Entry.class);
        verifyEntry(entry);
        return entry;
    } else {
        return null;
    }
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:13,代码来源:AtomBinding.java


示例16: verifyFeed

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
private void verifyFeed(Feed feed) {
    for (Object key : feed.getExtensionAttributes().keySet()) {
        QName qname = (QName) key;
        // Foundation 1.9
        assertEquals(NAMESPACE, qname.getNamespaceURI());
    }
    for (Entry entry : feed.getEntries()) {
        verifyEntry(entry);
  }
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:11,代码来源:AtomBinding.java


示例17: verifyEntry

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
private void verifyEntry(Entry entry) {
    for (Object key : entry.getExtensionAttributes().keySet()) {
        QName qname = (QName) key;
        // Foundation 1.9
        assertEquals(NAMESPACE, qname.getNamespaceURI());
    }
    
    // Atom 2.2
    assertTrue(entry.getId().toString().contains("urn:uuid:"));
    String uuid = entry.getId().toString().replace("urn:uuid:", "");
    
    // Atom 2.3.1
    assertTrue(entry.getCategories().size() > 0);
    Category typeCategory = findCategory(SrampAtomConstants.X_S_RAMP_TYPE, entry);
    assertNotNull(typeCategory);
    if (typeCategory.getTerm().equals("query") || typeCategory.getTerm().equals("classification")) {
        // Do nothing: stored query or classification.
    } else {
        // Else, assume it's an artifact.
        ArtifactType artifactType = SrampAtomUtils.getArtifactTypeFromEntry(entry);
        if (artifactType.isDocument()) {
            // Atom 2.3.5.3 -- verify /media returns the content.
            verifyMedia(uuid, artifactType);
        }
        // TODO: Not sure if this is correct.  In Overlord, the term is the name of the extended type,
        // not "ExtendedArtifactType"
        if (! artifactType.isExtendedType()) {
            assertEquals(artifactType.getArtifactType().getType(), typeCategory.getTerm());
        }
        
        // verify :kind
        Category kindCategory = findCategory(SrampAtomConstants.X_S_RAMP_KIND, entry);
        assertNotNull(kindCategory);
        if (artifactType.isDerived()) {
            assertEquals("derived", kindCategory.getTerm());
        } else {
            assertEquals("modeled", kindCategory.getTerm());
        }
    }
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:41,代码来源:AtomBinding.java


示例18: findCategory

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
private Category findCategory(String scheme, Entry entry) {
    for (Category category : entry.getCategories()) {
        if (category.getScheme().toString().equals(scheme)) {
            return category;
        }
    }
    return null;
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:9,代码来源:AtomBinding.java


示例19: test_2_3_1

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Test
    public void test_2_3_1() throws Exception {
        XmlDocument artifact = XmlDocument();
        artifact.setCreatedBy("admin");
        artifact.setLastModifiedBy("admin");
        artifact.setName("PO");
        artifact.setDescription("Foo PO");
        Entry entry = binding.uploadReturnEntry(artifact, "/PO.xml");
        artifact = (XmlDocument) SrampAtomUtils.unwrapSrampArtifact(entry);
        
        assertEquals(artifact.getCreatedBy(), entry.getAuthors().get(0).getName());
        assertEquals(artifact.getUuid(), entry.getId().toString().replace("urn:uuid:", ""));
        GregorianCalendar c = new GregorianCalendar();
        c.setTime(entry.getPublished());
        XMLGregorianCalendar gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
        assertEquals(artifact.getCreatedTimestamp(), gc);
        c.setTime(entry.getUpdated());
        gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
        assertEquals(artifact.getLastModifiedTimestamp(), gc);
        assertEquals(artifact.getName(), entry.getTitle());
        assertEquals(artifact.getDescription(), entry.getSummary());
        // TODO: The spec isn't clear on this.  The artifact content type should simply be application/xml,
        // but the links are application/atom+xml;type='entry'.  *content* != *atom* link
//        assertEquals(artifact.getContentType(), entry.getLinks().get(0).getType().toString());
        assertEquals(artifact.getContentType() + ";charset=" + artifact.getContentEncoding(),
                entry.getContent().getType().toString());
        assertEquals(AtomBinding.BASE_URL + "/s-ramp/core/XmlDocument/" + artifact.getUuid(),
                entry.getContent().getSrc().toString());
    }
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:30,代码来源:Test_2_3.java


示例20: test_2_3_2

import org.jboss.resteasy.plugins.providers.atom.Entry; //导入依赖的package包/类
@Test
public void test_2_3_2() throws Exception {
    XmlDocument artifact1 = XmlDocument();
    artifact1.setName("PO 1");
    Entry entry1 = binding.uploadReturnEntry(artifact1, "/PO.xml");
    artifact1 = (XmlDocument) SrampAtomUtils.unwrapSrampArtifact(entry1);
    
    XmlDocument artifact2 = XmlDocument();
    artifact2.setName("PO 2");
    Target target = new Target();
    target.setValue(artifact1.getUuid());
    Relationship relationship = new Relationship();
    relationship.setRelationshipType("fooRelationship");
    relationship.getRelationshipTarget().add(target);
    artifact2.getRelationship().add(relationship);
    Entry entry2 = binding.uploadReturnEntry(artifact2, "/PO.xml");
    artifact2 = (XmlDocument) SrampAtomUtils.unwrapSrampArtifact(entry2);
    
    // TODO: Improve the assertions.  Simply looking for the UUID is probably overly-simple.
    Link link = entry2.getLinkByRel("self");
    assertNotNull(link);
    assertTrue(link.getHref().toString().contains(artifact2.getUuid()));
    link = entry2.getLinkByRel("edit-media");
    assertNotNull(link);
    assertTrue(link.getHref().toString().contains(artifact2.getUuid()));
    link = entry2.getLinkByRel("edit");
    assertNotNull(link);
    assertTrue(link.getHref().toString().contains(artifact2.getUuid()));
}
 
开发者ID:ArtificerRepo,项目名称:s-ramp-tck,代码行数:30,代码来源:Test_2_3.java



注:本文中的org.jboss.resteasy.plugins.providers.atom.Entry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DatagramChannel类代码示例发布时间:2022-05-23
下一篇:
Java Extractor类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap