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

Commit

Permalink
Merge pull request #402 from zanata/gitDescribe
Browse files Browse the repository at this point in the history
Show SCM id instead of build timestamp; refactor extraction of build met...
  • Loading branch information
carlosmunoz committed Mar 24, 2014
2 parents c1c04a2 + f7a5fb8 commit 6724cf1
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 51 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -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
2 changes: 1 addition & 1 deletion zanata-war/pom.xml
Expand Up @@ -1015,7 +1015,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 @@ -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("============================================");
}
}
2 changes: 1 addition & 1 deletion zanata-war/src/main/resources/messages.properties
Expand Up @@ -103,7 +103,7 @@ jsf.IrcHelp=IRC Help
jsf.FAQ=FAQ
jsf.SiteMap=Site map

jsf.RunningVersionInfo=<a href="http://zanata.org/" target="_blank">#{messages['jsf.Zanata']}</a> #{applicationConfiguration.version} (#{applicationConfiguration.buildTimestamp})
jsf.RunningVersionInfo=<a href="http://zanata.org/" target="_blank">#{messages['jsf.Zanata']}</a> #{applicationConfiguration.version} (#{applicationConfiguration.scmDescribe})
! &#169; is a copyright symbol
! "Red Hat, Inc" should only be translated to an alternative legal name for the same entity. If in doubt, leave it as-is.
jsf.CopyrightNotice=Copyright &#169; 2008-14 <a href="http://www.redhat.com/" target="_blank">Red Hat, Inc</a>
Expand Down
Expand Up @@ -22,9 +22,11 @@

import org.dbunit.operation.DatabaseOperation;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.junit.Before;
import org.junit.Test;
import org.zanata.RestTest;
import org.zanata.provider.DBUnitProvider;
import org.zanata.apicompat.rest.client.IStatisticsResource;
import org.zanata.apicompat.rest.dto.stats.ContainerTranslationStatistics;
import org.zanata.apicompat.rest.dto.stats.TranslationStatistics;
import org.zanata.apicompat.rest.service.StatisticsResource;
Expand All @@ -41,6 +43,16 @@
*/
public class StatisticsCompatibilityITCase extends RestTest {

private StatisticsResource statsResource;

@Before
public void before() {
statsResource =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
IStatisticsResource.class);
}

@Override
protected void prepareDBUnitOperations() {
addBeforeTestOperation(new DBUnitProvider.DataSetOperation(
Expand Down Expand Up @@ -70,11 +82,6 @@ protected void prepareDBUnitOperations() {
@Test
@RunAsClient
public void getStatisticsForIteration() throws Exception {
StatisticsResource statsResource =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
StatisticsResource.class, "/");

ContainerTranslationStatistics stats =
statsResource.getStatistics("sample-project", "1.0", true,
true, null);
Expand Down Expand Up @@ -120,11 +127,6 @@ public void getStatisticsForIteration() throws Exception {
@Test
@RunAsClient
public void getStatisticsForDocument() throws Exception {
StatisticsResource statsResource =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
StatisticsResource.class, "/");

ContainerTranslationStatistics stats =
statsResource.getStatistics("sample-project", "1.0",
"my/path/document.txt", true, null);
Expand Down Expand Up @@ -167,11 +169,6 @@ public void getStatisticsForDocument() throws Exception {
@Test
@RunAsClient
public void getStatisticsForIterationAndLocale() throws Exception {
StatisticsResource statsResource =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
StatisticsResource.class, "/");

ContainerTranslationStatistics stats =
statsResource.getStatistics("sample-project", "1.0", true,
false, new String[] { "as" });
Expand Down Expand Up @@ -209,11 +206,6 @@ public void getStatisticsForIterationAndLocale() throws Exception {
@Test
@RunAsClient
public void getStatisticsForDocumentAndLocale() throws Exception {
StatisticsResource statsResource =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
StatisticsResource.class, "/");

ContainerTranslationStatistics stats =
statsResource.getStatistics("sample-project", "1.0",
"my/path/document.txt", true, new String[] { "as" });
Expand Down
Expand Up @@ -41,10 +41,7 @@ public void getVersionXml() {
IVersionResource versionClient =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
IVersionResource.class,
// TODO remove this parameter after upgrading
// to apicompat 3.2
"/version");
IVersionResource.class);
VersionInfo versionInfo = versionClient.get().getEntity();

assertThat(versionInfo.getVersionNo(), notNullValue());
Expand Down

0 comments on commit 6724cf1

Please sign in to comment.