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

Commit

Permalink
Merge remote branch 'origin/master' into integration/master
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Feb 26, 2013
2 parents 87b7961 + a47446f commit c6741a6
Show file tree
Hide file tree
Showing 61 changed files with 464 additions and 116 deletions.
2 changes: 1 addition & 1 deletion zanata-model/src/main/java/org/zanata/model/HProject.java
Expand Up @@ -56,9 +56,9 @@
import org.hibernate.validator.NotEmpty;
import org.jboss.seam.annotations.security.Restrict;
import org.zanata.annotation.EntityRestrict;
import org.zanata.common.ProjectType;
import org.zanata.model.type.EntityStatusType;
import org.zanata.rest.dto.Project;
import org.zanata.rest.dto.ProjectType;

/**
* @see Project
Expand Down
Expand Up @@ -61,10 +61,10 @@
import org.hibernate.validator.NotNull;
import org.jboss.seam.annotations.security.Restrict;
import org.zanata.annotation.EntityRestrict;
import org.zanata.common.ProjectType;
import org.zanata.hibernate.search.GroupSearchBridge;
import org.zanata.model.type.EntityStatusType;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.rest.dto.ProjectType;

/**
*
Expand Down
Expand Up @@ -30,7 +30,6 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Level;
Expand Down Expand Up @@ -274,8 +273,11 @@ public String getServerPath()
if( configuredValue == null )
{
HttpServletRequest request = ServletContexts.instance().getRequest();
// TODO what if request is null?
configuredValue = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
if( request != null )
{
configuredValue =
request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
}
}
return configuredValue;
}
Expand Down
Expand Up @@ -44,8 +44,6 @@ public class ConfigurationAction implements Serializable
private String iterationSlug;
@RequestParameter
private String projectSlug;
@RequestParameter
private String projectType;

@Logger
private Log log;
Expand All @@ -64,7 +62,7 @@ public void getData()
ServletOutputStream os = response.getOutputStream();

os.write(
configurationServiceImpl.getConfigurationFileContents(this.projectSlug, this.iterationSlug, this.projectType).getBytes());
configurationServiceImpl.getConfigurationFileContents(this.projectSlug, this.iterationSlug).getBytes());
os.flush();
os.close();
FacesContext.getCurrentInstance().responseComplete();
Expand Down
Expand Up @@ -62,6 +62,7 @@
import org.zanata.common.EntityStatus;
import org.zanata.common.LocaleId;
import org.zanata.common.MergeType;
import org.zanata.common.ProjectType;
import org.zanata.dao.DocumentDAO;
import org.zanata.dao.LocaleDAO;
import org.zanata.dao.PersonDAO;
Expand Down Expand Up @@ -533,6 +534,34 @@ public boolean isIterationActive()
return getProjectIteration().getProject().getStatus() == EntityStatus.ACTIVE || getProjectIteration().getStatus() == EntityStatus.ACTIVE;
}

public boolean isZipFileDownloadAllowed()
{
return getProjectIteration().getProjectType() == ProjectType.Gettext ||
getProjectIteration().getProjectType() == ProjectType.Podir;
}

public String getZipFileDownloadTitle()
{
String message = null;
if( !isZipFileDownloadAllowed() )
{
if( getProjectIteration().getProjectType() == null )
{
message = zanataMessages.getMessage("jsf.iteration.files.DownloadAllFiles.ProjectTypeNotSet");
}
else if( getProjectIteration().getProjectType() != ProjectType.Gettext &&
getProjectIteration().getProjectType() != ProjectType.Podir )
{
message = zanataMessages.getMessage("jsf.iteration.files.DownloadAllFiles.ProjectTypeNotAllowed");
}
}
else
{
message = zanataMessages.getMessage("jsf.iteration.files.DownloadAllFiles.title");
}
return message;
}

/**
* Returns the display zanataMessages to show when a user cannot translate.
*/
Expand Down
Expand Up @@ -37,11 +37,11 @@
import org.jboss.seam.core.Events;
import org.jboss.seam.faces.FacesMessages;
import org.zanata.common.EntityStatus;
import org.zanata.common.ProjectType;
import org.zanata.dao.ProjectDAO;
import org.zanata.model.HLocale;
import org.zanata.model.HProject;
import org.zanata.model.HProjectIteration;
import org.zanata.rest.dto.ProjectType;
import org.zanata.service.LocaleService;
import org.zanata.service.SlugEntityService;

