forked from Archives/Athou_commafeed
detect categories in opml files by checking if they have children
This commit is contained in:
@@ -11,6 +11,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.commafeed.backend.cache.CacheService;
|
import com.commafeed.backend.cache.CacheService;
|
||||||
@@ -57,8 +58,8 @@ public class OPMLImporter {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void handleOutline(User user, Outline outline, FeedCategory parent) {
|
private void handleOutline(User user, Outline outline, FeedCategory parent) {
|
||||||
|
List<Outline> children = outline.getChildren();
|
||||||
if (StringUtils.isEmpty(outline.getType())) {
|
if (CollectionUtils.isNotEmpty(children)) {
|
||||||
String name = FeedUtils.truncate(outline.getText(), 128);
|
String name = FeedUtils.truncate(outline.getText(), 128);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = FeedUtils.truncate(outline.getTitle(), 128);
|
name = FeedUtils.truncate(outline.getTitle(), 128);
|
||||||
@@ -76,7 +77,6 @@ public class OPMLImporter {
|
|||||||
feedCategoryDAO.saveOrUpdate(category);
|
feedCategoryDAO.saveOrUpdate(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Outline> children = outline.getChildren();
|
|
||||||
for (Outline child : children) {
|
for (Outline child : children) {
|
||||||
handleOutline(user, child, category);
|
handleOutline(user, child, category);
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ public class OPMLImporter {
|
|||||||
if (StringUtils.isBlank(name)) {
|
if (StringUtils.isBlank(name)) {
|
||||||
name = "Unnamed subscription";
|
name = "Unnamed subscription";
|
||||||
}
|
}
|
||||||
// make sure we continue with the import process even a feed failed
|
// make sure we continue with the import process even if a feed failed
|
||||||
try {
|
try {
|
||||||
feedSubscriptionService.subscribe(user, outline.getXmlUrl(), name, parent);
|
feedSubscriptionService.subscribe(user, outline.getXmlUrl(), name, parent);
|
||||||
} catch (FeedSubscriptionException e) {
|
} catch (FeedSubscriptionException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user