This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add enpoint for locales list from zanata server
- Loading branch information
Alex Eng
committed
Sep 29, 2014
1 parent
c888437
commit 1ea9a4e
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
zanata-common-api/src/main/java/org/zanata/rest/dto/Locale.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.zanata.rest.dto; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.xml.bind.annotation.XmlAttribute; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlType; | ||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | ||
|
||
import org.codehaus.jackson.annotate.JsonIgnoreProperties; | ||
import org.codehaus.jackson.annotate.JsonPropertyOrder; | ||
import org.codehaus.jackson.map.annotate.JsonSerialize; | ||
import org.hibernate.validator.constraints.Email; | ||
import org.hibernate.validator.constraints.NotEmpty; | ||
import org.zanata.common.LocaleId; | ||
import org.zanata.common.Namespaces; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonPropertyOrder({ "localeId", "name"}) | ||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | ||
public class Locale implements Serializable { | ||
|
||
private LocaleId localeId; | ||
private String name; | ||
|
||
public Locale(LocaleId localeId, String name) { | ||
this.localeId = localeId; | ||
this.name = name; | ||
} | ||
|
||
@NotNull | ||
public LocaleId getLocaleId() { | ||
return localeId; | ||
} | ||
|
||
public void setLocaleId(LocaleId localeId) { | ||
this.localeId = localeId; | ||
} | ||
|
||
|
||
@NotNull | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
zanata-common-api/src/main/java/org/zanata/rest/service/LocalesResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.zanata.rest.service; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.codehaus.enunciate.jaxrs.TypeHint; | ||
import org.jboss.resteasy.annotations.providers.jaxb.Wrapped; | ||
import org.zanata.common.Namespaces; | ||
import org.zanata.rest.MediaTypes; | ||
import org.zanata.rest.dto.Locale; | ||
|
||
/** | ||
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a> | ||
*/ | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@Consumes({ MediaType.APPLICATION_JSON }) | ||
public interface LocalesResource { | ||
|
||
public static final String SERVICE_PATH = "/locales"; | ||
|
||
@GET | ||
@Produces({ MediaTypes.APPLICATION_ZANATA_LOCALES_JSON, | ||
MediaType.APPLICATION_JSON }) | ||
@Wrapped(element = "locales", namespace = Namespaces.ZANATA_API) | ||
@TypeHint(Locale[].class) | ||
public Response get(); | ||
} |