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

Commit

Permalink
Merge branch 'master' into isolate-file-storage
Browse files Browse the repository at this point in the history
Conflicts:
	zanata-war/src/main/java/org/zanata/file/GlobalDocumentId.java
        lombok annotations added in remote, toString added in local.
        kept changes from remote + toString method.
  • Loading branch information
davidmason committed Jul 24, 2013
2 parents bea5282 + 6cd9947 commit dbcf19a
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 17 deletions.
2 changes: 2 additions & 0 deletions zanata-war/pom.xml
Expand Up @@ -39,6 +39,8 @@
<!-- Groovy and Gmaven properties -->
<gmavenProviderSelection>2.0</gmavenProviderSelection>
<groovyVersion>2.0.7</groovyVersion>

<zanata.web.assets.version>1</zanata.web.assets.version>
</properties>

<build>
Expand Down
10 changes: 10 additions & 0 deletions zanata-war/src/main/java/org/zanata/ApplicationConfiguration.java
Expand Up @@ -49,6 +49,7 @@
import org.zanata.log4j.ZanataHTMLLayout;
import org.zanata.log4j.ZanataSMTPAppender;
import org.zanata.security.AuthenticationType;
import com.google.common.base.Objects;

@Name("applicationConfiguration")
@Scope(ScopeType.APPLICATION)
Expand Down Expand Up @@ -76,6 +77,9 @@ public class ApplicationConfiguration implements Serializable
private Map<AuthenticationType, String> loginModuleNames = new HashMap<AuthenticationType, String>();
private Set<String> adminUsers = new HashSet<String>();

// set by component.xml
private String webAssetsVersion = "";

@Observer( { EVENT_CONFIGURATION_CHANGED })
@Create
public void load()
Expand Down Expand Up @@ -378,4 +382,10 @@ public boolean useEmailServerSsl()
{
return jndiBackedConfig.getStmpUsesSsl() != null ? Boolean.parseBoolean(jndiBackedConfig.getStmpUsesSsl()) : false;
}

public String getWebAssetsUrl()
{
return String.format("%s/%s/assets/css/style.css",
Objects.firstNonNull(jndiBackedConfig.getWebAssetsUrlBase(), "//assets-zanata.rhcloud.com"), webAssetsVersion);
}
}
Expand Up @@ -61,6 +61,7 @@ public class JndiBackedConfig implements Serializable
private static final String KEY_EMAIL_PASSWORD = "java:global/zanata/smtp/password";
private static final String KEY_EMAIL_TLS = "java:global/zanata/smtp/tls";
private static final String KEY_EMAIL_SSL = "java:global/zanata/smtp/ssl";
private static final String KEY_WEB_ASSETS_URL_BASE = "java:global/zanata/webassets/url-base";

private Map<String, String> configurationValues;

Expand Down Expand Up @@ -194,4 +195,9 @@ public String getStmpUsesSsl()
{
return getConfigValue(KEY_EMAIL_SSL);
}

public String getWebAssetsUrlBase()
{
return getConfigValue(KEY_WEB_ASSETS_URL_BASE);
}
}
Expand Up @@ -25,9 +25,11 @@
import java.util.Iterator;
import java.util.NoSuchElementException;

import org.hibernate.HibernateException;
import lombok.extern.slf4j.Slf4j;

import org.hibernate.ScrollableResults;

