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 #177 from zanata/use-api-3.1
Browse files Browse the repository at this point in the history
Update to api 3.1-SNAPSHOT; work around Seam RESTEasy problem
  • Loading branch information
carlosmunoz committed Sep 12, 2013
2 parents 0484d0d + 7a3bc99 commit 8d3816e
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -32,7 +32,7 @@
<gwteventservice.version>1.2.1</gwteventservice.version>
<okapi.version>0.22</okapi.version>

<zanata.api.version>3.0.2</zanata.api.version>
<zanata.api.version>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.0.1</zanata.api.compat.version>
<zanata.client.version>3.0.1</zanata.client.version>
Expand Down
@@ -1,6 +1,7 @@
package org.zanata.rest;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Collection;

import javax.ws.rs.core.Response.Status;
Expand All @@ -24,6 +25,7 @@
import org.jboss.seam.log.Log;
import org.jboss.seam.resteasy.ResteasyBootstrap;
import org.jboss.seam.resteasy.SeamResteasyProviderFactory;
import org.zanata.seam.resteasy.IgnoreInterfacePath;

@Name("org.jboss.seam.resteasy.bootstrap")
@Scope(ScopeType.APPLICATION)
Expand Down Expand Up @@ -88,4 +90,30 @@ public void invoke(HttpRequest request, HttpResponse response)
}
};
}

/**
* If the seam bean is annotated with @IgnoreInterfacePath, any @Path
* annotation on the bean's interfaces will be ignored when deciding whether
* to inject @Context variables based on the interface class or the bean
* class.
* @param annotation
* @param seamComponent
* @return
*/
@Override
protected Class getAnnotatedInterface(Class<? extends Annotation> annotation,
Component seamComponent)
{
if (annotation == javax.ws.rs.Path.class &&
seamComponent.getBeanClass().isAnnotationPresent(
IgnoreInterfacePath.class))
{
return null;
}
else
{
return super.getAnnotatedInterface(annotation, seamComponent);
}
}

}
Expand Up @@ -35,10 +35,12 @@
import org.zanata.model.HPerson;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.Account;
import org.zanata.seam.resteasy.IgnoreInterfacePath;

