diff --git a/pom.xml b/pom.xml
index a822533b..7f14e2b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -237,16 +237,6 @@
commons-fileupload
1.3
-
- com.googlecode.lambdaj
- lambdaj
- 2.3.3
-
-
- joda-time
- joda-time
- 2.2
-
net.java.dev.rome
@@ -291,17 +281,6 @@
0.9.9
-
- com.google.oauth-client
- google-oauth-client-servlet
- 1.14.1-beta
-
-
- com.google.http-client
- google-http-client-jackson2
- 1.14.1-beta
-
-
org.apache.httpcomponents
httpclient
@@ -358,26 +337,8 @@
com.wordnik
- swagger-jaxrs_2.9.1
+ swagger-annotations_2.9.1
1.2.5
-
-
- jersey-server
- com.sun.jersey
-
-
- jersey-servlet
- com.sun.jersey
-
-
- jersey-client
- com.sun.jersey
-
-
- jersey-core
- com.sun.jersey
-
-
@@ -510,6 +471,11 @@
commons-io
2.4
+
+ com.wordnik
+ swagger-jaxrs_2.9.1
+ 1.2.5
+
@@ -523,6 +489,7 @@
templates/
${basedir}/target/generated-sources/angularjs/all-templates.html
${basedir}/src/main/resources/i18n/
+ ${basedir}/target/generated-sources/swagger-doc
${basedir}/src/main/script
@@ -538,6 +505,11 @@
new
HTMLConcat().concat(source,
prefix, dest, i18n);
+
+ def docPath =
+ project.properties['doc.path'];
+ new
+ SwaggerStaticGenerator().generate(docPath);
@@ -572,6 +544,13 @@
**/*.html
+
+ target/generated-sources/swagger-doc/
+ api/swagger-doc
+
+ **/*
+
+
diff --git a/src/main/java/com/commafeed/backend/StartupBean.java b/src/main/java/com/commafeed/backend/StartupBean.java
index 114a0d44..72c43028 100644
--- a/src/main/java/com/commafeed/backend/StartupBean.java
+++ b/src/main/java/com/commafeed/backend/StartupBean.java
@@ -23,7 +23,7 @@ import com.commafeed.backend.model.ApplicationSettings;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.UserService;
-import com.google.api.client.util.Maps;
+import com.google.common.collect.Maps;
/**
* Starting point of the application
diff --git a/src/main/java/com/commafeed/backend/cache/RedisCacheService.java b/src/main/java/com/commafeed/backend/cache/RedisCacheService.java
index a7ea2f06..e8d76aa5 100644
--- a/src/main/java/com/commafeed/backend/cache/RedisCacheService.java
+++ b/src/main/java/com/commafeed/backend/cache/RedisCacheService.java
@@ -22,7 +22,7 @@ import com.commafeed.backend.model.User;
import com.commafeed.frontend.model.Category;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.api.client.util.Lists;
+import com.google.common.collect.Lists;
@Alternative
@ApplicationScoped
diff --git a/src/main/java/com/commafeed/backend/feeds/FeedRefreshTaskGiver.java b/src/main/java/com/commafeed/backend/feeds/FeedRefreshTaskGiver.java
index e2ac9872..d4bc643a 100644
--- a/src/main/java/com/commafeed/backend/feeds/FeedRefreshTaskGiver.java
+++ b/src/main/java/com/commafeed/backend/feeds/FeedRefreshTaskGiver.java
@@ -21,8 +21,8 @@ import com.commafeed.backend.MetricsBean;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.services.ApplicationSettingsService;
-import com.google.api.client.util.Maps;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
/**
diff --git a/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java b/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java
index ec1fd358..d571150e 100644
--- a/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java
+++ b/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java
@@ -34,7 +34,7 @@ import com.commafeed.backend.model.User;
import com.commafeed.backend.pubsubhubbub.SubscriptionHandler;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.FeedUpdateService;
-import com.google.api.client.util.Lists;
+import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Striped;
@ApplicationScoped
diff --git a/src/main/java/com/commafeed/backend/feeds/FeedUtils.java b/src/main/java/com/commafeed/backend/feeds/FeedUtils.java
index b2bece61..ef03a86b 100644
--- a/src/main/java/com/commafeed/backend/feeds/FeedUtils.java
+++ b/src/main/java/com/commafeed/backend/feeds/FeedUtils.java
@@ -8,6 +8,7 @@ import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
@@ -28,8 +29,7 @@ import org.w3c.dom.css.CSSStyleDeclaration;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedSubscription;
-import com.google.api.client.util.Base64;
-import com.google.api.client.util.Lists;
+import com.google.common.collect.Lists;
import com.google.gwt.i18n.client.HasDirection.Direction;
import com.google.gwt.i18n.shared.BidiUtils;
import com.steadystate.css.parser.CSSOMParser;
diff --git a/src/main/java/com/commafeed/backend/feeds/FetchedFeed.java b/src/main/java/com/commafeed/backend/feeds/FetchedFeed.java
index 77fab91f..2ca5c5e9 100644
--- a/src/main/java/com/commafeed/backend/feeds/FetchedFeed.java
+++ b/src/main/java/com/commafeed/backend/feeds/FetchedFeed.java
@@ -4,7 +4,7 @@ import java.util.List;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
-import com.google.api.client.util.Lists;
+import com.google.common.collect.Lists;
public class FetchedFeed {
diff --git a/src/main/java/com/commafeed/backend/services/FeedSubscriptionService.java b/src/main/java/com/commafeed/backend/services/FeedSubscriptionService.java
index c321dab9..801b2757 100644
--- a/src/main/java/com/commafeed/backend/services/FeedSubscriptionService.java
+++ b/src/main/java/com/commafeed/backend/services/FeedSubscriptionService.java
@@ -21,7 +21,7 @@ import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.Models;
import com.commafeed.backend.model.User;
-import com.google.api.client.util.Maps;
+import com.google.common.collect.Maps;
public class FeedSubscriptionService {
diff --git a/src/main/java/com/commafeed/frontend/CommaFeedApplication.java b/src/main/java/com/commafeed/frontend/CommaFeedApplication.java
index 5d6e2d17..4a8386f5 100644
--- a/src/main/java/com/commafeed/frontend/CommaFeedApplication.java
+++ b/src/main/java/com/commafeed/frontend/CommaFeedApplication.java
@@ -69,9 +69,6 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
mountPage("logout", LogoutPage.class);
mountPage("error", DisplayExceptionPage.class);
- // mountPage("google/import/redirect", GoogleImportRedirectPage.class);
- // mountPage(GoogleImportCallbackPage.PAGE_PATH, GoogleImportCallbackPage.class);
-
mountPage("next", NextUnreadRedirectPage.class);
setupInjection();
diff --git a/src/main/java/com/commafeed/frontend/model/ServerInfo.java b/src/main/java/com/commafeed/frontend/model/ServerInfo.java
index 889c870b..0e66203a 100644
--- a/src/main/java/com/commafeed/frontend/model/ServerInfo.java
+++ b/src/main/java/com/commafeed/frontend/model/ServerInfo.java
@@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import com.google.api.client.util.Maps;
+import com.google.common.collect.Maps;
import com.wordnik.swagger.annotations.ApiClass;
@SuppressWarnings("serial")
diff --git a/src/main/java/com/commafeed/frontend/pages/BasePage.java b/src/main/java/com/commafeed/frontend/pages/BasePage.java
index 65ecd881..f0f96b96 100644
--- a/src/main/java/com/commafeed/frontend/pages/BasePage.java
+++ b/src/main/java/com/commafeed/frontend/pages/BasePage.java
@@ -31,7 +31,7 @@ import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.MailService;
import com.commafeed.frontend.CommaFeedSession;
import com.commafeed.frontend.utils.WicketUtils;
-import com.google.api.client.util.Maps;
+import com.google.common.collect.Maps;
@SuppressWarnings("serial")
public abstract class BasePage extends WebPage {
diff --git a/src/main/java/com/commafeed/frontend/pages/GoogleImportCallbackPage.java b/src/main/java/com/commafeed/frontend/pages/GoogleImportCallbackPage.java
deleted file mode 100644
index 3b65d843..00000000
--- a/src/main/java/com/commafeed/frontend/pages/GoogleImportCallbackPage.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.commafeed.frontend.pages;
-
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.wicket.RestartResponseException;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.commafeed.backend.StartupBean;
-import com.commafeed.backend.dao.UserDAO;
-import com.commafeed.backend.feeds.FeedUtils;
-import com.commafeed.backend.feeds.OPMLImporter;
-import com.commafeed.backend.model.ApplicationSettings;
-import com.commafeed.backend.model.User;
-import com.commafeed.backend.services.ApplicationSettingsService;
-import com.commafeed.frontend.CommaFeedSession;
-import com.commafeed.frontend.utils.WicketUtils;
-import com.commafeed.frontend.utils.exception.DisplayException;
-import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl;
-import com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest;
-import com.google.api.client.auth.oauth2.BearerToken;
-import com.google.api.client.auth.oauth2.TokenResponse;
-import com.google.api.client.http.GenericUrl;
-import com.google.api.client.http.HttpRequest;
-import com.google.api.client.http.HttpTransport;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import com.google.api.client.json.jackson2.JacksonFactory;
-
-@SuppressWarnings("serial")
-public class GoogleImportCallbackPage extends WebPage {
-
- private static final String TOKEN_URL = "https://accounts.google.com/o/oauth2/token";
- private static final String EXPORT_URL = "https://www.google.com/reader/subscriptions/export";
-
- public static final String PAGE_PATH = "google/import/callback";
-
- @Inject
- ApplicationSettingsService applicationSettingsService;
-
- @Inject
- OPMLImporter importer;
-
- @Inject
- UserDAO userDAO;
-
- public static String getCallbackUrl(String publicUrl) {
- return FeedUtils.removeTrailingSlash(publicUrl) + "/" + PAGE_PATH;
- }
-
- public GoogleImportCallbackPage(PageParameters params) {
-
- HttpServletRequest request = WicketUtils.getHttpServletRequest();
- StringBuffer urlBuffer = request.getRequestURL();
- if (request.getQueryString() != null) {
- urlBuffer.append('?').append(request.getQueryString());
- }
- AuthorizationCodeResponseUrl responseUrl = new AuthorizationCodeResponseUrl(urlBuffer.toString());
- String code = responseUrl.getCode();
-
- if (responseUrl.getError() != null) {
- // user declined
- throw new RestartResponseException(getApplication().getHomePage());
- } else if (code == null) {
- throw new DisplayException("Missing authorization code");
- } else {
- ApplicationSettings settings = applicationSettingsService.get();
- String redirectUri = getCallbackUrl(settings.getPublicUrl());
- String clientId = settings.getGoogleClientId();
- String clientSecret = settings.getGoogleClientSecret();
-
- HttpTransport httpTransport = new NetHttpTransport();
- JacksonFactory jsonFactory = new JacksonFactory();
-
- AuthorizationCodeTokenRequest tokenRequest = new AuthorizationCodeTokenRequest(httpTransport, jsonFactory, new GenericUrl(
- TOKEN_URL), code);
- tokenRequest.setRedirectUri(redirectUri);
- tokenRequest.put("client_id", clientId);
- tokenRequest.put("client_secret", clientSecret);
- tokenRequest.setGrantType("authorization_code");
-
- try {
- // potential fix for invalid_grant error, happens if local
- // system time is ahead of google servers time
- Thread.sleep(1000);
- TokenResponse tokenResponse = tokenRequest.execute();
- String accessToken = tokenResponse.getAccessToken();
-
- HttpRequest httpRequest = httpTransport.createRequestFactory().buildGetRequest(new GenericUrl(EXPORT_URL));
- BearerToken.authorizationHeaderAccessMethod().intercept(httpRequest, accessToken);
- String opml = httpRequest.execute().parseAsString();
- User user = CommaFeedSession.get().getUser();
- if (user != null) {
- if (StartupBean.USERNAME_DEMO.equals(user.getName())) {
- throw new DisplayException("Import is disabled for the demo account");
- }
- importer.importOpml(CommaFeedSession.get().getUser(), opml);
- }
- } catch (Exception e) {
- throw new DisplayException(e);
- }
- }
- setResponsePage(getApplication().getHomePage());
- }
-}
diff --git a/src/main/java/com/commafeed/frontend/pages/GoogleImportRedirectPage.java b/src/main/java/com/commafeed/frontend/pages/GoogleImportRedirectPage.java
deleted file mode 100644
index ed60cbe2..00000000
--- a/src/main/java/com/commafeed/frontend/pages/GoogleImportRedirectPage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.commafeed.frontend.pages;
-
-import java.net.URISyntaxException;
-
-import javax.inject.Inject;
-
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.flow.RedirectToUrlException;
-import org.jboss.logging.Logger;
-
-import com.commafeed.backend.model.ApplicationSettings;
-import com.commafeed.backend.services.ApplicationSettingsService;
-
-@SuppressWarnings("serial")
-public class GoogleImportRedirectPage extends WebPage {
-
- private static Logger log = Logger.getLogger(GoogleImportRedirectPage.class);
-
- private static final String SCOPE = "https://www.google.com/reader/subscriptions/export email profile";
- private static final String AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
-
- @Inject
- ApplicationSettingsService applicationSettingsService;
-
- public GoogleImportRedirectPage() {
-
- ApplicationSettings settings = applicationSettingsService.get();
-
- String clientId = settings.getGoogleClientId();
-
- String redirectUri = GoogleImportCallbackPage.getCallbackUrl(settings.getPublicUrl());
- try {
- URIBuilder builder = new URIBuilder(AUTH_URL);
-
- builder.addParameter("redirect_uri", redirectUri);
- builder.addParameter("response_type", "code");
- builder.addParameter("scope", SCOPE);
- builder.addParameter("approval_prompt", "force");
- builder.addParameter("client_id", clientId);
- builder.addParameter("access_type", "offline");
-
- throw new RedirectToUrlException(builder.build().toString());
- } catch (URISyntaxException e) {
- log.error(e.getMessage(), e);
- }
-
- }
-}
diff --git a/src/main/java/com/commafeed/frontend/pages/components/RegisterPanel.java b/src/main/java/com/commafeed/frontend/pages/components/RegisterPanel.java
index 0df3a279..616c7055 100644
--- a/src/main/java/com/commafeed/frontend/pages/components/RegisterPanel.java
+++ b/src/main/java/com/commafeed/frontend/pages/components/RegisterPanel.java
@@ -14,6 +14,7 @@ import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;
@@ -26,7 +27,6 @@ import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.UserService;
import com.commafeed.frontend.CommaFeedSession;
import com.commafeed.frontend.model.request.RegistrationRequest;
-import com.commafeed.frontend.utils.ModelFactory.MF;
@SuppressWarnings("serial")
public class RegisterPanel extends Panel {
@@ -62,9 +62,8 @@ public class RegisterPanel extends Panel {
add(form);
add(new BootstrapFeedbackPanel("feedback", new ContainerFeedbackMessageFilter(form)));
- RegistrationRequest p = MF.p(RegistrationRequest.class);
- form.add(new RequiredTextField("name", MF.m(model, p.getName())).add(StringValidator.lengthBetween(3, 32)).add(
- new IValidator() {
+ form.add(new RequiredTextField("name", new PropertyModel(model, "name")).add(StringValidator.lengthBetween(3, 32))
+ .add(new IValidator() {
@Override
public void validate(IValidatable validatable) {
String name = validatable.getValue();
@@ -74,9 +73,9 @@ public class RegisterPanel extends Panel {
}
}
}));
- form.add(new PasswordTextField("password", MF.m(model, p.getPassword())).setResetPassword(false).add(
+ form.add(new PasswordTextField("password", new PropertyModel(model, "password")).setResetPassword(false).add(
StringValidator.minimumLength(6)));
- form.add(new RequiredTextField("email", MF.m(model, p.getEmail())) {
+ form.add(new RequiredTextField("email", new PropertyModel(model, "email")) {
@Override
protected String getInputType() {
return "email";
diff --git a/src/main/java/com/commafeed/frontend/resources/WroAdditionalProvider.java b/src/main/java/com/commafeed/frontend/resources/WroAdditionalProvider.java
index 950ad329..b7b85864 100644
--- a/src/main/java/com/commafeed/frontend/resources/WroAdditionalProvider.java
+++ b/src/main/java/com/commafeed/frontend/resources/WroAdditionalProvider.java
@@ -6,7 +6,7 @@ import ro.isdc.wro.model.resource.processor.ResourcePostProcessor;
import ro.isdc.wro.model.resource.processor.ResourcePreProcessor;
import ro.isdc.wro.model.resource.processor.support.ProcessorProvider;
-import com.google.api.client.util.Maps;
+import com.google.common.collect.Maps;
/**
* Build-time solution
diff --git a/src/main/java/com/commafeed/frontend/rest/RESTApplication.java b/src/main/java/com/commafeed/frontend/rest/RESTApplication.java
index d03e344d..eeb42c52 100644
--- a/src/main/java/com/commafeed/frontend/rest/RESTApplication.java
+++ b/src/main/java/com/commafeed/frontend/rest/RESTApplication.java
@@ -6,7 +6,6 @@ import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import com.commafeed.frontend.rest.resources.AdminREST;
-import com.commafeed.frontend.rest.resources.ApiDocumentationREST;
import com.commafeed.frontend.rest.resources.CategoryREST;
import com.commafeed.frontend.rest.resources.EntryREST;
import com.commafeed.frontend.rest.resources.FeedREST;
@@ -14,15 +13,10 @@ import com.commafeed.frontend.rest.resources.PubSubHubbubCallbackREST;
import com.commafeed.frontend.rest.resources.ServerREST;
import com.commafeed.frontend.rest.resources.UserREST;
import com.google.common.collect.Sets;
-import com.wordnik.swagger.jaxrs.JaxrsApiReader;
@ApplicationPath("/rest")
public class RESTApplication extends Application {
- static {
- JaxrsApiReader.setFormatString("");
- }
-
@Override
public Set> getClasses() {
Set> set = Sets.newHashSet();
@@ -35,7 +29,6 @@ public class RESTApplication extends Application {
set.add(ServerREST.class);
set.add(AdminREST.class);
- set.add(ApiDocumentationREST.class);
set.add(PubSubHubbubCallbackREST.class);
return set;
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java b/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java
index bc2ba7bc..788eb6f4 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java
@@ -33,6 +33,7 @@ import com.commafeed.frontend.SecurityCheck;
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
+@SecurityCheck(Role.USER)
public abstract class AbstractREST {
@Context
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/AbstractResourceREST.java b/src/main/java/com/commafeed/frontend/rest/resources/AbstractResourceREST.java
deleted file mode 100644
index 8cbebf01..00000000
--- a/src/main/java/com/commafeed/frontend/rest/resources/AbstractResourceREST.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.commafeed.frontend.rest.resources;
-
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.commafeed.backend.model.UserRole.Role;
-import com.commafeed.backend.services.ApplicationSettingsService;
-import com.commafeed.frontend.SecurityCheck;
-import com.commafeed.frontend.model.Entries;
-import com.commafeed.frontend.model.request.MarkRequest;
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-import com.wordnik.swagger.core.Documentation;
-import com.wordnik.swagger.core.SwaggerSpec;
-import com.wordnik.swagger.core.util.TypeUtil;
-import com.wordnik.swagger.jaxrs.HelpApi;
-import com.wordnik.swagger.jaxrs.JaxrsApiReader;
-
-@SecurityCheck(Role.USER)
-public abstract class AbstractResourceREST extends AbstractREST {
-
- @Inject
- ApplicationSettingsService applicationSettingsService;
-
- @GET
- @SecurityCheck(value = Role.NONE)
- @ApiOperation(value = "Returns information about API parameters", responseClass = "com.wordnik.swagger.core.Documentation")
- public Response getHelp(@Context Application app, @Context HttpHeaders headers, @Context UriInfo uriInfo) {
-
- TypeUtil.addAllowablePackage(Entries.class.getPackage().getName());
- TypeUtil.addAllowablePackage(MarkRequest.class.getPackage().getName());
-
- String apiVersion = ApiDocumentationREST.API_VERSION;
- String swaggerVersion = SwaggerSpec.version();
- String basePath = ApiDocumentationREST.getBasePath(applicationSettingsService.get().getPublicUrl());
-
- Class> resource = null;
- String path = prependSlash(uriInfo.getPath());
- for (Class> klass : app.getClasses()) {
- Api api = klass.getAnnotation(Api.class);
- if (api != null && api.value() != null && StringUtils.equals(prependSlash(api.value()), path)) {
- resource = klass;
- break;
- }
- }
-
- if (resource == null) {
- return Response.status(Status.NOT_FOUND).entity("Api annotation not found on class " + getClass().getName()).build();
- }
- Api api = resource.getAnnotation(Api.class);
- String apiPath = api.value();
- String apiListingPath = api.value();
-
- Documentation doc = new HelpApi(null).filterDocs(JaxrsApiReader.read(resource, apiVersion, swaggerVersion, basePath, apiPath),
- headers, uriInfo, apiListingPath, apiPath);
-
- doc.setSwaggerVersion(swaggerVersion);
- doc.setBasePath(basePath);
- doc.setApiVersion(apiVersion);
- return Response.ok().entity(doc).build();
- }
-
- private String prependSlash(String path) {
- if (!path.startsWith("/")) {
- path = "/" + path;
- }
- return path;
- }
-}
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java b/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java
index 638a9039..d1476e17 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java
@@ -33,6 +33,7 @@ import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole;
import com.commafeed.backend.model.UserRole.Role;
+import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.FeedService;
import com.commafeed.backend.services.PasswordEncryptionService;
import com.commafeed.backend.services.UserService;
@@ -51,7 +52,7 @@ import com.wordnik.swagger.annotations.ApiParam;
@SecurityCheck(Role.ADMIN)
@Path("/admin")
@Api(value = "/admin", description = "Operations about application administration")
-public class AdminREST extends AbstractResourceREST {
+public class AdminREST extends AbstractREST {
@Inject
FeedService feedService;
@@ -86,6 +87,9 @@ public class AdminREST extends AbstractResourceREST {
@Inject
PasswordEncryptionService encryptionService;
+ @Inject
+ ApplicationSettingsService applicationSettingsService;
+
@Path("/user/save")
@POST
@ApiOperation(value = "Save or update a user", notes = "Save or update a user. If the id is not specified, a new user will be created")
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/ApiDocumentationREST.java b/src/main/java/com/commafeed/frontend/rest/resources/ApiDocumentationREST.java
deleted file mode 100644
index e411b45a..00000000
--- a/src/main/java/com/commafeed/frontend/rest/resources/ApiDocumentationREST.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.commafeed.frontend.rest.resources;
-
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-import com.commafeed.backend.services.ApplicationSettingsService;
-import com.commafeed.frontend.model.Entries;
-import com.commafeed.frontend.model.request.MarkRequest;
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-import com.wordnik.swagger.core.Documentation;
-import com.wordnik.swagger.core.DocumentationEndPoint;
-import com.wordnik.swagger.core.SwaggerSpec;
-import com.wordnik.swagger.core.util.TypeUtil;
-
-@Path("/resources")
-@Api("/resources")
-public class ApiDocumentationREST extends AbstractREST {
-
- public static final String API_VERSION = "1.0";
-
- @Inject
- ApplicationSettingsService applicationSettingsService;
-
- @GET
- @ApiOperation(value = "Returns list of all available api endpoints", responseClass = "List[DocumentationEndPoint]")
- public Response getAllApis(@Context Application app) {
-
- TypeUtil.addAllowablePackage(Entries.class.getPackage().getName());
- TypeUtil.addAllowablePackage(MarkRequest.class.getPackage().getName());
-
- Documentation doc = new Documentation();
- for (Class> resource : app.getClasses()) {
- if (ApiDocumentationREST.class.equals(resource)) {
- continue;
- }
- Api api = resource.getAnnotation(Api.class);
- if (api != null) {
- doc.addApi(new DocumentationEndPoint(api.value(), api.description()));
- }
- }
-
- doc.setSwaggerVersion(SwaggerSpec.version());
- doc.setBasePath(getBasePath(applicationSettingsService.get().getPublicUrl()));
- doc.setApiVersion(API_VERSION);
-
- return Response.ok().entity(doc).build();
- }
-
- public static String getBasePath(String publicUrl) {
- if (!publicUrl.endsWith("/")) {
- publicUrl = publicUrl + "/";
- }
- publicUrl += "rest";
-
- return publicUrl;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/CategoryREST.java b/src/main/java/com/commafeed/frontend/rest/resources/CategoryREST.java
index 88a1b007..4be2cc2b 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/CategoryREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/CategoryREST.java
@@ -33,6 +33,7 @@ import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
+import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.FeedEntryService;
import com.commafeed.backend.services.FeedSubscriptionService;
import com.commafeed.frontend.SecurityCheck;
@@ -59,7 +60,7 @@ import com.wordnik.swagger.annotations.ApiParam;
@Path("/category")
@Api(value = "/category", description = "Operations about user categories")
-public class CategoryREST extends AbstractResourceREST {
+public class CategoryREST extends AbstractREST {
private static Logger log = LoggerFactory.getLogger(CategoryREST.class);
@@ -83,6 +84,9 @@ public class CategoryREST extends AbstractResourceREST {
@Inject
CacheService cache;
+
+ @Inject
+ ApplicationSettingsService applicationSettingsService;
@Path("/entries")
@GET
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/EntryREST.java b/src/main/java/com/commafeed/frontend/rest/resources/EntryREST.java
index c4dcbf5a..84145c84 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/EntryREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/EntryREST.java
@@ -20,6 +20,7 @@ import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
+import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.FeedEntryService;
import com.commafeed.frontend.model.Entries;
import com.commafeed.frontend.model.Entry;
@@ -33,7 +34,7 @@ import com.wordnik.swagger.annotations.ApiParam;
@Path("/entry")
@Api(value = "/entry", description = "Operations about feed entries")
-public class EntryREST extends AbstractResourceREST {
+public class EntryREST extends AbstractREST {
@Inject
FeedEntryService feedEntryService;
@@ -43,6 +44,9 @@ public class EntryREST extends AbstractResourceREST {
@Inject
FeedSubscriptionDAO feedSubscriptionDAO;
+
+ @Inject
+ ApplicationSettingsService applicationSettingsService;
@Path("/mark")
@POST
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java b/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java
index d1d5c9b2..04de9bc6 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java
@@ -55,6 +55,7 @@ import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
+import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.FeedEntryService;
import com.commafeed.backend.services.FeedSubscriptionService;
import com.commafeed.frontend.SecurityCheck;
@@ -82,7 +83,7 @@ import com.wordnik.swagger.annotations.ApiParam;
@Path("/feed")
@Api(value = "/feed", description = "Operations about feeds")
-public class FeedREST extends AbstractResourceREST {
+public class FeedREST extends AbstractREST {
private static Logger log = LoggerFactory.getLogger(FeedREST.class);
@@ -124,6 +125,9 @@ public class FeedREST extends AbstractResourceREST {
@Context
private HttpServletRequest request;
+
+ @Inject
+ ApplicationSettingsService applicationSettingsService;
@Path("/entries")
@GET
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/PubSubHubbubCallbackREST.java b/src/main/java/com/commafeed/frontend/rest/resources/PubSubHubbubCallbackREST.java
index a662e71d..a5f61861 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/PubSubHubbubCallbackREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/PubSubHubbubCallbackREST.java
@@ -28,16 +28,18 @@ import com.commafeed.backend.feeds.FeedParser;
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
import com.commafeed.backend.feeds.FetchedFeed;
import com.commafeed.backend.model.Feed;
+import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.services.ApplicationSettingsService;
-import com.google.api.client.repackaged.com.google.common.base.Preconditions;
+import com.commafeed.frontend.SecurityCheck;
+import com.google.common.base.Preconditions;
@Path("/push")
-public class PubSubHubbubCallbackREST {
+public class PubSubHubbubCallbackREST extends AbstractREST {
private static Logger log = LoggerFactory.getLogger(PubSubHubbubCallbackREST.class);
-
+
@Context
- HttpServletRequest request;
+ private HttpServletRequest request;
@Inject
FeedDAO feedDAO;
@@ -57,6 +59,7 @@ public class PubSubHubbubCallbackREST {
@Path("/callback")
@GET
@Produces(MediaType.TEXT_PLAIN)
+ @SecurityCheck(Role.NONE)
public Response verify(@QueryParam("hub.mode") String mode, @QueryParam("hub.topic") String topic,
@QueryParam("hub.challenge") String challenge, @QueryParam("hub.lease_seconds") String leaseSeconds,
@QueryParam("hub.verify_token") String verifyToken) {
@@ -87,6 +90,7 @@ public class PubSubHubbubCallbackREST {
@Path("/callback")
@POST
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
+ @SecurityCheck(Role.NONE)
public Response callback() {
if (!applicationSettingsService.get().isPubsubhubbub()) {
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java b/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java
index 5be802de..83c4d1ed 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java
@@ -13,19 +13,23 @@ import com.commafeed.backend.HttpGetter.HttpResult;
import com.commafeed.backend.StartupBean;
import com.commafeed.backend.feeds.FeedUtils;
import com.commafeed.backend.services.ApplicationPropertiesService;
+import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.frontend.model.ServerInfo;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@Path("/server")
@Api(value = "/server", description = "Operations about server infos")
-public class ServerREST extends AbstractResourceREST {
+public class ServerREST extends AbstractREST {
@Inject
StartupBean startupBean;
@Inject
HttpGetter httpGetter;
+
+ @Inject
+ ApplicationSettingsService applicationSettingsService;
@Path("/get")
@GET
diff --git a/src/main/java/com/commafeed/frontend/rest/resources/UserREST.java b/src/main/java/com/commafeed/frontend/rest/resources/UserREST.java
index dfd8d887..394b0fb9 100644
--- a/src/main/java/com/commafeed/frontend/rest/resources/UserREST.java
+++ b/src/main/java/com/commafeed/frontend/rest/resources/UserREST.java
@@ -37,7 +37,7 @@ import com.wordnik.swagger.annotations.ApiParam;
@Path("/user")
@Api(value = "/user", description = "Operations about the user")
-public class UserREST extends AbstractResourceREST {
+public class UserREST extends AbstractREST {
@Inject
UserDAO userDAO;
diff --git a/src/main/java/com/commafeed/frontend/utils/ModelFactory.java b/src/main/java/com/commafeed/frontend/utils/ModelFactory.java
deleted file mode 100644
index f6764f2c..00000000
--- a/src/main/java/com/commafeed/frontend/utils/ModelFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.commafeed.frontend.utils;
-
-import org.apache.wicket.model.PropertyModel;
-
-import ch.lambdaj.Lambda;
-import ch.lambdaj.function.argument.Argument;
-import ch.lambdaj.function.argument.ArgumentsFactory;
-
-/**
- * Utility class to generate PropertyModels in a type-safe way
- *
- */
-public class ModelFactory {
-
- public static String invokedProperty(T proxiedValue) {
- Argument a = ArgumentsFactory.actualArgument(proxiedValue);
- return a.getInkvokedPropertyName();
- }
-
- public static PropertyModel model(Object value, T proxiedValue) {
- String invokedPN = invokedProperty(proxiedValue);
- PropertyModel m = new PropertyModel(value, invokedPN);
- return m;
- }
-
- @SuppressWarnings("unchecked")
- public static T proxy(T t) {
- Object object = Lambda.on(t.getClass());
- return (T) object;
- }
-
- public static T proxy(Class clazz) {
- return Lambda.on(clazz);
- }
-
- /**
- * shortcuts to ModelFactory
- *
- */
- public static class MF {
-
- public static String i(T proxiedValue) {
- return ModelFactory.invokedProperty(proxiedValue);
- }
-
- public static PropertyModel m(Object value, T proxiedValue) {
- return ModelFactory.model(value, proxiedValue);
- }
-
- public static T p(T t) {
- return ModelFactory.proxy(t);
- }
-
- public static T p(Class clazz) {
- return ModelFactory.proxy(clazz);
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/script/SwaggerStaticGenerator.groovy b/src/main/script/SwaggerStaticGenerator.groovy
new file mode 100644
index 00000000..a0dec1d2
--- /dev/null
+++ b/src/main/script/SwaggerStaticGenerator.groovy
@@ -0,0 +1,57 @@
+import java.io.File;
+
+import org.apache.commons.io.FileUtils;
+
+import com.commafeed.frontend.model.Entries;
+import com.commafeed.frontend.model.request.MarkRequest;
+import com.commafeed.frontend.rest.RESTApplication;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.core.Documentation;
+import com.wordnik.swagger.core.DocumentationEndPoint;
+import com.wordnik.swagger.core.SwaggerSpec;
+import com.wordnik.swagger.core.util.TypeUtil;
+import com.wordnik.swagger.jaxrs.HelpApi;
+import com.wordnik.swagger.jaxrs.JaxrsApiReader;
+
+public class SwaggerStaticGenerator {
+ public void generate(String directory) throws Exception {
+
+ JaxrsApiReader.setFormatString("");
+ TypeUtil.addAllowablePackage(Entries.class.getPackage().getName());
+ TypeUtil.addAllowablePackage(MarkRequest.class.getPackage().getName());
+
+ RESTApplication app = new RESTApplication();
+
+ String apiVersion = "1.0";
+ String swaggerVersion = SwaggerSpec.version();
+ String basePath = "../rest";
+
+ Documentation doc = new Documentation();
+ for (Class> resource : app.getClasses()) {
+ Api api = resource.getAnnotation(Api.class);
+ if (api != null) {
+ String apiPath = api.value();
+ String apiListingPath = api.value();
+
+ Documentation apiDoc = new HelpApi(null).filterDocs(
+ JaxrsApiReader.read(resource, apiVersion, swaggerVersion, basePath, apiPath), null, null, apiListingPath, apiPath);
+
+ apiDoc.setSwaggerVersion(swaggerVersion);
+ apiDoc.setApiVersion(apiVersion);
+ write(apiDoc, directory);
+
+ doc.addApi(new DocumentationEndPoint(api.value(), api.description()));
+ }
+ }
+ doc.setSwaggerVersion(swaggerVersion);
+ doc.setApiVersion(apiVersion);
+
+ write(doc, directory);
+ }
+
+ private static void write(Documentation doc, String directory) throws Exception {
+ FileUtils.writeStringToFile(new File(directory, doc.getResourcePath() == null ? "resources" : doc.getResourcePath()), new ObjectMapper().writeValueAsString(doc));
+
+ }
+}
diff --git a/src/main/webapp/api/index.html b/src/main/webapp/api/index.html
index b380811b..cc9714fa 100644
--- a/src/main/webapp/api/index.html
+++ b/src/main/webapp/api/index.html
@@ -25,7 +25,7 @@
}
url = url.substring(0, url.length - 1);
url = url.substring(0, url.lastIndexOf('/'));
- url = url + '/rest/resources';
+ url = url + '/api/swagger-doc/resources';
window.swaggerUi = new SwaggerUi({
discoveryUrl:url,
apiKey:"",