Expand Down
Expand Up @@ -10,6 +10,7 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.security.Identity;
import org.zanata.ApplicationConfiguration;
import org.zanata.dao.ProjectIterationDAO;
import org.zanata.process.IterationZipFileBuildProcess;
import org.zanata.process.IterationZipFileBuildProcessHandle;
Expand All @@ -28,6 +29,9 @@ public class ProjectIterationZipFileAction implements Serializable

@In
ProcessManagerService processManagerServiceImpl;

@In
private ApplicationConfiguration applicationConfiguration;

private String projectSlug;

Expand Down Expand Up @@ -55,6 +59,9 @@ public void prepareIterationZipFile()
processHandle.setIterationSlug( this.iterationSlug );
processHandle.setLocaleId( this.localeId );
processHandle.setInitiatingUserName( Identity.instance().getCredentials().getUsername() );
processHandle.setServerPath(applicationConfiguration.getServerPath()); // This needs to be done here as the server
// path may not be available when running
// asynchronously

// Fire the zip file building process and wait until it is ready to return
this.processManagerServiceImpl.startProcess( new IterationZipFileBuildProcess(), processHandle );
Expand Down
2 changes: 1 addition & 1 deletion zanata-war/src/main/java/org/zanata/action/SlugHome.java
Expand Up @@ -34,7 +34,7 @@
import org.jboss.seam.framework.EntityHome;
import org.jboss.seam.security.Identity;
import org.zanata.common.EntityStatus;
import org.zanata.rest.dto.ProjectType;
import org.zanata.common.ProjectType;