@Slf4j
class ScrollableResultsIterator implements Iterator<Object[]>, Closeable
{
private boolean closed;
Expand Down Expand Up @@ -82,8 +84,11 @@ public boolean hasNext()
catch (RuntimeException e)
{
// UGLY hack to work around https://hibernate.atlassian.net/browse/HHH-2811
if (e.getMessage() != null && e.getMessage().contains("could not perform sequential read of results (forward)"))
if (e.getMessage() != null &&
(e.getMessage().contains("could not perform sequential read of results (forward)") ||
e.getMessage().contains("could not doAfterTransactionCompletion sequential read of results (forward)")))
{
log.debug("assuming empty ResultSet", e);
close();
return false;
}
Expand Down
19 changes: 8 additions & 11 deletions zanata-war/src/main/java/org/zanata/file/GlobalDocumentId.java
@@ -1,21 +1,18 @@
package org.zanata.file;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;

@Getter
@AllArgsConstructor
@EqualsAndHashCode
public class GlobalDocumentId
{

private final String projectSlug;
private final String versionSlug;
private final String docId;

public GlobalDocumentId(String projectSlug, String versionSlug, String docId)
{
this.projectSlug = projectSlug;
this.versionSlug = versionSlug;
this.docId = docId;
}
@NonNull private final String projectSlug;
@NonNull private final String versionSlug;
@NonNull private final String docId;

@Override
public String toString()
Expand Down
Expand Up @@ -17,8 +17,7 @@
<link rel="stylesheet" href="gwt/standard/standard.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/resources/fontello/css/fontello.css"/>
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/resources/css/menu.css"/>
<!-- see http://stackoverflow.com/questions/2725523/how-to-include-css-and-js-files-via-https-when-needed-->
<link type="text/css" rel="stylesheet" href="//webassets-zanata.rhcloud.com/1/assets/css/style.css"/>
<link type="text/css" rel="stylesheet" href="#{applicationConfiguration.webAssetsUrl}"/>

<script src="codemirror-compressed.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="codemirror.css"/>
Expand Down
Expand Up @@ -116,6 +116,7 @@
<component class="org.zanata.ApplicationConfiguration" name="applicationConfiguration" precedence="30">
<property name="debug">@env.debug@</property>
<property name="authenticatedSessionTimeoutMinutes">180</property>
<property name="webAssetsVersion">@web.assets.version@</property>
</component>

<!-- Zanata Background Job scheduler.
Expand Down
Expand Up @@ -4,3 +4,4 @@
env.debug=${env.debug}
env.dbunit.type=${env.dbunit.type}
persistence-unit-name=${ds.jndi.name}PU
web.assets.version=${zanata.web.assets.version}
1 change: 1 addition & 0 deletions zanata-war/src/main/webapp/WEB-INF/layout/template.xhtml
Expand Up @@ -19,6 +19,7 @@
<h:outputStylesheet library="css" name="menu.css" />
<h:outputStylesheet library="css" name="jsf-skin.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/resources/fontello/css/fontello.css"/>
<link type="text/css" rel="stylesheet" href="#{applicationConfiguration.webAssetsUrl}"/>
<ui:insert name="head" />
</h:head>

Expand Down
Expand Up @@ -18,7 +18,12 @@ public class GlobalDocumentIdTest
@BeforeMethod
public void setup()
{
id = new GlobalDocumentId(PROJECT_SLUG, VERSION_SLUG, DOCUMENT_ID);
id = newBasicInstance();
}

private GlobalDocumentId newBasicInstance()
{
return new GlobalDocumentId(PROJECT_SLUG, VERSION_SLUG, DOCUMENT_ID);
}

public void getDocId()
Expand All @@ -35,4 +40,22 @@ public void getProjectSlug()
{
assertThat(id.getProjectSlug(), is(PROJECT_SLUG));
}

public void equalsIsReflexive()
{
assertThat(id, equalTo(id));
}

public void equalsIsSymmetric()
{
GlobalDocumentId sameId = newBasicInstance();
assertThat(sameId, equalTo(id));
assertThat(id, equalTo(sameId));
}

public void sameHashForEqualObjects()
{
GlobalDocumentId sameId = newBasicInstance();
assertThat(sameId.hashCode(), is(id.hashCode()));
}
}
Expand Up @@ -3,4 +3,5 @@

env.debug=true
env.dbunit.type=HSQL
persistence-unit-name=zanataTestDatasourcePU
persistence-unit-name=zanataTestDatasourcePU
web.assets.version=1

0 comments on commit dbcf19a

Please sign in to comment.