Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into rhbz1066756
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos A. Munoz committed Apr 7, 2014
2 parents ae3d184 + 5e0a2e9 commit 850b1e1
Show file tree
Hide file tree
Showing 40 changed files with 238 additions and 176 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/dealing-with-line-endings

# This setting tells git to always normalize the files specified.
# When committed they are stored with LF, on checkout they are
# This setting tells git always to normalize the files specified.
# When committed they are stored with LF, on checkout they are
# converted to the OS's native line endings.
* text

Expand Down
1 change: 0 additions & 1 deletion branch-release.sh
Expand Up @@ -19,4 +19,3 @@ git commit pom.xml */pom.xml -m "prepare for next development iteration"

# push all the changes back to the server
git push origin legacy release integration/master

15 changes: 11 additions & 4 deletions pom.xml
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>zanata-parent</artifactId>
<version>17</version>
<version>18-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>

Expand All @@ -31,11 +31,11 @@
<gwteventservice.version>1.2.1</gwteventservice.version>
<okapi.version>0.22</okapi.version>

<zanata.api.version>3.3.0</zanata.api.version>
<zanata.api.version>3.3.1-SNAPSHOT</zanata.api.version>
<!-- This should always be the previous version of the used api version above (but only 3.0.1 or later will work) -->
<zanata.api.compat.version>3.1.1</zanata.api.compat.version>
<zanata.api.compat.version>3.3.0</zanata.api.compat.version>
<zanata.client.version>3.3.0</zanata.client.version>
<zanata.common.version>3.0.2</zanata.common.version>
<zanata.common.version>3.3.0-SNAPSHOT</zanata.common.version>

<richfaces.version>4.3.4.Final</richfaces.version>

Expand Down Expand Up @@ -124,6 +124,13 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.opensymphony.quartz</groupId>
<artifactId>quartz</artifactId>
Expand Down
Expand Up @@ -69,6 +69,7 @@ public ConfigurableNgramAnalyzer(int ngramMinLength, int ngramMaxLength,
this.foldCase = foldCase;
}

@SuppressWarnings("resource") // caller should close
@Override
public TokenStream tokenStream(String fieldName, Reader reader) {
TokenStream tokenStream;
Expand Down
Expand Up @@ -20,12 +20,15 @@
*/
package org.zanata.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import javax.validation.constraints.NotNull;

import lombok.NoArgsConstructor;
Expand All @@ -46,7 +49,8 @@
@Setter
@NoArgsConstructor
@ToString(of = "comment")
public class HTermComment {
public class HTermComment implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;

private String comment;
Expand Down
3 changes: 1 addition & 2 deletions zanata-model/src/main/java/org/zanata/model/HTextFlow.java
Expand Up @@ -447,8 +447,7 @@ private void updateContentHash() {
this.setContentHash(HashUtil.generateHash(contents));
}

private String toBCP47(HLocale hLocale) {
HLocale docLocale = document.getLocale();
private static String toBCP47(HLocale docLocale) {
if (docLocale == null) {
// *should* only happen in tests
log.warn("null locale, assuming 'en'");
Expand Down
22 changes: 11 additions & 11 deletions zanata-model/src/test/java/org/zanata/model/HGlossaryEntryTest.java
Expand Up @@ -40,13 +40,13 @@ public class HGlossaryEntryTest {
@BeforeTest
public void setup() {
entry = new HGlossaryEntry();
entry.setId(new Long(1));
entry.setId(1L);
entry.setVersionNum(1);
entry.setCreationDate(new Date());
entry.setLastChanged(new Date());

HLocale srcLang = new HLocale(LocaleId.EN_US);
setupHLocale(srcLang, new Long(1));
setupHLocale(srcLang, 1L);

entry.setSrcLocale(srcLang);
entry.setSourceRef("source ref");
Expand All @@ -59,7 +59,7 @@ public void hashMapDataTerm1Test() {

// Glossary Term 1 - EN_US
HLocale term1Locale =
setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1));
setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L);

assertEquals(1, entry.getGlossaryTerms().size());
assertEquals(true, entry.getGlossaryTerms().containsKey(term1Locale));
Expand All @@ -74,11 +74,11 @@ public void hashMapDataTerm2Test() {

// Glossary Term 1 - EN_US
HLocale term1Locale =
setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1));
setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L);

// Glossary Term 2 - DE
HLocale term2Locale =
setupTerm(new Long(2), "TERM 2", LocaleId.DE, new Long(2));
setupTerm(2L, "TERM 2", LocaleId.DE, 2L);

assertEquals(2, entry.getGlossaryTerms().size());
assertEquals(true, entry.getGlossaryTerms().containsKey(term2Locale));
Expand All @@ -93,15 +93,15 @@ public void hashMapDataTerm3Test() {

// Glossary Term 1 - EN_US
HLocale term1Locale =
setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1));
setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L);

// Glossary Term 2 - DE
HLocale term2Locale =
setupTerm(new Long(2), "TERM 2", LocaleId.DE, new Long(2));
setupTerm(2L, "TERM 2", LocaleId.DE, 2L);

// Glossary Term 3 - ES
HLocale term3Locale =
setupTerm(new Long(3), "TERM 3", LocaleId.ES, new Long(3));
setupTerm(3L, "TERM 3", LocaleId.ES, 3L);

assertEquals(3, entry.getGlossaryTerms().size());
assertEquals(true, entry.getGlossaryTerms().containsKey(term3Locale));
Expand All @@ -115,13 +115,13 @@ public void hashMapDataTest() {
entry.getGlossaryTerms().clear();

// Glossary Term 1 - EN_US
setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1));
setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L);