/**
* This implementation uses a field 'slug' to refer to the id of the object.
Expand Down
Expand Up @@ -44,6 +44,7 @@
import org.zanata.annotation.CachedMethodResult;
import org.zanata.annotation.CachedMethods;
import org.zanata.common.LocaleId;
import org.zanata.common.ProjectType;
import org.zanata.dao.PersonDAO;
import org.zanata.dao.ProjectIterationDAO;
import org.zanata.model.HAccount;
Expand All @@ -52,7 +53,6 @@
import org.zanata.model.HProject;
import org.zanata.model.HProjectIteration;
import org.zanata.process.CopyTransProcessHandle;
import org.zanata.rest.dto.ProjectType;
import org.zanata.rest.dto.stats.ContainerTranslationStatistics;
import org.zanata.rest.dto.stats.TranslationStatistics;
import org.zanata.rest.dto.stats.TranslationStatistics.StatUnit;
Expand Down
Expand Up @@ -37,7 +37,6 @@
import org.zanata.dao.TextFlowTargetDAO;
import org.zanata.model.HDocument;
import org.zanata.model.HLocale;
import org.zanata.model.HProjectIteration;
import org.zanata.model.HTextFlowTarget;
import org.zanata.rest.dto.resource.Resource;
import org.zanata.rest.dto.resource.TranslationsResource;
Expand Down Expand Up @@ -90,9 +89,6 @@ protected void run(IterationZipFileBuildProcessHandle zipHandle) throws Exceptio
final String localeId = zipHandle.getLocaleId();
final String userName = zipHandle.getInitiatingUserName();

HProjectIteration version = projectIterationDAO.getBySlug(projectSlug, iterationSlug);
final String projectType = version.getProjectType().name().toLowerCase();

final List<HDocument> allIterationDocs = this.documentDAO.getAllByProjectIteration(projectSlug, iterationSlug);
zipHandle.setMaxProgress(allIterationDocs.size() + 1);

Expand Down Expand Up @@ -123,7 +119,7 @@ protected void run(IterationZipFileBuildProcessHandle zipHandle) throws Exceptio
String configFilename = projectDirectory + this.configurationServiceImpl.getConfigurationFileName();
zipOutput.putNextEntry(new ZipEntry(configFilename));
zipOutput.write(
this.configurationServiceImpl.getConfigurationFileContents(projectSlug, iterationSlug, projectType).getBytes());
this.configurationServiceImpl.getConfigurationFileContents(projectSlug, iterationSlug, zipHandle.getServerPath()).getBytes());
zipOutput.closeEntry();
zipHandle.incrementProgress(1);

Expand Down
Expand Up @@ -23,7 +23,7 @@
import java.util.concurrent.Semaphore;

/**
* Extension of the basci RunnableProcess Handle class to include data pertinent to the
* Extension of the basic RunnableProcess Handle class to include data pertinent to the
* building of an iteration zip file.
*
* @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
Expand All @@ -33,12 +33,12 @@ public class IterationZipFileBuildProcessHandle extends ProcessHandle

private String projectSlug;
private String iterationSlug;
private String projectType;
private String localeId;
private String localeId;
private String initiatingUserName;
private String downloadId;
private Semaphore readySemaphore;

private String serverPath;

public IterationZipFileBuildProcessHandle()
{
this.readySemaphore = new Semaphore(1);
Expand All @@ -51,47 +51,37 @@ public IterationZipFileBuildProcessHandle()
// Ignore
}
}

public String getProjectSlug()
{
return projectSlug;
}

public void setProjectSlug(String projectSlug)
{
this.projectSlug = projectSlug;
}

public String getIterationSlug()
{
return iterationSlug;
}

public void setIterationSlug(String iterationSlug)
{
this.iterationSlug = iterationSlug;
}

public String getProjectType()
{
return projectType;
}

public void setProjectType(String projectType)
{
this.projectType = projectType;
}

public String getLocaleId()
{
return localeId;
}

public void setLocaleId(String localeId)
{
this.localeId = localeId;
}

public String getDownloadId()
{
return downloadId;
Expand All @@ -111,7 +101,17 @@ public void setInitiatingUserName(String initiatingUserName)
{
this.initiatingUserName = initiatingUserName;
}


public String getServerPath()
{
return serverPath;
}

public void setServerPath(String serverPath)
{
this.serverPath = serverPath;
}

/**
* Waits until the process represented by this handle is ready to proceed.
*
Expand Down
Expand Up @@ -49,14 +49,14 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.security.Identity;
import org.zanata.common.ProjectType;
import org.zanata.dao.ProjectDAO;
import org.zanata.dao.ProjectIterationDAO;
import org.zanata.model.HProject;
import org.zanata.model.HProjectIteration;
import org.zanata.model.validator.SlugValidator;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.rest.dto.ProjectType;

import com.google.common.base.Objects;

Expand Down
Expand Up @@ -33,6 +33,7 @@
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;
import org.zanata.common.ProjectType;
import org.zanata.dao.AccountDAO;
import org.zanata.dao.ProjectDAO;
import org.zanata.model.HAccount;
Expand All @@ -44,7 +45,6 @@
import org.zanata.rest.dto.Link;
import org.zanata.rest.dto.Project;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.rest.dto.ProjectType;

import com.google.common.base.Objects;

Expand Down
10 changes: 10 additions & 0 deletions zanata-war/src/main/java/org/zanata/security/ZanataOpenId.java
Expand Up @@ -36,7 +36,9 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Events;
import org.jboss.seam.faces.FacesManager;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.faces.Redirect;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.openid.OpenIdPrincipal;
Expand Down Expand Up @@ -188,6 +190,14 @@ public String verifyResponse(HttpServletRequest httpReq)
// (static) instance used to place the authentication request
VerificationResult verification = manager.verify(receivingURL.toString(), response, discovered);

// The OpenId provider cancelled the authentication
if( "cancel".equals( response.getParameterValue("openid.mode") ) )
{
// TODO This should be done at a higher level. i.e. instead of returning a string, return an
// object that holds more information for the UI to render
FacesMessages.instance().add(StatusMessage.Severity.INFO, "Authentication Request Cancelled");
}

// examine the verification result and extract the verified identifier
Identifier verified = verification.getVerifiedId();
if (verified != null)
Expand Down
Expand Up @@ -27,11 +27,22 @@ public interface ConfigurationService
*
* @param projectSlug
* @param iterationSlug
* @param projectType
* @return The configuration file contents for the given project and
* iteration.
*/
String getConfigurationFileContents(String projectSlug, String iterationSlug, String projectType);
String getConfigurationFileContents(String projectSlug, String iterationSlug);

/**
* Returns the contents of the configuration for a given project. Use this method
* when the server path of the zanata server needs to be customized
*
* @param projectSlug
* @param iterationSlug
* @param serverPath
* @return The configuration file contents for the given project and
* iteration.
*/
String getConfigurationFileContents(String projectSlug, String iterationSlug, String serverPath);

/**
* Returns the default configuration file Name.
Expand Down

0 comments on commit c6741a6

Please sign in to comment.