本文整理汇总了Java中com.rometools.rome.io.impl.Atom10Parser.parseEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Atom10Parser.parseEntry方法的具体用法?Java Atom10Parser.parseEntry怎么用?Java Atom10Parser.parseEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.io.impl.Atom10Parser
的用法示例。
在下文中一共展示了Atom10Parser.parseEntry方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntry
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
/**
* Get full entry specified by entry edit URI. Note that entry may or may not be associated with
* this collection.
*
* @return ClientEntry or ClientMediaEntry specified by URI.
*/
public ClientEntry getEntry(final String uri) throws ProponoException {
final GetMethod method = new GetMethod(uri);
authStrategy.addAuthentication(httpClient, method);
try {
httpClient.executeMethod(method);
if (method.getStatusCode() != 200) {
throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
}
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
if (!romeEntry.isMediaEntry()) {
return new ClientEntry(service, this, romeEntry, false);
} else {
return new ClientMediaEntry(service, this, romeEntry, false);
}
} catch (final Exception e) {
throw new ProponoException("ERROR: getting or parsing entry/media, HTTP code: ", e);
} finally {
method.releaseConnection();
}
}
示例2: getEntry
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
/**
* Get full entry from service by entry edit URI.
*/
public ClientEntry getEntry(final String uri) throws ProponoException {
final GetMethod method = new GetMethod(uri);
authStrategy.addAuthentication(httpClient, method);
try {
httpClient.executeMethod(method);
if (method.getStatusCode() != 200) {
throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
}
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
if (!romeEntry.isMediaEntry()) {
return new ClientEntry(this, null, romeEntry, false);
} else {
return new ClientMediaEntry(this, null, romeEntry, false);
}
} catch (final Exception e) {
throw new ProponoException("ERROR: getting or parsing entry/media", e);
} finally {
method.releaseConnection();
}
}
示例3: addToCollection
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
void addToCollection(final ClientCollection col) throws ProponoException {
setCollection(col);
final EntityEnclosingMethod method = new PostMethod(getCollection().getHrefResolved());
addAuthentication(method);
final StringWriter sw = new StringWriter();
int code = -1;
try {
Atom10Generator.serializeEntry(this, sw);
method.setRequestEntity(new StringRequestEntity(sw.toString(), null, null));
method.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
getHttpClient().executeMethod(method);
final InputStream is = method.getResponseBodyAsStream();
code = method.getStatusCode();
if (code != 200 && code != 201) {
throw new ProponoException("ERROR HTTP status=" + code + " : " + Utilities.streamToString(is));
}
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(is), getCollection().getHrefResolved(), Locale.US);
BeanUtils.copyProperties(this, romeEntry);
} catch (final Exception e) {
final String msg = "ERROR: saving entry, HTTP code: " + code;
LOG.debug(msg, e);
throw new ProponoException(msg, e);
} finally {
method.releaseConnection();
}
final Header locationHeader = method.getResponseHeader("Location");
if (locationHeader == null) {
LOG.warn("WARNING added entry, but no location header returned");
} else if (getEditURI() == null) {
final List<Link> links = getOtherLinks();
final Link link = new Link();
link.setHref(locationHeader.getValue());
link.setRel("edit");
links.add(link);
setOtherLinks(links);
}
}
示例4: loadAtomResourceEntry
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
private Entry loadAtomResourceEntry(final InputStream in, final File file) {
try {
final Entry entry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(in)), null, Locale.US);
updateMediaEntryAppLinks(entry, file.getName(), true);
return entry;
} catch (final Exception e) {
e.printStackTrace();
return null;
}
}
示例5: loadAtomEntry
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
/**
* Create a Rome Atom entry based on a Roller entry. Content is escaped. Link is stored as
* rel=alternate link.
*/
private Entry loadAtomEntry(final InputStream in) {
try {
return Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(in, "UTF-8")), null, Locale.US);
} catch (final Exception e) {
e.printStackTrace();
return null;
}
}
示例6: addToCollection
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
/** Package access, to be called by DefaultClientCollection */
@Override
void addToCollection(final ClientCollection col) throws ProponoException {
setCollection(col);
final EntityEnclosingMethod method = new PostMethod(col.getHrefResolved());
getCollection().addAuthentication(method);
try {
final Content c = getContents().get(0);
if (inputStream != null) {
method.setRequestEntity(new InputStreamRequestEntity(inputStream));
} else {
method.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(getBytes())));
}
method.setRequestHeader("Content-type", c.getType());
method.setRequestHeader("Title", getTitle());
method.setRequestHeader("Slug", getSlug());
getCollection().getHttpClient().executeMethod(method);
if (inputStream != null) {
inputStream.close();
}
final InputStream is = method.getResponseBodyAsStream();
if (method.getStatusCode() == 200 || method.getStatusCode() == 201) {
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(is), col.getHrefResolved(), Locale.US);
BeanUtils.copyProperties(this, romeEntry);
} else {
throw new ProponoException("ERROR HTTP status-code=" + method.getStatusCode() + " status-line: " + method.getStatusLine());
}
} catch (final IOException ie) {
throw new ProponoException("ERROR: saving media entry", ie);
} catch (final JDOMException je) {
throw new ProponoException("ERROR: saving media entry", je);
} catch (final FeedException fe) {
throw new ProponoException("ERROR: saving media entry", fe);
} catch (final IllegalAccessException ae) {
throw new ProponoException("ERROR: saving media entry", ae);
} catch (final InvocationTargetException te) {
throw new ProponoException("ERROR: saving media entry", te);
}
final Header locationHeader = method.getResponseHeader("Location");
if (locationHeader == null) {
LOG.warn("WARNING added entry, but no location header returned");
} else if (getEditURI() == null) {
final List<Link> links = getOtherLinks();
final Link link = new Link();
link.setHref(locationHeader.getValue());
link.setRel("edit");
links.add(link);
setOtherLinks(links);
}
}
示例7: doPut
import com.rometools.rome.io.impl.Atom10Parser; //导入方法依赖的package包/类
/**
* Handles an Atom PUT by calling handler to identify URI, reading/parsing data, calling handler
* and writing results to response.
*/
@Override
protected void doPut(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
final AtomRequest areq = new AtomRequestImpl(req);
try {
if (handler.isEntryURI(areq)) {
// parse incoming entry
final Entry unsavedEntry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(req.getInputStream(), "UTF-8")), null,
Locale.US);
// call handler to put entry
handler.putEntry(areq, unsavedEntry);
res.setStatus(HttpServletResponse.SC_OK);
} else if (handler.isMediaEditURI(areq)) {
// hand input stream to handler
handler.putMedia(areq);
res.setStatus(HttpServletResponse.SC_OK);
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
LOG.debug("An error occured while processing PUT", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
LOG.debug("An error occured while processing PUT", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
// Wanted to use sendError() here but Tomcat sends 403 forbidden
// when I do that, so sticking with setStatus() for time being.
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
LOG.debug("Exiting");
}