code cleanup

This commit is contained in:
Athou
2014-08-14 11:40:30 +02:00
parent cda6cb5cc0
commit 1324269f1d
7 changed files with 16 additions and 53 deletions

View File

@@ -192,7 +192,7 @@ public class HttpGetter {
private long duration; private long duration;
private String urlAfterRedirect; private String urlAfterRedirect;
public HttpResult(byte[] content, String contentType, String lastModifiedSince, String eTag, long duration, String urlAfterRedirect) { private HttpResult(byte[] content, String contentType, String lastModifiedSince, String eTag, long duration, String urlAfterRedirect) {
this.content = content; this.content = content;
this.contentType = contentType; this.contentType = contentType;
this.lastModifiedSince = lastModifiedSince; this.lastModifiedSince = lastModifiedSince;

View File

@@ -59,7 +59,7 @@ public class FeedCategoryDAO extends GenericDAO<FeedCategory> {
return list; return list;
} }
public boolean isChild(FeedCategory child, FeedCategory parent) { private boolean isChild(FeedCategory child, FeedCategory parent) {
if (parent == null) { if (parent == null) {
return true; return true;
} }

View File

@@ -34,13 +34,6 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
.list(entry); .list(entry);
} }
public int delete(Feed feed, int max) {
List<FeedEntry> list = newQuery().from(entry).where(entry.feed.eq(feed)).limit(max).list(entry);
int deleted = list.size();
delete(list);
return deleted;
}
public int delete(Date olderThan, int max) { public int delete(Date olderThan, int max) {
List<FeedEntry> list = newQuery().from(entry).where(entry.inserted.lt(olderThan)).limit(max).list(entry); List<FeedEntry> list = newQuery().from(entry).where(entry.inserted.lt(olderThan)).limit(max).list(entry);
int deleted = list.size(); int deleted = list.size();

View File

@@ -11,7 +11,7 @@ import com.mysema.query.jpa.hibernate.HibernateQuery;
public abstract class GenericDAO<T extends AbstractModel> extends AbstractDAO<T> { public abstract class GenericDAO<T extends AbstractModel> extends AbstractDAO<T> {
public GenericDAO(SessionFactory sessionFactory) { protected GenericDAO(SessionFactory sessionFactory) {
super(sessionFactory); super(sessionFactory);
} }
@@ -56,9 +56,4 @@ public abstract class GenericDAO<T extends AbstractModel> extends AbstractDAO<T>
return objects.size(); return objects.size();
} }
protected void setTimeout(javax.persistence.Query query, int queryTimeout) {
if (queryTimeout > 0) {
query.setHint("javax.persistence.query.timeout", queryTimeout);
}
}
} }

View File

@@ -28,7 +28,7 @@ public class FeedSubscriptionService {
@SuppressWarnings("serial") @SuppressWarnings("serial")
public static class FeedSubscriptionException extends RuntimeException { public static class FeedSubscriptionException extends RuntimeException {
public FeedSubscriptionException(String msg) { private FeedSubscriptionException(String msg) {
super(msg); super(msg);
} }
} }
@@ -87,16 +87,6 @@ public class FeedSubscriptionService {
} }
} }
public UnreadCount getUnreadCount(User user, FeedSubscription sub) {
UnreadCount count = cache.getUnreadCount(sub);
if (count == null) {
log.debug("unread count cache miss for {}", Models.getId(sub));
count = feedEntryStatusDAO.getUnreadCount(user, sub);
cache.setUnreadCount(sub, count);
}
return count;
}
public Map<Long, UnreadCount> getUnreadCount(User user) { public Map<Long, UnreadCount> getUnreadCount(User user) {
Map<Long, UnreadCount> map = Maps.newHashMap(); Map<Long, UnreadCount> map = Maps.newHashMap();
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user); List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
@@ -106,4 +96,14 @@ public class FeedSubscriptionService {
return map; return map;
} }
private UnreadCount getUnreadCount(User user, FeedSubscription sub) {
UnreadCount count = cache.getUnreadCount(sub);
if (count == null) {
log.debug("unread count cache miss for {}", Models.getId(sub));
count = feedEntryStatusDAO.getUnreadCount(user, sub);
cache.setUnreadCount(sub, count);
}
return count;
}
} }

View File

@@ -1,25 +0,0 @@
package com.commafeed.frontend.model;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import com.commafeed.backend.model.Feed;
import com.google.common.collect.Lists;
import com.wordnik.swagger.annotations.ApiModel;
@ApiModel("Feed count")
@Data
public class FeedCount implements Serializable {
private static final long serialVersionUID = 1L;
private String value;
private List<Feed> feeds = Lists.newArrayList();;
public FeedCount(String value) {
this.value = value;
}
}

View File

@@ -31,8 +31,8 @@ import com.google.common.collect.Iterables;
@RequiredArgsConstructor @RequiredArgsConstructor
public class NextUnreadServlet extends HttpServlet { public class NextUnreadServlet extends HttpServlet {
public static final String PARAM_CATEGORYID = "category"; private static final String PARAM_CATEGORYID = "category";
public static final String PARAM_READINGORDER = "order"; private static final String PARAM_READINGORDER = "order";
private final SessionFactory sessionFactory; private final SessionFactory sessionFactory;
private final FeedSubscriptionDAO feedSubscriptionDAO; private final FeedSubscriptionDAO feedSubscriptionDAO;