Skip to content

Commit

Permalink
Merge branch 'master' into ZNTA-2173-hide-private-project
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 10, 2017
2 parents 98780bb + 93aa66f commit 9d574f6
Show file tree
Hide file tree
Showing 55 changed files with 2,045 additions and 2,326 deletions.
3 changes: 1 addition & 2 deletions Jenkinsfile
Expand Up @@ -214,7 +214,7 @@ timestamps {
clean install jxr:aggregate \
--batch-mode \
--update-snapshots \
-DstaticAnalysis \
-DstaticAnalysisCI \
$gwtOpts \
-DskipFuncTests \
-DskipArqTests \
Expand Down Expand Up @@ -285,7 +285,6 @@ timestamps {
//step([$class: 'PmdPublisher', pattern: '**/target/pmd.xml', unstableTotalAll:'0'])
//step([$class: 'DryPublisher', canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '**/cpd/cpdCheck.xml', unHealthy: ''])

// TODO reduce unstableTotal thresholds as bugs are eliminated
step([$class: 'FindBugsPublisher',
pattern: '**/findbugsXml.xml',
unstableTotalAll: '0'])
Expand Down
5 changes: 2 additions & 3 deletions client/zanata-client-commands/pom.xml
Expand Up @@ -158,9 +158,8 @@
<artifactId>simple</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
Expand Down
2 changes: 2 additions & 0 deletions docs/release-notes.md
Expand Up @@ -11,6 +11,7 @@ The property 'zanata.file.directory' is still supported, but if it is missing, a
* [ZNTA-2184](https://zanata.atlassian.net/browse/ZNTA-2184) - A better icon for role Requests in language
* [ZNTA-2172](https://zanata.atlassian.net/browse/ZNTA-2172) - Profile page should not render anything with inactive/non-existing account
* [ZNTA-2171](https://zanata.atlassian.net/browse/ZNTA-2171) - Storybook: reject with reason HISTORY UI
* [ZNTA-2161](https://zanata.atlassian.net/browse/ZNTA-2161) - Tooling to help developers use the correct yarn version
* [ZNTA-2156](https://zanata.atlassian.net/browse/ZNTA-2156) - Storybook: reject with reason MODAL UI
* [ZNTA-2147](https://zanata.atlassian.net/browse/ZNTA-2147) - Editor heading -> flex
* [ZNTA-2134](https://zanata.atlassian.net/browse/ZNTA-2134) - Help pages required for Version TM Merge
Expand All @@ -28,6 +29,7 @@ The property 'zanata.file.directory' is still supported, but if it is missing, a

##### Bug Fixes
* [ZNTA-2220](https://zanata.atlassian.net/browse/ZNTA-2220) - Dialogs have a "scroll line" on the right
* [ZNTA-2218](https://zanata.atlassian.net/browse/ZNTA-2218) - Translation Memory broken in GWT editor
* [ZNTA-2208](https://zanata.atlassian.net/browse/ZNTA-2208) - NotSupportedException on po/csv glossary import
* [ZNTA-2206](https://zanata.atlassian.net/browse/ZNTA-2206) - 404 page not found on help from more options
* [ZNTA-2201](https://zanata.atlassian.net/browse/ZNTA-2201) - updateGitHubCommitStatus should use the correct SHA in correct repo
Expand Down
37 changes: 35 additions & 2 deletions parent/pom.xml
Expand Up @@ -924,23 +924,56 @@
</profile>

<profile>
<!-- This profile is for *strict* local builds - the Maven build fails
if there is a problem -->
<id>staticAnalysis</id>
<activation>
<property>
<name>staticAnalysis</name>
<value>true</value>
</property>
</activation>
<build>
<properties>
<animal.sniffer.skip>false</animal.sniffer.skip>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<checkstyle.skip>false</checkstyle.skip>
<dupfind.skip>false</dupfind.skip>
<enforcer.skip>false</enforcer.skip>
<findbugs.skip>false</findbugs.skip>
<!-- takari doesn't support this yet: https://github.com/takari/takari-lifecycle/issues/39 -->
<maven.compiler.failOnWarning>true</maven.compiler.failOnWarning>
<mdep.analyze.skip>false</mdep.analyze.skip>
<!-- restrict-maven-plugin -->
<restrict.skip>false</restrict.skip>
</properties>
</profile>

</build>
<profile>
<!-- For Jenkins, we want to run static analysis, but for some plugins we
don't want Maven to fail the build - Jenkins will. (With some plugins, we
don't have that control, or Jenkins doesn't know how to check the
output.) -->
<id>staticAnalysisCI</id>
<activation>
<property>
<name>staticAnalysisCI</name>
<value>true</value>
</property>
</activation>
<properties>
<animal.sniffer.skip>false</animal.sniffer.skip>
<!-- These violations will be picked up by CheckStylePublisher -->
<checkstyle.failOnViolation>false</checkstyle.failOnViolation>
<checkstyle.skip>false</checkstyle.skip>
<dupfind.skip>false</dupfind.skip>
<enforcer.skip>false</enforcer.skip>
<!-- These violations will be picked up by FindBugsPublisher -->
<findbugs.failOnError>true</findbugs.failOnError>
<findbugs.skip>false</findbugs.skip>
<!-- These violations will be picked up by WarningsPublisher -->
<maven.compiler.failOnWarning>false</maven.compiler.failOnWarning>
<mdep.analyze.skip>false</mdep.analyze.skip>
<!-- restrict-maven-plugin -->
<restrict.skip>false</restrict.skip>
</properties>
</profile>
Expand Down
102 changes: 62 additions & 40 deletions server/pom.xml
Expand Up @@ -2160,7 +2160,44 @@
</target>
</configuration>
</execution>
<execution>
<!-- This can be run separately with mvn antrun:run@detekt -->
<id>detekt</id>
<!-- Profiles should use 'test' to activate this -->
<phase>none</phase>
<goals><goal>run</goal></goals>
<configuration>
<target name="detekt">
<java taskname="detekt" dir="${basedir}" fork="true" failonerror="true"
classname="io.gitlab.arturbosch.detekt.cli.Main" classpathref="maven.plugin.classpath">
<arg value="--config-resource"/>
<arg value="zanata-build-tools/detekt.yml"/>
<arg value="--project"/>
<arg value="${basedir}/src"/>
<arg value="--filters"/>
<arg value=".*test.*"/>
</java>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.zanata</groupId>
<artifactId>build-tools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-cli</artifactId>
<version>1.0.0.M11</version>
</dependency>
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-formatting</artifactId>
<version>1.0.0.M11</version>
</dependency>
</dependencies>
</plugin>
</plugins>

Expand Down Expand Up @@ -2201,12 +2238,6 @@
</goals>
</execution>
</executions>
<configuration>
<ignores>
<!-- not part of java18 sig, but seems to be public API -->
<ignore>jdk.nashorn.api.*</ignore>
</ignores>
</configuration>
</plugin>

<plugin>
Expand Down Expand Up @@ -2393,49 +2424,40 @@
<value>true</value>
</property>
</activation>
<!-- With kotlin-maven-plugin 1.2, we should be able to use <args>-Werror</args> -->
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<!--<version>1.8</version>-->
<executions>
<execution>
<!-- This can be run separately with mvn antrun:run@detekt -DstaticAnalysis -->
<id>detekt</id>
<phase>verify</phase>
<configuration>
<target name="detekt">
<java taskname="detekt" dir="${basedir}" fork="true" failonerror="true"
classname="io.gitlab.arturbosch.detekt.cli.Main" classpathref="maven.plugin.classpath">
<arg value="--config-resource"/>
<arg value="zanata-build-tools/detekt.yml"/>
<arg value="--project"/>
<arg value="${basedir}/src"/>
<arg value="--filters"/>
<arg value=".*test.*"/>
</java>
</target>
</configuration>
<goals><goal>run</goal></goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>staticAnalysisCI</id>
<activation>
<property>
<name>staticAnalysisCI</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>detekt</id>
<phase>test</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.zanata</groupId>
<artifactId>build-tools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-cli</artifactId>
<version>1.0.0.M11</version>
</dependency>
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-formatting</artifactId>
<version>1.0.0.M11</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
@@ -0,0 +1,139 @@
/*
* Copyright 2017, Red Hat, Inc. and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.zanata.rest.review;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.apache.deltaspike.jpa.api.transaction.Transactional;
import org.zanata.exception.ZanataServiceException;
import org.zanata.model.ReviewCriteria;
import org.zanata.rest.review.dto.TransReviewCriteria;
import org.zanata.security.annotations.CheckRole;
import com.google.common.annotations.VisibleForTesting;

/**
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
@RequestScoped
@Path("review")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class ReviewService {
@Inject
private EntityManager entityManager;

@Context
UriInfo uriInfo;

public ReviewService() {
}

@VisibleForTesting
protected ReviewService(EntityManager entityManager, UriInfo uriInfo) {
this.entityManager = entityManager;
this.uriInfo = uriInfo;
}

private static TransReviewCriteria fromModel(ReviewCriteria criteria) {
return new TransReviewCriteria(criteria.getId(), criteria.getPriority(),
criteria.getDescription(), criteria.isEditable());
}

@POST
@CheckRole("admin")
@Path("criteria")
@Transactional
public Response addCriteria(TransReviewCriteria criteria) {
ReviewCriteria reviewCriteria =
new ReviewCriteria(criteria.getPriority(),
criteria.isEditable(), criteria.getDescription());
entityManager.persist(reviewCriteria);
try {
return Response.created(new URI(uriInfo.getRequestUri() + "/" + reviewCriteria.getId()))
.entity(fromModel(reviewCriteria))
.build();
} catch (URISyntaxException e) {
throw new ZanataServiceException(e);
}
}

@PUT
@Path("criteria/{id}")
@CheckRole("admin")
@Transactional
public Response editCriteria(@PathParam("id") Long id, TransReviewCriteria criteria) {
ReviewCriteria reviewCriteria =
entityManager.find(ReviewCriteria.class, id);
if (reviewCriteria == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
reviewCriteria.setDescription(criteria.getDescription());
reviewCriteria.setEditable(criteria.isEditable());
reviewCriteria.setPriority(criteria.getPriority());
return Response.ok(fromModel(reviewCriteria)).build();
}

@DELETE
@Path("criteria/{id}")
@CheckRole("admin")
@Transactional
public Response deleteCriteria(@PathParam("id") Long id) {
ReviewCriteria reviewCriteria =
entityManager.find(ReviewCriteria.class, id);
if (reviewCriteria == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
TransReviewCriteria dto =
fromModel(reviewCriteria);
entityManager.remove(reviewCriteria);
return Response.ok(dto).build();
}

@GET
@Transactional(readOnly = true)
public Response getAllCriteria() {
List<ReviewCriteria> resultList = entityManager
.createQuery("from ReviewCriteria", ReviewCriteria.class)
.getResultList();
List<TransReviewCriteria> entity =
resultList.stream().map(ReviewService::fromModel).collect(
Collectors.toList());
return Response.ok(entity).build();
}
}

0 comments on commit 9d574f6

Please sign in to comment.