added mailing class

This commit is contained in:
Athou
2013-04-12 13:27:30 +02:00
parent 679fcad2b5
commit 38233be861
11 changed files with 154 additions and 54 deletions

View File

@@ -10,10 +10,10 @@ import org.apache.wicket.request.UrlRenderer;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.commafeed.backend.dao.ApplicationSettingsDAO;
import com.commafeed.backend.dao.UserDAO;
import com.commafeed.backend.feeds.OPMLImporter;
import com.commafeed.backend.model.ApplicationSettings;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.frontend.utils.WicketUtils;
import com.commafeed.frontend.utils.exception.DisplayException;
import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl;
@@ -33,7 +33,7 @@ public class GoogleImportCallbackPage extends WebPage {
private static final String EXPORT_URL = "https://www.google.com/reader/subscriptions/export";
@Inject
ApplicationSettingsDAO applicationSettingsDAO;
ApplicationSettingsService applicationSettingsService;
@Inject
OPMLImporter importer;
@@ -65,7 +65,7 @@ public class GoogleImportCallbackPage extends WebPage {
} else if (code == null) {
throw new DisplayException("Missing authorization code");
} else {
ApplicationSettings settings = applicationSettingsDAO.get();
ApplicationSettings settings = applicationSettingsService.get();
String redirectUri = getCallbackUrl();
String clientId = settings.getGoogleClientId();
String clientSecret = settings.getGoogleClientSecret();
@@ -90,8 +90,7 @@ public class GoogleImportCallbackPage extends WebPage {
httpRequest, accessToken);
String opml = httpRequest.execute().parseAsString();
String state = responseUrl.getState();
importer.importOpml(userDAO.findById(Long.valueOf(state)),
opml);
importer.importOpml(userDAO.findById(Long.valueOf(state)), opml);
} catch (Exception e) {
throw new DisplayException(e);
}

View File

@@ -9,8 +9,8 @@ import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.flow.RedirectToUrlException;
import org.jboss.logging.Logger;
import com.commafeed.backend.dao.ApplicationSettingsDAO;
import com.commafeed.backend.model.ApplicationSettings;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.frontend.CommaFeedSession;
@SuppressWarnings("serial")
@@ -23,11 +23,11 @@ public class GoogleImportRedirectPage extends WebPage {
private static final String AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
@Inject
ApplicationSettingsDAO applicationSettingsDAO;
ApplicationSettingsService applicationSettingsService;
public GoogleImportRedirectPage() {
ApplicationSettings settings = applicationSettingsDAO.get();
ApplicationSettings settings = applicationSettingsService.get();
String clientId = settings.getGoogleClientId();

View File

@@ -5,7 +5,7 @@ import javax.inject.Inject;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import com.commafeed.backend.dao.ApplicationSettingsDAO;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.frontend.pages.components.LoginPanel;
import com.commafeed.frontend.pages.components.RegisterPanel;
import com.commafeed.frontend.utils.WicketUtils;
@@ -14,7 +14,7 @@ import com.commafeed.frontend.utils.WicketUtils;
public class WelcomePage extends BasePage {
@Inject
ApplicationSettingsDAO applicationSettingsDAO;
ApplicationSettingsService applicationSettingsService;
public WelcomePage() {
add(new BookmarkablePageLink<Void>("logo-link", getApplication()
@@ -24,7 +24,7 @@ public class WelcomePage extends BasePage {
@Override
protected void onConfigure() {
super.onConfigure();
setVisibilityAllowed(applicationSettingsDAO.get()
setVisibilityAllowed(applicationSettingsService.get()
.isAllowRegistrations());
}
});

View File

@@ -20,10 +20,10 @@ import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;
import org.apache.wicket.validation.validator.StringValidator;
import com.commafeed.backend.dao.ApplicationSettingsDAO;
import com.commafeed.backend.dao.UserDAO;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.UserService;
import com.commafeed.frontend.CommaFeedSession;
import com.commafeed.frontend.model.RegistrationRequest;
@@ -40,7 +40,7 @@ public class RegisterPanel extends Panel {
UserService userService;
@Inject
ApplicationSettingsDAO applicationSettingsDAO;
ApplicationSettingsService applicationSettingsService;
public RegisterPanel(String markupId) {
super(markupId);
@@ -51,7 +51,7 @@ public class RegisterPanel extends Panel {
"form", model) {
@Override
protected void onSubmit() {
if (applicationSettingsDAO.get().isAllowRegistrations()) {
if (applicationSettingsService.get().isAllowRegistrations()) {
RegistrationRequest req = getModelObject();
userService.register(req.getName(), req.getPassword(),
Arrays.asList(Role.USER));

View File

@@ -6,9 +6,9 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import com.commafeed.backend.dao.ApplicationSettingsDAO;
import com.commafeed.backend.model.ApplicationSettings;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.frontend.SecurityCheck;
@SecurityCheck(Role.ADMIN)
@@ -16,18 +16,18 @@ import com.commafeed.frontend.SecurityCheck;
public class AdminSettingsREST {
@Inject
ApplicationSettingsDAO applicationSettingsDAO;
ApplicationSettingsService applicationSettingsService;
@Path("get")
@GET
public ApplicationSettings get() {
return applicationSettingsDAO.get();
return applicationSettingsService.get();
}
@Path("save")
@POST
public Response save(ApplicationSettings settings) {
applicationSettingsDAO.save(settings);
applicationSettingsService.save(settings);
return Response.ok().build();
}
}

View File

@@ -74,15 +74,15 @@ public class EntriesREST extends AbstractREST {
if (ALL.equals(id)) {
entries.setName("All");
List<FeedEntryStatus> unreadEntries = feedEntryStatusDAO
.findAll(getUser(), unreadOnly, offset, limit,
order, true);
.findAll(getUser(), unreadOnly, offset, limit, order,
true);
for (FeedEntryStatus status : unreadEntries) {
entries.getEntries().add(buildEntry(status));
}
} else {
FeedCategory feedCategory = feedCategoryDAO.findById(
getUser(), Long.valueOf(id));
FeedCategory feedCategory = feedCategoryDAO.findById(getUser(),
Long.valueOf(id));
if (feedCategory != null) {
List<FeedCategory> childrenCategories = feedCategoryDAO
.findAllChildrenCategories(getUser(), feedCategory);
@@ -142,8 +142,8 @@ public class EntriesREST extends AbstractREST {
feedEntryStatusDAO.update(status);
} else if (type == Type.feed) {
if (read) {
FeedSubscription subscription = feedSubscriptionDAO
.findById(getUser(), Long.valueOf(id));
FeedSubscription subscription = feedSubscriptionDAO.findById(
getUser(), Long.valueOf(id));
feedEntryStatusDAO.markFeedEntries(getUser(),
subscription.getFeed(), olderThan);
} else {
@@ -156,7 +156,8 @@ public class EntriesREST extends AbstractREST {
feedEntryStatusDAO.markAllEntries(getUser(), olderThan);
} else {
List<FeedCategory> categories = feedCategoryDAO
.findAllChildrenCategories(getUser(),
.findAllChildrenCategories(
getUser(),
feedCategoryDAO.findById(getUser(),
Long.valueOf(id)));
feedEntryStatusDAO.markCategoryEntries(getUser(),