// Glossary Term 2 - DE
setupTerm(new Long(2), "TERM 2", LocaleId.DE, new Long(2));
setupTerm(2L, "TERM 2", LocaleId.DE, 2L);

// Glossary Term 3 - ES
setupTerm(new Long(3), "TERM 3", LocaleId.ES, new Long(3));
setupTerm(3L, "TERM 3", LocaleId.ES, 3L);

for (HLocale key : entry.getGlossaryTerms().keySet()) {
assertTrue(entry.getGlossaryTerms().containsKey(key));
Expand Down
35 changes: 24 additions & 11 deletions zanata-war/pom.xml
Expand Up @@ -129,7 +129,6 @@
<usedDependency>javax.xml.bind:jaxb-api</usedDependency>
<!-- runtime dep for liquibase logging -->
<usedDependency>com.mattbertolini:liquibase-slf4j</usedDependency>
<usedDependency>com.google.code.findbugs:annotations</usedDependency>
<usedDependency>org.opensymphony.quartz:quartz</usedDependency>
<!-- Used indirectly by org.zanata.arquillian.Deployments -->
<usedDependency>org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api</usedDependency>
Expand Down Expand Up @@ -335,7 +334,7 @@
</manifest>
<manifestEntries>
<Implementation-Build>${maven.build.timestamp}</Implementation-Build>
<SCM-Changeset>${changeSet}</SCM-Changeset>
<SCM-Describe>${gitDescribe}</SCM-Describe>
</manifestEntries>
</archive>
</configuration>
Expand Down Expand Up @@ -442,22 +441,17 @@

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<argLine>-Dconcordion.output.dir=${concordion.output.dir}</argLine>
<junitArtifactName>none:none</junitArtifactName>
<testNGArtifactName>org.testng:testng</testNGArtifactName>
<forkMode>once</forkMode>
<argLine xml:space="preserve">-Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=${project.build.directory} -Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
<forkCount>1.5C</forkCount>
<reuseForks>false</reuseForks>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/AllNonContainerTests.tng.xml</suiteXmlFile>
</suiteXmlFiles>
<runOrder>alphabetical</runOrder>
<!-- TODO try parallel execution
<parallel>methods</parallel>
<threadCount>4</threadCount>
-->
</configuration>
<!-- below trick is to let surefire run both junit and testng.
see http://stackoverflow.com/questions/1232853/how-to-execute-junit-and-testng-tests-in-same-project-using-maven-surefire-plugi-->
Expand Down Expand Up @@ -1015,7 +1009,7 @@
</property>
</activation>
<properties>
<groovy.eclipse.compiler.version>2.9.0-01-20130710.222406-4</groovy.eclipse.compiler.version>
<groovy.eclipse.compiler.version>2.9.0-01-20140221.234306-6</groovy.eclipse.compiler.version>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -1115,6 +1109,13 @@

<dependencies>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>


<!-- Zanata-specific dependencies -->

<dependency>
Expand Down Expand Up @@ -2016,6 +2017,18 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>se.jiderhamn</groupId>
<artifactId>classloader-leak-prevention</artifactId>
<version>1.9.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- missing dependencies identified by mvn dependency:analyze: -->

<dependency>
Expand Down
1 change: 0 additions & 1 deletion zanata-war/src/etc/FillInTranslationGap.groovy
Expand Up @@ -70,4 +70,3 @@ genPropNames.each {
}
log.info("processed {}", skeleton.name)
}

