deal with posts containing no tags by using the implicit tag "[none]" (thanks ardvark!)

This commit is contained in:
jrandom
2005-09-10 06:07:25 +00:00
committed by zzz
parent 44770b7c07
commit 727d76d43e
2 changed files with 16 additions and 8 deletions

View File

@ -115,12 +115,19 @@ public class EntryContainer {
if (len <= 0)
break;
int split = line.indexOf(':');
if ( (split <= 0) || (split >= len - 2) )
if (split <= 0) {
throw new IOException("Invalid format of the syndie entry: line=" + line);
String key = line.substring(0, split);
String val = line.substring(split+1);
_rawKeys.add(key);
_rawValues.add(val);
} else if (split >= len - 2) {
// foo:\n
String key = line.substring(0, split);
_rawKeys.add(key);
_rawValues.add("");
} else {
String key = line.substring(0, split);
String val = line.substring(split+1);
_rawKeys.add(key);
_rawValues.add(val);
}
}
parseHeaders();
@ -275,7 +282,8 @@ public class EntryContainer {
}
public BlogURI getURI() { return _entryURI; }
private static final String NO_TAGS[] = new String[0];
public static final String NO_TAGS_TAG = "[none]";
private static final String NO_TAGS[] = new String[] { NO_TAGS_TAG };
public String[] getTags() {
String tags = getHeader(HEADER_BLOGTAGS);
if ( (tags == null) || (tags.trim().length() <= 0) ) {

View File

@ -21,7 +21,7 @@ if ((contentType != null) && (contentType.indexOf("boundary=") != -1) ) {
int metaId = 0;
while (true) {
InputStream meta = req.getInputStream("blogmeta" + metaId);
if (meta == null)
if ( (meta == null) || (meta.available() <= 0) )
break;
if (!BlogManager.instance().importBlogMetadata(meta)) {
%><span class="b_importMsgErr">Metadata <%=metaId%> failed to be imported</span><br /><%
@ -32,7 +32,7 @@ if ((contentType != null) && (contentType.indexOf("boundary=") != -1) ) {
int entryId = 0;
while (true) {
InputStream entry = req.getInputStream("blogpost" + entryId);
if (entry == null)
if ( (entry == null) || (entry.available() <= 0) )
break;
if (!BlogManager.instance().importBlogEntry(entry)) {
%><span class="b_importMsgErr">Entry <%=entryId%> failed to be imported</span><br /><%