Skip to content
Snippets Groups Projects
Commit fde60129 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

Merge branch 'sonar_suggestions' into 'stable'

use sonar maven plugin at dockerhost:9000 + many fixes according to sonar report



See merge request !9
parents d493cd17 dc9787ae
No related branches found
No related tags found
No related merge requests found
...@@ -180,6 +180,9 @@ ...@@ -180,6 +180,9 @@
<asciidoctor.maven.plugin.version>1.5.3</asciidoctor.maven.plugin.version> <asciidoctor.maven.plugin.version>1.5.3</asciidoctor.maven.plugin.version>
<asciidoctorj.pdf.version>1.5.0-alpha.11</asciidoctorj.pdf.version> <asciidoctorj.pdf.version>1.5.0-alpha.11</asciidoctorj.pdf.version>
<asciidoctorj.version>1.5.4</asciidoctorj.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> </properties>
<build> <build>
...@@ -264,6 +267,11 @@ ...@@ -264,6 +267,11 @@
</attributes> </attributes>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
</plugins> </plugins>
</build> </build>
......
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
...@@ -166,11 +166,10 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { ...@@ -166,11 +166,10 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
try { try {
String userJSON = mapper.writeValueAsString(getUser()); String userJSON = mapper.writeValueAsString(getUser());
Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON, "UTF-8")); Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON, "UTF-8"));
cookie.setSecure(true);
cookie.setPath("/"); cookie.setPath("/");
response.addCookie(cookie); response.addCookie(cookie);
} catch (JsonProcessingException e) { } catch (JsonProcessingException | UnsupportedEncodingException e) {
LOGGER.trace(e);
} catch (UnsupportedEncodingException e) {
LOGGER.trace(e); LOGGER.trace(e);
} }
return principal; return principal;
......
...@@ -96,6 +96,7 @@ public class ExperimentApi { ...@@ -96,6 +96,7 @@ public class ExperimentApi {
transaction.commit(); transaction.commit();
session.close(); session.close();
} catch (DataException e) { } catch (DataException e) {
LOGGER.trace(e);
throw e; throw e;
} }
...@@ -263,6 +264,7 @@ public class ExperimentApi { ...@@ -263,6 +264,7 @@ public class ExperimentApi {
transaction.commit(); transaction.commit();
session.close(); session.close();
} catch (DataException e) { } catch (DataException e) {
LOGGER.trace(e);
throw e; throw e;
} }
...@@ -447,7 +449,8 @@ public class ExperimentApi { ...@@ -447,7 +449,8 @@ public class ExperimentApi {
if (modelSlug == null || "".equals(modelSlug)) { if (modelSlug == null || "".equals(modelSlug)) {
hibernateQuery = session.createQuery(baseQuery); hibernateQuery = session.createQuery(baseQuery);
} else { } 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("slug", modelSlug);
} }
hibernateQuery.setParameter("user", user); hibernateQuery.setParameter("user", user);
...@@ -469,6 +472,7 @@ public class ExperimentApi { ...@@ -469,6 +472,7 @@ public class ExperimentApi {
} }
} catch (Exception e) { } catch (Exception e) {
// 404 here probably // 404 here probably
LOGGER.trace(e);
throw e; throw e;
} finally { } finally {
if(session.getTransaction() != null) if(session.getTransaction() != null)
......
...@@ -26,12 +26,12 @@ public class Article { ...@@ -26,12 +26,12 @@ public class Article {
@NotNull @NotNull
@Size(min = 1, max = 255) @Size(min = 1, max = 255)
private String title = null; private String title;
private String status = null; private String status = null;
@Column(columnDefinition = "text") @Column(columnDefinition = "text", name = "abstract")
private String _abstract = null; private String abstractText = null;
@Column(columnDefinition = "text") @Column(columnDefinition = "text")
private String content = null; private String content = null;
...@@ -58,6 +58,7 @@ public class Article { ...@@ -58,6 +58,7 @@ public class Article {
/* /*
* Empty constructor is needed by Hibernate * Empty constructor is needed by Hibernate
*/ */
title = "";
} }
...@@ -90,11 +91,11 @@ public class Article { ...@@ -90,11 +91,11 @@ public class Article {
@JsonProperty("abstract") @JsonProperty("abstract")
public String getAbstract() { public String getAbstract() {
return _abstract; return abstractText;
} }
public void setAbstract(String _abstract) { public void setAbstract(String abstractText) {
this._abstract = _abstract; this.abstractText = abstractText;
} }
......
...@@ -9,6 +9,7 @@ import java.io.IOException; ...@@ -9,6 +9,7 @@ import java.io.IOException;
*/ */
public class CORSFilter implements Filter { public class CORSFilter implements Filter {
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res; HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Origin", "*");
...@@ -18,10 +19,12 @@ public class CORSFilter implements Filter { ...@@ -18,10 +19,12 @@ public class CORSFilter implements Filter {
chain.doFilter(req, res); chain.doFilter(req, res);
} }
@Override
public void init(FilterConfig filterConfig) { public void init(FilterConfig filterConfig) {
/* Nothing to do */ /* Nothing to do */
} }
@Override
public void destroy() { public void destroy() {
/* Nothing to do */ /* Nothing to do */
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment