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

Commit

Permalink
Get JAX-RS @path values from constants in zanata-common-api
Browse files Browse the repository at this point in the history
This lets us put @path into the API interfaces, so that Enunciate can generate REST docs.
  • Loading branch information
seanf committed Sep 10, 2013
1 parent 5214070 commit 8e4e000
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -31,7 +31,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
Expand Up @@ -25,11 +25,12 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.zanata.rest.service.RestConstants;

public class SlugValidator implements ConstraintValidator<Slug, String>, Serializable
{

private static final long serialVersionUID = 1L;
public static final String PATTERN = "[a-zA-Z0-9]+([a-zA-Z0-9_\\-{.}]*[a-zA-Z0-9]+)?";

@Override
public void initialize(Slug parameters)
Expand All @@ -43,7 +44,7 @@ public boolean isValid(String string, ConstraintValidatorContext context)
{
return true;
}
return string.isEmpty() || string.matches(PATTERN);
return string.isEmpty() || string.matches(RestConstants.SLUG_PATTERN);
}

}
Expand Up @@ -36,7 +36,7 @@
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.Account;

@Name("accountService")
@Name(AccountResource.SERVICE_PATH)
@Path("/accounts/u/{username:[a-z\\d_]{3,20}}")
@Transactional
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 @@ -57,10 +58,10 @@
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 @@ -69,7 +70,7 @@
* @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Name("asynchronousProcessResourceService")
@Path("/async")
@Path(AsynchronousProcessResource.SERVICE_PATH)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Transactional
@Slf4j
Expand Down
Expand Up @@ -38,7 +38,7 @@
* @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Name("copyTransResourceService")
@Path("/copytrans")
@Path(CopyTransResource.SERVICE_PATH)
public class CopyTransResourceService implements CopyTransResource
{
@In
Expand Down
Expand Up @@ -66,10 +66,6 @@
@Transactional
public class ProjectIterationService implements ProjectIterationResource
{

public static final String ITERATION_SLUG_TEMPLATE = "{iterationSlug:" + SlugValidator.PATTERN + "}";
public static final String SERVICE_PATH = ProjectService.SERVICE_PATH + "/iterations/i/" + ITERATION_SLUG_TEMPLATE;

/** Project Identifier. */
@PathParam("projectSlug")
private String projectSlug;
Expand Down
Expand Up @@ -53,10 +53,6 @@
@Transactional
public class ProjectService implements ProjectResource
{

public static final String PROJECT_SLUG_TEMPLATE = "{projectSlug:" + SlugValidator.PATTERN + "}";
public static final String SERVICE_PATH = "/projects/p/" + PROJECT_SLUG_TEMPLATE;

/** Project Identifier. */
@PathParam("projectSlug")
String projectSlug;
Expand Down
Expand Up @@ -56,7 +56,7 @@
import com.google.common.base.Objects;

@Name("projectsService")
@Path("/projects")
@Path(ProjectsResource.SERVICE_PATH)
@Transactional
public class ProjectsService implements ProjectsResource
{
Expand Down
Expand Up @@ -85,7 +85,6 @@
@Transactional
public class SourceDocResourceService implements SourceDocResource
{
public static final String SERVICE_PATH = ProjectIterationService.SERVICE_PATH + "/r";

@Logger
private Log log;
Expand Down
Expand Up @@ -86,8 +86,6 @@ public class TranslatedDocResourceService implements TranslatedDocResource
// private static final String ACTION_IMPORT_TEMPLATE = "import-template";
// private static final String ACTION_IMPORT_TRANSLATION = "import-translation";

public static final String SERVICE_PATH = ProjectIterationService.SERVICE_PATH + "/r";

public static final String EVENT_COPY_TRANS = "org.zanata.rest.service.copyTrans";

/** Project Identifier. */
Expand Down
Expand Up @@ -56,7 +56,7 @@

import com.google.common.base.Optional;
@Name("translationMemoryResource")
@Path("/tm")
@Path(TranslationMemoryResource.SERVICE_PATH)
@Transactional(TransactionPropagationType.SUPPORTS)
@Slf4j
@ParametersAreNonnullByDefault
Expand Down
Expand Up @@ -14,10 +14,9 @@


@Name("versionService")
@Path(VersionService.SERVICE_PATH)
@Path(VersionResource.SERVICE_PATH)
public class VersionService implements VersionResource
{
public static final String SERVICE_PATH = "/version";

private final VersionInfo version;

Expand Down
Expand Up @@ -54,7 +54,7 @@ public class ZPathService
* Public ZPaths.
* Used for rest resource path declaration.
*/
public static final String PROJECT_ZPATH = "/proj/" + SlugValidator.PATTERN;
public static final String PROJECT_ZPATH = "/proj/" + RestConstants.SLUG_PATTERN;

/*
* Private ZPaths.
Expand Down

0 comments on commit 8e4e000

Please sign in to comment.