use title if text is empty (fix #419)

This commit is contained in:
Athou
2013-07-11 13:35:58 +02:00
parent 0eef8d70ad
commit e02532aa7b

View File

@@ -59,14 +59,19 @@ public class OPMLImporter {
private void handleOutline(User user, Outline outline, FeedCategory parent) { private void handleOutline(User user, Outline outline, FeedCategory parent) {
if (StringUtils.isEmpty(outline.getType())) { if (StringUtils.isEmpty(outline.getType())) {
FeedCategory category = feedCategoryDAO.findByName(user, String name = FeedUtils.truncate(outline.getText(), 128);
outline.getText(), parent); if (name == null) {
name = FeedUtils.truncate(outline.getTitle(), 128);
}
FeedCategory category = feedCategoryDAO.findByName(user, name,
parent);
if (category == null) { if (category == null) {
category = new FeedCategory(); if (StringUtils.isBlank(name)) {
category.setName(FeedUtils.truncate(outline.getText(), 128)); name = "Unnamed category";
if (StringUtils.isBlank(category.getName())) {
category.setName("Unnamed category");
} }
category = new FeedCategory();
category.setName(name);
category.setParent(parent); category.setParent(parent);
category.setUser(user); category.setUser(user);
feedCategoryDAO.saveOrUpdate(category); feedCategoryDAO.saveOrUpdate(category);
@@ -77,19 +82,22 @@ public class OPMLImporter {
handleOutline(user, child, category); handleOutline(user, child, category);
} }
} else { } else {
String title = outline.getText(); String name = FeedUtils.truncate(outline.getText(), 128);
if (StringUtils.isBlank(title)) { if (name == null) {
title = "Unnamed subscription"; name = FeedUtils.truncate(outline.getTitle(), 128);
}
if (StringUtils.isBlank(name)) {
name = "Unnamed subscription";
} }
// make sure we continue with the import process even a feed failed // make sure we continue with the import process even a feed failed
try { try {
feedSubscriptionService.subscribe(user, outline.getXmlUrl(), title, feedSubscriptionService.subscribe(user, outline.getXmlUrl(),
parent); name, parent);
} catch (FeedSubscriptionException e) { } catch (FeedSubscriptionException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
log.error("error while importing {}: {}", outline.getXmlUrl(), e.getMessage()); log.error("error while importing {}: {}", outline.getXmlUrl(),
e.getMessage());
} }
} }
cache.invalidateUserData(user); cache.invalidateUserData(user);