Expand Up @@ -94,6 +94,10 @@ public class ApplicationConfiguration implements Serializable {
@Setter
private String buildTimestamp;

@Getter
@Setter
private String scmDescribe;

@Getter
private boolean copyTransEnabled = true;

Expand Down
37 changes: 15 additions & 22 deletions zanata-war/src/main/java/org/zanata/ZanataInit.java
Expand Up @@ -49,6 +49,8 @@
import org.jboss.seam.contexts.ServletLifecycle;
import org.jboss.seam.core.Events;
import org.zanata.exception.ZanataInitializationException;
import org.zanata.rest.dto.VersionInfo;
import org.zanata.util.VersionUtility;

import com.beust.jcommander.internal.Lists;

Expand All @@ -72,7 +74,6 @@ public class ZanataInit {
}

public static final String EVENT_Zanata_Startup = "Zanata.startup";
public static final String UNKNOWN_VERSION = "UNKNOWN";

@In
private ApplicationConfiguration applicationConfiguration;
Expand All @@ -84,9 +85,9 @@ public void initZanata() throws Exception {
String appServerHome = servletContext.getRealPath("/");

File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");
String version = "UNKOWN";
String buildTimestamp = "UNKOWN";

VersionInfo ver = new VersionInfo();
Attributes atts = null;
if (manifestFile.canRead()) {
Manifest mf = new Manifest();
final FileInputStream fis = new FileInputStream(manifestFile);
Expand All @@ -95,24 +96,15 @@ public void initZanata() throws Exception {
} finally {
fis.close();
}

Attributes atts = mf.getMainAttributes();

version = atts.getValue("Implementation-Version");
buildTimestamp = atts.getValue("Implementation-Build");

if (version == null) {
version = UNKNOWN_VERSION;
}
if (buildTimestamp == null) {
buildTimestamp = UNKNOWN_VERSION;
}
this.applicationConfiguration.setVersion(version);
this.applicationConfiguration.setBuildTimestamp(buildTimestamp);

atts = mf.getMainAttributes();
}
ver = VersionUtility.getVersionInfo(atts, ZanataInit.class);

this.applicationConfiguration.setVersion(ver.getVersionNo());
this.applicationConfiguration.setBuildTimestamp(ver.getBuildTimeStamp());
this.applicationConfiguration.setScmDescribe(ver.getScmDescribe());

this.logBanner(version, buildTimestamp);
logBanner(ver);

if (this.applicationConfiguration.isDebug()) {
log.info("debug: enabled");
Expand Down Expand Up @@ -310,16 +302,17 @@ private static void list(Context ctx, String indent, StringBuffer buffer,
}
}

private void logBanner(final String version, final String build) {
private void logBanner(VersionInfo ver) {
log.info("============================================");
log.info(" _____ _ ");
log.info(" |__ /__ _ _ __ __ _| |_ __ _ ");
log.info(" / // _' | '_ \\ / _' | __/ _' | ");
log.info(" / /| (_| | | | | (_| | || (_| | ");
log.info(" /____\\__,_|_| |_|\\__,_|\\__\\__,_| ");
log.info(" ");
log.info(" version " + version + ", build " + build);
log.info(" Red Hat Inc 2012");
log.info(" Version: " + ver.getVersionNo());
log.info(" SCM: " + ver.getScmDescribe());
log.info(" Red Hat Inc 2008-2014");
log.info("============================================");
}
}
Expand Up @@ -159,15 +159,16 @@ public Status(String locale, String nativeName,

@Override
public int compareTo(Status o) {
int per =
getStats().getTotal() == 0 ? 0 : (int) Math.ceil(100.0
* getStats().getApproved() / getStats().getTotal());
int comparePer =
o.getStats().getTotal() == 0 ? 0 : (int) Math.ceil(100.0
* o.getStats().getApproved()
/ o.getStats().getTotal());

return Double.compare(comparePer, per);
// TODO compare by locale too?
// TODO if totals are the same, we only need to compare approved
return Double.compare(o.getPercentApproved(), getPercentApproved());
}

private double getPercentApproved() {
// TODO move to TranslationStatistics.getPercentApproved() ?
long total = getStats().getTotal();
long approved = getStats().getApproved();
return total == 0 ? 0 : 100d * approved / total;
}
}

Expand Down
2 changes: 1 addition & 1 deletion zanata-war/src/main/java/org/zanata/dao/AccountDAO.java
Expand Up @@ -157,6 +157,6 @@ public List<HAccount> getAllMergedAccounts(HAccount mergedInto) {
"from HAccount as a where a.mergedInto = :mergedInto");
query.setParameter("mergedInto", mergedInto);
query.setComment("AccountDAO.getAllMergedAccounts");
return query.list();
return (List<HAccount>) query.list();
}
}
2 changes: 1 addition & 1 deletion zanata-war/src/main/java/org/zanata/dao/ActivityDAO.java
Expand Up @@ -99,7 +99,7 @@ public List<Activity> findLatestActivities(long personId, int offset,
query.setFirstResult(offset);
query.setCacheable(true);
query.setComment("activityDAO.findLatestActivities");
return query.list();
return (List<Activity>) query.list();
}

public int getActivityCountByActor(Long personId) {
Expand Down

0 comments on commit 850b1e1

Please sign in to comment.