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

Commit

Permalink
Merge pull request #166 from zanata/move-path-to-api
Browse files Browse the repository at this point in the history
Move @path to api (for Enunciate docs)
  • Loading branch information
carlosmunoz committed Sep 25, 2013
2 parents b987b1a + 9697e41 commit 7616058
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 814 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Expand Up @@ -23,7 +23,6 @@
<cobertura.total-branch-rate>30</cobertura.total-branch-rate>
<cobertura.halt.failure>false</cobertura.halt.failure>
<delombok.dir>${project.build.directory}/delombok/org/zanata</delombok.dir>
<enunciate.version>1.24</enunciate.version>
<gwt.version>2.5.0</gwt.version>
<icu4j.version>4.8</icu4j.version>
<lombok.source.dir>${project.build.sourceDirectory}/org/zanata</lombok.source.dir>
Expand Down Expand Up @@ -649,11 +648,6 @@
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>${enunciate.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
Expand Down
Expand Up @@ -25,11 +25,12 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.zanata.rest.service.RestConstants;

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

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

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

}
51 changes: 3 additions & 48 deletions zanata-war/pom.xml
Expand Up @@ -110,6 +110,9 @@
<usedDependency>quartz:quartz</usedDependency>
<!-- Used indirectly by org.zanata.arquillian.Deployments -->
<usedDependency>org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api</usedDependency>
<!-- used by REST API interfaces -->
<usedDependency>org.jboss.resteasy:resteasy-jaxb-provider</usedDependency>
<usedDependency>org.jboss.resteasy:resteasy-multipart-provider</usedDependency>

<!-- Grandfathered entries: -->
<!-- TODO validate or remove each of these -->
Expand Down Expand Up @@ -601,23 +604,6 @@
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.enunciate
</groupId>
<artifactId>
maven-enunciate-plugin
</artifactId>
<versionRange>[1.9-RC1,)</versionRange>
<goals>
<goal>assemble</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
Expand Down Expand Up @@ -708,31 +694,6 @@
</pluginManagement>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<!-- apparently pluginManagement is ignored in reporting -->
<version>${enunciate.version}</version>
<configuration>
<configFile>etc/enunciate/enunciate.xml</configFile>

<!--
These two enunciate options are undocumented, but
their absence causes an error during site generation.
-->
<enunciateArtifactId>unused</enunciateArtifactId>
<moduleName>unused</moduleName>

<!-- The subdirectory of the site where the documentation will be put. -->
<!-- Note that if this isn't set, the documentation will overwrite the site. -->
<docsSubdir>apidocs</docsSubdir>
</configuration>
</plugin>
</plugins>
</reporting>

<profiles>
<profile>
<!-- This profile will copy the exploded war to AS7 and trigger a re-deployment. -->
Expand Down Expand Up @@ -1438,12 +1399,6 @@
<artifactId>openprops</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-core-annotations</artifactId>
<version>${enunciate.version}</version>
</dependency>

<!-- Quartz -->

<dependency>
Expand Down
@@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -91,29 +89,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<? extends Annotation> annotation,
Component seamComponent)
{
if (annotation == javax.ws.rs.Path.class &&
seamComponent.getBeanClass().isAnnotationPresent(
IgnoreInterfacePath.class))
{
return null;
}
else
{
return super.getAnnotatedInterface(annotation, seamComponent);
}
}

}
Expand Up @@ -4,19 +4,14 @@
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;
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;
Expand All @@ -33,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("/accounts/u/{username:[a-z\\d_]{3,20}}")
@Path(AccountResource.SERVICE_PATH)
@Transactional
@IgnoreInterfacePath
public class AccountService implements AccountResource
{
private static final Log log = Logging.getLog(AccountService.class);
Expand Down Expand Up @@ -70,19 +62,7 @@ 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:<br>
* OK(200) - Response containing information for the user account.<br>
* 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());
Expand All @@ -98,22 +78,7 @@ 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:<br>
* OK(200) - If a new account was created.<br>
* CREATED(201) - If an existing account was modified.<br>
* UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.<br>
* INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation.
*/
@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);
Expand Down
Expand Up @@ -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;
Expand All @@ -51,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;
Expand All @@ -63,6 +55,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;

/**
Expand All @@ -71,11 +66,9 @@
* @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Name("asynchronousProcessResourceService")
@Path("/async")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Path(AsynchronousProcessResource.SERVICE_PATH)
@Transactional
@Slf4j
@IgnoreInterfacePath
public class AsynchronousProcessResourceService implements AsynchronousProcessResource
{
@In
Expand All @@ -98,12 +91,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<String> extensions,
final @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans)
final Set<String> extensions,
final boolean copytrans)
{
HProjectIteration hProjectIteration = retrieveAndCheckIteration(projectSlug, iterationSlug, true);

Expand Down Expand Up @@ -144,12 +137,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<String> extensions,
final @QueryParam("copyTrans") @DefaultValue("true") boolean copytrans)
final Set<String> extensions,
final boolean copytrans)
{

HProjectIteration hProjectIteration = retrieveAndCheckIteration(projectSlug, iterationSlug, true);
Expand All @@ -176,13 +169,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<String> extensions,
final @QueryParam("merge") String merge)
final Set<String> extensions,
final String merge)
{
// check security (cannot be on @Restrict as it refers to method parameters)
identity.checkPermission("modify-translation", this.localeServiceImpl.getByLocaleId(locale),
Expand Down Expand Up @@ -226,7 +219,7 @@ public List<String> call() throws Exception
}

@Override
public ProcessStatus getProcessStatus(@PathParam("processId") String processId)
public ProcessStatus getProcessStatus(String processId)
{
AsyncTaskHandle handle = asyncTaskManagerServiceImpl.getHandle(processId);

Expand Down

0 comments on commit 7616058

Please sign in to comment.