Skip to content

Instantly share code, notes, and snippets.

@rmannibucau
Created March 18, 2012 18:13
Show Gist options
  • Save rmannibucau/2079015 to your computer and use it in GitHub Desktop.
Save rmannibucau/2079015 to your computer and use it in GitHub Desktop.
diff -r 0170ba313366 galleria-ejb/pom.xml
--- a/galleria-ejb/pom.xml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-ejb/pom.xml Sun Mar 18 19:12:37 2012 +0100
@@ -186,17 +186,13 @@
</execution>
</executions>
</plugin>
- <plugin>
+ <!--plugin>
<groupId>com.dbdeploy</groupId>
<artifactId>maven-dbdeploy-plugin</artifactId>
<version>3.0M3</version>
<configuration>
<scriptdirectory>${basedir}/src/main/sql</scriptdirectory>
<driver>org.apache.derby.jdbc.ClientDriver</driver>
- <!--
- Use an separate Derby instance for unit testing.
- Ensure that the values here match with the ones used in persistence-test.xml.
- -->
<url>${galleria.derby.testInstance.jdbcUrl}</url>
<userid>${galleria.derby.testInstance.user}</userid>
<password>${galleria.derby.testInstance.password}</password>
@@ -226,7 +222,7 @@
<version>10.8.1.2</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin-->
</plugins>
<pluginManagement>
<plugins>
@@ -396,4 +392,4 @@
<sonar.phase>verify</sonar.phase>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
</properties>
-</project>
\ No newline at end of file
+</project>
diff -r 0170ba313366 galleria-ejb/src/main/java/info/galleria/domain/Photo.java
--- a/galleria-ejb/src/main/java/info/galleria/domain/Photo.java Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-ejb/src/main/java/info/galleria/domain/Photo.java Sun Mar 18 19:12:37 2012 +0100
@@ -80,7 +80,7 @@
// {{ file
@Lob()
- @Basic(fetch = FetchType.LAZY)
+ @Basic(fetch = FetchType.EAGER)
@Column(nullable = false)
@NotNull
private byte[] file;
diff -r 0170ba313366 galleria-ejb/src/main/java/info/galleria/service/ejb/PhotoServiceImpl.java
--- a/galleria-ejb/src/main/java/info/galleria/service/ejb/PhotoServiceImpl.java Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-ejb/src/main/java/info/galleria/service/ejb/PhotoServiceImpl.java Sun Mar 18 19:12:37 2012 +0100
@@ -1,17 +1,27 @@
package info.galleria.service.ejb;
-import info.galleria.domain.*;
-import info.galleria.service.jpa.*;
-
-import java.security.Principal;
-import java.util.*;
+import info.galleria.domain.Album;
+import info.galleria.domain.Photo;
+import info.galleria.domain.User;
+import info.galleria.service.jpa.AlbumRepository;
+import info.galleria.service.jpa.PhotoRepository;
+import info.galleria.service.jpa.UserRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import javax.annotation.security.RolesAllowed;
-import javax.ejb.*;
-import javax.validation.*;
-
-import org.slf4j.*;
+import javax.ejb.EJB;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.validation.Validator;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
@Stateless
@EJB(name = "java:global/galleria/galleria-ejb/PhotoService", beanInterface = PhotoService.class)
@@ -36,7 +46,10 @@
@EJB
private PhotoRepository photoRepository;
- @Override
+ @Resource
+ private Validator validator;
+
+ @Override
public Photo uploadPhoto(Photo photo, Album album) throws PhotoException
{
validatePhoto(photo);
@@ -168,7 +181,6 @@
private void validatePhoto(Photo photo) throws PhotoException
{
- Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set violations = validator.validate(photo);
if (violations.size() > 0)
{
diff -r 0170ba313366 galleria-ejb/src/main/resources/META-INF/persistence.xml
--- a/galleria-ejb/src/main/resources/META-INF/persistence.xml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-ejb/src/main/resources/META-INF/persistence.xml Sun Mar 18 19:12:37 2012 +0100
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="galleria-ejb" transaction-type="JTA">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/galleriaDS</jta-data-source>
<class>info.galleria.domain.User</class>
<class>info.galleria.domain.Group</class>
<class>info.galleria.domain.Album</class>
<class>info.galleria.domain.Photo</class>
<properties>
- <property name="hibernate.show_sql" value="true"/>
<property name="javax.persistence.validation.group.pre-persist" value="info.galleria.domain.PersistenceConstraint"/>
<property name="javax.persistence.validation.group.pre-update" value="info.galleria.domain.PersistenceConstraint"/>
+
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
</persistence>
diff -r 0170ba313366 galleria-jsf/pom.xml
--- a/galleria-jsf/pom.xml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/pom.xml Sun Mar 18 19:12:37 2012 +0100
@@ -296,4 +296,4 @@
</dependency>
</dependencies>
</dependencyManagement>
-</project>
\ No newline at end of file
+</project>
diff -r 0170ba313366 galleria-jsf/src/main/webapp/WEB-INF/web.xml
--- a/galleria-jsf/src/main/webapp/WEB-INF/web.xml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/WEB-INF/web.xml Sun Mar 18 19:12:37 2012 +0100
@@ -12,6 +12,10 @@
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
+ <param-value>false</param-value>
+ </context-param>
<filter>
<filter-name>Galleria User Redirect Filter</filter-name>
<filter-class>info.galleria.filters.UserRedirectFilter</filter-class>
diff -r 0170ba313366 galleria-jsf/src/main/webapp/private/album/EditAlbum.xhtml
--- a/galleria-jsf/src/main/webapp/private/album/EditAlbum.xhtml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/private/album/EditAlbum.xhtml Sun Mar 18 19:12:37 2012 +0100
@@ -6,10 +6,10 @@
<ui:define name="title">
<h:outputText value="#{msg['EditAlbum.title']}" />
</ui:define>
- <ui:define name="content">
- <f:metadata>
- <f:viewParam id="albumId" name="albumId" immediate="true" required="true" value="#{albumManager.currentAlbumId}" />
- </f:metadata>
+ <f:metadata>
+ <f:viewParam id="albumId" name="albumId" immediate="true" required="true" value="#{albumManager.currentAlbumId}" />
+ </f:metadata>
+ <ui:define name="content">
<div class="fullpane">
<h:form id="editAlbumForm" styleClass="form">
<ul>
diff -r 0170ba313366 galleria-jsf/src/main/webapp/private/album/ViewAlbum.xhtml
--- a/galleria-jsf/src/main/webapp/private/album/ViewAlbum.xhtml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/private/album/ViewAlbum.xhtml Sun Mar 18 19:12:37 2012 +0100
@@ -7,10 +7,10 @@
<ui:define name="title">
<h:outputText value="#{msg['ViewAlbum.title']}" />
</ui:define>
- <ui:define name="content">
- <f:metadata>
- <f:viewParam id="albumId" name="albumId" required="true" value="#{albumManager.currentAlbumId}" />
- </f:metadata>
+ <f:metadata>
+ <f:viewParam id="albumId" name="albumId" required="true" value="#{albumManager.currentAlbumId}" />
+ </f:metadata>
+ <ui:define name="content">
<div class="mainpane">
<h:form id="viewAllPhotos">
<p:dataGrid id="photoGrid" value="#{albumManager.photosInCurrentAlbum}" var="photo" columns="3" rows="6" paginator="true" rendered="#{albumManager.photosInCurrentAlbum.size() > 0}">
diff -r 0170ba313366 galleria-jsf/src/main/webapp/private/photo/EditPhoto.xhtml
--- a/galleria-jsf/src/main/webapp/private/photo/EditPhoto.xhtml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/private/photo/EditPhoto.xhtml Sun Mar 18 19:12:37 2012 +0100
@@ -6,10 +6,10 @@
<ui:define name="title">
<h:outputText value="#{msg['EditPhoto.title']}" />
</ui:define>
- <ui:define name="content">
- <f:metadata>
- <f:viewParam id="photoId" name="photoId" immediate="true" required="true" value="#{photoManager.photoId}" />
- </f:metadata>
+ <f:metadata>
+ <f:viewParam id="photoId" name="photoId" immediate="true" required="true" value="#{photoManager.photoId}" />
+ </f:metadata>
+ <ui:define name="content">
<div class="fullpane">
<h:form id="editPhotoForm" styleClass="form">
<ul>
diff -r 0170ba313366 galleria-jsf/src/main/webapp/private/photo/ViewPhoto.xhtml
--- a/galleria-jsf/src/main/webapp/private/photo/ViewPhoto.xhtml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/private/photo/ViewPhoto.xhtml Sun Mar 18 19:12:37 2012 +0100
@@ -7,10 +7,10 @@
<ui:define name="title">
<h:outputText value="#{msg['ViewPhoto.title']}" />
</ui:define>
+ <f:metadata>
+ <f:viewParam id="photoId" name="photoId" required="true" value="#{photoManager.photoId}" />
+ </f:metadata>
<ui:define name="content">
- <f:metadata>
- <f:viewParam id="photoId" name="photoId" required="true" value="#{photoManager.photoId}" />
- </f:metadata>
<div class="mainpane">
<div>
<p:graphicImage id="photo" value="#{photoStreamer.fileContent}" styleClass="photopane">
diff -r 0170ba313366 galleria-jsf/src/main/webapp/templates/content.xhtml
--- a/galleria-jsf/src/main/webapp/templates/content.xhtml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/templates/content.xhtml Sun Mar 18 19:12:37 2012 +0100
@@ -6,7 +6,7 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
<ui:composition>
- <p>Default content</p>
+ <p>Default content</p>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
diff -r 0170ba313366 galleria-jsf/src/main/webapp/templates/privateLayout.xhtml
--- a/galleria-jsf/src/main/webapp/templates/privateLayout.xhtml Fri Mar 16 15:50:50 2012 +0530
+++ b/galleria-jsf/src/main/webapp/templates/privateLayout.xhtml Sun Mar 18 19:12:37 2012 +0100
@@ -14,42 +14,42 @@
<h:outputStylesheet name="all.css" library="styles" target="head" />
</h:head>
<h:body>
+ <f:view>
+ <div id="wrapper">
- <div id="wrapper">
+ <div id="header">
- <div id="header">
-
- <ui:insert name="header">
- <ui:include src="header.xhtml" />
- </ui:insert>
-
- <div id="headerLinks">
- <h:form id="commonActions" styleClass="headerLinkContent">
- <h:commandLink id="logout" action="#{authenticator.logout}">
- <h:outputText value="#{msg['Application.logout.label']}" />
- </h:commandLink>
- <h:outputLink id="AccountPreferences" value="#{request.contextPath}/private/user/AccountPreferences.xhtml">
- <h:outputText value="#{msg['Application.AccountPreferences.label']}" />
- </h:outputLink>
- </h:form>
- </div>
-
- </div>
-
- <div id="content">
- <ui:insert name="content">
- <ui:include src="content.xhtml" />
- </ui:insert>
- </div>
+ <ui:insert name="header">
+ <ui:include src="header.xhtml" />
+ </ui:insert>
- </div>
+ <div id="headerLinks">
+ <h:form id="commonActions" styleClass="headerLinkContent">
+ <h:commandLink id="logout" action="#{authenticator.logout}">
+ <h:outputText value="#{msg['Application.logout.label']}" />
+ </h:commandLink>
+ <h:outputLink id="AccountPreferences" value="#{request.contextPath}/private/user/AccountPreferences.xhtml">
+ <h:outputText value="#{msg['Application.AccountPreferences.label']}" />
+ </h:outputLink>
+ </h:form>
+ </div>
- <div id="footer">
- <ui:insert name="footer">
- <ui:include src="footer.xhtml" />
- </ui:insert>
- </div>
+ </div>
+ <div id="content">
+ <ui:insert name="content">
+ <ui:include src="content.xhtml" />
+ </ui:insert>
+ </div>
+
+ </div>
+
+ <div id="footer">
+ <ui:insert name="footer">
+ <ui:include src="footer.xhtml" />
+ </ui:insert>
+ </div>
+ </f:view>
</h:body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment