adapted new module api with locale (rometools/rome-modules#22)
This commit is contained in:
parent
8055c61580
commit
fc6ee1cba7
7 changed files with 18 additions and 11 deletions
|
@ -18,6 +18,7 @@ package org.rometools.propono.atom.client;
|
|||
import java.io.InputStreamReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpMethodBase;
|
||||
|
@ -68,7 +69,7 @@ public class ClientAtomService extends AtomService {
|
|||
if (method.getStatusCode() != 200) {
|
||||
throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
|
||||
}
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri);
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
|
||||
if (!romeEntry.isMediaEntry()) {
|
||||
return new ClientEntry(this, null, romeEntry, false);
|
||||
} else {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.InputStreamReader;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpMethodBase;
|
||||
|
@ -103,7 +104,7 @@ public class ClientCollection extends Collection {
|
|||
if (method.getStatusCode() != 200) {
|
||||
throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
|
||||
}
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri);
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
|
||||
if (!romeEntry.isMediaEntry()) {
|
||||
return new ClientEntry(service, this, romeEntry, false);
|
||||
} else {
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.InputStreamReader;
|
|||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.httpclient.Header;
|
||||
|
@ -209,7 +210,7 @@ public class ClientEntry extends Entry {
|
|||
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());
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(is), getCollection().getHrefResolved(), Locale.US);
|
||||
BeanUtils.copyProperties(this, romeEntry);
|
||||
|
||||
} catch (final Exception e) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.StringWriter;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.httpclient.Header;
|
||||
|
@ -254,7 +255,7 @@ public class ClientMediaEntry extends ClientEntry {
|
|||
}
|
||||
final InputStream is = method.getResponseBodyAsStream();
|
||||
if (method.getStatusCode() == 200 || method.getStatusCode() == 201) {
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(is), col.getHrefResolved());
|
||||
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(is), col.getHrefResolved(), Locale.US);
|
||||
BeanUtils.copyProperties(this, romeEntry);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*/
|
||||
package org.rometools.propono.atom.common.rome;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
|
@ -44,8 +46,7 @@ public class AppModuleParser implements ModuleParser {
|
|||
|
||||
/** Parse JDOM element into module */
|
||||
@Override
|
||||
public Module parse(final Element elem) {
|
||||
final boolean foundSomething = false;
|
||||
public Module parse(final Element elem, final Locale locale) {
|
||||
final AppModule m = new AppModuleImpl();
|
||||
final Element control = elem.getChild("control", getContentNamespace());
|
||||
if (control != null) {
|
||||
|
@ -62,7 +63,7 @@ public class AppModuleParser implements ModuleParser {
|
|||
final Element edited = elem.getChild("edited", getContentNamespace());
|
||||
if (edited != null) {
|
||||
try {
|
||||
m.setEdited(DateParser.parseW3CDateTime(edited.getTextTrim()));
|
||||
m.setEdited(DateParser.parseW3CDateTime(edited.getTextTrim(), locale));
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -174,7 +175,7 @@ public class AtomServlet extends HttpServlet {
|
|||
if (req.getContentType().startsWith("application/atom+xml")) {
|
||||
|
||||
// parse incoming entry
|
||||
final Entry entry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(req.getInputStream(), "UTF-8")), null);
|
||||
final Entry entry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(req.getInputStream(), "UTF-8")), null, Locale.US);
|
||||
|
||||
// call handler to post it
|
||||
final Entry newEntry = handler.postEntry(areq, entry);
|
||||
|
@ -277,7 +278,7 @@ public class AtomServlet extends HttpServlet {
|
|||
if (handler.isEntryURI(areq)) {
|
||||
|
||||
// parse incoming entry
|
||||
final Entry unsavedEntry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(req.getInputStream(), "UTF-8")), null);
|
||||
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);
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.activation.FileTypeMap;
|
||||
|
@ -509,7 +510,7 @@ public class FileBasedCollection extends Collection {
|
|||
|
||||
private Entry loadAtomResourceEntry(final InputStream in, final File file) {
|
||||
try {
|
||||
final Entry entry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(in)), null);
|
||||
final Entry entry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(in)), null, Locale.US);
|
||||
updateMediaEntryAppLinks(entry, file.getName(), true);
|
||||
return entry;
|
||||
|
||||
|
@ -615,7 +616,7 @@ public class FileBasedCollection extends Collection {
|
|||
*/
|
||||
private Entry loadAtomEntry(final InputStream in) {
|
||||
try {
|
||||
return Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(in, "UTF-8")), null);
|
||||
return Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(in, "UTF-8")), null, Locale.US);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue