当前位置: 首页>>代码示例>>Java>>正文


Java Entry类代码示例

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


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


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