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 #45 from zanata/add-path-to-rest-interfaces
Browse files Browse the repository at this point in the history
Add @path annotations to REST interfaces
  • Loading branch information
seanf committed Apr 1, 2016
2 parents e36786f + 88c69b8 commit c2cbcd1
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 17 deletions.
Expand Up @@ -24,10 +24,12 @@
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.Account;

Expand All @@ -38,7 +40,9 @@
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
public interface AccountResource {
@Path(AccountResource.SERVICE_PATH)
@ExternallyManagedLifecycle
public interface AccountResource extends RestResource {
public static final String SERVICE_PATH =
"/accounts/u/{username:[a-z\\d_]{3,20}}";

Expand Down
Expand Up @@ -34,6 +34,7 @@
import javax.ws.rs.core.MediaType;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.common.LocaleId;
import org.zanata.rest.dto.ProcessStatus;
import org.zanata.rest.dto.resource.Resource;
Expand All @@ -46,9 +47,11 @@
* @author Carlos Munoz <a
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Path(AsynchronousProcessResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface AsynchronousProcessResource {
public interface AsynchronousProcessResource extends RestResource {
public static final String SERVICE_PATH = "/async";

/**
Expand Down
Expand Up @@ -29,15 +29,18 @@
import javax.ws.rs.core.MediaType;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.dto.CopyTransStatus;

/**
* @author Carlos Munoz <a
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Path(CopyTransResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface CopyTransResource {
public interface CopyTransResource extends RestResource {
public static final String SERVICE_PATH = "/copytrans";

/**
Expand Down
Expand Up @@ -33,6 +33,7 @@
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
import org.zanata.common.DocumentType;
import org.zanata.rest.DocumentFileUploadForm;
Expand All @@ -41,9 +42,11 @@
/**
* Interface for file upload and download REST methods.
*/
@Path(FileResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
@Consumes({ MediaType.APPLICATION_OCTET_STREAM })
public interface FileResource {
public interface FileResource extends RestResource {
public static final String SERVICE_PATH = "/file";
@Deprecated
public static final String FILE_RESOURCE = SERVICE_PATH;
Expand Down
Expand Up @@ -35,6 +35,7 @@
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
import org.zanata.common.LocaleId;
import org.zanata.rest.GlossaryFileUploadForm;
Expand All @@ -49,13 +50,15 @@
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
*
**/
@Path(GlossaryResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON,
MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML,
MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON,
MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML,
MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON })
public interface GlossaryResource {
public interface GlossaryResource extends RestResource {
public static final String SERVICE_PATH = "/glossary";

/**
Expand Down
Expand Up @@ -22,16 +22,20 @@
package org.zanata.rest.service;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.LocaleDetails;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path(ProjectIterationLocalesResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface ProjectIterationLocalesResource {
public interface ProjectIterationLocalesResource extends RestResource {
public static final String SERVICE_PATH = ProjectIterationResource.SERVICE_PATH
+ "/locales";

Expand Down
Expand Up @@ -31,6 +31,7 @@
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.ProjectIteration;

Expand All @@ -44,10 +45,12 @@
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
@Path(ProjectIterationResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Deprecated
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface ProjectIterationResource {
public interface ProjectIterationResource extends RestResource {
public static final String ITERATION_SLUG_TEMPLATE = "{iterationSlug:"
+ RestConstants.SLUG_PATTERN + "}";
public static final String SERVICE_PATH = ProjectResource.SERVICE_PATH
Expand Down
Expand Up @@ -22,16 +22,20 @@
package org.zanata.rest.service;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.LocaleDetails;

@Path(ProjectLocalesResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface ProjectLocalesResource {
public interface ProjectLocalesResource extends RestResource {
public static final String SERVICE_PATH = ProjectResource.SERVICE_PATH
+ "/locales";

Expand Down
Expand Up @@ -25,11 +25,13 @@
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.Project;

Expand All @@ -40,9 +42,11 @@
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
@Path(ProjectResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface ProjectResource {
public interface ProjectResource extends RestResource {
public static final String PROJECT_SLUG_TEMPLATE = "{projectSlug:"
+ RestConstants.SLUG_PATTERN + "}";
public static final String SERVICE_PATH = "/projects/p/"
Expand Down
Expand Up @@ -22,6 +22,7 @@
package org.zanata.rest.service;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.LocaleDetails;
import org.zanata.rest.dto.ProjectIteration;
Expand All @@ -46,9 +47,11 @@
*
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
*/
@Path(ProjectVersionResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface ProjectVersionResource {
public interface ProjectVersionResource extends RestResource {
public static final String PROJECT_SERVICE_PATH = "/project";

public static final String VERSION_SLUG_TEMPLATE = "/{versionSlug:"
Expand Down
Expand Up @@ -23,11 +23,13 @@

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.jboss.resteasy.annotations.providers.jaxb.Wrapped;
import org.zanata.common.Namespaces;
import org.zanata.rest.MediaTypes;
Expand All @@ -38,9 +40,11 @@
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
@Path(ProjectsResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface ProjectsResource {
public interface ProjectsResource extends RestResource {
public static final String SERVICE_PATH = "/projects";

/**
Expand Down
@@ -0,0 +1,32 @@
/*
* Copyright 2016, Red Hat, Inc. and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.zanata.rest.service;

/**
* Marker interface for REST Resource classes (used by org.zanata.util.JaxRSClassIndexProcessor)
*
* @author Sean Flanigan <a
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
public interface RestResource {
}
Expand Up @@ -21,6 +21,7 @@
package org.zanata.rest.service;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.jboss.resteasy.annotations.providers.jaxb.Wrapped;
import org.zanata.common.Namespaces;
import org.zanata.rest.dto.resource.Resource;
Expand Down Expand Up @@ -48,9 +49,11 @@
* @author Carlos Munoz <a
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Path(SourceDocResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface SourceDocResource {
public interface SourceDocResource extends RestResource {
String SERVICE_PATH =
ProjectIterationResource.SERVICE_PATH + "/r";
String RESOURCE_SLUG_REGEX =
Expand Down
Expand Up @@ -30,16 +30,19 @@
import javax.ws.rs.core.MediaType;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.dto.stats.ContainerTranslationStatistics;
import org.zanata.rest.dto.stats.contribution.ContributionStatistics;

/**
* @author Carlos Munoz <a
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Path(StatisticsResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface StatisticsResource {
public interface StatisticsResource extends RestResource {
public static final String DATE_FORMAT = "yyyy-MM-dd";

public static final String SERVICE_PATH = "/stats";
Expand Down
Expand Up @@ -37,6 +37,7 @@
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.jboss.resteasy.util.HttpHeaderNames;
import org.zanata.common.LocaleId;
import org.zanata.rest.dto.resource.TranslationsResource;
Expand All @@ -50,9 +51,11 @@
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
@Path(TranslatedDocResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface TranslatedDocResource {
public interface TranslatedDocResource extends RestResource {
public static final String SERVICE_PATH =
ProjectIterationResource.SERVICE_PATH + "/r";

Expand Down
Expand Up @@ -36,6 +36,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.common.LocaleId;

/**
Expand All @@ -44,9 +45,11 @@
* @author Sean Flanigan <a
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*/
@Path(TranslationMemoryResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML /* , "application/x-tmx" */})
@Consumes({ MediaType.APPLICATION_XML /* , "application/x-tmx" */})
public interface TranslationMemoryResource {
public interface TranslationMemoryResource extends RestResource {
public static final String SERVICE_PATH = "/tm";

public static final String PREFERRED_MEDIA_TYPE = MediaType.APPLICATION_XML;
Expand Down
Expand Up @@ -22,18 +22,21 @@

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.codehaus.enunciate.jaxrs.TypeHint;
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.VersionInfo;

@org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle
@Path(VersionResource.SERVICE_PATH)
@ExternallyManagedLifecycle
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface VersionResource {
public interface VersionResource extends RestResource {
public static final String SERVICE_PATH = "/version";

/**
Expand Down

0 comments on commit c2cbcd1

Please sign in to comment.