diff --git a/pom.xml b/pom.xml index d776d26fba7817cf6977fb68282dc88837c25975..a9cb39f28e7cf809c411420afed6756ec9965b9e 100644 --- a/pom.xml +++ b/pom.xml @@ -180,6 +180,9 @@ <asciidoctor.maven.plugin.version>1.5.3</asciidoctor.maven.plugin.version> <asciidoctorj.pdf.version>1.5.0-alpha.11</asciidoctorj.pdf.version> <asciidoctorj.version>1.5.4</asciidoctorj.version> + <sonar.host.url>http://dockerhost:9000</sonar.host.url> + <sonar.projectName>MIP Backend</sonar.projectName> + <sonar.sources>src/main/java/</sonar.sources> </properties> <build> @@ -264,6 +267,11 @@ </attributes> </configuration> </plugin> + <plugin> + <groupId>org.sonarsource.scanner.maven</groupId> + <artifactId>sonar-maven-plugin</artifactId> + <version>3.0.1</version> + </plugin> </plugins> </build> diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 2897991fa1987310aeeb244710e2ab99372ebeeb..0000000000000000000000000000000000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,4 +0,0 @@ -sonar.projectName=MIP Backend - stable -sonar.projectVersion=1.0 -sonar.projectKey=mip:backend:stable -sonar.sources=./src/main/java/ \ No newline at end of file diff --git a/src/main/java/org/hbp/mip/MIPApplication.java b/src/main/java/org/hbp/mip/MIPApplication.java index e721ed77483285090be89a972ddf98d54881db3c..f6d5aeb3d156eeac8afd31340c8bf1b190065e61 100644 --- a/src/main/java/org/hbp/mip/MIPApplication.java +++ b/src/main/java/org/hbp/mip/MIPApplication.java @@ -166,11 +166,10 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { try { String userJSON = mapper.writeValueAsString(getUser()); Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON, "UTF-8")); + cookie.setSecure(true); cookie.setPath("/"); response.addCookie(cookie); - } catch (JsonProcessingException e) { - LOGGER.trace(e); - } catch (UnsupportedEncodingException e) { + } catch (JsonProcessingException | UnsupportedEncodingException e) { LOGGER.trace(e); } return principal; diff --git a/src/main/java/org/hbp/mip/controllers/ExperimentApi.java b/src/main/java/org/hbp/mip/controllers/ExperimentApi.java index 0281039e3bb3bce2d514418cfc76fc25b4e0c2ca..c6fe664376c58e1b2646a745bf5873f1da7b736d 100644 --- a/src/main/java/org/hbp/mip/controllers/ExperimentApi.java +++ b/src/main/java/org/hbp/mip/controllers/ExperimentApi.java @@ -96,6 +96,7 @@ public class ExperimentApi { transaction.commit(); session.close(); } catch (DataException e) { + LOGGER.trace(e); throw e; } @@ -263,6 +264,7 @@ public class ExperimentApi { transaction.commit(); session.close(); } catch (DataException e) { + LOGGER.trace(e); throw e; } @@ -447,7 +449,8 @@ public class ExperimentApi { if (modelSlug == null || "".equals(modelSlug)) { hibernateQuery = session.createQuery(baseQuery); } else { - hibernateQuery = session.createQuery(baseQuery + " AND e.model.slug = :slug"); + baseQuery += " AND e.model.slug = :slug"; + hibernateQuery = session.createQuery(baseQuery); hibernateQuery.setParameter("slug", modelSlug); } hibernateQuery.setParameter("user", user); @@ -469,6 +472,7 @@ public class ExperimentApi { } } catch (Exception e) { // 404 here probably + LOGGER.trace(e); throw e; } finally { if(session.getTransaction() != null) diff --git a/src/main/java/org/hbp/mip/model/Article.java b/src/main/java/org/hbp/mip/model/Article.java index 26e36e60fc49e1d6e3b3adad37555e8e4671f26b..b7821db0ca22566bb2aff06a847d566fff0a40e7 100644 --- a/src/main/java/org/hbp/mip/model/Article.java +++ b/src/main/java/org/hbp/mip/model/Article.java @@ -26,12 +26,12 @@ public class Article { @NotNull @Size(min = 1, max = 255) - private String title = null; + private String title; private String status = null; - @Column(columnDefinition = "text") - private String _abstract = null; + @Column(columnDefinition = "text", name = "abstract") + private String abstractText = null; @Column(columnDefinition = "text") private String content = null; @@ -58,6 +58,7 @@ public class Article { /* * Empty constructor is needed by Hibernate */ + title = ""; } @@ -90,11 +91,11 @@ public class Article { @JsonProperty("abstract") public String getAbstract() { - return _abstract; + return abstractText; } - public void setAbstract(String _abstract) { - this._abstract = _abstract; + public void setAbstract(String abstractText) { + this.abstractText = abstractText; } diff --git a/src/main/java/org/hbp/mip/utils/CORSFilter.java b/src/main/java/org/hbp/mip/utils/CORSFilter.java index 02349cffae160c1f7fcc221676074ef7de84a452..9feb2895dd7af50acfcb61e0e35810e3a71d2ebe 100644 --- a/src/main/java/org/hbp/mip/utils/CORSFilter.java +++ b/src/main/java/org/hbp/mip/utils/CORSFilter.java @@ -9,6 +9,7 @@ import java.io.IOException; */ public class CORSFilter implements Filter { + @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*"); @@ -18,10 +19,12 @@ public class CORSFilter implements Filter { chain.doFilter(req, res); } + @Override public void init(FilterConfig filterConfig) { /* Nothing to do */ } + @Override public void destroy() { /* Nothing to do */ }