@Name("accountService")
@Path("/accounts/u/{username:[a-z\\d_]{3,20}}")
@Transactional
@IgnoreInterfacePath
public class AccountService implements AccountResource
{

Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;

import javax.ws.rs.DefaultValue;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
Expand Down Expand Up @@ -50,17 +51,18 @@
import org.zanata.rest.dto.ProcessStatus;
import org.zanata.rest.dto.resource.Resource;
import org.zanata.rest.dto.resource.TranslationsResource;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.security.ZanataIdentity;
import org.zanata.service.AsyncTaskManagerService;
import org.zanata.service.DocumentService;
import org.zanata.service.LocaleService;
import org.zanata.service.TranslationService;
import org.zanata.service.impl.DocumentServiceImpl;
import org.zanata.service.impl.TranslationServiceImpl;

import com.google.common.collect.Lists;

import lombok.extern.slf4j.Slf4j;

import static org.zanata.rest.dto.ProcessStatus.ProcessStatusCode;

/**
Expand All @@ -73,6 +75,7 @@
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Transactional
@Slf4j
@IgnoreInterfacePath
public class AsynchronousProcessResourceService implements AsynchronousProcessResource
{
@In
Expand Down
Expand Up @@ -31,13 +31,15 @@
import org.zanata.model.HDocument;
import org.zanata.rest.NoSuchEntityException;
import org.zanata.rest.dto.CopyTransStatus;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.security.ZanataIdentity;

/**
* @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Name("copyTransResourceService")
@Path("/copytrans")
@IgnoreInterfacePath
public class CopyTransResourceService implements CopyTransResource
{
@In
Expand Down
Expand Up @@ -66,6 +66,7 @@
import org.zanata.rest.dto.resource.Resource;
import org.zanata.rest.dto.resource.TextFlowTarget;
import org.zanata.rest.dto.resource.TranslationsResource;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.service.FileSystemService;
import org.zanata.service.FileSystemService.DownloadDescriptorProperties;
import org.zanata.service.TranslationFileService;
Expand All @@ -78,6 +79,7 @@
@Path(FileResource.FILE_RESOURCE)
@Produces( { MediaType.APPLICATION_OCTET_STREAM })
@Consumes( { MediaType.APPLICATION_OCTET_STREAM })
@IgnoreInterfacePath
public class FileService implements FileResource
{
private static final String FILE_TYPE_OFFLINE_PO = "offlinepo";
Expand Down
Expand Up @@ -34,11 +34,13 @@
import org.zanata.rest.dto.Glossary;
import org.zanata.rest.dto.GlossaryEntry;
import org.zanata.rest.dto.GlossaryTerm;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.service.GlossaryFileService;

@Name("glossaryService")
@Path(GlossaryService.SERVICE_PATH)
@Transactional
@IgnoreInterfacePath
public class GlossaryService implements GlossaryResource
{
@Context
Expand Down
Expand Up @@ -58,12 +58,14 @@
import org.zanata.model.validator.SlugValidator;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.seam.resteasy.IgnoreInterfacePath;

import com.google.common.base.Objects;

@Name("projectIterationService")
@Path(ProjectIterationService.SERVICE_PATH)
@Transactional
@IgnoreInterfacePath
public class ProjectIterationService implements ProjectIterationResource
{

Expand Down
Expand Up @@ -45,12 +45,14 @@
import org.zanata.rest.dto.Link;
import org.zanata.rest.dto.Project;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.seam.resteasy.IgnoreInterfacePath;

import com.google.common.base.Objects;

@Name("projectService")
@Path(ProjectService.SERVICE_PATH)
@Transactional
@IgnoreInterfacePath
public class ProjectService implements ProjectResource
{

Expand Down
Expand Up @@ -52,12 +52,14 @@
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.Link;
import org.zanata.rest.dto.Project;
import org.zanata.seam.resteasy.IgnoreInterfacePath;

import com.google.common.base.Objects;

@Name("projectsService")
@Path("/projects")
@Transactional
@IgnoreInterfacePath
public class ProjectsService implements ProjectsResource
{

Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.zanata.rest.dto.resource.Resource;
import org.zanata.rest.dto.resource.ResourceMeta;
import org.zanata.rest.dto.resource.TextFlow;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.service.DocumentService;
import org.zanata.service.LocaleService;

Expand All @@ -67,6 +68,7 @@
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import java.lang.reflect.Type;
import java.net.URI;
import java.util.ArrayList;
Expand All @@ -83,6 +85,7 @@
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Transactional
@IgnoreInterfacePath
public class SourceDocResourceService implements SourceDocResource
{
public static final String SERVICE_PATH = ProjectIterationService.SERVICE_PATH + "/r";
Expand Down
Expand Up @@ -65,20 +65,23 @@
import org.zanata.model.HProjectIteration;
import org.zanata.model.HTextFlowTarget;
import org.zanata.rest.dto.resource.TranslationsResource;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.security.ZanataIdentity;
import org.zanata.service.CopyTransService;
import org.zanata.service.LocaleService;
import org.zanata.service.TranslationService;

import com.google.common.base.Optional;

/**
* This service allows clients to push and pull both source documents and translations.
*/
@Name("translatedDocResourceService")
@Path(TranslatedDocResourceService.SERVICE_PATH)
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Transactional
/**
* This service allows clients to push and pull both source documents and translations.
*/
@IgnoreInterfacePath
public class TranslatedDocResourceService implements TranslatedDocResource
{

Expand Down
Expand Up @@ -49,6 +49,7 @@
import org.zanata.model.ITextFlow;
import org.zanata.model.tm.TransMemory;
import org.zanata.model.tm.TransMemoryUnit;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.service.LocaleService;
import org.zanata.service.LockManagerService;
import org.zanata.tmx.TMXParser;
Expand All @@ -60,6 +61,7 @@
@Transactional(TransactionPropagationType.SUPPORTS)
@Slf4j
@ParametersAreNonnullByDefault
@IgnoreInterfacePath
// TODO options to export obsolete docs and textflows to TMX?
public class TranslationMemoryResourceService implements TranslationMemoryResource
{
Expand Down
Expand Up @@ -10,11 +10,13 @@
import org.jboss.seam.annotations.Name;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.VersionInfo;
import org.zanata.seam.resteasy.IgnoreInterfacePath;
import org.zanata.util.VersionUtility;


@Name("versionService")
@Path(VersionService.SERVICE_PATH)
@IgnoreInterfacePath
public class VersionService implements VersionResource
{
public static final String SERVICE_PATH = "/version";
Expand Down
@@ -0,0 +1,17 @@
package org.zanata.seam.resteasy;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
/**
* Tells ZanataResteasyBootstrap to ignore the @Path annotation on any
* interfaces in favour of the Bean itself.
* @see org.zanata.rest.ZanataResteasyBootstrap#getAnnotatedInterface(Class, org.jboss.seam.Component)
*/
public @interface IgnoreInterfacePath
{
}

0 comments on commit 8d3816e

Please sign in to comment.