diff --git a/archetype/html-rest/.gitignore b/archetype/html-rest/.gitignore new file mode 100644 index 0000000..8cf413e --- /dev/null +++ b/archetype/html-rest/.gitignore @@ -0,0 +1,8 @@ +/bin +/target +/.project +/.classpath +/.settings +/.externalToolBuilders +/.DS_Store +/target diff --git a/archetype/html-rest/pom.xml b/archetype/html-rest/pom.xml new file mode 100755 index 0000000..d9fbb71 --- /dev/null +++ b/archetype/html-rest/pom.xml @@ -0,0 +1,94 @@ + + + + 4.0.0 + + br.gov.frameworkdemoiselle.archetypes + demoiselle-html-rest + jar + + + br.gov.frameworkdemoiselle + demoiselle-archetype-parent + 2.5.0-SNAPSHOT + ../../parent/archetype + + + Demoiselle Framework HTML and REST Archetype + + Archetype for web applications (HTML + REST) using Demoiselle Framework + + http://www.frameworkdemoiselle.gov.br + + + + GNU Lesser General Public License, Version 3 + http://www.gnu.org/licenses/lgpl-3.0.txt + + + + + SERPRO - Serviço Federal de Processamento de Dados + http://www.serpro.gov.br + + + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + false + + + + sonatype-nexus-releases + Sonatype Nexus Releases + https://oss.sonatype.org/content/repositories/releases + + false + + + true + + + + diff --git a/archetype/html-rest/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/html-rest/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100755 index 0000000..4132c8d --- /dev/null +++ b/archetype/html-rest/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,79 @@ + + + + + + + + readme.txt + + + + src/main/webapp + + **/*.png + **/*.gif + **/*.jpg + + + + src/main/webapp + + **/*.png + **/*.gif + **/*.jpg + + + + src/main/java + + + src/main/resources + + + src/test/java + + + src/test/resources + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/pom.xml b/archetype/html-rest/src/main/resources/archetype-resources/pom.xml new file mode 100755 index 0000000..ed65e1d --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + ${groupId} + ${artifactId} + ${version} + war + + + + + + + br.gov.frameworkdemoiselle + demoiselle-rest-parent + #{parent.version} + + + + + br.gov.frameworkdemoiselle + demoiselle-jpa + compile + + + + + + br.gov.frameworkdemoiselle.component + demoiselle-junit + 2.3.1 + test + + + org.slf4j + slf4j-log4j12 + test + + + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/business/BookmarkBC.java b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/business/BookmarkBC.java new file mode 100644 index 0000000..c838079 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/business/BookmarkBC.java @@ -0,0 +1,33 @@ +package ${package}.business; + +import br.gov.frameworkdemoiselle.lifecycle.Startup; +import br.gov.frameworkdemoiselle.stereotype.BusinessController; +import br.gov.frameworkdemoiselle.template.DelegateCrud; +import br.gov.frameworkdemoiselle.transaction.Transactional; + +import ${package}.domain.Bookmark; +import ${package}.persistence.BookmarkDAO; + +@BusinessController +public class BookmarkBC extends DelegateCrud { + + private static final long serialVersionUID = 1L; + + @Startup + @Transactional + public void load() { + if (findAll().isEmpty()) { + insert(new Bookmark("Demoiselle Portal", "http://www.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Demoiselle SourceForge", "http://sf.net/projects/demoiselle")); + insert(new Bookmark("Twitter", "http://twitter.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Blog", "http://blog.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Wiki", "http://wiki.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Bug Tracking", "http://tracker.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Forum", "http://forum.frameworkdemoiselle.gov.br")); + insert(new Bookmark("SVN", "http://svn.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Maven", "http://repository.frameworkdemoiselle.gov.br")); + insert(new Bookmark("Downloads", "http://download.frameworkdemoiselle.gov.br")); + } + } + +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/constant/readme.txt b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/constant/readme.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/constant/readme.txt diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/domain/Bookmark.java b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/domain/Bookmark.java new file mode 100644 index 0000000..589a6ec --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/domain/Bookmark.java @@ -0,0 +1,63 @@ +package ${package}.domain; + +import static javax.persistence.GenerationType.SEQUENCE; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Bookmark implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * If you are using Glassfish then remove the strategy attribute + */ + @Id + @GeneratedValue(strategy = SEQUENCE) + private Long id; + + @Column + private String description; + + @Column + private String link; + + public Bookmark() { + super(); + } + + public Bookmark(String description, String link) { + this.description = description; + this.link = link; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/exception/readme.txt b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/exception/readme.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/exception/readme.txt diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/message/readme.txt b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/message/readme.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/message/readme.txt diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/persistence/BookmarkDAO.java b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/persistence/BookmarkDAO.java new file mode 100644 index 0000000..9105753 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/persistence/BookmarkDAO.java @@ -0,0 +1,13 @@ +package ${package}.persistence; + +import br.gov.frameworkdemoiselle.stereotype.PersistenceController; +import br.gov.frameworkdemoiselle.template.JPACrud; + +import ${package}.domain.Bookmark; + +@PersistenceController +public class BookmarkDAO extends JPACrud { + + private static final long serialVersionUID = 1L; + +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java new file mode 100644 index 0000000..fb64f19 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java @@ -0,0 +1,79 @@ +package ${package}.rest; + +import java.net.URI; +import java.util.List; + +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +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.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import ${package}.business.BookmarkBC; +import ${package}.domain.Bookmark; +import br.gov.frameworkdemoiselle.BadRequestException; +import br.gov.frameworkdemoiselle.NotFoundException; +import br.gov.frameworkdemoiselle.transaction.Transactional; + +//@ValidateRequest +@Path("bookmark") +// @Consumes(APPLICATION_JSON) +public class BookmarkREST { + + @Inject + private BookmarkBC bc; + + @GET + @Produces("application/json") + public List find() throws Exception { + return bc.findAll(); + } + + @GET + @Path("{id}") + @Produces("application/json") + public Bookmark load(@PathParam("id") Long id) throws Exception { + Bookmark result = bc.load(id); + + if (result == null) { + throw new NotFoundException(); + } + + return result; + } + + @POST + @Transactional + @Consumes("application/json") + @Produces("text/plain") + public Response insert(Bookmark entity, @Context UriInfo uriInfo) { + if (entity.getId() != null) { + throw new BadRequestException(); + } + + String id = bc.insert(entity).getId().toString(); + URI location = uriInfo.getRequestUriBuilder().path(id).build(); + + return Response.created(location).entity(id).build(); + } + + @DELETE + @Transactional + @Consumes("application/json") + public void delete(List ids) { + bc.delete(ids); + } + + @DELETE + @Path("{id}") + @Transactional + public void delete(@PathParam("id") Long id) { + bc.delete(id); + } +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/RESTApp.java b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/RESTApp.java new file mode 100644 index 0000000..4130960 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/RESTApp.java @@ -0,0 +1,9 @@ +package ${package}.rest; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("api") +public class RESTApp extends Application { + +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/util/readme.txt b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/util/readme.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/util/readme.txt diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..f49f2f2 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml @@ -0,0 +1,4 @@ + + + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..b5f8044 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,121 @@ + + + + + + + java:jboss/datasources/ExampleDS + + ${package}.domain.Bookmark + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/ValidationMessages.properties b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/ValidationMessages.properties new file mode 100644 index 0000000..0d63b4b --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/ValidationMessages.properties @@ -0,0 +1,28 @@ +br.gov.frameworkdemoiselle.pispasep=Informe um PIS/PASEP v\u00E1lido. +br.gov.frameworkdemoiselle.inscricaoestadual=Informe uma Inscri\u00E7\u00E3o Estadual v\u00E1lida. +br.gov.frameworkdemoiselle.cpf=Informe um CPF v\u00E1lido. +br.gov.frameworkdemoiselle.cnpj=Informe um CNPJ v\u00E1lido. +br.gov.frameworkdemoiselle.cep=Informe um CEP v\u00E1lido. + +javax.validation.constraints.AssertFalse.message=Este campo deve conter o valor falso. +javax.validation.constraints.AssertTrue.message=Este campo deve conter o valor verdadeiro. +javax.validation.constraints.DecimalMax.message=O valor deve ser menor ou igual a {value}. +javax.validation.constraints.DecimalMin.message=O valor deve ser maior ou igual a {value}. +javax.validation.constraints.Digits.message=Valor num\u00E9rico incorreto. (<{integer} d\u00EDgitos>.<{fraction} d\u00EDgitos> esperado). +javax.validation.constraints.Future.message=Deve ser uma data no futuro. +javax.validation.constraints.Max.message=O valor deve ser menor ou igual a {value}. +javax.validation.constraints.Min.message=O valor deve ser maior ou igual a {value}. +javax.validation.constraints.NotNull.message=N\u00E3o pode ser nulo. +javax.validation.constraints.Null.message=Deve ser nulo. +javax.validation.constraints.Past.message=Deve ser uma data no passado. +javax.validation.constraints.Pattern.message=O valor deve seguir o padr\u00E3o "{regexp}". +javax.validation.constraints.Size.message=O tamanho deve ser entre {min} e {max}. + +org.hibernate.validator.constraints.Email.message=E-mail inv\u00E1lido. +org.hibernate.validator.constraints.Length.message=O tamanho deve ser entre {min} e {max}. +org.hibernate.validator.constraints.NotBlank.message=N\u00E3o pode ser vazio. +org.hibernate.validator.constraints.NotEmpty.message=N\u00E3o pode ser vazio. +org.hibernate.validator.constraints.Range.message=Deve ser um valor entre {min} e {max}. +org.hibernate.validator.constraints.URL.message=Endere\u00E7o de Internet inv\u00E1lido. +org.hibernate.validator.constraints.CreditCardNumber.message=N\u00FAmero de cart\u00E3o de cr\u00E9dito inv\u00E1lido. +org.hibernate.validator.constraints.ScriptAssert.message=Express\u00E3o de script "{script}" n\u00E3o avaliada como verdadeira. diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/demoiselle.properties b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/demoiselle.properties new file mode 100755 index 0000000..71ae24e --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/demoiselle.properties @@ -0,0 +1,5 @@ +# Enables JPA transaction strategy, automatically detected if demoiselle-jpa component is detected. Use only if you need to overwrite the default behaviour +#frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction + +# Enables JTA transaction strategy, automatically detected if demoiselle-jta component is detected. Use only if you need to overwrite the default behaviour +#frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JTATransaction diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/log4j.properties new file mode 100644 index 0000000..0c34517 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/log4j.properties @@ -0,0 +1,4 @@ +log4j.rootLogger=INFO, A1 +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c - %m%n diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/messages.properties b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/messages.properties new file mode 100644 index 0000000..a5bcd2c --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/messages.properties @@ -0,0 +1,45 @@ +menu.bookmark=Bookmarks +bookmark.label=Bookmark + +bookmark-delete-ok=Bookmark exclu\u00EDdo\: {0} +bookmark-insert-ok=Bookmark inserido: {0} +bookmark-update-ok=Bookmark atualizado: {0} + +bookmark.list.table.title=Lista de Links + +bookmark.label.id=ID +bookmark.label.link=Link +bookmark.label.description=Descri\u00E7\u00E3o + +bookmark.alt.id=ID +bookmark.alt.link=Link +bookmark.alt.description=Descri\u00E7\u00E3o + +button.add.new=Incluir Novo +button.back=Voltar +button.delete=Excluir +button.dialog.no=N\u00E3o, desculpe\! +button.dialog.yes=Sim, claro! +button.edit=Editar +button.new=Novo +button.save=Salvar + +label.action=A\u00E7\u00E3o +label.dialog.alert=Alerta +label.dialog.delete=Excluir +label.confirm.delete=Confirma? +label.date.pattern=dd/MM/yyyy + +main.app.title=Bookmarks +main.app.welcome=Bem-vindo \u00E0 aplica\u00E7\u00E3o de exemplo Bookmark. Este \u00E9 o seu ponto de partida, portanto sinta-se \u00E0 vontade para modificar esta aplica\u00E7\u00E3o. +main.change.skin=Mudar Pele +main.skin=Pele +main.footer.text=Aplica\u00E7\u00E3o de exemplo do Demoiselle ${parent.version} + +menu.language=Idioma +menu.menuitem.language-portuguese=Portugu\u00EAs +menu.menuitem.language-english=Ingl\u00EAs +menu.menuitem.contents=Conte\u00FAdo +menu.menuitem.list=Listar +menu.menuitem.new=Novo +menu.menuitem.quit=Sair diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/messages_en.properties b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/messages_en.properties new file mode 100644 index 0000000..540894e --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/resources/messages_en.properties @@ -0,0 +1,45 @@ +menu.bookmark=Bookmarks +bookmark.label=Bookmark + +bookmark-delete-ok=Bookmark removed\: {0} +bookmark-insert-ok=Bookmark inserted\: {0} +bookmark-update-ok=Bookmark updated\: {0} + +bookmark.list.table.title=All Links + +bookmark.label.id=ID +bookmark.label.link=Link +bookmark.label.description=Description + +bookmark.alt.id=ID +bookmark.alt.link=Link +bookmark.alt.description=Description + +button.add.new=Insert New +button.back=Back +button.delete=Remove +button.dialog.no=No, sorry\! +button.dialog.yes=Yes, sure\! +button.edit=Edit +button.new=New +button.save=Save + +label.action=Action +label.dialog.alert=Alert +label.dialog.delete=Remove +label.confirm.delete=Confirm? +label.date.pattern=MM/dd/yyyy + +main.app.title=Bookmarks +main.app.welcome=Welcome to the example application Bookmark. This is your starting point, feel free to change this application. +main.change.skin=Change Skin +main.skin=Skin +main.footer.text=Example Application for Demoiselle ${parent.version} + +menu.language=Language +menu.menuitem.language-portuguese=Portuguese +menu.menuitem.language-english=English +menu.menuitem.contents=Content +menu.menuitem.list=List +menu.menuitem.new=New +menu.menuitem.quit=Quit diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..d85497f --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,11 @@ + + + + br.gov.frameworkdemoiselle.transaction.TransactionalInterceptor + br.gov.frameworkdemoiselle.security.RequiredPermissionInterceptor + br.gov.frameworkdemoiselle.security.RequiredRoleInterceptor + br.gov.frameworkdemoiselle.exception.ExceptionHandlerInterceptor + + + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml new file mode 100755 index 0000000..dcbddcb --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,5 @@ + + + + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml new file mode 100755 index 0000000..cafede6 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + + Faces Servlet + *.jsf + + + + Restrict raw XHTML Documents + + XHTML + *.xhtml + + + + + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark_edit.xhtml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark_edit.xhtml new file mode 100644 index 0000000..c1bf422 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark_edit.xhtml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark_list.xhtml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark_list.xhtml new file mode 100644 index 0000000..b4af609 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark_list.xhtml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + #{messages['bookmark.list.table.title']} + + + + + #{messages['bookmark.label.id']} + + + + #{messages['bookmark.label.description']} + + + + + + + #{messages['bookmark.label.link']} + + + + + + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/css/styles.css b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/css/styles.css new file mode 100644 index 0000000..7f6e3fa --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/css/styles.css @@ -0,0 +1,19 @@ +@CHARSET "UTF-8"; + +.ui-icon-locale-pt + ,.ui-icon-locale-en{ + width: 32px; + height: 31px; + background-position: center; + display: block; + float: left; + background-repeat: no-repeat; +} + +.ui-icon-locale-pt{ + background-image: url("../images/locale_pt.png"); +} + +.ui-icon-locale-en{ + background-image: url("../images/locale_en.png"); +} \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/locale_en.png b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/locale_en.png new file mode 100644 index 0000000..ba7dbed Binary files /dev/null and b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/locale_en.png differ diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/locale_pt.png b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/locale_pt.png new file mode 100644 index 0000000..4521af9 Binary files /dev/null and b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/locale_pt.png differ diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/logo.png b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/logo.png new file mode 100644 index 0000000..5be30b0 Binary files /dev/null and b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/images/logo.png differ diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html new file mode 100644 index 0000000..80c5da2 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.xhtml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.xhtml new file mode 100644 index 0000000..210fd7f --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.xhtml @@ -0,0 +1,11 @@ + + + + + #{messages['main.app.welcome']} + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.xhtml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.xhtml new file mode 100644 index 0000000..faa1a60 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.xhtml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/template/main.xhtml b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/template/main.xhtml new file mode 100644 index 0000000..37c5fa1 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/template/main.xhtml @@ -0,0 +1,51 @@ + + + + + + #{messages['main.app.title']} + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
#{messages['main.footer.text']}
+ + + + + + + + + + + + +
+ \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/test/java/business/BookmarkBCTest.java b/archetype/html-rest/src/main/resources/archetype-resources/src/test/java/business/BookmarkBCTest.java new file mode 100644 index 0000000..ef2188d --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/test/java/business/BookmarkBCTest.java @@ -0,0 +1,77 @@ +package ${package}.business; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.List; + +import javax.inject.Inject; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.junit.DemoiselleRunner; +import ${package}.domain.Bookmark; + +@RunWith(DemoiselleRunner.class) +public class BookmarkBCTest { + + @Inject + private BookmarkBC bookmarkBC; + + @Before + public void before() { + for (Bookmark bookmark : bookmarkBC.findAll()) { + bookmarkBC.delete(bookmark.getId()); + } + } + + @Test + public void testLoad() { + bookmarkBC.load(); + List listaBookmarks = bookmarkBC.findAll(); + assertNotNull(listaBookmarks); + assertEquals(10, listaBookmarks.size()); + } + + @Test + public void testInsert() { + Bookmark bookmark = new Bookmark("Demoiselle Portal", "http://www.frameworkdemoiselle.gov.br"); + bookmarkBC.insert(bookmark); + List listaBookmarks = bookmarkBC.findAll(); + assertNotNull(listaBookmarks); + assertEquals(1, listaBookmarks.size()); + } + + @Test + public void testDelete() { + Bookmark bookmark = new Bookmark("Demoiselle Portal", "http://www.frameworkdemoiselle.gov.br"); + bookmarkBC.insert(bookmark); + + List listaBookmarks = bookmarkBC.findAll(); + assertNotNull(listaBookmarks); + assertEquals(1, listaBookmarks.size()); + + bookmarkBC.delete(bookmark.getId()); + listaBookmarks = bookmarkBC.findAll(); + assertEquals(0, listaBookmarks.size()); + } + @Test + public void testUpdate() { + Bookmark bookmark = new Bookmark("Demoiselle Portal", "http://www.frameworkdemoiselle.gov.br"); + bookmarkBC.insert(bookmark); + + List listaBookmarks = bookmarkBC.findAll(); + Bookmark bookmark2 = (Bookmark)listaBookmarks.get(0); + assertNotNull(listaBookmarks); + assertEquals("Demoiselle Portal", bookmark2.getDescription()); + + bookmark2.setDescription("Demoiselle Portal alterado"); + bookmarkBC.update(bookmark2); + + listaBookmarks = bookmarkBC.findAll(); + Bookmark bookmark3 = (Bookmark)listaBookmarks.get(0); + assertEquals("Demoiselle Portal alterado", bookmark3.getDescription()); + } +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/META-INF/beans.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/META-INF/beans.xml new file mode 100644 index 0000000..d85497f --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/META-INF/beans.xml @@ -0,0 +1,11 @@ + + + + br.gov.frameworkdemoiselle.transaction.TransactionalInterceptor + br.gov.frameworkdemoiselle.security.RequiredPermissionInterceptor + br.gov.frameworkdemoiselle.security.RequiredRoleInterceptor + br.gov.frameworkdemoiselle.exception.ExceptionHandlerInterceptor + + + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/META-INF/persistence.xml b/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/META-INF/persistence.xml new file mode 100644 index 0000000..106c5e6 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/META-INF/persistence.xml @@ -0,0 +1,60 @@ + + + + + + + + ${package}.domain.Bookmark + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/demoiselle.properties b/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/demoiselle.properties new file mode 100644 index 0000000..8bb4aa9 --- /dev/null +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/test/resources/demoiselle.properties @@ -0,0 +1 @@ +frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction diff --git a/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java b/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java index da26170..aadf226 100644 --- a/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java +++ b/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java @@ -218,7 +218,7 @@ public class JPACrud implements Crud { */ protected List findByJPQL(String jpql) { TypedQuery listQuery = getEntityManager().createQuery(jpql, getBeanClass()); - + if (getPagination() != null) { String countQuery = createCountQuery(jpql); Query query = getEntityManager().createQuery(countQuery); diff --git a/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/BadRequestException.java b/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/BadRequestException.java new file mode 100644 index 0000000..a2be3e8 --- /dev/null +++ b/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/BadRequestException.java @@ -0,0 +1,14 @@ +package br.gov.frameworkdemoiselle; + +import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; + +import javax.xml.ws.http.HTTPException; + +public class BadRequestException extends HTTPException { + + private static final long serialVersionUID = 1L; + + public BadRequestException() { + super(SC_BAD_REQUEST); + } +} diff --git a/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/NotFoundException.java b/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/NotFoundException.java new file mode 100644 index 0000000..167ec15 --- /dev/null +++ b/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/NotFoundException.java @@ -0,0 +1,14 @@ +package br.gov.frameworkdemoiselle; + +import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; + +import javax.xml.ws.http.HTTPException; + +public class NotFoundException extends HTTPException { + + private static final long serialVersionUID = 1L; + + public NotFoundException() { + super(SC_NOT_FOUND); + } +} diff --git a/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/HTTPExceptionMapper.java b/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/HTTPExceptionMapper.java new file mode 100644 index 0000000..6383971 --- /dev/null +++ b/impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/HTTPExceptionMapper.java @@ -0,0 +1,15 @@ +package br.gov.frameworkdemoiselle.internal.implementation; + +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; +import javax.xml.ws.http.HTTPException; + +@Provider +public class HTTPExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(HTTPException exception) { + return Response.status(exception.getStatusCode()).build(); + } +} diff --git a/impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/BasicAuthFilter.java b/impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/BasicAuthFilter.java index 03c4f24..0aa7ad3 100644 --- a/impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/BasicAuthFilter.java +++ b/impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/BasicAuthFilter.java @@ -53,6 +53,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; +import br.gov.frameworkdemoiselle.security.AuthenticationException; import br.gov.frameworkdemoiselle.security.Credentials; import br.gov.frameworkdemoiselle.security.InvalidCredentialsException; import br.gov.frameworkdemoiselle.security.SecurityContext; @@ -102,7 +103,7 @@ public class BasicAuthFilter implements Filter { Beans.getReference(SecurityContext.class).logout(); } - private void setUnauthorizedStatus(HttpServletResponse response, Exception cause) throws IOException { + private void setUnauthorizedStatus(HttpServletResponse response, AuthenticationException cause) throws IOException { response.setStatus(SC_UNAUTHORIZED); response.setContentType("text/html"); diff --git a/parent/rest/pom.xml b/parent/rest/pom.xml index 9d871a2..d307b63 100755 --- a/parent/rest/pom.xml +++ b/parent/rest/pom.xml @@ -71,12 +71,6 @@ br.gov.frameworkdemoiselle demoiselle-rest compile - - - javax.ws.rs - jsr311-api - - diff --git a/pom.xml b/pom.xml index 07f0b97..99336d4 100755 --- a/pom.xml +++ b/pom.xml @@ -74,11 +74,12 @@ impl/extension/servlet impl/extension/rest impl/extension/jmx - + --> archetype/minimal archetype/jsf-jpa + archetype/html-rest documentation/quickstart documentation/reference -- libgit2 0.21.2