From 521407077bb93797b97853b8330f3932a7b14693 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Mon, 9 Sep 2013 14:00:28 +1000 Subject: [PATCH 01/13] Remove Enunciate config from zanata-war --- pom.xml | 6 ------ zanata-war/pom.xml | 43 ------------------------------------------- 2 files changed, 49 deletions(-) diff --git a/pom.xml b/pom.xml index 2a95190843..5d2928740b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,6 @@ 30 false ${project.build.directory}/delombok/org/zanata - 1.24 2.5.0 4.8 ${project.build.sourceDirectory}/org/zanata @@ -649,11 +648,6 @@ maven-war-plugin 2.1.1 - - org.codehaus.enunciate - maven-enunciate-plugin - ${enunciate.version} - org.codehaus.mojo gwt-maven-plugin diff --git a/zanata-war/pom.xml b/zanata-war/pom.xml index 8e217cba88..8c92edca88 100644 --- a/zanata-war/pom.xml +++ b/zanata-war/pom.xml @@ -602,23 +602,6 @@ - - - - org.codehaus.enunciate - - - maven-enunciate-plugin - - [1.9-RC1,) - - assemble - - - - - - @@ -708,31 +691,6 @@ - - - - org.codehaus.enunciate - maven-enunciate-plugin - - ${enunciate.version} - - etc/enunciate/enunciate.xml - - - unused - unused - - - - apidocs - - - - - @@ -1382,7 +1340,6 @@ org.codehaus.enunciate enunciate-core-annotations - ${enunciate.version} From 8e4e00014ad5e6a6b05dc69052525570129d83ea Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Mon, 9 Sep 2013 14:03:59 +1000 Subject: [PATCH 02/13] Get JAX-RS @Path values from constants in zanata-common-api This lets us put @Path into the API interfaces, so that Enunciate can generate REST docs. --- pom.xml | 2 +- .../main/java/org/zanata/model/validator/SlugValidator.java | 5 +++-- .../main/java/org/zanata/rest/service/AccountService.java | 2 +- .../rest/service/AsynchronousProcessResourceService.java | 5 +++-- .../org/zanata/rest/service/CopyTransResourceService.java | 2 +- .../org/zanata/rest/service/ProjectIterationService.java | 4 ---- .../main/java/org/zanata/rest/service/ProjectService.java | 4 ---- .../main/java/org/zanata/rest/service/ProjectsService.java | 2 +- .../org/zanata/rest/service/SourceDocResourceService.java | 1 - .../zanata/rest/service/TranslatedDocResourceService.java | 2 -- .../rest/service/TranslationMemoryResourceService.java | 2 +- .../main/java/org/zanata/rest/service/VersionService.java | 3 +-- .../src/main/java/org/zanata/rest/service/ZPathService.java | 2 +- 13 files changed, 13 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 5d2928740b..ee52a40d1c 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 1.2.1 0.22 - 3.0.2 + 3.1-SNAPSHOT 3.0.1 3.0.1 diff --git a/zanata-model/src/main/java/org/zanata/model/validator/SlugValidator.java b/zanata-model/src/main/java/org/zanata/model/validator/SlugValidator.java index 716da4a470..72b1446ec7 100644 --- a/zanata-model/src/main/java/org/zanata/model/validator/SlugValidator.java +++ b/zanata-model/src/main/java/org/zanata/model/validator/SlugValidator.java @@ -25,11 +25,12 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; +import org.zanata.rest.service.RestConstants; + public class SlugValidator implements ConstraintValidator, 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) @@ -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); } } diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index d2f1db64bf..5a2885ab7a 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -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 diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java index 168d5a4f25..feaa9355e9 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java @@ -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; @@ -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; /** @@ -69,7 +70,7 @@ * @author Carlos Munoz camunoz@redhat.com */ @Name("asynchronousProcessResourceService") -@Path("/async") +@Path(AsynchronousProcessResource.SERVICE_PATH) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Transactional @Slf4j diff --git a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java index 8c9adc91cd..cfb73b99c4 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java @@ -38,7 +38,7 @@ * @author Carlos Munoz camunoz@redhat.com */ @Name("copyTransResourceService") -@Path("/copytrans") +@Path(CopyTransResource.SERVICE_PATH) public class CopyTransResourceService implements CopyTransResource { @In diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index 5b6122ca7a..7a6d1cf56a 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -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; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java index 81a7b52ced..7bba1af953 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java @@ -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; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java index 7b1ffbc408..e7a6178176 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java @@ -56,7 +56,7 @@ import com.google.common.base.Objects; @Name("projectsService") -@Path("/projects") +@Path(ProjectsResource.SERVICE_PATH) @Transactional public class ProjectsService implements ProjectsResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java index 990f3bca46..128313d3d8 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java @@ -85,7 +85,6 @@ @Transactional public class SourceDocResourceService implements SourceDocResource { - public static final String SERVICE_PATH = ProjectIterationService.SERVICE_PATH + "/r"; @Logger private Log log; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 380eb68eaf..5e170ddebe 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -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. */ diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java index 201e85f861..1675087091 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java @@ -56,7 +56,7 @@ import com.google.common.base.Optional; @Name("translationMemoryResource") -@Path("/tm") +@Path(TranslationMemoryResource.SERVICE_PATH) @Transactional(TransactionPropagationType.SUPPORTS) @Slf4j @ParametersAreNonnullByDefault diff --git a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java index a2527a34af..95c4a52b1a 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java @@ -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; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ZPathService.java b/zanata-war/src/main/java/org/zanata/rest/service/ZPathService.java index 40b69622d2..5a356acb96 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ZPathService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ZPathService.java @@ -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. From b3d73b35c00ea4a346ce5d8c4d9bfb1e5ff15b2b Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 10 Sep 2013 16:06:23 +1000 Subject: [PATCH 03/13] Move REST docs and TypeHints from server to api --- zanata-war/pom.xml | 5 - .../zanata/rest/service/AccountService.java | 22 ---- .../service/CopyTransResourceService.java | 31 ----- .../org/zanata/rest/service/FileService.java | 46 -------- .../zanata/rest/service/GlossaryService.java | 57 --------- .../rest/service/ProjectIterationService.java | 31 ----- .../zanata/rest/service/ProjectService.java | 41 ------- .../zanata/rest/service/ProjectsService.java | 10 -- .../service/SourceDocResourceService.java | 111 ------------------ .../service/TranslatedDocResourceService.java | 57 --------- .../zanata/rest/service/VersionService.java | 11 +- 11 files changed, 1 insertion(+), 421 deletions(-) diff --git a/zanata-war/pom.xml b/zanata-war/pom.xml index 8c92edca88..a9ac0c07ac 100644 --- a/zanata-war/pom.xml +++ b/zanata-war/pom.xml @@ -1337,11 +1337,6 @@ openprops - - org.codehaus.enunciate - enunciate-core-annotations - - diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index 5a2885ab7a..4d4cbc5d5f 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -16,7 +16,6 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.hibernate.Session; import org.jboss.resteasy.spi.NoLogWebApplicationException; import org.jboss.seam.annotations.In; @@ -69,19 +68,10 @@ public class AccountService implements AccountResource @In private Session session; - - /** - * Retrieves a user account. - * - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response containing information for the user account.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Produces( {MediaTypes.APPLICATION_ZANATA_ACCOUNT_XML, MediaTypes.APPLICATION_ZANATA_ACCOUNT_JSON}) - @TypeHint(Account.class) public Response get() { log.debug("HTTP GET {0}", request.getRequestURL()); @@ -97,18 +87,6 @@ public Response get() return Response.ok(result).build(); } - /** - * Creates or updates a user account. If an account with the given user name already exists, - * said account will be overwritten with the provided data. Otherwise, a new account will - * be created. - * - * @param account The account information to create/update. - * @return The following response status codes will be returned from this operation:
- * OK(200) - If a new account was created.
- * CREATED(201) - If an existing account was modified.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @PUT @Consumes( diff --git a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java index cfb73b99c4..f1c11d8141 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java @@ -50,22 +50,6 @@ public class CopyTransResourceService implements CopyTransResource @In private DocumentDAO documentDAO; - /** - * Starts a Translation copy for an individual document. - * - * @param projectSlug Project identifier - * @param iterationSlug Project version identifier - * @param docId Document Id to copy translations into. - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - Translation copy was started for the given document. The status of the - * process is also returned in the response contents.
- * UNAUTHORIZED(401) - If the user does not have the proper - * permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected - * error in the server while performing this operation. Translation copy will - * not start in this case. - */ @Override public CopyTransStatus startCopyTrans(@PathParam("projectSlug") String projectSlug, @PathParam("iterationSlug") String iterationSlug, @@ -83,21 +67,6 @@ public CopyTransStatus startCopyTrans(@PathParam("projectSlug") String projectSl return this.getCopyTransStatus(projectSlug, iterationSlug, docId); } - /** - * Retrieves the status for a Translation copy process for a document. - * - * @param projectSlug Project identifier - * @param iterationSlug Project version identifier - * @param docId Document Id - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - A Translation copy process was found, and its status will be returned - * in the body of the response.
- * NOT_FOUND(404) - If there is no record of a recent translation copy process for - * the specified document. - * INTERNAL SERVER ERROR(500) - If there is an unexpected - * error in the server while performing this operation. - */ @Override public CopyTransStatus getCopyTransStatus(@PathParam("projectSlug") String projectSlug, @PathParam("iterationSlug") String iterationSlug, diff --git a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java index a3cb7ce381..caeef36a25 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java @@ -152,18 +152,6 @@ public Response uploadTranslationFile( @PathParam("projectSlug") String projectS return translationUploader.tryUploadTranslationFile(id, localeId, merge, uploadForm); } - /** - * Downloads a single source file. - * - * @param projectSlug - * @param iterationSlug - * @param fileType use 'raw' for original source if available, or 'pot' to - * generate pot from source strings - * @param docId - * @return response with status code 404 if the document is not found, 415 if - * fileType is not valid for the document, otherwise 200 with - * attached document. - */ @Override @GET @Path(SOURCE_DOWNLOAD_TEMPLATE) @@ -220,29 +208,6 @@ else if ("pot".equals(fileType) || FILE_TYPE_OFFLINE_PO_TEMPLATE.equals(fileType } } - /** - * Downloads a single translation file. - * - * To download a preview-document or translated document where a raw source - * document is available, use fileType 'half_baked' and 'baked' respectively. - * - * @param projectSlug Project identifier. - * @param iterationSlug Project iteration identifier. - * @param locale Translations for this locale will be contained in the - * downloaded document. - * @param fileType File type to be downloaded. (Options: 'po', 'half_baked', - * 'baked') - * @param docId Document identifier to fetch translations for. - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - A translation file in the requested format with - * translations for the requested document in a project, iteration - * and locale.
- * NOT FOUND(404) - If a document is not found with the given - * parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @GET @Path(FILE_DOWNLOAD_TEMPLATE) @@ -339,17 +304,6 @@ else if (FILETYPE_TRANSLATED_APPROVED.equals(fileType) || FILETYPE_TRANSLATED_AP return response; } - /** - * Downloads a previously generated file. - * - * @param downloadId The Zanata generated download id. - * @return The following response status codes will be returned from this operation:
- * OK(200) - A translation file in the requested format with translations for the requested document in a - * project, iteration and locale.
- * NOT FOUND(404) - If a downloadable file is not found for the given id, or is not yet ready for download - * (i.e. the system is still preparing it).
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Path(DOWNLOAD_TEMPLATE) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java index 62d9a870b8..858dbc65e1 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java @@ -18,7 +18,6 @@ import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.UriInfo; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Transactional; @@ -62,19 +61,9 @@ public class GlossaryService implements GlossaryResource Log log = Logging.getLog(GlossaryService.class); - /** - * Returns all Glossary entries. - * - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - Response containing all Glossary entries in the system. - * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @GET @Produces({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML, MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @TypeHint(Glossary.class) public Response getEntries() { ResponseBuilder response = request.evaluatePreconditions(); @@ -91,21 +80,10 @@ public Response getEntries() return Response.ok(glossary).build(); } - /** - * Returns Glossary entries for a single locale. - * - * @param locale Locale for which to retrieve entries. - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - Response containing all Glossary entries for the given - * locale. INTERNAL SERVER ERROR(500) - If there is an unexpected - * error in the server while performing this operation. - */ @Override @GET @Path("/{locale}") @Produces({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML, MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @TypeHint(Glossary.class) public Response get(@PathParam("locale") LocaleId locale) { @@ -123,18 +101,6 @@ public Response get(@PathParam("locale") return Response.ok(glossary).build(); } - /** - * Adds glossary entries. - * - * @param glossary The Glossary entries to add. - * @return The following response status codes will be returned from this - * operation:
- * CREATED(201) - If the glossary entries were successfully created. - * UNAUTHORIZED(401) - If the user does not have the proper - * permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @PUT @Consumes({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML, MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @@ -156,18 +122,6 @@ public Response put(Glossary glossary) return response.build(); } - /** - * Delete all glossary terms with the specified locale. - * - * @param targetLocale The target locale to delete glossary entries from. - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - If the glossary entries were successfully deleted. - * UNAUTHORIZED(401) - If the user does not have the proper - * permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @DELETE @Path("/{locale}") @@ -186,17 +140,6 @@ public Response deleteGlossary(@PathParam("locale") LocaleId targetLocale) return Response.ok().build(); } - /** - * Delete all glossary terms. - * - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - If the glossary entries were successfully deleted. - * UNAUTHORIZED(401) - If the user does not have the proper - * permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @DELETE @Restrict("#{s:hasPermission('', 'glossary-delete')}") diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index 7a6d1cf56a..0c382ff988 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -44,7 +44,6 @@ import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.jboss.resteasy.util.HttpHeaderNames; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; @@ -118,14 +117,6 @@ public String getIterationSlug() return iterationSlug; } - /** - * Returns header information for a project iteration. - * - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response with an "Etag" header for the requested project iteration.
- * NOT FOUND(404) - If a project iteration could not be found for the given parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @HEAD @Produces( { MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @@ -142,18 +133,9 @@ public Response head() return Response.ok().tag(etag).build(); } - /** - * Returns data for a single Project iteration. - * - * @return The following response status codes will be returned from this operation:
- * OK(200) - Contains the Project iteration data.
- * NOT FOUND(404) - response, if a Project iteration could not be found for the given parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Produces( { MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @TypeHint(ProjectIteration.class) public Response get() { @@ -173,19 +155,6 @@ public Response get() return Response.ok(it).tag(etag).build(); } - /** - * Creates or modifies a Project iteration. - * - * @param projectIteration The project iteration information. - * @return The following response status codes will be returned from this operation:
- * OK(200) - If an already existing project iteration was updated as a result of this operation.
- * CREATED(201) - If a new project iteration was added.
- * NOT FOUND(404) - If no project was found for the given project slug.
- * FORBIDDEN(403) - If the user was not allowed to create/modify the project iteration. In this case an error message - * is contained in the response.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @PUT @Consumes( { MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java index 7bba1af953..023478b44a 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java @@ -25,7 +25,6 @@ import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.jboss.resteasy.util.HttpHeaderNames; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; @@ -88,17 +87,6 @@ public String getProjectSlug() return projectSlug; } - /** - * Returns header information for a project. - * - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - An "Etag" header for the requested project.
- * NOT FOUND(404) - If a project could not be found for the given - * parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @HEAD @Produces({ MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @@ -113,21 +101,9 @@ public Response head() return Response.ok().tag(etag).build(); } - /** - * Returns data for a single Project. - * - * @return The following response status codes will be returned from this - * operation:
- * OK(200) - Containing the Project data.
- * NOT FOUND(404) - If a Project could not be found for the given - * parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @GET @Produces({ MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @TypeHint(Project.class) public Response get() { try @@ -150,23 +126,6 @@ public Response get() } } - /** - * Creates or modifies a Project. - * - * @param project The project's information. - * @return The following response status codes will be returned from this - * method:
- * OK(200) - If an already existing project was updated as a result - * of this operation.
- * CREATED(201) - If a new project was added.
- * FORBIDDEN(403) - If the user was not allowed to create/modify the - * project. In this case an error message is contained in the - * response.
- * UNAUTHORIZED(401) - If the user does not have the proper - * permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in - * the server while performing this operation. - */ @Override @PUT @Consumes({ MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java index e7a6178176..10962e8b41 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java @@ -37,7 +37,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.hibernate.Query; import org.hibernate.Session; import org.jboss.resteasy.annotations.providers.jaxb.Wrapped; @@ -73,19 +72,10 @@ public class ProjectsService implements ProjectsResource @Context MediaType accept; - /** - * Retrieves a full list of projects in the system. - * - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response containing a full list of projects. The list will be wrapped around a 'projects' element, and - * all it's child elements will be projects.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Produces( { MediaTypes.APPLICATION_ZANATA_PROJECTS_XML, MediaTypes.APPLICATION_ZANATA_PROJECTS_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Wrapped(element = "projects", namespace = Namespaces.ZANATA_API) - @TypeHint(Project.class) public Response get() { Query query = session.createQuery("from HProject p"); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java index 128313d3d8..7993ef6c81 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java @@ -20,7 +20,6 @@ */ package org.zanata.rest.service; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.jboss.resteasy.annotations.providers.jaxb.Wrapped; import org.jboss.resteasy.util.GenericType; import org.jboss.seam.annotations.In; @@ -122,14 +121,6 @@ public class SourceDocResourceService implements SourceDocResource private ETagUtils eTagUtils; - /** - * Returns header information for a Project's iteration translations. - * - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response containing an "Etag" header for the requested project iteration translations.
- * NOT FOUND(404) - If a project iteration could not be found for the given parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @HEAD public Response head() @@ -144,20 +135,9 @@ public Response head() return Response.ok().tag(etag).build(); } - /** - * Retrieve the List of Documents (Resources) belonging to a Project iteration. - * - * @param extensions The document extensions to fetch along with the documents (e.g. "gettext", "comment"). This parameter - * allows multiple values e.g. "ext=gettext&ext=comment". - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response with a list of documents wrapped around a "resources" tag.
- * NOT FOUND(404) - If a Project iteration could not be found with the given parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Wrapped(element = "resources", namespace = Namespaces.ZANATA_API) - @TypeHint(ResourceMeta.class) public Response get(@QueryParam("ext") Set extensions) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(false); @@ -191,20 +171,6 @@ public Response get(@QueryParam("ext") Set extensions) } - /** - * Creates a new Document. - * - * @param resource The document information. - * @param extensions The document extensions to save with the new document (e.g. "gettext", "comment"). This parameter - * allows multiple values e.g. "ext=gettext&ext=comment". - * @param copytrans Boolean value that indicates whether reasonably close translations from other projects should be - * found to initially populate this document's translations. - * @return The following response status codes will be returned from this operation:
- * CREATED (201) - If the document was successfully created.
- * CONFLICT(409) - If another document already exists with the same name, on the same project iteration.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @POST @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") @@ -243,23 +209,9 @@ public Response post(Resource resource, @QueryParam("ext") Set extension return Response.created(URI.create("r/" + resourceUtils.encodeDocId(document.getDocId()))).tag(etag).build(); } - /** - * Retrieves information for a Document. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param extensions The document extensions to fetch along with the document (e.g. "gettext", "comment"). This parameter - * allows multiple values e.g. "ext=gettext&ext=comment". - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response with the document's information.
- * NOT FOUND(404) - If a document could not be found with the given parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Path(RESOURCE_SLUG_TEMPLATE) - @TypeHint(Resource.class) // /r/{id} public Response getResource(@PathParam("id") String idNoSlash, @QueryParam("ext") Set extensions) { @@ -303,26 +255,6 @@ public Response getResource(@PathParam("id") String idNoSlash, @QueryParam("ext" return Response.ok().entity(entity).tag(etag).lastModified(doc.getLastChanged()).build(); } - /** - * Creates or modifies a Document. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param resource The document information. - * @param extensions The document extensions to save with the document (e.g. "gettext", "comment"). This parameter - * allows multiple values e.g. "ext=gettext&ext=comment". - * @param copytrans Boolean value that indicates whether reasonably close translations from other projects should be - * found to initially populate this document's translations. - * @return The following response status codes will be returned from this operation:
- * CREATED(201) - If a new document was successfully created.
- * OK(200) - If an already existing document was modified.
- * NOT FOUND(404) - If a project or project iteration could not be found with the given parameters.
- * FORBIDDEN(403) - If the user is not allowed to modify the project, project iteration or document. This might be - * due to the project or iteration being in Read-Only mode.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @PUT @Path(RESOURCE_SLUG_TEMPLATE) @@ -356,20 +288,6 @@ public Response putResource(@PathParam("id") String idNoSlash, Resource resource return response.tag(etag).build(); } - /** - * Delete a Document. The system keeps the history of this document however. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @return The following response status codes will be returned from this operation:
- * OK(200) - If The document was successfully deleted.
- * NOT FOUND(404) - If a project or project iteration could not be found with the given parameters.
- * FORBIDDEN(403) - If the user is not allowed to modify the project, project iteration or document. This might be - * due to the project or iteration being in Read-Only mode.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @DELETE @Path(RESOURCE_SLUG_TEMPLATE) @@ -393,23 +311,9 @@ public Response deleteResource(@PathParam("id") String idNoSlash) return Response.ok().build(); } - /** - * Retrieves meta-data information for a Document. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param extensions The document extensions to retrieve with the document's meta-data (e.g. "gettext", "comment"). - * This parameter allows multiple values e.g. "ext=gettext&ext=comment". - * @return The following response status codes will be returned from this operation:
- * OK(200) - If the Document's meta-data was found. The data will be contained in the response.
- * NOT FOUND(404) - If a project, project iteration or document could not be found with the given parameters.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @GET @Path(RESOURCE_SLUG_TEMPLATE + "/meta") - @TypeHint(ResourceMeta.class) // /r/{id}/meta public Response getResourceMeta(@PathParam("id") String idNoSlash, @QueryParam("ext") Set extensions) { @@ -442,21 +346,6 @@ public Response getResourceMeta(@PathParam("id") String idNoSlash, @QueryParam(" return Response.ok().entity(entity).tag(etag).build(); } - /** - * Modifies an existing document's meta-data. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param messageBody The document's meta-data. - * @param extensions The document extensions to save with the document (e.g. "gettext", "comment"). This parameter - * allows multiple values e.g. "ext=gettext&ext=comment". - * @return The following response status codes will be returned from this operation:
- * OK(200) - If the Document's meta-data was successfully modified.
- * NOT FOUND(404) - If a document was not found using the given parameters.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @PUT @Path(RESOURCE_SLUG_TEMPLATE + "/meta") diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 5e170ddebe..0476181568 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -46,7 +46,6 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Transactional; @@ -147,30 +146,9 @@ public class TranslatedDocResourceService implements TranslatedDocResource @In private LocaleService localeServiceImpl; - /** - * Retrieves a set of translations for a given locale. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param locale The locale for which to get translations. - * @param extensions The translation extensions to retrieve (e.g. "comment"). This parameter - * allows multiple values. - * @param skeletons Indicates whether to generate untranslated entries or not. - * @param eTag An Entity tag identifier. Based on this identifier (if provided), the server will decide if it needs - * to send a response to the client or not (See return section). - * @return The following response status codes will be returned from this operation:
- * OK(200) - Successfully retrieved translations. The data will be contained in the response.
- * NOT FOUND(404) - If a project, project iteration or document could not be found with the given parameters. Also - * if no translations are found for the given document and locale.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation.
- * NOT_MODIFIED(304) - If the provided ETag matches the server's stored ETag, it will reply with this code, indicating - * that the last received response is still valid and should be reused. - */ @Override @GET @Path(RESOURCE_SLUG_TEMPLATE + "/translations/{locale}") - @TypeHint(TranslationsResource.class) // /r/{id}/translations/{locale} public Response getTranslations( @PathParam("id") String idNoSlash, @@ -225,20 +203,6 @@ public Response getTranslations( return Response.ok().entity(translationResource).tag(generatedEtag).build(); } - /** - * Deletes a set of translations for a given locale. Also deletes any extensions recorded for the translations in - * question. The system will keep history of the translations. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param locale The locale for which to get translations. - * @return The following response status codes will be returned from this operation:
- * OK(200) - Successfully deleted the translations.
- * NOT FOUND(404) - If a project, project iteration or document could not be found with the given parameters. - * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @DELETE @Path(RESOURCE_SLUG_TEMPLATE + "/translations/{locale}") @@ -279,27 +243,6 @@ public Response deleteTranslations(@PathParam("id") String idNoSlash, @PathParam } - /** - * Updates the translations for a document and a locale. - * - * @param idNoSlash The document identifier. Some document ids could have forward slashes ('/') in them which would - * cause conflicts with the browser's own url interpreter. For this reason, the supplied id must have all its '/' - * characters replaced with commas (','). - * @param locale The locale for which to get translations. - * @param messageBody The translations to modify. - * @param extensions The translation extension types to modify (e.g. "comment"). This parameter - * allows multiple values. - * @param merge Indicates how to deal with existing translations (valid options: 'auto', 'import'). Import will - * overwrite all current values with the values being pushed (even empty ones), while Auto will check the history - * of your translations and will not overwrite any translations for which it detects a previous value is being pushed. - * @return The following response status codes will be returned from this operation:
- * OK(200) - Translations were successfully updated.
- * NOT FOUND(404) - If a project, project iteration or document could not be found with the given parameters.
- * UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.
- * BAD REQUEST(400) - If there are problems with the parameters passed. i.e. Merge type is not one of the accepted - * types. This response should have a content message indicating a reason.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ @Override @PUT @Path(RESOURCE_SLUG_TEMPLATE + "/translations/{locale}") diff --git a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java index 95c4a52b1a..bd1d4ca69d 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java @@ -6,7 +6,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import org.codehaus.enunciate.jaxrs.TypeHint; import org.jboss.seam.annotations.Name; import org.zanata.rest.MediaTypes; import org.zanata.rest.dto.VersionInfo; @@ -29,18 +28,10 @@ public VersionService() { this.version = ver; } - - /** - * Retrieve Version information for the application. - * - * @return The following response status codes will be returned from this operation:
- * OK(200) - Response with the system's version information in the content.
- * INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation. - */ + @Override @GET @Produces({ MediaTypes.APPLICATION_ZANATA_VERSION_JSON, MediaTypes.APPLICATION_ZANATA_VERSION_XML }) - @TypeHint(VersionInfo.class) public Response get() { return Response.ok(version).build(); From 76f3486933e5d64a8c2419dd72fd8d5b9e1677bf Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Thu, 12 Sep 2013 13:15:51 +1000 Subject: [PATCH 04/13] Fix AccountService name --- .../src/main/java/org/zanata/rest/service/AccountService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index 87b18106ef..9a7b1634ae 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -36,8 +36,8 @@ import org.zanata.rest.dto.Account; import org.zanata.seam.resteasy.IgnoreInterfacePath; -@Name(AccountResource.SERVICE_PATH) -@Path("/accounts/u/{username:[a-z\\d_]{3,20}}") +@Name("accountService") +@Path(AccountResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class AccountService implements AccountResource From 39cd4424e33250b90baaa42c4fe012706be7b414 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 17 Sep 2013 14:27:57 +1000 Subject: [PATCH 05/13] Remove redundant annotations --- .../zanata/rest/service/AccountService.java | 6 ----- .../AsynchronousProcessResourceService.java | 1 - .../org/zanata/rest/service/FileService.java | 23 ------------------- .../zanata/rest/service/GlossaryService.java | 10 -------- .../rest/service/ProjectIterationService.java | 6 ----- .../zanata/rest/service/ProjectService.java | 6 ----- .../zanata/rest/service/ProjectsService.java | 3 --- .../service/SourceDocResourceService.java | 21 ----------------- .../service/TranslatedDocResourceService.java | 13 +---------- .../zanata/rest/service/VersionService.java | 2 -- .../service/impl/StatisticsServiceImpl.java | 1 - 11 files changed, 1 insertion(+), 91 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index 9a7b1634ae..737d6ae53c 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -71,9 +71,6 @@ public class AccountService implements AccountResource private Session session; @Override - @GET - @Produces( - {MediaTypes.APPLICATION_ZANATA_ACCOUNT_XML, MediaTypes.APPLICATION_ZANATA_ACCOUNT_JSON}) public Response get() { log.debug("HTTP GET {0}", request.getRequestURL()); @@ -90,9 +87,6 @@ public Response get() } @Override - @PUT - @Consumes( - {MediaTypes.APPLICATION_ZANATA_ACCOUNT_XML, MediaTypes.APPLICATION_ZANATA_ACCOUNT_JSON}) public Response put(Account account) { log.debug("HTTP PUT {0} : \n{1}", request.getRequestURL(), account); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java index 6da5264465..270328232c 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java @@ -72,7 +72,6 @@ */ @Name("asynchronousProcessResourceService") @Path(AsynchronousProcessResource.SERVICE_PATH) -@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Transactional @Slf4j @IgnoreInterfacePath diff --git a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java index 30c5fdc560..f9065997ea 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java @@ -77,8 +77,6 @@ @Name("fileService") @Path(FileResource.FILE_RESOURCE) -@Produces( { MediaType.APPLICATION_OCTET_STREAM }) -@Consumes( { MediaType.APPLICATION_OCTET_STREAM }) @IgnoreInterfacePath public class FileService implements FileResource { @@ -113,10 +111,6 @@ public class FileService implements FileResource private FilePersistService filePersistService; @Override - @GET - @Path(ACCEPTED_TYPES_RESOURCE) - @Produces( MediaType.TEXT_PLAIN ) - // /file/accepted_types public Response acceptedFileTypes() { StringSet acceptedTypes = new StringSet(""); @@ -125,10 +119,6 @@ public Response acceptedFileTypes() } @Override - @POST - @Path(SOURCE_UPLOAD_TEMPLATE) - @Consumes( MediaType.MULTIPART_FORM_DATA) - @Produces( MediaType.APPLICATION_XML) public Response uploadSourceFile( @PathParam("projectSlug") String projectSlug, @PathParam("iterationSlug") String iterationSlug, @QueryParam("docId") String docId, @@ -139,10 +129,6 @@ public Response uploadSourceFile( @PathParam("projectSlug") String projectSlug, } @Override - @POST - @Path(TRANSLATION_UPLOAD_TEMPLATE) - @Consumes( MediaType.MULTIPART_FORM_DATA) - @Produces( MediaType.APPLICATION_XML) public Response uploadTranslationFile( @PathParam("projectSlug") String projectSlug, @PathParam("iterationSlug") String iterationSlug, @PathParam("locale") String localeId, @@ -155,9 +141,6 @@ public Response uploadTranslationFile( @PathParam("projectSlug") String projectS } @Override - @GET - @Path(SOURCE_DOWNLOAD_TEMPLATE) - // /file/source/{projectSlug}/{iterationSlug}/{fileType}?docId={docId} public Response downloadSourceFile( @PathParam("projectSlug") String projectSlug, @PathParam("iterationSlug") String iterationSlug, @PathParam("fileType") String fileType, @@ -211,9 +194,6 @@ else if ("pot".equals(fileType) || FILE_TYPE_OFFLINE_PO_TEMPLATE.equals(fileType } @Override - @GET - @Path(FILE_DOWNLOAD_TEMPLATE) - // /file/translation/{projectSlug}/{iterationSlug}/{locale}/{fileType}?docId={docId} public Response downloadTranslationFile( @PathParam("projectSlug") String projectSlug, @PathParam("iterationSlug") String iterationSlug, @PathParam("locale") String locale, @@ -307,9 +287,6 @@ else if (FILETYPE_TRANSLATED_APPROVED.equals(fileType) || FILETYPE_TRANSLATED_AP } @Override - @GET - @Path(DOWNLOAD_TEMPLATE) - // /file/download/{downloadId} public Response download( @PathParam("downloadId") String downloadId ) { // TODO scan (again) for virus diff --git a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java index 640d9ab0ae..4e0a7b236a 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java @@ -64,8 +64,6 @@ public class GlossaryService implements GlossaryResource Log log = Logging.getLog(GlossaryService.class); @Override - @GET - @Produces({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML, MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response getEntries() { ResponseBuilder response = request.evaluatePreconditions(); @@ -83,9 +81,6 @@ public Response getEntries() } @Override - @GET - @Path("/{locale}") - @Produces({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML, MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response get(@PathParam("locale") LocaleId locale) { @@ -104,8 +99,6 @@ public Response get(@PathParam("locale") } @Override - @PUT - @Consumes({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_XML, MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Restrict("#{s:hasPermission('', 'glossary-insert')}") public Response put(Glossary glossary) { @@ -125,8 +118,6 @@ public Response put(Glossary glossary) } @Override - @DELETE - @Path("/{locale}") @Restrict("#{s:hasPermission('', 'glossary-delete')}") public Response deleteGlossary(@PathParam("locale") LocaleId targetLocale) { @@ -143,7 +134,6 @@ public Response deleteGlossary(@PathParam("locale") LocaleId targetLocale) } @Override - @DELETE @Restrict("#{s:hasPermission('', 'glossary-delete')}") public Response deleteGlossaries() { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index 3190d7d39d..37397f15dd 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -120,8 +120,6 @@ public String getIterationSlug() } @Override - @HEAD - @Produces( { MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response head() { EntityTag etag = eTagUtils.generateETagForIteration(projectSlug, iterationSlug); @@ -136,8 +134,6 @@ public Response head() } @Override - @GET - @Produces( { MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response get() { @@ -158,8 +154,6 @@ public Response get() } @Override - @PUT - @Consumes( { MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response put(ProjectIteration projectIteration) { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java index dfd80bfb1b..33c22ecde0 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java @@ -90,8 +90,6 @@ public String getProjectSlug() } @Override - @HEAD - @Produces({ MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response head() { EntityTag etag = eTagUtils.generateTagForProject(projectSlug); @@ -104,8 +102,6 @@ public Response head() } @Override - @GET - @Produces({ MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response get() { try @@ -129,8 +125,6 @@ public Response get() } @Override - @PUT - @Consumes({ MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response put(Project project) { ResponseBuilder response; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java index 5980ebaf93..a3f927c28e 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java @@ -75,9 +75,6 @@ public class ProjectsService implements ProjectsResource MediaType accept; @Override - @GET - @Produces( { MediaTypes.APPLICATION_ZANATA_PROJECTS_XML, MediaTypes.APPLICATION_ZANATA_PROJECTS_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Wrapped(element = "projects", namespace = Namespaces.ZANATA_API) public Response get() { Query query = session.createQuery("from HProject p"); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java index 6976b1a0f0..3f372c1f0e 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java @@ -81,8 +81,6 @@ */ @Name("sourceDocResourceService") @Path(SourceDocResourceService.SERVICE_PATH) -@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) -@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Transactional @IgnoreInterfacePath public class SourceDocResourceService implements SourceDocResource @@ -125,7 +123,6 @@ public class SourceDocResourceService implements SourceDocResource @Override - @HEAD public Response head() { HProjectIteration hProjectIteration = retrieveAndCheckIteration(false); @@ -139,8 +136,6 @@ public Response head() } @Override - @GET - @Wrapped(element = "resources", namespace = Namespaces.ZANATA_API) public Response get(@QueryParam("ext") Set extensions) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(false); @@ -175,7 +170,6 @@ public Response get(@QueryParam("ext") Set extensions) @Override - @POST @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") public Response post(Resource resource, @QueryParam("ext") Set extensions, @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans) { @@ -213,9 +207,6 @@ public Response post(Resource resource, @QueryParam("ext") Set extension } @Override - @GET - @Path(RESOURCE_SLUG_TEMPLATE) - // /r/{id} public Response getResource(@PathParam("id") String idNoSlash, @QueryParam("ext") Set extensions) { log.debug("start get resource"); @@ -259,10 +250,7 @@ public Response getResource(@PathParam("id") String idNoSlash, @QueryParam("ext" } @Override - @PUT - @Path(RESOURCE_SLUG_TEMPLATE) @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - // /r/{id} public Response putResource(@PathParam("id") String idNoSlash, Resource resource, @QueryParam("ext") Set extensions, @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans) { log.debug("start put resource"); @@ -292,10 +280,7 @@ public Response putResource(@PathParam("id") String idNoSlash, Resource resource } @Override - @DELETE - @Path(RESOURCE_SLUG_TEMPLATE) @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - // /r/{id} public Response deleteResource(@PathParam("id") String idNoSlash) { String id = URIHelper.convertFromDocumentURIId(idNoSlash); @@ -315,9 +300,6 @@ public Response deleteResource(@PathParam("id") String idNoSlash) } @Override - @GET - @Path(RESOURCE_SLUG_TEMPLATE + "/meta") - // /r/{id}/meta public Response getResourceMeta(@PathParam("id") String idNoSlash, @QueryParam("ext") Set extensions) { log.debug("start to get resource meta"); @@ -350,10 +332,7 @@ public Response getResourceMeta(@PathParam("id") String idNoSlash, @QueryParam(" } @Override - @PUT - @Path(RESOURCE_SLUG_TEMPLATE + "/meta") @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - // /r/{id}/meta public Response putResourceMeta(@PathParam("id") String idNoSlash, ResourceMeta messageBody, @QueryParam("ext") Set extensions) { log.debug("start to put resource meta"); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 7667c27e7f..215b0f17d7 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -76,9 +76,7 @@ * 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 }) +@Path(TranslatedDocResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class TranslatedDocResourceService implements TranslatedDocResource @@ -150,9 +148,6 @@ public class TranslatedDocResourceService implements TranslatedDocResource private LocaleService localeServiceImpl; @Override - @GET - @Path(RESOURCE_SLUG_TEMPLATE + "/translations/{locale}") - // /r/{id}/translations/{locale} public Response getTranslations( @PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale, @@ -207,10 +202,7 @@ public Response getTranslations( } @Override - @DELETE - @Path(RESOURCE_SLUG_TEMPLATE + "/translations/{locale}") @Restrict("#{s:hasPermission(translatedDocResourceService.securedIteration.project, 'modify-translation')}") - // /r/{id}/translations/{locale} public Response deleteTranslations(@PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale) { String id = URIHelper.convertFromDocumentURIId(idNoSlash); @@ -247,9 +239,6 @@ public Response deleteTranslations(@PathParam("id") String idNoSlash, @PathParam } @Override - @PUT - @Path(RESOURCE_SLUG_TEMPLATE + "/translations/{locale}") - // /r/{id}/translations/{locale} public Response putTranslations(@PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale, TranslationsResource messageBody, @QueryParam("ext") Set extensions, @QueryParam("merge") @DefaultValue("auto") String merge) { // check security (cannot be on @Restrict as it refers to method parameters) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java index fad9187b71..dd633ed901 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java @@ -32,8 +32,6 @@ public VersionService() } @Override - @GET - @Produces({ MediaTypes.APPLICATION_ZANATA_VERSION_JSON, MediaTypes.APPLICATION_ZANATA_VERSION_XML }) public Response get() { return Response.ok(version).build(); diff --git a/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java b/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java index 33ce8baf64..ee5ac79953 100644 --- a/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java +++ b/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java @@ -64,7 +64,6 @@ * href="mailto:camunoz@redhat.com">camunoz@redhat.com */ @Path("/stats") -@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Name("statisticsServiceImpl") @Scope(ScopeType.STATELESS) public class StatisticsServiceImpl implements StatisticsResource From cbce91fa5343e2021a5b58c8cc124b99950aa260 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 17 Sep 2013 15:44:40 +1000 Subject: [PATCH 06/13] Remove JAX-RS annotations from methods --- .../zanata/rest/service/AccountService.java | 7 +-- .../AsynchronousProcessResourceService.java | 43 +++++++--------- .../service/CopyTransResourceService.java | 17 +++---- .../org/zanata/rest/service/FileService.java | 50 ++++++++----------- .../zanata/rest/service/GlossaryService.java | 14 ++---- .../rest/service/ProjectIterationService.java | 8 +-- .../zanata/rest/service/ProjectService.java | 8 +-- .../zanata/rest/service/ProjectsService.java | 5 +- .../service/SourceDocResourceService.java | 26 +++------- .../service/TranslatedDocResourceService.java | 23 +++------ .../TranslationMemoryResourceService.java | 3 +- .../zanata/rest/service/VersionService.java | 5 +- .../service/impl/StatisticsServiceImpl.java | 6 +-- 13 files changed, 71 insertions(+), 144 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index 737d6ae53c..1c08d7f9dd 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -4,12 +4,7 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; @@ -37,7 +32,7 @@ import org.zanata.seam.resteasy.IgnoreInterfacePath; @Name("accountService") -@Path(AccountResource.SERVICE_PATH) +//@Path(AccountResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class AccountService implements AccountResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java index 270328232c..b5e0482af7 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java @@ -24,13 +24,6 @@ import java.util.Set; import java.util.concurrent.ExecutionException; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - import org.jboss.resteasy.spi.NotFoundException; import org.jboss.seam.Component; import org.jboss.seam.annotations.In; @@ -71,7 +64,7 @@ * @author Carlos Munoz camunoz@redhat.com */ @Name("asynchronousProcessResourceService") -@Path(AsynchronousProcessResource.SERVICE_PATH) +//@Path(AsynchronousProcessResource.SERVICE_PATH) @Transactional @Slf4j @IgnoreInterfacePath @@ -97,12 +90,12 @@ public class AsynchronousProcessResourceService implements AsynchronousProcessRe @Override - public ProcessStatus startSourceDocCreation(final @PathParam("id") String idNoSlash, - final @PathParam("projectSlug") String projectSlug, - final @PathParam("iterationSlug") String iterationSlug, + public ProcessStatus startSourceDocCreation(final String idNoSlash, + final String projectSlug, + final String iterationSlug, final Resource resource, - final @QueryParam("ext") Set extensions, - final @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans) + final Set extensions, + final boolean copytrans) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(projectSlug, iterationSlug, true); @@ -143,12 +136,12 @@ public Void call() throws Exception } @Override - public ProcessStatus startSourceDocCreationOrUpdate(final @PathParam("id") String idNoSlash, - final @PathParam("projectSlug") String projectSlug, - final @PathParam("iterationSlug") String iterationSlug, + public ProcessStatus startSourceDocCreationOrUpdate(final String idNoSlash, + final String projectSlug, + final String iterationSlug, final Resource resource, - final @QueryParam("ext") Set extensions, - final @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans) + final Set extensions, + final boolean copytrans) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(projectSlug, iterationSlug, true); @@ -175,13 +168,13 @@ public Void call() throws Exception } @Override - public ProcessStatus startTranslatedDocCreationOrUpdate(final @PathParam("id") String idNoSlash, - final @PathParam("projectSlug") String projectSlug, - final @PathParam("iterationSlug") String iterationSlug, - final @PathParam("locale") LocaleId locale, + public ProcessStatus startTranslatedDocCreationOrUpdate(final String idNoSlash, + final String projectSlug, + final String iterationSlug, + final LocaleId locale, final TranslationsResource translatedDoc, - final @QueryParam("ext") Set extensions, - final @QueryParam("merge") String merge) + final Set extensions, + final String merge) { // check security (cannot be on @Restrict as it refers to method parameters) identity.checkPermission("modify-translation", this.localeServiceImpl.getByLocaleId(locale), @@ -225,7 +218,7 @@ public List call() throws Exception } @Override - public ProcessStatus getProcessStatus(@PathParam("processId") String processId) + public ProcessStatus getProcessStatus(String processId) { AsyncTaskHandle handle = asyncTaskManagerServiceImpl.getHandle(processId); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java index 9819e9e2dd..15c191cdca 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java @@ -20,9 +20,6 @@ */ package org.zanata.rest.service; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.zanata.action.CopyTransManager; @@ -38,7 +35,7 @@ * @author Carlos Munoz camunoz@redhat.com */ @Name("copyTransResourceService") -@Path(CopyTransResource.SERVICE_PATH) +//@Path(CopyTransResource.SERVICE_PATH) @IgnoreInterfacePath public class CopyTransResourceService implements CopyTransResource { @@ -52,9 +49,9 @@ public class CopyTransResourceService implements CopyTransResource private DocumentDAO documentDAO; @Override - public CopyTransStatus startCopyTrans(@PathParam("projectSlug") String projectSlug, - @PathParam("iterationSlug") String iterationSlug, - @PathParam("docId") String docId) + public CopyTransStatus startCopyTrans(String projectSlug, + String iterationSlug, + String docId) { HDocument document = documentDAO.getByProjectIterationAndDocId(projectSlug, iterationSlug, docId); if( document == null ) @@ -69,9 +66,9 @@ public CopyTransStatus startCopyTrans(@PathParam("projectSlug") String projectSl } @Override - public CopyTransStatus getCopyTransStatus(@PathParam("projectSlug") String projectSlug, - @PathParam("iterationSlug") String iterationSlug, - @PathParam("docId") String docId) + public CopyTransStatus getCopyTransStatus(String projectSlug, + String iterationSlug, + String docId) { HDocument document = documentDAO.getByProjectIterationAndDocId(projectSlug, iterationSlug, docId); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java index f9065997ea..d64f726f87 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java @@ -34,20 +34,12 @@ import java.util.Set; import javax.annotation.Nonnull; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; -import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.zanata.adapter.FileFormatAdapter; @@ -76,7 +68,7 @@ import com.google.common.io.ByteStreams; @Name("fileService") -@Path(FileResource.FILE_RESOURCE) +//@Path(FileResource.FILE_RESOURCE) @IgnoreInterfacePath public class FileService implements FileResource { @@ -119,32 +111,32 @@ public Response acceptedFileTypes() } @Override - public Response uploadSourceFile( @PathParam("projectSlug") String projectSlug, - @PathParam("iterationSlug") String iterationSlug, - @QueryParam("docId") String docId, - @MultipartForm DocumentFileUploadForm uploadForm ) + public Response uploadSourceFile(String projectSlug, + String iterationSlug, + String docId, + /*@MultipartForm*/ DocumentFileUploadForm uploadForm ) { GlobalDocumentId id = new GlobalDocumentId(projectSlug, iterationSlug, docId); return sourceUploader.tryUploadSourceFile(id, uploadForm); } @Override - public Response uploadTranslationFile( @PathParam("projectSlug") String projectSlug, - @PathParam("iterationSlug") String iterationSlug, - @PathParam("locale") String localeId, - @QueryParam("docId") String docId, - @QueryParam("merge") String merge, - @MultipartForm DocumentFileUploadForm uploadForm ) + public Response uploadTranslationFile(String projectSlug, + String iterationSlug, + String localeId, + String docId, + String merge, + /*@MultipartForm*/ DocumentFileUploadForm uploadForm ) { GlobalDocumentId id = new GlobalDocumentId(projectSlug, iterationSlug, docId); return translationUploader.tryUploadTranslationFile(id, localeId, merge, uploadForm); } @Override - public Response downloadSourceFile( @PathParam("projectSlug") String projectSlug, - @PathParam("iterationSlug") String iterationSlug, - @PathParam("fileType") String fileType, - @QueryParam("docId") String docId) + public Response downloadSourceFile(String projectSlug, + String iterationSlug, + String fileType, + String docId) { // TODO scan (again) for virus HDocument document = documentDAO.getByProjectIterationAndDocId(projectSlug, iterationSlug, docId); @@ -194,11 +186,11 @@ else if ("pot".equals(fileType) || FILE_TYPE_OFFLINE_PO_TEMPLATE.equals(fileType } @Override - public Response downloadTranslationFile( @PathParam("projectSlug") String projectSlug, - @PathParam("iterationSlug") String iterationSlug, - @PathParam("locale") String locale, - @PathParam("fileType") String fileType, - @QueryParam("docId") String docId ) + public Response downloadTranslationFile(String projectSlug, + String iterationSlug, + String locale, + String fileType, + String docId ) { GlobalDocumentId id = new GlobalDocumentId(projectSlug, iterationSlug, docId); // TODO scan (again) for virus @@ -287,7 +279,7 @@ else if (FILETYPE_TRANSLATED_APPROVED.equals(fileType) || FILETYPE_TRANSLATED_AP } @Override - public Response download( @PathParam("downloadId") String downloadId ) + public Response download(String downloadId) { // TODO scan (again) for virus try diff --git a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java index 4e0a7b236a..9ff02a64bb 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java @@ -2,14 +2,7 @@ import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; @@ -37,7 +30,7 @@ import org.zanata.service.GlossaryFileService; @Name("glossaryService") -@Path(GlossaryService.SERVICE_PATH) +//@Path(GlossaryService.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class GlossaryService implements GlossaryResource @@ -81,8 +74,7 @@ public Response getEntries() } @Override - public Response get(@PathParam("locale") - LocaleId locale) + public Response get(LocaleId locale) { ResponseBuilder response = request.evaluatePreconditions(); if (response != null) @@ -119,7 +111,7 @@ public Response put(Glossary glossary) @Override @Restrict("#{s:hasPermission('', 'glossary-delete')}") - public Response deleteGlossary(@PathParam("locale") LocaleId targetLocale) + public Response deleteGlossary(LocaleId targetLocale) { ResponseBuilder response = request.evaluatePreconditions(); if (response != null) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index 37397f15dd..3bfb545b2f 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -24,15 +24,9 @@ import static org.zanata.common.EntityStatus.READONLY; import javax.annotation.Nonnull; -import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.HttpHeaders; @@ -62,7 +56,7 @@ import com.google.common.base.Objects; @Name("projectIterationService") -@Path(ProjectIterationService.SERVICE_PATH) +//@Path(ProjectIterationService.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class ProjectIterationService implements ProjectIterationResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java index 33c22ecde0..9d64a2fa3e 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java @@ -6,15 +6,9 @@ import java.net.URI; import javax.annotation.Nonnull; -import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.MediaType; @@ -49,7 +43,7 @@ import com.google.common.base.Objects; @Name("projectService") -@Path(ProjectService.SERVICE_PATH) +//@Path(ProjectService.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class ProjectService implements ProjectResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java index a3f927c28e..b7c30d8bd2 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java @@ -28,10 +28,7 @@ import java.util.List; import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; @@ -56,7 +53,7 @@ import com.google.common.base.Objects; @Name("projectsService") -@Path(ProjectsResource.SERVICE_PATH) +//@Path(ProjectsResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class ProjectsService implements ProjectsResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java index 3f372c1f0e..bf5d74e551 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java @@ -48,22 +48,12 @@ import org.zanata.service.DocumentService; import org.zanata.service.LocaleService; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Request; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; @@ -80,7 +70,7 @@ * @author Carlos Munoz camunoz@redhat.com */ @Name("sourceDocResourceService") -@Path(SourceDocResourceService.SERVICE_PATH) +@Path(SourceDocResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class SourceDocResourceService implements SourceDocResource @@ -136,7 +126,7 @@ public Response head() } @Override - public Response get(@QueryParam("ext") Set extensions) + public Response get(Set extensions) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(false); @@ -171,7 +161,7 @@ public Response get(@QueryParam("ext") Set extensions) @Override @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - public Response post(Resource resource, @QueryParam("ext") Set extensions, @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans) + public Response post(Resource resource, Set extensions, boolean copytrans) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(true); @@ -207,7 +197,7 @@ public Response post(Resource resource, @QueryParam("ext") Set extension } @Override - public Response getResource(@PathParam("id") String idNoSlash, @QueryParam("ext") Set extensions) + public Response getResource(String idNoSlash, Set extensions) { log.debug("start get resource"); String id = URIHelper.convertFromDocumentURIId(idNoSlash); @@ -251,7 +241,7 @@ public Response getResource(@PathParam("id") String idNoSlash, @QueryParam("ext" @Override @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - public Response putResource(@PathParam("id") String idNoSlash, Resource resource, @QueryParam("ext") Set extensions, @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans) + public Response putResource(String idNoSlash, Resource resource, Set extensions, boolean copytrans) { log.debug("start put resource"); String id = URIHelper.convertFromDocumentURIId(idNoSlash); @@ -281,7 +271,7 @@ public Response putResource(@PathParam("id") String idNoSlash, Resource resource @Override @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - public Response deleteResource(@PathParam("id") String idNoSlash) + public Response deleteResource(String idNoSlash) { String id = URIHelper.convertFromDocumentURIId(idNoSlash); HProjectIteration hProjectIteration = retrieveAndCheckIteration(true); @@ -300,7 +290,7 @@ public Response deleteResource(@PathParam("id") String idNoSlash) } @Override - public Response getResourceMeta(@PathParam("id") String idNoSlash, @QueryParam("ext") Set extensions) + public Response getResourceMeta(String idNoSlash, Set extensions) { log.debug("start to get resource meta"); String id = URIHelper.convertFromDocumentURIId(idNoSlash); @@ -333,7 +323,7 @@ public Response getResourceMeta(@PathParam("id") String idNoSlash, @QueryParam(" @Override @Restrict("#{s:hasPermission(sourceDocResourceService.securedIteration, 'import-template')}") - public Response putResourceMeta(@PathParam("id") String idNoSlash, ResourceMeta messageBody, @QueryParam("ext") Set extensions) + public Response putResourceMeta(String idNoSlash, ResourceMeta messageBody, Set extensions) { log.debug("start to put resource meta"); String id = URIHelper.convertFromDocumentURIId(idNoSlash); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 215b0f17d7..88c03018d4 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -20,22 +20,13 @@ */ package org.zanata.rest.service; -import static org.zanata.rest.service.SourceDocResource.RESOURCE_SLUG_TEMPLATE; - import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.HttpHeaders; @@ -149,11 +140,11 @@ public class TranslatedDocResourceService implements TranslatedDocResource @Override public Response getTranslations( - @PathParam("id") String idNoSlash, - @PathParam("locale") LocaleId locale, - @QueryParam("ext") Set extensions, - @QueryParam("skeletons") @DefaultValue("false") boolean skeletons, - @HeaderParam(HttpHeaders.IF_NONE_MATCH) String eTag + String idNoSlash, + LocaleId locale, + Set extensions, + boolean skeletons, + /*@HeaderParam(HttpHeaders.IF_NONE_MATCH)*/ String eTag ) { log.debug("start to get translation"); @@ -203,7 +194,7 @@ public Response getTranslations( @Override @Restrict("#{s:hasPermission(translatedDocResourceService.securedIteration.project, 'modify-translation')}") - public Response deleteTranslations(@PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale) + public Response deleteTranslations(String idNoSlash, LocaleId locale) { String id = URIHelper.convertFromDocumentURIId(idNoSlash); HProjectIteration hProjectIteration = restSlugValidator.retrieveAndCheckIteration(projectSlug, iterationSlug, true); @@ -239,7 +230,7 @@ public Response deleteTranslations(@PathParam("id") String idNoSlash, @PathParam } @Override - public Response putTranslations(@PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale, TranslationsResource messageBody, @QueryParam("ext") Set extensions, @QueryParam("merge") @DefaultValue("auto") String merge) + public Response putTranslations(String idNoSlash, LocaleId locale, TranslationsResource messageBody, Set extensions, String merge) { // check security (cannot be on @Restrict as it refers to method parameters) identity.checkPermission("modify-translation", this.localeServiceImpl.getByLocaleId(locale), diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java index 802dd1cbf0..65b0c55bbb 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java @@ -25,7 +25,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import javax.ws.rs.Path; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; @@ -57,7 +56,7 @@ import com.google.common.base.Optional; @Name("translationMemoryResource") -@Path(TranslationMemoryResource.SERVICE_PATH) +//@Path(TranslationMemoryResource.SERVICE_PATH) @Transactional(TransactionPropagationType.SUPPORTS) @Slf4j @ParametersAreNonnullByDefault diff --git a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java index dd633ed901..6ef3460d61 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java @@ -1,9 +1,6 @@ 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.Response; import org.jboss.seam.annotations.Name; @@ -14,7 +11,7 @@ @Name("versionService") -@Path(VersionResource.SERVICE_PATH) +//@Path(VersionResource.SERVICE_PATH) @IgnoreInterfacePath public class VersionService implements VersionResource { diff --git a/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java b/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java index ee5ac79953..4da98410b1 100644 --- a/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java +++ b/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java @@ -25,10 +25,6 @@ import java.util.List; import java.util.Map; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - import org.apache.commons.lang.StringUtils; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.In; @@ -63,7 +59,7 @@ * @author Carlos Munoz camunoz@redhat.com */ -@Path("/stats") +//@Path("/stats") @Name("statisticsServiceImpl") @Scope(ScopeType.STATELESS) public class StatisticsServiceImpl implements StatisticsResource From 5417de9a3e82b2109b6e556e4824e0f34d471fca Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 24 Sep 2013 17:52:10 +1000 Subject: [PATCH 07/13] Avoid mutation of test data; use DTOUtil.toXML instead of toString --- .../zanata/rest/service/RestUtilsTest.java | 36 ++++++++++++----- .../service/TranslationServiceRestTest.java | 40 ++++++++++++++----- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/zanata-war/src/test/java/org/zanata/rest/service/RestUtilsTest.java b/zanata-war/src/test/java/org/zanata/rest/service/RestUtilsTest.java index 6e0eb035d8..f784467447 100644 --- a/zanata-war/src/test/java/org/zanata/rest/service/RestUtilsTest.java +++ b/zanata-war/src/test/java/org/zanata/rest/service/RestUtilsTest.java @@ -15,6 +15,7 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import org.zanata.rest.dto.DTOUtil; import org.zanata.rest.dto.VersionInfo; import org.zanata.rest.dto.resource.Resource; import org.zanata.rest.dto.resource.ResourceMeta; @@ -50,27 +51,42 @@ public void prepareSeam() @DataProvider(name = "ResourceTestData") public Object[][] getResourceTestData() { - return new Object[][] { new Object[] { resourceTestFactory.getPoHeaderTest() }, new Object[] { resourceTestFactory.getPotEntryHeaderTest() }, new Object[] { resourceTestFactory.getTextFlowCommentTest() } -, new Object[] { resourceTestFactory.getTextFlowTest2() } + // @formatter:off + return new Object[][] { + new Object[] { "getPoHeaderTest", resourceTestFactory.getPoHeaderTest() }, + new Object[] { "getPotEntryHeaderTest", resourceTestFactory.getPotEntryHeaderTest() }, + new Object[] { "getTextFlowCommentTest", resourceTestFactory.getTextFlowCommentTest() }, + new Object[] { "getTextFlowTest2", resourceTestFactory.getTextFlowTest2() } }; + // @formatter:on } @DataProvider(name = "ResourceMetaTestData") public Object[][] getResourceMetaTestData() { - return new Object[][] { new Object[] { resourceTestFactory.getResourceMeta() }, new Object[] { resourceTestFactory.getPoHeaderResourceMeta() } + // @formatter:off + return new Object[][] { + new Object[] { "getResourceMeta", resourceTestFactory.getResourceMeta() }, + new Object[] { "getPoHeaderResourceMeta", resourceTestFactory.getPoHeaderResourceMeta() } }; + // @formatter:on } @DataProvider(name = "TranslationTestData") public Object[][] getTranslationTestData() { - return new Object[][] { new Object[] { transTestFactory.getPoTargetHeaderTextFlowTargetTest() }, new Object[] { transTestFactory.getTestObject() }, new Object[] { transTestFactory.getTestObject2() }, new Object[] { transTestFactory.getTextFlowTargetCommentTest() } + // @formatter:off + return new Object[][] { + new Object[] { "getPoTargetHeaderTextFlowTargetTest", transTestFactory.getPoTargetHeaderTextFlowTargetTest() }, + new Object[] { "getTestObject", transTestFactory.getTestObject() }, + new Object[] { "getTestObject2", transTestFactory.getTestObject2() }, + new Object[] { "getTextFlowTargetCommentTest", transTestFactory.getTextFlowTargetCommentTest() } }; + // @formatter:on } @Test(dataProvider = "ResourceTestData") - public void testUnmarshallResource(Resource res) throws UnsupportedEncodingException + public void testUnmarshallResource(String desc, Resource res) throws UnsupportedEncodingException { // SeamMockClientExecutor test = new SeamMockClientExecutor(); // ClientRequest client = test.createRequest("http://example.com/"); @@ -83,13 +99,13 @@ private void testRestUtilUnmarshall(T entity, Class InputStream messageBody = null; try { - String testStr = entity.toString(); + String testStr = DTOUtil.toXML(entity); log.info("expect:" + testStr); messageBody = new ByteArrayInputStream(testStr.getBytes("UTF-8")); T unmarshall = restUtils.unmarshall(type, messageBody, MediaType.APPLICATION_XML_TYPE, new Headers()); - Log.info("got:" + unmarshall.toString()); - assertThat(entity.toString(), is(testStr)); + Log.info("got:" + DTOUtil.toXML(unmarshall)); + assertThat(DTOUtil.toXML(entity), is(testStr)); } finally { @@ -142,13 +158,13 @@ public void testUnmarshallJasonTranslationsResource() @Test(dataProvider = "TranslationTestData") - public void testUnmarshallTranslation(TranslationsResource res) throws UnsupportedEncodingException + public void testUnmarshallTranslation(String desc, TranslationsResource res) throws UnsupportedEncodingException { testRestUtilUnmarshall(res, TranslationsResource.class); } @Test(dataProvider = "ResourceMetaTestData") - public void testUnmarshallResourceMeta(ResourceMeta res) throws UnsupportedEncodingException + public void testUnmarshallResourceMeta(String desc, ResourceMeta res) throws UnsupportedEncodingException { testRestUtilUnmarshall(res, ResourceMeta.class); } diff --git a/zanata-war/src/test/java/org/zanata/rest/service/TranslationServiceRestTest.java b/zanata-war/src/test/java/org/zanata/rest/service/TranslationServiceRestTest.java index 33f3e27980..68950d4f48 100644 --- a/zanata-war/src/test/java/org/zanata/rest/service/TranslationServiceRestTest.java +++ b/zanata-war/src/test/java/org/zanata/rest/service/TranslationServiceRestTest.java @@ -1,6 +1,7 @@ package org.zanata.rest.service; import javax.ws.rs.core.Response.Status; +import javax.xml.bind.JAXBException; import org.jboss.resteasy.client.ClientResponse; import org.mockito.Mockito; @@ -11,6 +12,7 @@ import org.testng.annotations.Test; import org.zanata.common.LocaleId; import org.zanata.rest.StringSet; +import org.zanata.rest.dto.DTOUtil; import org.zanata.rest.dto.resource.Resource; import org.zanata.rest.dto.resource.TranslationsResource; import org.zanata.seam.SeamAutowire; @@ -36,12 +38,12 @@ public Object[][] getTestData() { // @formatter:off return new Object[][] - { - new Object[] { transTestFactory.getTestObject() }, - new Object[] { transTestFactory.getPoTargetHeaderTextFlowTargetTest() }, - new Object[] { transTestFactory.getTextFlowTargetCommentTest() }, - new Object[] { transTestFactory.getAllExtension() } - }; + { + new Object[] { "getTestObject", transTestFactory.getTestObject() }, + new Object[] { "getPoTargetHeaderTextFlowTargetTest", transTestFactory.getPoTargetHeaderTextFlowTargetTest() }, + new Object[] { "getTextFlowTargetCommentTest", transTestFactory.getTextFlowTargetCommentTest() }, + new Object[] { "getAllExtension", transTestFactory.getAllExtension() } + }; // @formatter:on } @@ -81,8 +83,9 @@ public void testDeleteTranslation() } @Test(dataProvider = "TranslationTestData") - public void testPutGetTranslation(TranslationsResource sr) + public void testPutGetTranslation(String desc, TranslationsResource sr) { + sr = cloneDTO(sr); Resource res = resourceTestFactory.getTextFlowTest(); sourceDocResource.putResource(res.getName(), res, new StringSet("gettext;comment")); log.debug("successful put resource:" + res.getName()); @@ -97,8 +100,9 @@ public void testPutGetTranslation(TranslationsResource sr) } @Test(dataProvider = "TranslationTestData") - public void testPutGetTranslationNoExtension(TranslationsResource sr) + public void testPutGetTranslationNoExtension(String desc, TranslationsResource sr) { + sr = cloneDTO(sr); Resource res = resourceTestFactory.getTextFlowTest(); sourceDocResource.putResource(res.getName(), res, new StringSet("gettext;comment")); log.debug("successful put resource:" + res.getName()); @@ -113,9 +117,10 @@ public void testPutGetTranslationNoExtension(TranslationsResource sr) assertThat(base.toString(), is(get.toString())); } - @Test(dataProvider = "TranslationTestData") - public void testPutNoExtensionGetTranslation(TranslationsResource sr) + @Test(dataProvider = "TranslationTestData", dependsOnMethods = { "testPutGetTranslation" }) + public void testPutNoExtensionGetTranslation(String desc, TranslationsResource sr) { + sr = cloneDTO(sr); Resource res = resourceTestFactory.getTextFlowTest(); sourceDocResource.putResource(res.getName(), res, new StringSet("gettext;comment")); log.debug("successful put resource:" + res.getName()); @@ -131,8 +136,9 @@ public void testPutNoExtensionGetTranslation(TranslationsResource sr) } @Test(dataProvider = "TranslationTestData") - public void testPutGetNoExtensionTranslation(TranslationsResource sr) + public void testPutGetNoExtensionTranslation(String desc, TranslationsResource sr) { + sr = cloneDTO(sr); Resource res = resourceTestFactory.getTextFlowTest(); sourceDocResource.putResource(res.getName(), res, new StringSet("gettext;comment")); log.debug("successful put resource:" + res.getName()); @@ -147,4 +153,16 @@ public void testPutGetNoExtensionTranslation(TranslationsResource sr) assertThat(base.toString(), is(get.toString())); } + private T cloneDTO(T dto) + { + try + { + return (T) DTOUtil.toObject(DTOUtil.toXML(dto), dto.getClass()); + } + catch (JAXBException e) + { + throw new RuntimeException(e); + } + } + } From 7a794e2e09fa7e9f0efd2316e7b7a3935a2444de Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 24 Sep 2013 18:10:53 +1000 Subject: [PATCH 08/13] Improve exception handling --- .../org/zanata/rest/service/TranslatedDocResourceService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 88c03018d4..2179f25080 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -242,7 +242,7 @@ public Response putTranslations(String idNoSlash, LocaleId locale, TranslationsR { mergeType = MergeType.valueOf(merge.toUpperCase()); } - catch (Exception e) + catch (IllegalArgumentException e) { return Response.status(Status.BAD_REQUEST).entity("bad merge type "+merge).build(); } From e950c6f3924eeedee9d5265d0d771ad80e0c3b45 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 24 Sep 2013 18:12:04 +1000 Subject: [PATCH 09/13] Remove ZanataResteasyBootstrap @Path workaround --- .../zanata/rest/ZanataResteasyBootstrap.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java b/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java index d4663589e4..b2914c5680 100644 --- a/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java +++ b/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java @@ -91,29 +91,4 @@ 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 annotation, - Component seamComponent) - { - if (annotation == javax.ws.rs.Path.class && - seamComponent.getBeanClass().isAnnotationPresent( - IgnoreInterfacePath.class)) - { - return null; - } - else - { - return super.getAnnotatedInterface(annotation, seamComponent); - } - } - } From 7d5f10f5d42e0436040a21129340c32a7380dbb0 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 24 Sep 2013 18:14:13 +1000 Subject: [PATCH 10/13] Put back @Path on REST services --- .../main/java/org/zanata/rest/service/AccountService.java | 3 ++- .../rest/service/AsynchronousProcessResourceService.java | 5 ++++- .../src/main/java/org/zanata/rest/service/FileService.java | 3 ++- .../main/java/org/zanata/rest/service/GlossaryService.java | 3 ++- .../org/zanata/rest/service/ProjectIterationService.java | 3 ++- .../main/java/org/zanata/rest/service/ProjectService.java | 3 ++- .../main/java/org/zanata/rest/service/ProjectsService.java | 3 ++- .../org/zanata/rest/service/SourceDocResourceService.java | 3 +++ .../rest/service/TranslationMemoryResourceService.java | 3 ++- .../main/java/org/zanata/rest/service/VersionService.java | 3 ++- 10 files changed, 23 insertions(+), 9 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index 1c08d7f9dd..3126439044 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -4,6 +4,7 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; @@ -32,7 +33,7 @@ import org.zanata.seam.resteasy.IgnoreInterfacePath; @Name("accountService") -//@Path(AccountResource.SERVICE_PATH) +@Path(AccountResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class AccountService implements AccountResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java index b5e0482af7..a7462d616d 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java @@ -56,6 +56,9 @@ import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; + +import javax.ws.rs.Path; + import static org.zanata.rest.dto.ProcessStatus.ProcessStatusCode; /** @@ -64,7 +67,7 @@ * @author Carlos Munoz camunoz@redhat.com */ @Name("asynchronousProcessResourceService") -//@Path(AsynchronousProcessResource.SERVICE_PATH) +@Path(AsynchronousProcessResource.SERVICE_PATH) @Transactional @Slf4j @IgnoreInterfacePath diff --git a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java index d64f726f87..9ad268e0bb 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java @@ -34,6 +34,7 @@ import java.util.Set; import javax.annotation.Nonnull; +import javax.ws.rs.Path; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -68,7 +69,7 @@ import com.google.common.io.ByteStreams; @Name("fileService") -//@Path(FileResource.FILE_RESOURCE) +@Path(FileResource.FILE_RESOURCE) @IgnoreInterfacePath public class FileService implements FileResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java index 9ff02a64bb..6e09b12205 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java @@ -3,6 +3,7 @@ import java.util.List; import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; @@ -30,7 +31,7 @@ import org.zanata.service.GlossaryFileService; @Name("glossaryService") -//@Path(GlossaryService.SERVICE_PATH) +@Path(GlossaryService.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class GlossaryService implements GlossaryResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index 3bfb545b2f..1555865637 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -26,6 +26,7 @@ import javax.annotation.Nonnull; import javax.ws.rs.DefaultValue; import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; @@ -56,7 +57,7 @@ import com.google.common.base.Objects; @Name("projectIterationService") -//@Path(ProjectIterationService.SERVICE_PATH) +@Path(ProjectIterationService.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class ProjectIterationService implements ProjectIterationResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java index 9d64a2fa3e..b3e62ab126 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java @@ -8,6 +8,7 @@ import javax.annotation.Nonnull; import javax.ws.rs.DefaultValue; import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; @@ -43,7 +44,7 @@ import com.google.common.base.Objects; @Name("projectService") -//@Path(ProjectService.SERVICE_PATH) +@Path(ProjectService.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class ProjectService implements ProjectResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java index b7c30d8bd2..8c6ddc7cc1 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java @@ -29,6 +29,7 @@ import javax.ws.rs.DefaultValue; import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; import javax.ws.rs.core.Context; import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; @@ -53,7 +54,7 @@ import com.google.common.base.Objects; @Name("projectsService") -//@Path(ProjectsResource.SERVICE_PATH) +@Path(ProjectsResource.SERVICE_PATH) @Transactional @IgnoreInterfacePath public class ProjectsService implements ProjectsResource diff --git a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java index bf5d74e551..2c5b9afc64 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java @@ -48,12 +48,15 @@ import org.zanata.service.DocumentService; import org.zanata.service.LocaleService; +import javax.ws.rs.Consumes; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Request; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java index 65b0c55bbb..802dd1cbf0 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java @@ -25,6 +25,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import javax.ws.rs.Path; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; @@ -56,7 +57,7 @@ import com.google.common.base.Optional; @Name("translationMemoryResource") -//@Path(TranslationMemoryResource.SERVICE_PATH) +@Path(TranslationMemoryResource.SERVICE_PATH) @Transactional(TransactionPropagationType.SUPPORTS) @Slf4j @ParametersAreNonnullByDefault diff --git a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java index 6ef3460d61..ef138e95d7 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java @@ -1,6 +1,7 @@ package org.zanata.rest.service; +import javax.ws.rs.Path; import javax.ws.rs.core.Response; import org.jboss.seam.annotations.Name; @@ -11,7 +12,7 @@ @Name("versionService") -//@Path(VersionResource.SERVICE_PATH) +@Path(VersionResource.SERVICE_PATH) @IgnoreInterfacePath public class VersionService implements VersionResource { From 51174910a896a30a96e0ea34cd979bf9804547bc Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 25 Sep 2013 14:02:54 +1000 Subject: [PATCH 11/13] Remove IgnoreInterfacePath annotation --- .../zanata/rest/ZanataResteasyBootstrap.java | 2 -- .../org/zanata/rest/service/AccountService.java | 3 --- .../AsynchronousProcessResourceService.java | 2 -- .../rest/service/CopyTransResourceService.java | 2 -- .../org/zanata/rest/service/FileService.java | 2 -- .../zanata/rest/service/GlossaryService.java | 3 --- .../rest/service/ProjectIterationService.java | 4 ---- .../org/zanata/rest/service/ProjectService.java | 3 --- .../zanata/rest/service/ProjectsService.java | 4 ---- .../rest/service/SourceDocResourceService.java | 7 ------- .../service/TranslatedDocResourceService.java | 2 -- .../TranslationMemoryResourceService.java | 2 -- .../org/zanata/rest/service/VersionService.java | 3 --- .../seam/resteasy/IgnoreInterfacePath.java | 17 ----------------- 14 files changed, 56 deletions(-) delete mode 100644 zanata-war/src/main/java/org/zanata/seam/resteasy/IgnoreInterfacePath.java diff --git a/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java b/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java index b2914c5680..ce0f54b3a3 100644 --- a/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java +++ b/zanata-war/src/main/java/org/zanata/rest/ZanataResteasyBootstrap.java @@ -1,7 +1,6 @@ package org.zanata.rest; import java.io.IOException; -import java.lang.annotation.Annotation; import java.util.Collection; import javax.ws.rs.core.Response.Status; @@ -25,7 +24,6 @@ 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) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java index 3126439044..69ff77d6aa 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AccountService.java @@ -28,14 +28,11 @@ import org.zanata.model.HAccountRole; import org.zanata.model.HLocale; 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(AccountResource.SERVICE_PATH) @Transactional -@IgnoreInterfacePath public class AccountService implements AccountResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java index a7462d616d..e2350454ab 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/AsynchronousProcessResourceService.java @@ -44,7 +44,6 @@ 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; @@ -70,7 +69,6 @@ @Path(AsynchronousProcessResource.SERVICE_PATH) @Transactional @Slf4j -@IgnoreInterfacePath public class AsynchronousProcessResourceService implements AsynchronousProcessResource { @In diff --git a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java index 15c191cdca..3c50be38ee 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/CopyTransResourceService.java @@ -28,7 +28,6 @@ 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; /** @@ -36,7 +35,6 @@ */ @Name("copyTransResourceService") //@Path(CopyTransResource.SERVICE_PATH) -@IgnoreInterfacePath public class CopyTransResourceService implements CopyTransResource { @In diff --git a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java index 9ad268e0bb..bb439f0b50 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java @@ -59,7 +59,6 @@ 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; @@ -70,7 +69,6 @@ @Name("fileService") @Path(FileResource.FILE_RESOURCE) -@IgnoreInterfacePath public class FileService implements FileResource { private static final String FILE_TYPE_OFFLINE_PO = "offlinepo"; diff --git a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java index 6e09b12205..0d31f67a2a 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/GlossaryService.java @@ -23,17 +23,14 @@ import org.zanata.model.HGlossaryEntry; import org.zanata.model.HGlossaryTerm; import org.zanata.model.HTermComment; -import org.zanata.rest.MediaTypes; 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 diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index 1555865637..2a60df23fb 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -49,17 +49,13 @@ 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.seam.resteasy.IgnoreInterfacePath; import com.google.common.base.Objects; @Name("projectIterationService") @Path(ProjectIterationService.SERVICE_PATH) @Transactional -@IgnoreInterfacePath public class ProjectIterationService implements ProjectIterationResource { /** Project Identifier. */ diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java index b3e62ab126..1a485a6c35 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectService.java @@ -33,20 +33,17 @@ import org.zanata.model.HAccount; 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.NoSuchEntityException; 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 { /** Project Identifier. */ diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java index 8c6ddc7cc1..a5ca912595 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectsService.java @@ -37,26 +37,22 @@ import org.hibernate.Query; import org.hibernate.Session; -import org.jboss.resteasy.annotations.providers.jaxb.Wrapped; import org.jboss.resteasy.util.GenericType; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Transactional; import org.jboss.seam.log.Log; -import org.zanata.common.Namespaces; import org.zanata.model.HProject; 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(ProjectsResource.SERVICE_PATH) @Transactional -@IgnoreInterfacePath public class ProjectsService implements ProjectsResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java index 2c5b9afc64..0026c6f4e3 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/SourceDocResourceService.java @@ -20,7 +20,6 @@ */ package org.zanata.rest.service; -import org.jboss.resteasy.annotations.providers.jaxb.Wrapped; import org.jboss.resteasy.util.GenericType; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Logger; @@ -30,7 +29,6 @@ import org.jboss.seam.log.Log; import org.zanata.common.EntityStatus; import org.zanata.common.LocaleId; -import org.zanata.common.Namespaces; import org.zanata.dao.DocumentDAO; import org.zanata.dao.ProjectIterationDAO; import org.zanata.exception.ZanataServiceException; @@ -44,19 +42,15 @@ 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; -import javax.ws.rs.Consumes; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Request; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; @@ -75,7 +69,6 @@ @Name("sourceDocResourceService") @Path(SourceDocResource.SERVICE_PATH) @Transactional -@IgnoreInterfacePath public class SourceDocResourceService implements SourceDocResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 2179f25080..6874c0da8e 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -55,7 +55,6 @@ 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; @@ -69,7 +68,6 @@ @Name("translatedDocResourceService") @Path(TranslatedDocResource.SERVICE_PATH) @Transactional -@IgnoreInterfacePath public class TranslatedDocResourceService implements TranslatedDocResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java index 802dd1cbf0..1675087091 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslationMemoryResourceService.java @@ -49,7 +49,6 @@ 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; @@ -61,7 +60,6 @@ @Transactional(TransactionPropagationType.SUPPORTS) @Slf4j @ParametersAreNonnullByDefault -@IgnoreInterfacePath // TODO options to export obsolete docs and textflows to TMX? public class TranslationMemoryResourceService implements TranslationMemoryResource { diff --git a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java index ef138e95d7..cd30131205 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/VersionService.java @@ -5,15 +5,12 @@ import javax.ws.rs.core.Response; 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(VersionResource.SERVICE_PATH) -@IgnoreInterfacePath public class VersionService implements VersionResource { diff --git a/zanata-war/src/main/java/org/zanata/seam/resteasy/IgnoreInterfacePath.java b/zanata-war/src/main/java/org/zanata/seam/resteasy/IgnoreInterfacePath.java deleted file mode 100644 index 1be523955f..0000000000 --- a/zanata-war/src/main/java/org/zanata/seam/resteasy/IgnoreInterfacePath.java +++ /dev/null @@ -1,17 +0,0 @@ -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 -{ -} From 35f4b80d5c71f556496ac2a1b62003ed088c273b Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 25 Sep 2013 14:34:30 +1000 Subject: [PATCH 12/13] Add usedDependency entries for RESTEasy annotations --- zanata-war/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zanata-war/pom.xml b/zanata-war/pom.xml index a9ac0c07ac..76405e5363 100644 --- a/zanata-war/pom.xml +++ b/zanata-war/pom.xml @@ -111,6 +111,9 @@ quartz:quartz org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api + + org.jboss.resteasy:resteasy-jaxb-provider + org.jboss.resteasy:resteasy-multipart-provider From 9697e414f47aa470df7294ba5f893d7662eed7dd Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 25 Sep 2013 15:31:52 +1000 Subject: [PATCH 13/13] Remove commented-out annotations --- .../src/main/java/org/zanata/rest/service/FileService.java | 4 ++-- .../org/zanata/rest/service/TranslatedDocResourceService.java | 2 +- .../java/org/zanata/service/impl/StatisticsServiceImpl.java | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java index bb439f0b50..d7441335dc 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/FileService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/FileService.java @@ -113,7 +113,7 @@ public Response acceptedFileTypes() public Response uploadSourceFile(String projectSlug, String iterationSlug, String docId, - /*@MultipartForm*/ DocumentFileUploadForm uploadForm ) + DocumentFileUploadForm uploadForm ) { GlobalDocumentId id = new GlobalDocumentId(projectSlug, iterationSlug, docId); return sourceUploader.tryUploadSourceFile(id, uploadForm); @@ -125,7 +125,7 @@ public Response uploadTranslationFile(String projectSlug, String localeId, String docId, String merge, - /*@MultipartForm*/ DocumentFileUploadForm uploadForm ) + DocumentFileUploadForm uploadForm ) { GlobalDocumentId id = new GlobalDocumentId(projectSlug, iterationSlug, docId); return translationUploader.tryUploadTranslationFile(id, localeId, merge, uploadForm); diff --git a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java index 6874c0da8e..2b5cecbd1c 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/TranslatedDocResourceService.java @@ -142,7 +142,7 @@ public Response getTranslations( LocaleId locale, Set extensions, boolean skeletons, - /*@HeaderParam(HttpHeaders.IF_NONE_MATCH)*/ String eTag + String eTag ) { log.debug("start to get translation"); diff --git a/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java b/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java index 4da98410b1..4eb90e3886 100644 --- a/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java +++ b/zanata-war/src/main/java/org/zanata/service/impl/StatisticsServiceImpl.java @@ -59,7 +59,6 @@ * @author Carlos Munoz camunoz@redhat.com */ -//@Path("/stats") @Name("statisticsServiceImpl") @Scope(ScopeType.STATELESS) public class StatisticsServiceImpl implements StatisticsResource