Seam SVN: r13517 - branches/community/Seam_2_2/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium.
by seam-commits@lists.jboss.org
Author: plenyi(a)redhat.com
Date: 2010-07-27 11:26:49 -0400 (Tue, 27 Jul 2010)
New Revision: 13517
Modified:
branches/community/Seam_2_2/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java
Log:
Fixed seamdiscs functional tests failing in Internet Explorer on Windows.
Modified: branches/community/Seam_2_2/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java 2010-07-27 09:07:36 UTC (rev 13516)
+++ branches/community/Seam_2_2/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java 2010-07-27 15:26:49 UTC (rev 13517)
@@ -25,6 +25,7 @@
import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
import org.testng.annotations.BeforeMethod;
+import com.thoughtworks.selenium.SeleniumException;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
@@ -128,8 +129,12 @@
assertTrue("This is not expected (" + expectedDiscTitle + ") album (" + actualDiscTitle + ")!", actualDiscTitle.equals(expectedDiscTitle));
String actualReleaseDate = "";
- if (browser.isElementPresent(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "/attribute::value")) {
- actualReleaseDate = browser.getAttribute(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "@value");
+ if (browser.isElementPresent(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow))) {
+ try {
+ actualReleaseDate = browser.getAttribute(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "@value");
+ } catch (SeleniumException ex) {
+ // intentianally left blank
+ }
assertTrue("This is not expected (" + expectedReleaseDate + ") release date (" + actualReleaseDate + ")!", actualReleaseDate.equals(expectedReleaseDate));
}
14 years, 5 months
Seam SVN: r13516 - in modules/persistence/trunk/impl/src: main/java/org/jboss/seam/persistence/transaction and 2 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-27 05:07:36 -0400 (Tue, 27 Jul 2010)
New Revision: 13516
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
Log:
@TransactionAttribute now works on managed beans
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+import javax.naming.NamingException;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.seam.persistence.util.NamingUtils;
+import org.jboss.weld.extensions.core.Veto;
+
+/**
+ * Class that enabled the seam managed persitence context to be configured via
+ * xml.
+ *
+ * There are two ways to do this. Either the persistenceUnintJndi name can be
+ * set, in which case the entityManagerFactory is looked up from JNDI.
+ *
+ * Alternativly the @Inject annotation can be applied to the
+ * entityManagerFactory propery along with any qualifiers needed and the
+ * entityManagerFactory will be injected
+ *
+ * Any qualifiers that are applied to this class are also applied to the managed
+ * persistence context in question
+ *
+ * @author Stuart Douglas
+ *
+ */
+@Veto
+public class ManagedPersistenceContext
+{
+
+ public String getPersistenceUnitJndiName()
+ {
+ return persistenceUnitJndiName;
+ }
+
+ public void setPersistenceUnitJndiName(String persistenceUnitJndiName)
+ {
+ this.persistenceUnitJndiName = persistenceUnitJndiName;
+ }
+
+ public EntityManagerFactory getEntityManagerFactory()
+ {
+ if (entityManagerFactory != null)
+ {
+ return entityManagerFactory;
+ }
+ try
+ {
+ return (EntityManagerFactory) NamingUtils.getInitialContext().lookup(persistenceUnitJndiName);
+ }
+ catch (NamingException ne)
+ {
+ throw new IllegalArgumentException("EntityManagerFactory not found in JNDI : " + persistenceUnitJndiName, ne);
+ }
+ }
+
+ public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory)
+ {
+ this.entityManagerFactory = entityManagerFactory;
+ }
+
+ String persistenceUnitJndiName;
+
+ EntityManagerFactory entityManagerFactory;
+
+}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-27 08:58:14 UTC (rev 13515)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -22,6 +22,7 @@
package org.jboss.seam.persistence.transaction;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeanManager;
@@ -76,29 +77,35 @@
*/
public <X> void processAnnotatedType(@Observes ProcessAnnotatedType<X> event)
{
- if (event.getAnnotatedType().isAnnotationPresent(Transactional.class))
+ boolean addInterceptor = false;
+ AnnotatedType<X> type = event.getAnnotatedType();
+ if (type.isAnnotationPresent(Transactional.class))
{
- event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
- return;
+
+ addInterceptor = true;
}
- if (event.getAnnotatedType().isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType()))
+ else if (type.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType()))
{
- event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
- return;
+ checkTransactionAttributeIsValue(type, type);
+ addInterceptor = true;
}
- for (AnnotatedMethod<? super X> m : event.getAnnotatedType().getMethods())
+
+ for (AnnotatedMethod<? super X> m : type.getMethods())
{
if (m.isAnnotationPresent(Transactional.class))
{
- event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
- return;
+ addInterceptor = true;
}
else if (m.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType()))
{
- event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
- return;
+ checkTransactionAttributeIsValue(type, m);
+ addInterceptor = true;
}
}
+ if (addInterceptor)
+ {
+ event.setAnnotatedType(addInterceptorBinding(type));
+ }
}
public <X> AnnotatedType addInterceptorBinding(AnnotatedType<X> type)
@@ -109,4 +116,17 @@
});
return builder.create();
}
+
+ private void checkTransactionAttributeIsValue(AnnotatedType type, Annotated element)
+ {
+ Object attribute = element.getAnnotation(EjbApi.TRANSACTION_ATTRIBUTE);
+ if (attribute == EjbApi.REQUIRES_NEW)
+ {
+ throw new RuntimeException("TransactionAttributeType.REQUIRED_NEW is not supported on Managed Beans that are not EJB's. Annotation was found on type " + type);
+ }
+ if (attribute == EjbApi.NOT_SUPPORTED)
+ {
+ throw new RuntimeException("TransactionAttributeType.NOT_SUPPORTED is not supported on Managed Beans that are not EJB's. Annotation was found on type " + type);
+ }
+ }
}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java 2010-07-27 08:58:14 UTC (rev 13515)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -33,6 +33,8 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
+import org.jboss.seam.persistence.util.EjbApi;
+
/**
* Implements transaction propagation rules for Seam JavaBean components.
*
@@ -60,11 +62,52 @@
public TransactionMetadata(AnnotatedElement element)
{
annotationPresent = element.isAnnotationPresent(Transactional.class);
-
if (annotationPresent)
{
propType = element.getAnnotation(Transactional.class).value();
}
+ else if (element.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE))
+ {
+ annotationPresent = true;
+ Object annotation = element.getAnnotation(EjbApi.TRANSACTION_ATTRIBUTE);
+ try
+ {
+ Object value = annotation.getClass().getMethod("value").invoke(annotation);
+
+ if (value == EjbApi.REQUIRED)
+ {
+ propType = TransactionPropagation.REQUIRED;
+ }
+ else if (value == EjbApi.MANDATORY)
+ {
+ propType = TransactionPropagation.MANDATORY;
+ }
+ else if (value == EjbApi.NEVER)
+ {
+ propType = TransactionPropagation.NEVER;
+ }
+ else if (value == EjbApi.SUPPORTS)
+ {
+ propType = TransactionPropagation.SUPPORTS;
+ }
+ else if (value == EjbApi.NOT_SUPPORTED)
+ {
+ throw new RuntimeException("TransactionAttributeType.NOT_SUPPORTED is not allowed on managed beans that are not EJB's. Element: " + element);
+ }
+ else if (value == EjbApi.REQUIRES_NEW)
+ {
+ throw new RuntimeException("TransactionAttributeType.REQUIRES_NEW is not allowed on managed beans that are not EJB's Element: " + element);
+ }
+ else
+ {
+ throw new RuntimeException("Unkown TransactionAttributeType: " + value);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
public boolean isAnnotationPresent()
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java 2010-07-27 08:58:14 UTC (rev 13515)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -92,10 +92,8 @@
{
transaction.setRollbackOnly();
}
-
throw e;
}
-
}
public static boolean isRollbackRequired(Exception e, boolean isJavaBean)
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-27 08:58:14 UTC (rev 13515)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -50,17 +50,17 @@
public static final Class<? extends Annotation> MESSAGE_DRIVEN;
public static final Class<? extends Annotation> SINGLETON;
- private static final Object MANDATORY;
+ public static final Object MANDATORY;
- private static final Object REQUIRED;
+ public static final Object REQUIRED;
- private static final Object REQUIRES_NEW;
+ public static final Object REQUIRES_NEW;
- private static final Object SUPPORTS;
+ public static final Object SUPPORTS;
- private static final Object NOT_SUPPORTED;
+ public static final Object NOT_SUPPORTED;
- private static final Object NEVER;
+ public static final Object NEVER;
public static final boolean INVOCATION_CONTEXT_AVAILABLE;
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TransactionRequiredException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
+import org.jboss.seam.persistence.transaction.TransactionInterceptor;
+import org.jboss.seam.persistence.util.NamingUtils;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the @TransactionAttribute interceptor for non ee beans.
+ *
+ * TODO: refactor the tests to share a common superclass
+ *
+ * @author stuart
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class TransactionAttributeInterceptorTest
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addPackage(TransactionExtension.class.getPackage());
+ war.addPackage(NamingUtils.class.getPackage());
+ war.addClasses(TransactionAttributeInterceptorTest.class, TransactionAttributeManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+ @Inject
+ TransactionAttributeManagedBean bean;
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @PersistenceContext
+ EntityManager em;
+
+ @Test
+ public void testTransactionInterceptor() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ bean.addHotel();
+ assertHotels(1);
+ try
+ {
+ bean.failToAddHotel();
+ }
+ catch (Exception e)
+ {
+ }
+ assertHotels(1);
+ try
+ {
+ bean.addHotelWithApplicationException();
+ }
+ catch (DontRollBackException e)
+ {
+ }
+ assertHotels(2);
+ }
+
+ @Test(expected = TransactionRequiredException.class)
+ public void testTransactionInterceptorMethodOverrides()
+ {
+ bean.tryAndAddHotelWithNoTransaction();
+ }
+
+ public void assertHotels(int count) throws NotSupportedException, SystemException
+ {
+ transaction.begin();
+ em.joinTransaction();
+ List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
+ Assert.assertTrue("Wrong number of hotels: " + hotels.size(), hotels.size() == count);
+ transaction.rollback();
+ }
+}
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.Hotel;
+
+(a)TransactionAttribute(TransactionAttributeType.REQUIRED)
+public class TransactionAttributeManagedBean
+{
+
+ @Inject
+ EntityManager entityManager;
+
+ public void addHotel()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
+ public void failToAddHotel()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ throw new RuntimeException("Roll back transaction");
+ }
+
+ public void addHotelWithApplicationException() throws DontRollBackException
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ throw new DontRollBackException();
+ }
+
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public void tryAndAddHotelWithNoTransaction()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-27 08:58:14 UTC (rev 13515)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-27 09:07:36 UTC (rev 13516)
@@ -57,6 +57,8 @@
/**
* Tests the @Transactional interceptor
*
+ * TODO: refactor the tests to share a common superclass
+ *
* @author stuart
*
*/
@@ -92,7 +94,6 @@
@Test
public void testTransactionInterceptor() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
{
-
bean.addHotel();
assertHotels(1);
try
14 years, 5 months
Seam SVN: r13515 - in branches/community/Seam_2_2/examples/wiki: src/main/org/jboss/seam/wiki/connectors/feed and 4 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-27 04:58:14 -0400 (Tue, 27 Jul 2010)
New Revision: 13515
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java
Modified:
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml
Log:
more spam report enhancements, preparation for user nuke feature
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-27 08:58:14 UTC (rev 13515)
@@ -169,6 +169,8 @@
lacewiki.label.WriteProtected=Restrict edit access to admins
lacewiki.label.User=User
lacewiki.label.AreYouSureYouWantToDelete=Are you sure you want to delete
+lacewiki.label.AreYouSureYouWantToNukePrefix=WARNING!!! Are you sure you want to nuke user
+lacewiki.label.AreYouSureYouWantToNukeSuffix=\'s ass? This action is typically reserved for spammers who desecrate our beloved site. If you click the OK button, this user's account, posts and comments will all be deleted, and their e-mail address and IP address blacklisted. Also, an inter-continental ballistic missile carrying a million rabid fleas will be launched at their home address.
lacewiki.label.Confirmation=Confirmation
lacewiki.label.AreYouSureYouWantToExecute=Are you sure you want to execute this operation?
@@ -374,6 +376,7 @@
lacewiki.button.adminHome.Preferences=P<u>r</u>eferences
lacewiki.button.adminHome.Preferences.accesskey=R
lacewiki.button.adminHome.SpamReport=Spam Reports
+
lacewiki.button.adminHome.SaveSettings=<u>S</u>ave Settings
lacewiki.button.adminHome.SaveSettings.accesskey=S
lacewiki.label.adminHome.SearchIndex=Search Index
@@ -387,6 +390,7 @@
lacewiki.label.adminHome.spamReport.Reporter=Reporter
lacewiki.label.adminHome.spamReport.Comment=Comment
lacewiki.label.adminHome.spamReport.Poster=Comment Poster
+lacewiki.label.adminHome.spamReport.ViewOriginal=View the original post
lacewiki.label.adminHome.TargetWithPlaceHolder=Target with [[link]] placeholder
lacewiki.label.adminHome.NotAvailableForSkin=Administration is not available with this skin.
@@ -447,6 +451,7 @@
lacewiki.button.userHome.SaveSettings.accesskey=S
lacewiki.button.userHome.Delete=<u>D</u>elete
lacewiki.button.userHome.Delete.accesskey=D
+lacewiki.button.userHome.Nuke=Nuke Their Ass
lacewiki.label.userHome.NotAvailableForSkin=User management is not available with this skin.
lacewiki.msg.userHome.PortraitRemoved=The portrait has been removed, save to make changes permanent.
lacewiki.msg.userHome.WrongPortraitImageType=The file type '{0}' is not supported, the portrait was not updated.
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -6,29 +6,31 @@
*/
package org.jboss.seam.wiki.connectors.feed;
-import com.sun.syndication.feed.synd.SyndContent;
-import com.sun.syndication.feed.synd.SyndEntry;
-import com.sun.syndication.feed.synd.SyndFeed;
-import com.sun.syndication.io.FeedException;
-import com.sun.syndication.io.SyndFeedInput;
-import com.sun.syndication.io.XmlReader;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.*;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.wiki.core.model.Feed;
-import org.jboss.seam.wiki.core.model.FeedEntry;
-
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
import java.net.URL;
-import java.net.SocketTimeoutException;
-import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import sun.net.www.protocol.http.HttpURLConnection;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.wiki.core.model.Feed;
+import org.jboss.seam.wiki.core.model.FeedEntry;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
/**
*
* TODO: This requires a system property for timeout: sun.net.client.defaultConnectTimeout=30000
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -20,6 +20,7 @@
import org.jboss.seam.wiki.core.feeds.FeedEntryManager;
import org.jboss.seam.wiki.core.model.*;
import org.jboss.seam.wiki.core.action.prefs.CommentsPreferences;
+import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
import org.jboss.seam.wiki.core.ui.WikiRedirect;
import org.jboss.seam.wiki.core.wikitext.editor.WikiTextEditor;
@@ -42,6 +43,9 @@
@In
protected FeedDAO feedDAO;
+
+ @In
+ protected SpamReportDAO spamReportDAO;
@In("#{preferences.get('Comments')}")
protected CommentsPreferences commentsPreferences;
@@ -176,6 +180,8 @@
feedDAO.findFeeds(getInstance()),
feedDAO.findFeedEntry(getInstance())
);
+
+ spamReportDAO.removeReports(spamReportDAO.findReports(getInstance()));
remove();
getEntityManager().clear();
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -37,5 +37,7 @@
feedDAO.findFeeds(comment),
feedDAO.findFeedEntry(comment)
);
+
+ spamReportDAO.removeReports(spamReportDAO.findReports(comment));
}
}
\ No newline at end of file
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -11,6 +11,7 @@
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
+import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.dao.UserDAO;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.feeds.FeedDAO;
@@ -32,6 +33,9 @@
@In
protected FeedDAO feedDAO;
+
+ @In
+ protected SpamReportDAO spamReportDAO;
@In
protected WikiNodeDAO wikiNodeDAO;
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -353,7 +353,26 @@
}
return outcome;
}
+
+ @Restrict("#{s:hasPermission('User', 'delete', userHome.instance)}")
+ public String nuke() {
+ // TODO need to do almost the same as remove(), however we want to delete
+ // all the user's nodes instead of re-parenting them, plus add their
+ // e-mail and ip address to the blacklist
+
+ // Remove preferences for this user
+ PreferenceProvider prefProvider = (PreferenceProvider)Component.getInstance("preferenceProvider");
+ prefProvider.deleteUserPreferenceValues(getInstance());
+ prefProvider.flush();
+
+ String outcome = super.remove();
+ if (outcome != null) {
+ org.jboss.seam.core.Events.instance().raiseEvent("User.removed", getInstance());
+ }
+ return outcome;
+ }
+
@Restrict("#{s:hasPermission('User', 'edit', userHome.instance)}")
public void removePortrait() {
getInstance().getProfile().setImage(null);
Added: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -0,0 +1,44 @@
+package org.jboss.seam.wiki.core.dao;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.WikiFeed;
+import org.jboss.seam.wiki.core.model.WikiSpamReport;
+
+@Name("spamReportDAO")
+@AutoCreate
+public class SpamReportDAO
+{
+ @Logger static Log log;
+
+ @In protected EntityManager restrictedEntityManager;
+
+
+ public List<WikiSpamReport> findReports(WikiComment comment) {
+ if (comment == null || comment.getId() == null) throw new IllegalArgumentException("comment is null or unsaved");
+
+ return restrictedEntityManager
+ .createQuery(
+ "select distinct r from WikiSpamReport r " +
+ " where r.comment = :comment"
+ )
+ .setParameter("comment", comment)
+ .getResultList();
+ }
+
+ public void removeReports(List<WikiSpamReport> reports)
+ {
+ for (WikiSpamReport report : reports)
+ {
+ restrictedEntityManager.remove(report);
+ }
+ }
+}
Added: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java 2010-07-27 08:58:14 UTC (rev 13515)
@@ -0,0 +1,58 @@
+package org.jboss.seam.wiki.core.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * Stores a list of blacklisted e-mail addresses and IP addresses. Any users
+ * matching an entry in this table will not be permitted to register or to create
+ * any type of content.
+ *
+ * @author Shane Bryzak
+ */
+@Entity
+@Table(name = "BLACKLIST")
+public class Blacklist
+{
+ private Long id;
+ private String email;
+ private String ipAddress;
+
+ @Id
+ @GeneratedValue(generator = "wikiSequenceGenerator")
+ @Column(name = "ID")
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @Column(name = "EMAIL")
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail(String email)
+ {
+ this.email = email;
+ }
+
+ @Column(name = "IP_ADDRESS")
+ public String getIpAddress()
+ {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress)
+ {
+ this.ipAddress = ipAddress;
+ }
+}
Modified: branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-27 08:58:14 UTC (rev 13515)
@@ -290,17 +290,41 @@
</s:div>
<s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name == report.comment.subject}">
<h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
- </s:div>
+ </s:div>
+ <div>
+ <h:outputLink value="#{wikiURLRenderer.renderURL(report.comment)}">
+ <h:outputText value="#{messages['lacewiki.label.adminHome.spamReport.ViewOriginal']}"/>
+ </h:outputLink>
+ </div>
+
</h:column>
<h:column>
<f:facet name="header">
#{messages['lacewiki.label.adminHome.spamReport.Poster']}
</f:facet>
-
- <h:outputLink value="#{wikiURLRenderer.renderUserProfileURL(report.comment.createdBy)}">
- <h:outputText value="#{report.comment.createdBy}"/>
- </h:outputLink>
+
+ <s:div rendered="#{report.comment.ownedByRegularUser}">
+ <s:span styleClass="undecoratedLink">
+ <h:outputLink value="#{wikiURLRenderer.renderUserProfileURL(report.comment.createdBy)}">
+ <h:outputText value="#{report.comment.createdBy.fullname}"/>
+ </h:outputLink>
+ </s:span>
+ </s:div>
+
+ <s:div rendered="#{not report.comment.ownedByRegularUser}">
+ <h:outputText rendered="#{empty report.comment.fromUserHomepage}" value="#{report.comment.fromUserName}"/>
+ <s:fragment rendered="#{not empty report.comment.fromUserHomepage}">
+ <a href="#{report.comment.fromUserHomepage}">#{report.comment.fromUserName}</a>
+ </s:fragment>
+ <s:fragment rendered="#{not empty report.comment.fromUserEmail}">
+ <h:outputText value=" | "/>
+ <h:outputLink value="#{wiki:escapeEmailURL(wiki:concat('mailto:', report.comment.fromUserEmail))}">
+ <h:outputText value="#{wiki:escapeAtSymbol(report.comment.fromUserEmail)}"/>
+ </h:outputLink>
+ </s:fragment>
+ </s:div>
+
</h:column>
</h:dataTable>
Modified: branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml 2010-07-27 08:32:39 UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml 2010-07-27 08:58:14 UTC (rev 13515)
@@ -332,6 +332,25 @@
</ui:decorate>
</s:fragment>
+ <s:fragment rendered="#{s:hasPermission('User', 'delete', userHome.instance)}">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.userHome.Nuke']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button sessionEventTrigger"/>
+ <ui:param name="escapeLabel" value="false"/>
+ <ui:param name="jsFunctionName" value="nukeUser"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToNukePrefix']
+ .concat(userHome.instance.username)
+ .concat(messages['lacewiki.label.AreYouSureYouWantToNukeSuffix'])
+ }"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ action="#{userHome.nuke}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </s:fragment>
+
</div>
</div>
</div>
14 years, 5 months
Seam SVN: r13514 - in modules/persistence/trunk/impl/src: test/java/org/jboss/seam/persistence/transactions/test and 1 other directory.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-27 04:32:39 -0400 (Tue, 27 Jul 2010)
New Revision: 13514
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java
Log:
update tests and NPE fix
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java 2010-07-27 07:48:57 UTC (rev 13513)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java 2010-07-27 08:32:39 UTC (rev 13514)
@@ -29,7 +29,9 @@
import javax.interceptor.InterceptorBinding;
/**
- * Interceptor binding for {@link Transactional} beans
+ * Interceptor binding for the seam transaction interceceptor. This binding is
+ * applied automatically by a portable extension, the user should not need to
+ * apply it themselves
*
* @author Stuart Douglas
*
@@ -37,7 +39,7 @@
@Retention(RetentionPolicy.RUNTIME)
@InterceptorBinding
@Target( { ElementType.TYPE, ElementType.METHOD })
-public @interface TransactionalInterceptorBinding
+@interface TransactionalInterceptorBinding
{
}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java 2010-07-27 07:48:57 UTC (rev 13513)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java 2010-07-27 08:32:39 UTC (rev 13514)
@@ -23,7 +23,6 @@
import javax.ejb.ApplicationException;
import javax.transaction.Status;
-import javax.transaction.UserTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,14 +48,13 @@
boolean transactionActive = transaction.isActiveOrMarkedRollback() || transaction.isRolledBack();
// TODO: temp workaround, what should we really do in this case??
boolean newTransactionRequired = isNewTransactionRequired(transactionActive);
- UserTransaction userTransaction = newTransactionRequired ? transaction : null;
try
{
if (newTransactionRequired)
{
log.debug("beginning transaction");
- userTransaction.begin();
+ transaction.begin();
}
T result = work();
@@ -65,34 +63,34 @@
if (transaction.isMarkedRollback())
{
log.debug("rolling back transaction");
- userTransaction.rollback();
+ transaction.rollback();
}
else
{
log.debug("committing transaction");
- userTransaction.commit();
+ transaction.commit();
}
}
return result;
}
catch (Exception e)
{
- if (newTransactionRequired && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION )
+ if (newTransactionRequired && transaction.getStatus() != Status.STATUS_NO_TRANSACTION)
{
- if(isRollbackRequired(e, true))
+ if (isRollbackRequired(e, true))
{
log.debug("rolling back transaction");
- userTransaction.rollback();
+ transaction.rollback();
}
else
{
log.debug("committing transaction after ApplicationException(rollback=false):" + e.getMessage());
- userTransaction.commit();
+ transaction.commit();
}
}
- else if (userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION && isRollbackRequired(e, true))
+ else if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION && isRollbackRequired(e, true))
{
- userTransaction.setRollbackOnly();
+ transaction.setRollbackOnly();
}
throw e;
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-27 07:48:57 UTC (rev 13513)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-27 08:32:39 UTC (rev 13514)
@@ -26,6 +26,7 @@
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import javax.persistence.TransactionRequiredException;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
@@ -112,6 +113,12 @@
assertHotels(2);
}
+ @Test(expected = TransactionRequiredException.class)
+ public void testTransactionInterceptorMethodOverrides()
+ {
+ bean.tryAndAddHotelWithNoTransaction();
+ }
+
public void assertHotels(int count) throws NotSupportedException, SystemException
{
transaction.begin();
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java 2010-07-27 07:48:57 UTC (rev 13513)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java 2010-07-27 08:32:39 UTC (rev 13514)
@@ -62,4 +62,13 @@
throw new DontRollBackException();
}
+ @Transactional(TransactionPropagation.NEVER)
+ public void tryAndAddHotelWithNoTransaction()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
}
14 years, 5 months
Seam SVN: r13513 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence/transaction and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-27 03:48:57 -0400 (Tue, 27 Jul 2010)
New Revision: 13513
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/NamingUtils.java
Removed:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java
Modified:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
Log:
change implementation of transaction interceptor to allow overriding transaction type on methods
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -27,21 +27,22 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import javax.interceptor.InterceptorBinding;
-
/**
* Demarcates transaction boundaries
*
* Note that is you are using seam managed transactions seam will automatically
* manage your transactions for you, rendering this unnessesary
*
+ * Note that this annotation is not actually an interceptor binding. It is
+ * replaced by an interceptor binding at runtime by a portable extension in the
+ * ProcessAnnotatedType phase
*
+ *
* @author Dan Allen
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.METHOD, ElementType.TYPE })
-@InterceptorBinding
public @interface Transactional
{
/**
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -25,7 +25,7 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-import org.jboss.seam.persistence.util.Naming;
+import org.jboss.seam.persistence.util.NamingUtils;
/**
* utility class to look up the EJBContext
@@ -41,11 +41,11 @@
{
try
{
- return (EJBContext) Naming.getInitialContext().lookup(ejbContextName);
+ return (EJBContext) NamingUtils.getInitialContext().lookup(ejbContextName);
}
catch (NameNotFoundException nnfe)
{
- return (EJBContext) Naming.getInitialContext().lookup(STANDARD_EJB_CONTEXT_NAME);
+ return (EJBContext) NamingUtils.getInitialContext().lookup(STANDARD_EJB_CONTEXT_NAME);
}
}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -22,11 +22,16 @@
package org.jboss.seam.persistence.transaction;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.util.AnnotationLiteral;
import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
+import org.jboss.seam.persistence.util.EjbApi;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
import org.jboss.weld.extensions.bean.BeanBuilder;
import org.jboss.weld.extensions.defaultbean.DefaultBeanExtension;
@@ -63,4 +68,45 @@
builder.getQualifiers().add(DefaultTransactionLiteral.INSTANCE);
DefaultBeanExtension.addDefaultBean(SeamTransaction.class, builder.create());
}
+
+ /**
+ * Looks for @Transaction or @TransactionAttribute annotations and if they
+ * are found adds the transaction intercepter binding
+ *
+ */
+ public <X> void processAnnotatedType(@Observes ProcessAnnotatedType<X> event)
+ {
+ if (event.getAnnotatedType().isAnnotationPresent(Transactional.class))
+ {
+ event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
+ return;
+ }
+ if (event.getAnnotatedType().isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType()))
+ {
+ event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
+ return;
+ }
+ for (AnnotatedMethod<? super X> m : event.getAnnotatedType().getMethods())
+ {
+ if (m.isAnnotationPresent(Transactional.class))
+ {
+ event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
+ return;
+ }
+ else if (m.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType()))
+ {
+ event.setAnnotatedType(addInterceptorBinding(event.getAnnotatedType()));
+ return;
+ }
+ }
+ }
+
+ public <X> AnnotatedType addInterceptorBinding(AnnotatedType<X> type)
+ {
+ AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(type);
+ builder.addToClass(new AnnotationLiteral<TransactionalInterceptorBinding>()
+ {
+ });
+ return builder.create();
+ }
}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -38,8 +38,9 @@
*
* @author Gavin King
* @author Shane Bryzak
+ * @author Stuart Douglas
*/
-@Transactional
+@TransactionalInterceptorBinding
@Interceptor
public class TransactionInterceptor implements Serializable
{
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -10,7 +10,7 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-import org.jboss.seam.persistence.util.Naming;
+import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.weld.extensions.literal.DefaultLiteral;
/**
@@ -72,7 +72,7 @@
protected javax.transaction.UserTransaction getUserTransaction() throws NamingException
{
- InitialContext context = Naming.getInitialContext();
+ InitialContext context = NamingUtils.getInitialContext();
try
{
return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.persistence.transaction;
import java.lang.annotation.ElementType;
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -24,6 +24,8 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import javax.enterprise.inject.spi.AnnotatedType;
+
import org.jboss.weld.extensions.util.Reflections;
/**
@@ -43,6 +45,11 @@
public static final Class<? extends Enum> TRANSACTION_ATTRIBUTE_TYPE;
public static final Class<? extends Annotation> APPLICATION_EXCEPTION;
+ public static final Class<? extends Annotation> STATEFUL;
+ public static final Class<? extends Annotation> STATELESS;
+ public static final Class<? extends Annotation> MESSAGE_DRIVEN;
+ public static final Class<? extends Annotation> SINGLETON;
+
private static final Object MANDATORY;
private static final Object REQUIRED;
@@ -73,6 +80,7 @@
{
APPLICATION_EXCEPTION = classForName("javax.ejb.ApplicationException");
TRANSACTION_ATTRIBUTE = classForName("javax.ejb.TransactionAttribute");
+
TRANSACTION_ATTRIBUTE_TYPE = classForName("javax.ejb.TransactionAttributeType");
if (TRANSACTION_ATTRIBUTE_TYPE.getName().equals("javax.ejb.TransactionAttributeType"))
{
@@ -93,6 +101,12 @@
SUPPORTS = Dummy.class;
}
INVOCATION_CONTEXT_AVAILABLE = !classForName("javax.interceptor.InvocationContext").equals(Dummy.class);
+
+ STATEFUL = classForName("javax.ejb.Stateful");
+ STATELESS = classForName("javax.ejb.Stateless");
+ MESSAGE_DRIVEN = classForName("javax.ejb.MessageDriven");
+ SINGLETON = classForName("javax.ejb.Singleton");
+
}
public static String name(Annotation annotation)
@@ -122,4 +136,8 @@
}
}
+ public static <X> boolean isEjb(AnnotatedType<X> type)
+ {
+ return type.isAnnotationPresent(STATEFUL) || type.isAnnotationPresent(STATELESS) || type.isAnnotationPresent(MESSAGE_DRIVEN) || type.isAnnotationPresent(SINGLETON);
+ }
}
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.persistence.util;
-
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * this has been ported to seam and hacked to make it work
- *
- * we need to figure out what we are doing with JNDI in seam 3 and make this go
- * away
- *
- * @author stuart
- *
- */
-public final class Naming
-{
- private static final Logger log = LoggerFactory.getLogger(Naming.class);
- private static Hashtable initialContextProperties;
-
- private static InitialContext initialContext;
-
- public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
- {
- if (props == null)
- {
- // throw new
- // IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
- }
- props = new Hashtable<String, String>();
-
- if (log.isDebugEnabled())
- {
- log.debug("JNDI InitialContext properties:" + props);
- }
-
- try
- {
- return props.size() == 0 ? new InitialContext() : new InitialContext(props);
- }
- catch (NamingException e)
- {
- log.debug("Could not obtain initial context");
- throw e;
- }
-
- }
-
- public static InitialContext getInitialContext() throws NamingException
- {
- if (initialContext == null)
- initInitialContext();
-
- return initialContext;
- }
-
- private static synchronized void initInitialContext() throws NamingException
- {
- if (initialContext == null)
- {
- initialContext = getInitialContext(initialContextProperties);
- }
- }
-
- private Naming()
- {
- }
-
- public static void setInitialContextProperties(Hashtable initialContextProperties)
- {
- Naming.initialContextProperties = initialContextProperties;
- initialContext = null;
- }
-
- public static Hashtable getInitialContextProperties()
- {
- return initialContextProperties;
- }
-}
Copied: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/NamingUtils.java (from rev 13502, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java)
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/NamingUtils.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/NamingUtils.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.util;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * this has been ported to seam and hacked to make it work
+ *
+ * we need to figure out what we are doing with JNDI in seam 3 and make this go
+ * away
+ *
+ * @author stuart
+ *
+ */
+public final class NamingUtils
+{
+ private static final Logger log = LoggerFactory.getLogger(NamingUtils.class);
+ private static Hashtable initialContextProperties;
+
+ private static InitialContext initialContext;
+
+ public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
+ {
+ if (props == null)
+ {
+ // throw new
+ // IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
+ }
+ props = new Hashtable<String, String>();
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("JNDI InitialContext properties:" + props);
+ }
+
+ try
+ {
+ return props.size() == 0 ? new InitialContext() : new InitialContext(props);
+ }
+ catch (NamingException e)
+ {
+ log.debug("Could not obtain initial context");
+ throw e;
+ }
+
+ }
+
+ public static InitialContext getInitialContext() throws NamingException
+ {
+ if (initialContext == null)
+ initInitialContext();
+
+ return initialContext;
+ }
+
+ private static synchronized void initInitialContext() throws NamingException
+ {
+ if (initialContext == null)
+ {
+ initialContext = getInitialContext(initialContextProperties);
+ }
+ }
+
+ private NamingUtils()
+ {
+ }
+
+ public static void setInitialContextProperties(Hashtable initialContextProperties)
+ {
+ NamingUtils.initialContextProperties = initialContextProperties;
+ initialContext = null;
+ }
+
+ public static Hashtable getInitialContextProperties()
+ {
+ return initialContextProperties;
+ }
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -18,6 +18,7 @@
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.TransactionExtension;
+import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
@@ -40,6 +41,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(PersistenceContextExtension.class.getPackage());
+ war.addPackage(NamingUtils.class.getPackage());
war.addClasses(ManagedPersistenceContextTest.class, Hotel.class, ManagedPersistenceContextProvider.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -40,6 +40,7 @@
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.TransactionInterceptor;
+import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
import org.jboss.seam.transactions.test.util.EntityManagerProvider;
@@ -69,6 +70,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
+ war.addPackage(NamingUtils.class.getPackage());
war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -17,6 +17,7 @@
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
+import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
@@ -38,6 +39,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(TransactionScopeExtension.class.getPackage());
+ war.addPackage(NamingUtils.class.getPackage());
war.addClasses(TransactionScopedTest.class, Hotel.class, TransactionScopedObject.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-07-26 15:08:47 UTC (rev 13512)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-07-27 07:48:57 UTC (rev 13513)
@@ -18,6 +18,7 @@
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.TransactionExtension;
+import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
@@ -39,6 +40,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
war.addClasses(UserTransactionTest.class, Hotel.class);
+ war.addPackage(NamingUtils.class.getPackage());
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
14 years, 5 months
Seam SVN: r13512 - tags.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-26 11:08:47 -0400 (Mon, 26 Jul 2010)
New Revision: 13512
Added:
tags/JBPAPP_5_1_0-CR2/
Log:
created tag for EAP 5.1 CR2
Copied: tags/JBPAPP_5_1_0-CR2 (from rev 13511, branches/enterprise/JBPAPP_5_0)
14 years, 5 months
Seam SVN: r13511 - branches/enterprise/JBPAPP_5_0/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-26 10:33:36 -0400 (Mon, 26 Jul 2010)
New Revision: 13511
Modified:
branches/enterprise/JBPAPP_5_0/build/core.pom.xml
branches/enterprise/JBPAPP_5_0/build/ioc.pom.xml
branches/enterprise/JBPAPP_5_0/build/root.pom.xml
branches/enterprise/JBPAPP_5_0/build/ui.pom.xml
Log:
JBPAPP-4569 - excluded old hibernate dependency from jbpm3
Modified: branches/enterprise/JBPAPP_5_0/build/core.pom.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/build/core.pom.xml 2010-07-26 10:32:37 UTC (rev 13510)
+++ branches/enterprise/JBPAPP_5_0/build/core.pom.xml 2010-07-26 14:33:36 UTC (rev 13511)
@@ -13,7 +13,6 @@
<packaging>ejb</packaging>
<!-- See parent pom for notes on how to declare dependencies -->
-
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
@@ -148,10 +147,9 @@
</dependency>
<dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <optional>true</optional>
- <scope>provided</scope>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-transaction-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -254,6 +252,7 @@
<optional>true</optional>
</dependency>
+
<dependency>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm-jpdl</artifactId>
Modified: branches/enterprise/JBPAPP_5_0/build/ioc.pom.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/build/ioc.pom.xml 2010-07-26 10:32:37 UTC (rev 13510)
+++ branches/enterprise/JBPAPP_5_0/build/ioc.pom.xml 2010-07-26 14:33:36 UTC (rev 13511)
@@ -45,12 +45,11 @@
<optional>true</optional>
<scope>provided</scope>
</dependency>
-
+
<dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <optional>true</optional>
- <scope>provided</scope>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-transaction-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
Modified: branches/enterprise/JBPAPP_5_0/build/root.pom.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/build/root.pom.xml 2010-07-26 10:32:37 UTC (rev 13510)
+++ branches/enterprise/JBPAPP_5_0/build/root.pom.xml 2010-07-26 14:33:36 UTC (rev 13511)
@@ -8,18 +8,6 @@
<version>@seam.version@</version>
<name>JBoss Seam</name>
<packaging>pom</packaging>
-<!-- <pluginRepositories>-->
-<!-- <pluginRepository>-->
-<!-- <id>repository.jboss.org</id>-->
-<!-- <name>JBoss Repository</name>-->
-<!-- <url>http://repository.jboss.org/maven2</url>-->
-<!-- </pluginRepository>-->
-<!-- <pluginRepository>-->
-<!-- <id>maven_eap5</id>-->
-<!-- <name>EAP5 Central Repository</name>-->
-<!-- <url>http://repository.jboss.org/maven2-brew</url>-->
-<!-- </pluginRepository>-->
-<!-- </pluginRepositories>-->
<!-- Externalize some version numbers here -->
<properties>
@@ -28,6 +16,7 @@
<version.testng>5.9</version.testng>
<version.resteasy>1.2.1.GA_CP02</version.resteasy>
<version.spring>2.5.6.SEC02</version.spring>
+ <version.hibernate-core>3.3.2.GA_CP03</version.hibernate-core>
</properties>
<dependencyManagement>
@@ -354,7 +343,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <version>3.3.2.GA_CP03</version>
+ <version>${version.hibernate-core}</version>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
@@ -376,6 +365,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -420,7 +413,11 @@
<groupId>jboss</groupId>
<artifactId>javassist</artifactId>
</exclusion>
- </exclusions>
+ <exclusion>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -443,6 +440,12 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>3.1.1.GA_CP03</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -660,11 +663,11 @@
<version>2.1.3</version>
</dependency>
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <version>1.1</version>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-transaction-api</artifactId>
+ <version>1.0.1.GA</version>
+ </dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Modified: branches/enterprise/JBPAPP_5_0/build/ui.pom.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/build/ui.pom.xml 2010-07-26 10:32:37 UTC (rev 13510)
+++ branches/enterprise/JBPAPP_5_0/build/ui.pom.xml 2010-07-26 14:33:36 UTC (rev 13511)
@@ -124,6 +124,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ </exclusion>
</exclusions>
</dependency>
14 years, 5 months
Seam SVN: r13510 - branches/enterprise/JBPAPP_5_0/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-26 06:32:37 -0400 (Mon, 26 Jul 2010)
New Revision: 13510
Modified:
branches/enterprise/JBPAPP_5_0/build/root.pom.xml
Log:
upgraded hibernate deps and other EAP 5.1 upgrades for CR2 - JBPAPP-4699
Modified: branches/enterprise/JBPAPP_5_0/build/root.pom.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/build/root.pom.xml 2010-07-26 09:59:37 UTC (rev 13509)
+++ branches/enterprise/JBPAPP_5_0/build/root.pom.xml 2010-07-26 10:32:37 UTC (rev 13510)
@@ -27,7 +27,7 @@
<version.drools>5.0.1</version.drools>
<version.testng>5.9</version.testng>
<version.resteasy>1.2.1.GA_CP02</version.resteasy>
- <version.spring>2.5.6.SEC01</version.spring>
+ <version.spring>2.5.6.SEC02</version.spring>
</properties>
<dependencyManagement>
@@ -276,7 +276,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.15.GA</version>
+ <version>2.6.16.GA</version>
</dependency>
<dependency>
@@ -354,7 +354,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <version>3.3.2.GA_CP02</version>
+ <version>3.3.2.GA_CP03</version>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
@@ -382,7 +382,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
- <version>3.4.0.GA_CP02</version>
+ <version>3.4.0.GA_CP03</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
@@ -406,7 +406,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>3.4.0.GA_CP02</version>
+ <version>3.4.0.GA_CP03</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
@@ -442,7 +442,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
- <version>3.1.1.GA_CP02</version>
+ <version>3.1.1.GA_CP03</version>
</dependency>
<dependency>
@@ -1198,7 +1198,7 @@
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
- <version>1.8.0.8patch02-brew</version>
+ <version>1.8.0.8.patch03-brew</version>
</dependency>
<dependency>
14 years, 5 months
Seam SVN: r13509 - in sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet: jsf and 1 other directory.
by seam-commits@lists.jboss.org
Author: nickarls
Date: 2010-07-26 05:59:37 -0400 (Mon, 26 Jul 2010)
New Revision: 13509
Modified:
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java
Log:
more CSS parsing
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java 2010-07-26 09:39:06 UTC (rev 13508)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java 2010-07-26 09:59:37 UTC (rev 13509)
@@ -2,7 +2,7 @@
public class CSSNames
{
- public static final String FONT_FAMILY = "xls-font-family";
+ public static final String FONT_NAME = "xls-font-name";
public static final String FONT_SIZE = "xls-font-size";
public static final String FONT_COLOR = "xls-font-color";
public static final String FONT_ITALIC = "xls-font-italic";
@@ -35,14 +35,14 @@
public static final String BORDER = "xls-border";
public static final String ALIGNMENT = "xls-alignment";
- public static final String FORMAT_MASK = "xls-format-mask";
+ public static final String MASK = "xls-mask";
public static final String INDENTATION = "xls-indentation";
public static final String LOCKED = "xls-locked";
public static final String ORIENTATION = "xls-orientation";
public static final String SHRINK_TO_FIT = "xls-shrink-to-fit";
public static final String VERICAL_ALIGNMENT = "xls-vertical-alignment";
public static final String WRAP = "xls-wrap";
- public static final String FORCE_TYPE = "xls-force-type";
+ public static final String TYPE = "xls-type";
public static final String COLUMN_WIDTH = "xls-column-width";
public static final String COLUMN_WIDTHS = "xls-column-widths";
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java 2010-07-26 09:39:06 UTC (rev 13508)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java 2010-07-26 09:59:37 UTC (rev 13509)
@@ -17,7 +17,7 @@
public static Map<String, PropertyBuilder> getPropertyBuilders()
{
Map<String, PropertyBuilder> propertyBuilders = new HashMap<String, PropertyBuilder>();
- propertyBuilders.put(CSSNames.FONT_FAMILY, new PropertyBuilders.FontFamily());
+ propertyBuilders.put(CSSNames.FONT_NAME, new PropertyBuilders.FontFamily());
propertyBuilders.put(CSSNames.FONT_SIZE, new PropertyBuilders.FontSize());
propertyBuilders.put(CSSNames.FONT_COLOR, new PropertyBuilders.FontColor());
propertyBuilders.put(CSSNames.FONT_ITALIC, new PropertyBuilders.FontItalic());
@@ -42,7 +42,7 @@
propertyBuilders.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, new PropertyBuilders.BorderBottomLineStyle());
propertyBuilders.put(CSSNames.BORDER_BOTTOM, new PropertyBuilders.BorderBottomShorthand());
propertyBuilders.put(CSSNames.BORDER, new PropertyBuilders.BorderShorthand());
- propertyBuilders.put(CSSNames.FORMAT_MASK, new PropertyBuilders.FormatMask());
+ propertyBuilders.put(CSSNames.MASK, new PropertyBuilders.Mask());
propertyBuilders.put(CSSNames.ALIGNMENT, new PropertyBuilders.Alignment());
propertyBuilders.put(CSSNames.INDENTATION, new PropertyBuilders.Indentation());
propertyBuilders.put(CSSNames.ORIENTATION, new PropertyBuilders.Orientation());
@@ -55,11 +55,11 @@
propertyBuilders.put(CSSNames.COLUMN_HIDDEN, new PropertyBuilders.ColumnHidden());
propertyBuilders.put(CSSNames.COLUMN_EXPORT, new PropertyBuilders.ColumnExport());
propertyBuilders.put(CSSNames.COLUMN_WIDTHS, new PropertyBuilders.ColumnWidths());
- propertyBuilders.put(CSSNames.FORCE_TYPE, new PropertyBuilders.ForceType());
+ propertyBuilders.put(CSSNames.TYPE, new PropertyBuilders.Type());
return propertyBuilders;
}
- public static class ForceType extends StringPropertyBuilder
+ public static class Type extends StringPropertyBuilder
{
}
@@ -369,7 +369,7 @@
if (firstQuote > 0 && lastQuote > 0 && firstQuote != lastQuote)
{
String fontName = valueString.substring(firstQuote, lastQuote);
- styleMap.put(CSSNames.FONT_FAMILY, fontName);
+ styleMap.put(CSSNames.FONT_NAME, fontName);
String pre = valueString.substring(0, firstQuote - 1).trim();
String post = valueString.substring(lastQuote + 1).trim();
valueString = pre + post;
@@ -409,7 +409,7 @@
}
else
{
- styleMap.put(CSSNames.FONT_FAMILY, value);
+ styleMap.put(CSSNames.FONT_NAME, value);
}
}
@@ -463,7 +463,7 @@
{
}
- public static class FormatMask extends MergingStringPropertyBuilder
+ public static class Mask extends MergingStringPropertyBuilder
{
}
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java 2010-07-26 09:39:06 UTC (rev 13508)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java 2010-07-26 09:59:37 UTC (rev 13509)
@@ -5,4 +5,327 @@
public class StyleMap extends HashMap<String, Object>
{
private static final long serialVersionUID = 1L;
+
+ public boolean hasAlignment()
+ {
+ return super.containsKey(CSSNames.ALIGNMENT);
+ }
+
+ private boolean containsAnyOf(String[] keys)
+ {
+ for (String key : keys)
+ {
+ if (super.containsKey(key))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasBackground()
+ {
+ return containsAnyOf(new String[] { CSSNames.BACKGROUND, CSSNames.BACKGROUND_COLOR, CSSNames.BACKGROUND_PATTERN });
+ }
+
+ public boolean hasBackgroundColour()
+ {
+ return super.containsKey(CSSNames.BACKGROUND_COLOR);
+ }
+
+ public boolean hasBackgroundPattern()
+ {
+ return super.containsKey(CSSNames.BACKGROUND_PATTERN);
+ }
+
+ public boolean hasIndentation()
+ {
+ return super.containsKey(CSSNames.INDENTATION);
+ }
+
+ public boolean hasLocked()
+ {
+ return super.containsKey(CSSNames.LOCKED);
+ }
+
+ public boolean hasMask()
+ {
+ return super.containsKey(CSSNames.MASK);
+ }
+
+ public boolean hasOrientation()
+ {
+ return super.containsKey(CSSNames.ORIENTATION);
+ }
+
+ public boolean hasShrinkToFit()
+ {
+ return super.containsKey(CSSNames.SHRINK_TO_FIT);
+ }
+
+ public boolean hasType()
+ {
+ return super.containsKey(CSSNames.TYPE);
+ }
+
+ public boolean hasVerticalAlignment()
+ {
+ return super.containsKey(CSSNames.VERICAL_ALIGNMENT);
+ }
+
+ public boolean hasWrap()
+ {
+ return super.containsKey(CSSNames.WRAP);
+ }
+
+ public boolean hasFont()
+ {
+ return containsAnyOf(new String[] { CSSNames.FONT, CSSNames.FONT_BOLD, CSSNames.FONT_COLOR, CSSNames.FONT_NAME, CSSNames.FONT_ITALIC, CSSNames.FONT_SCRIPT_STYLE, CSSNames.FONT_SIZE, CSSNames.FONT_STRUCK_OUT, CSSNames.FONT_UNDERLINE_STYLE });
+ }
+
+ public boolean hasFontBold()
+ {
+ return super.containsKey(CSSNames.FONT_BOLD);
+ }
+
+ public boolean hasFontColour()
+ {
+ return super.containsKey(CSSNames.FONT_COLOR);
+ }
+
+ public boolean hasFontName()
+ {
+ return super.containsKey(CSSNames.FONT_NAME);
+ }
+
+ public boolean hasFontItalic()
+ {
+ return super.containsKey(CSSNames.FONT_ITALIC);
+ }
+
+ public boolean hasFontPointSize()
+ {
+ return super.containsKey(CSSNames.FONT_SIZE);
+ }
+
+ private String getString(String key)
+ {
+ return (String) super.get(key);
+ }
+
+ public String getAlignment()
+ {
+ return getString(CSSNames.ALIGNMENT);
+ }
+
+ public String getBackgroundPattern()
+ {
+ return getString(CSSNames.BACKGROUND_PATTERN);
+ }
+
+ public String getBackgroundColour()
+ {
+ return getString(CSSNames.BACKGROUND_COLOR);
+ }
+
+ public Boolean getFontBold()
+ {
+ return Boolean.parseBoolean(getString(CSSNames.FONT_BOLD));
+ }
+
+ public String getFontName()
+ {
+ return getString(CSSNames.FONT_NAME);
+ }
+
+ public boolean getFontItalic()
+ {
+ return Boolean.parseBoolean(getString(CSSNames.FONT_ITALIC));
+ }
+
+ public int getFontPointSize()
+ {
+ return Integer.parseInt(getString(CSSNames.FONT_SIZE));
+ }
+
+ public String getFontColour()
+ {
+ return getString(CSSNames.FONT_COLOR);
+ }
+
+ public Integer getIndentation()
+ {
+ return Integer.parseInt(getString(CSSNames.INDENTATION));
+ }
+
+ public Boolean getLocked()
+ {
+ return Boolean.parseBoolean(getString(CSSNames.LOCKED));
+ }
+
+ public String getMask()
+ {
+ return getString(CSSNames.MASK);
+ }
+
+ public String getOrientation()
+ {
+ return getString(CSSNames.ORIENTATION);
+ }
+
+ public Boolean getShrinkToFit()
+ {
+ return Boolean.parseBoolean(getString(CSSNames.SHRINK_TO_FIT));
+ }
+
+ public String getType()
+ {
+ return getString(CSSNames.TYPE);
+ }
+
+ public String getVerticalAlignment()
+ {
+ return getString(CSSNames.VERICAL_ALIGNMENT);
+ }
+
+ public Boolean getWrap()
+ {
+ return Boolean.parseBoolean(getString(CSSNames.WRAP));
+ }
+
+ public boolean hasFontScriptStyle()
+ {
+ return super.containsKey(CSSNames.FONT_SCRIPT_STYLE);
+ }
+
+ public String getFontScriptStyle()
+ {
+ return getString(CSSNames.FONT_SCRIPT_STYLE);
+ }
+
+ public boolean hasFontStruckOut()
+ {
+ return super.containsKey(CSSNames.FONT_STRUCK_OUT);
+ }
+
+ public boolean getFontStruckOut()
+ {
+ return Boolean.parseBoolean(getString(CSSNames.FONT_STRUCK_OUT));
+ }
+
+ public boolean hasFontUnderlineStyle()
+ {
+ return super.containsKey(CSSNames.FONT_UNDERLINE_STYLE);
+ }
+
+ public String getFontUnderlineStyle()
+ {
+ return getString(CSSNames.FONT_UNDERLINE_STYLE);
+ }
+
+ public boolean hasBorders()
+ {
+ return containsAnyOf(new String[] { CSSNames.BORDER, CSSNames.BORDER_BOTTOM, CSSNames.BORDER_BOTTOM_COLOR, CSSNames.BORDER_BOTTOM_LINE_STYLE, CSSNames.BORDER_LEFT, CSSNames.BORDER_LEFT_COLOR, CSSNames.BORDER_LEFT_LINE_STYLE, CSSNames.BORDER_RIGHT, CSSNames.BORDER_RIGHT_COLOR, CSSNames.BORDER_RIGHT_LINE_STYLE, CSSNames.BORDER_TOP, CSSNames.BORDER_TOP_COLOR, CSSNames.BORDER_TOP_LINE_STYLE });
+ }
+
+ public boolean hasTopBorder()
+ {
+ return containsAnyOf(new String[] { CSSNames.BORDER_TOP, CSSNames.BORDER_TOP_COLOR, CSSNames.BORDER_TOP_LINE_STYLE });
+ }
+
+ public boolean hasBottomBorder()
+ {
+ return containsAnyOf(new String[] { CSSNames.BORDER_TOP, CSSNames.BORDER_BOTTOM_COLOR, CSSNames.BORDER_BOTTOM_LINE_STYLE });
+ }
+
+ public boolean hasRightBorder()
+ {
+ return containsAnyOf(new String[] { CSSNames.BORDER_RIGHT, CSSNames.BORDER_RIGHT_COLOR, CSSNames.BORDER_RIGHT_LINE_STYLE });
+ }
+
+ public boolean hasLeftBorder()
+ {
+ return containsAnyOf(new String[] { CSSNames.BORDER_LEFT, CSSNames.BORDER_LEFT_COLOR, CSSNames.BORDER_LEFT_LINE_STYLE });
+ }
+
+ public boolean hasBorderTopColour()
+ {
+ return super.containsKey(CSSNames.BORDER_TOP_COLOR);
+ }
+
+ public String getBorderTopColour()
+ {
+ return getString(CSSNames.BORDER_TOP_COLOR);
+ }
+
+ public boolean hasBorderTopLineStyle()
+ {
+ return super.containsKey(CSSNames.BORDER_TOP_LINE_STYLE);
+ }
+
+ public String getBorderTopLineStyle()
+ {
+ return getString(CSSNames.BORDER_TOP_LINE_STYLE);
+ }
+
+ public boolean hasBorderLeftColour()
+ {
+ return super.containsKey(CSSNames.BORDER_LEFT_COLOR);
+ }
+
+ public String getBorderLeftColour()
+ {
+ return getString(CSSNames.BORDER_LEFT_COLOR);
+ }
+
+ public boolean hasBorderLeftLineStyle()
+ {
+ return super.containsKey(CSSNames.BORDER_LEFT_LINE_STYLE);
+ }
+
+ public String getBorderLeftLineStyle()
+ {
+ return getString(CSSNames.BORDER_LEFT_LINE_STYLE);
+ }
+
+ public boolean hasBorderBottomColour()
+ {
+ return super.containsKey(CSSNames.BORDER_BOTTOM_COLOR);
+ }
+
+ public String getBorderBottomColour()
+ {
+ return getString(CSSNames.BORDER_BOTTOM_COLOR);
+ }
+
+ public boolean hasBorderBottomLineStyle()
+ {
+ return super.containsKey(CSSNames.BORDER_BOTTOM_LINE_STYLE);
+ }
+
+ public String getBorderBottomLineStyle()
+ {
+ return getString(CSSNames.BORDER_BOTTOM_LINE_STYLE);
+ }
+
+ public boolean hasBorderRightColour()
+ {
+ return super.containsKey(CSSNames.BORDER_RIGHT_COLOR);
+ }
+
+ public String getBorderRightColour()
+ {
+ return getString(CSSNames.BORDER_RIGHT_COLOR);
+ }
+
+ public boolean hasBorderRightLineStyle()
+ {
+ return super.containsKey(CSSNames.BORDER_RIGHT_LINE_STYLE);
+ }
+
+ public String getBorderRightLineStyle()
+ {
+ return getString(CSSNames.BORDER_RIGHT_LINE_STYLE);
+ }
+
}
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java 2010-07-26 09:39:06 UTC (rev 13508)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java 2010-07-26 09:59:37 UTC (rev 13509)
@@ -1,15 +1,303 @@
package org.jboss.seam.spreadsheet.jsf;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.spreadsheet.SpreadsheetException;
import org.jboss.seam.spreadsheet.css.StyleMap;
+import org.jboss.seam.spreadsheet.model.formatting.Background;
+import org.jboss.seam.spreadsheet.model.formatting.Background.Pattern;
+import org.jboss.seam.spreadsheet.model.formatting.Border;
+import org.jboss.seam.spreadsheet.model.formatting.Border.BorderLineStyle;
+import org.jboss.seam.spreadsheet.model.formatting.Border.BorderType;
import org.jboss.seam.spreadsheet.model.formatting.CellFormat;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat.Alignment;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat.Orientation;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat.Type;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat.VerticalAlignment;
+import org.jboss.seam.spreadsheet.model.formatting.Colour;
+import org.jboss.seam.spreadsheet.model.formatting.Font;
+import org.jboss.seam.spreadsheet.model.formatting.Font.ScriptStyle;
+import org.jboss.seam.spreadsheet.model.formatting.Font.UnderlineStyle;
public class CellFormatFactory
{
- public static CellFormat getCellFormat(StyleMap styleMap)
+ public static CellFormat createCellFormat(StyleMap styleMap)
{
CellFormat cellFormat = new CellFormat();
+ if (styleMap.hasAlignment())
+ {
+ cellFormat.setAlignment(createAlignment(styleMap));
+ }
+ if (styleMap.hasBackground())
+ {
+ cellFormat.setBackground(createBackground(styleMap));
+ }
+ if (styleMap.hasBorders())
+ {
+ cellFormat.setBorders(createBorders(styleMap));
+ }
+ if (styleMap.hasFont())
+ {
+ cellFormat.setFont(createFont(styleMap));
+ }
+ if (styleMap.hasIndentation())
+ {
+ cellFormat.setIndentation(createIndentation(styleMap));
+ }
+ if (styleMap.hasLocked())
+ {
+ cellFormat.setLocked(createLocked(styleMap));
+ }
+ if (styleMap.hasMask())
+ {
+ cellFormat.setMask(createMask(styleMap));
+ }
+ if (styleMap.hasOrientation())
+ {
+ cellFormat.setOrientation(createOrientation(styleMap));
+ }
+ if (styleMap.hasShrinkToFit())
+ {
+ cellFormat.setShrinkToFit(createShrinkToFit(styleMap));
+ }
+ if (styleMap.hasType())
+ {
+ cellFormat.setType(createType(styleMap));
+ }
+ if (styleMap.hasVerticalAlignment())
+ {
+ cellFormat.setVerticalAlignment(createVerticalAlignment(styleMap));
+ }
+ if (styleMap.hasWrap())
+ {
+ cellFormat.setWrap(createWrap(styleMap));
+ }
return cellFormat;
}
+ private static <T extends Enum<T>> T createEnum(Class<T> clazz, String value)
+ {
+ try
+ {
+ return Enum.valueOf(clazz, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new SpreadsheetException(String.format("Could not create enum %s of %s", clazz, value));
+ }
+ }
+
+ private static Alignment createAlignment(StyleMap styleMap)
+ {
+ return createEnum(Alignment.class, styleMap.getAlignment());
+ }
+
+ private static Background createBackground(StyleMap styleMap)
+ {
+ Background background = new Background();
+ if (styleMap.hasBackgroundColour())
+ {
+ background.setColour(createBackgroundColour(styleMap));
+ }
+ if (styleMap.hasBackgroundPattern())
+ {
+ background.setPattern(createBackgroundPattern(styleMap));
+ }
+ return background;
+ }
+
+ private static Pattern createBackgroundPattern(StyleMap styleMap)
+ {
+ return createEnum(Pattern.class, styleMap.getBackgroundPattern());
+ }
+
+ private static Colour createBackgroundColour(StyleMap styleMap)
+ {
+ return createColour(styleMap.getBackgroundColour());
+ }
+
+ private static Colour createColour(String colour)
+ {
+ return createEnum(Colour.class, colour);
+ }
+
+ private static List<Border> createBorders(StyleMap styleMap)
+ {
+ List<Border> borders = new ArrayList<Border>();
+ if (styleMap.hasTopBorder())
+ {
+ borders.add(createTopBorder(styleMap));
+ }
+ if (styleMap.hasBottomBorder())
+ {
+ borders.add(createBottomBorder(styleMap));
+ }
+ if (styleMap.hasLeftBorder())
+ {
+ borders.add(createLeftBorder(styleMap));
+ }
+ if (styleMap.hasRightBorder())
+ {
+ borders.add(createRightBorder(styleMap));
+ }
+
+ return borders;
+ }
+
+ private static Border createTopBorder(StyleMap styleMap)
+ {
+ Border border = new Border(BorderType.TOP);
+ if (styleMap.hasBorderTopColour())
+ {
+ border.setColour(createColour(styleMap.getBorderTopColour()));
+ }
+ if (styleMap.hasBorderTopLineStyle())
+ {
+ border.setLineStyle(createLineStyle(styleMap.getBorderTopLineStyle()));
+ }
+ return border;
+ }
+
+ private static Border createBottomBorder(StyleMap styleMap)
+ {
+ Border border = new Border(BorderType.BOTTOM);
+ if (styleMap.hasBorderBottomColour())
+ {
+ border.setColour(createColour(styleMap.getBorderBottomColour()));
+ }
+ if (styleMap.hasBorderBottomLineStyle())
+ {
+ border.setLineStyle(createLineStyle(styleMap.getBorderBottomLineStyle()));
+ }
+ return border;
+ }
+
+ private static Border createLeftBorder(StyleMap styleMap)
+ {
+ Border border = new Border(BorderType.LEFT);
+ if (styleMap.hasBorderLeftColour())
+ {
+ border.setColour(createColour(styleMap.getBorderLeftColour()));
+ }
+ if (styleMap.hasBorderLeftLineStyle())
+ {
+ border.setLineStyle(createLineStyle(styleMap.getBorderLeftLineStyle()));
+ }
+ return border;
+ }
+
+ private static Border createRightBorder(StyleMap styleMap)
+ {
+ Border border = new Border(BorderType.RIGHT);
+ if (styleMap.hasBorderRightColour())
+ {
+ border.setColour(createColour(styleMap.getBorderRightColour()));
+ }
+ if (styleMap.hasBorderRightLineStyle())
+ {
+ border.setLineStyle(createLineStyle(styleMap.getBorderRightLineStyle()));
+ }
+ return border;
+ }
+
+ private static BorderLineStyle createLineStyle(String lineStyle)
+ {
+ return createEnum(BorderLineStyle.class, lineStyle);
+ }
+
+ private static Font createFont(StyleMap styleMap)
+ {
+ Font font = new Font();
+ if (styleMap.hasFontBold())
+ {
+ font.setBold(styleMap.getFontBold());
+ }
+ if (styleMap.hasFontColour())
+ {
+ font.setColour(createFontColour(styleMap));
+ }
+ if (styleMap.hasFontName())
+ {
+ font.setFontName(styleMap.getFontName());
+ }
+ if (styleMap.hasFontItalic())
+ {
+ font.setItalic(styleMap.getFontItalic());
+ }
+ if (styleMap.hasFontPointSize())
+ {
+ font.setPointSize(styleMap.getFontPointSize());
+ }
+ if (styleMap.hasFontScriptStyle())
+ {
+ font.setScriptStyle(createFontScriptStyle(styleMap.getFontScriptStyle()));
+ }
+ if (styleMap.hasFontStruckOut())
+ {
+ font.setStruckOut(styleMap.getFontStruckOut());
+ }
+ if (styleMap.hasFontUnderlineStyle())
+ {
+ font.setUnderlineStyle(createFontUnderlineStyle(styleMap.getFontUnderlineStyle()));
+ }
+ return font;
+ }
+
+ private static UnderlineStyle createFontUnderlineStyle(String underlineStyle)
+ {
+ return createEnum(UnderlineStyle.class, underlineStyle);
+ }
+
+ private static ScriptStyle createFontScriptStyle(String scriptStyle)
+ {
+ return createEnum(ScriptStyle.class, scriptStyle);
+ }
+
+ private static Colour createFontColour(StyleMap styleMap)
+ {
+ return createColour(styleMap.getFontColour());
+ }
+
+ private static Integer createIndentation(StyleMap styleMap)
+ {
+ return styleMap.getIndentation();
+ }
+
+ private static Boolean createLocked(StyleMap styleMap)
+ {
+ return styleMap.getLocked();
+ }
+
+ private static String createMask(StyleMap styleMap)
+ {
+ return styleMap.getMask();
+ }
+
+ private static Orientation createOrientation(StyleMap styleMap)
+ {
+ return createEnum(Orientation.class, styleMap.getOrientation());
+ }
+
+ private static Boolean createShrinkToFit(StyleMap styleMap)
+ {
+ return styleMap.getShrinkToFit();
+ }
+
+ private static Type createType(StyleMap styleMap)
+ {
+ return createEnum(Type.class, styleMap.getType());
+ }
+
+ private static VerticalAlignment createVerticalAlignment(StyleMap styleMap)
+ {
+ return createEnum(VerticalAlignment.class, styleMap.getVerticalAlignment());
+ }
+
+ private static Boolean createWrap(StyleMap styleMap)
+ {
+ return styleMap.getWrap();
+ }
+
}
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java 2010-07-26 09:39:06 UTC (rev 13508)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java 2010-07-26 09:59:37 UTC (rev 13509)
@@ -54,7 +54,7 @@
List<CellFormat> cellFormats = new ArrayList<CellFormat>();
for (StyleMap styleMap : styleMaps)
{
- cellFormats.add(CellFormatFactory.getCellFormat(styleMap));
+ cellFormats.add(CellFormatFactory.createCellFormat(styleMap));
}
return cellFormats;
}
14 years, 5 months
Seam SVN: r13508 - in branches/community/Seam_2_2/examples/wiki: src/main/org/jboss/seam/wiki/core/action and 8 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-26 05:39:06 -0400 (Mon, 26 Jul 2010)
New Revision: 13508
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java
branches/community/Seam_2_2/examples/wiki/view/themes/default/img/btn.report.bg.gif
branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/img/btn.report.bg.gif
branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/img/btn.report.bg.gif
Modified:
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml
branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css
branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css
branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css
Log:
add report as spam button, added spam report to admin screen
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-26 09:39:06 UTC (rev 13508)
@@ -301,6 +301,10 @@
lacewiki.label.commentsDisplay.Comment=comment
lacewiki.label.commentsDisplay.Comments=comments
lacewiki.label.commentsDisplay.CommentThread=the whole comment thread
+lacewiki.button.commentsDisplay.ReportCommentAsSpam=Report as spam
+lacewiki.label.AreYouSureYouWantToReport=Are you sure you want to report the comment made by
+lacewiki.label.AsSpam=as spam
+lacewiki.label.ReportThankYou=Thank you for your assistance, the comment has been reported.
lacewiki.button.commentsDisplay.RemoveComment=Remove
lacewiki.button.commentsDisplay.ReplyTo=Reply
lacewiki.button.commentsDisplay.Quote=Quote
@@ -369,6 +373,7 @@
lacewiki.button.adminHome.LinkProtocols.accesskey=L
lacewiki.button.adminHome.Preferences=P<u>r</u>eferences
lacewiki.button.adminHome.Preferences.accesskey=R
+lacewiki.button.adminHome.SpamReport=Spam Reports
lacewiki.button.adminHome.SaveSettings=<u>S</u>ave Settings
lacewiki.button.adminHome.SaveSettings.accesskey=S
lacewiki.label.adminHome.SearchIndex=Search Index
@@ -378,6 +383,11 @@
lacewiki.button.adminHome.RebuildIndex=Rebuild Index
lacewiki.label.adminHome.Prefix=Prefix
lacewiki.label.adminHome.TargetLink=Target Link
+
+lacewiki.label.adminHome.spamReport.Reporter=Reporter
+lacewiki.label.adminHome.spamReport.Comment=Comment
+lacewiki.label.adminHome.spamReport.Poster=Comment Poster
+
lacewiki.label.adminHome.TargetWithPlaceHolder=Target with [[link]] placeholder
lacewiki.label.adminHome.NotAvailableForSkin=Administration is not available with this skin.
lacewiki.label.adminHome.plugins.InstalledPlugins=Installed Plugins
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -22,6 +22,7 @@
import org.jboss.seam.security.Identity;
import org.jboss.seam.wiki.core.model.LinkProtocol;
import org.jboss.seam.wiki.core.model.User;
+import org.jboss.seam.wiki.core.model.WikiSpamReport;
import org.jboss.seam.wiki.core.search.IndexManager;
import org.jboss.seam.wiki.core.search.metamodel.SearchRegistry;
import org.jboss.seam.wiki.core.search.metamodel.SearchableEntity;
@@ -115,6 +116,16 @@
public LinkProtocol getLinkProtocol() {
return linkProtocol;
}
+
+ @DataModel(value = "spamReports")
+ private List<WikiSpamReport> spamReports;
+
+ @Factory("spamReports")
+ public void loadSpamReports()
+ {
+ spamReports = entityManager.createQuery("select r from WikiSpamReport r")
+ .getResultList();
+ }
public void addLinkProtocol() {
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -185,7 +185,31 @@
return null; // Prevent navigation
}
+ /**
+ * Creates a spam report for the selected comment
+ *
+ * @param commentId
+ * @return
+ */
+ public String reportAsSpam(Long commentId)
+ {
+ WikiSpamReport report = new WikiSpamReport();
+ setNodeId(commentId);
+ report.setComment(getInstance());
+ report.setReporter(currentUser);
+
+ getEntityManager().persist(report);
+
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ INFO,
+ "lacewiki.label.ReportThankYou",
+ "Thank you for your assistance."
+ );
+
+ return "success";
+ }
+
@Override
protected NodeRemover getNodeRemover() {
return (CommentNodeRemover)Component.getInstance(CommentNodeRemover.class);
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -81,6 +81,9 @@
if ("Comment".equals(name) && "create".equals(action)) {
return checkCommentCreate((WikiDocument)args[0]);
} else
+ if ("Comment".equals(name) && "reportSpam".equals(action)) {
+ return checkCommentReportSpam((WikiNode)args[0]);
+ }
if ("Comment".equals(name) && "delete".equals(action)) {
return checkCommentDelete((WikiNode)args[0]);
} else
@@ -230,6 +233,11 @@
doc.isEnableComments() && doc.isEnableCommentForm()) return true;
return false;
}
+
+ private boolean checkCommentReportSpam(WikiNode node) {
+ if (currentAccessLevel > Role.GUESTROLE_ACCESSLEVEL) return true;
+ return false;
+ }
/*
Only admins can delete comments.
Added: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -0,0 +1,68 @@
+package org.jboss.seam.wiki.core.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * Stores user reports of comment spam
+ *
+ * @author Shane Bryzak
+ *
+ */
+@Entity
+@Inheritance(strategy = InheritanceType.JOINED)
+@Table(name = "WIKI_SPAM_REPORT")
+public class WikiSpamReport implements Serializable
+{
+ private static final long serialVersionUID = -5259814434570251579L;
+
+ private Long reportId;
+ private WikiComment comment;
+ private User reporter;
+
+ @Id
+ @GeneratedValue(generator = "wikiSequenceGenerator")
+ @Column(name = "REPORT_ID")
+ public Long getReportId()
+ {
+ return reportId;
+ }
+
+ public void setReportId(Long reportId)
+ {
+ this.reportId = reportId;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "COMMENT_ID")
+ public WikiComment getComment()
+ {
+ return comment;
+ }
+
+ public void setComment(WikiComment comment)
+ {
+ this.comment = comment;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "REPORTER_USER_ID")
+ public User getReporter()
+ {
+ return reporter;
+ }
+
+ public void setReporter(User reporter)
+ {
+ this.reporter = reporter;
+ }
+}
Modified: branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-26 09:39:06 UTC (rev 13508)
@@ -87,6 +87,10 @@
accesskey="#{messages['lacewiki.button.adminHome.Preferences.accesskey']}">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.Preferences']}"/>
</a></li>
+ <li id="spamReportTab"><a href="#spamReport">
+ <h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.SpamReport']}"/>
+ </a></li>
+
</ul>
<div id="formTabsTitle"/>
@@ -246,7 +250,62 @@
</ui:include>
</div>
</div>
+
+ <div id="spamReport" style="padding: 20px">
+ <h:dataTable id="spamReportTable" var="report"
+ value="#{spamReports}"
+ rendered="#{spamReports.rowCount >0}"
+ styleClass="datatable topLeftBottomBorder"
+ headerClass="regularHeader rightBorder smallFont"
+ columnClasses="tenPercentColumn rightBorder alignLeft,
+ defaultColumn rightBorder alignLeft wrapWhitespace,
+ tenPercentColumn rightBorder alignCenter"
+ rowClasses="rowOdd,rowEven"
+ cellpadding="0" cellspacing="0" border="0">
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.spamReport.Reporter']}
+ </f:facet>
+
+ <h:outputLink value="#{wikiURLRenderer.renderUserProfileURL(report.reporter)}">
+ <h:outputText value="#{report.reporter.fullname}"/>
+ </h:outputLink>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.spamReport.Comment']}
+ </f:facet>
+
+ <s:div styleClass="commentText" rendered="#{report.comment.useWikiText and not empty report.comment.parent.areaNumber}">
+ <s:formattedText value="#{report.comment.content}"
+ linkStyleClass="regularLink"
+ brokenLinkStyleClass="brokenLink"
+ attachmentLinkStyleClass="regularLink"
+ thumbnailLinkStyleClass="regularLink"
+ enableMacroRendering="false"/>
+ </s:div>
+ <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name != report.comment.subject}" style="margin-top:15px;">
+ <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
+ </s:div>
+ <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name == report.comment.subject}">
+ <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
+ </s:div>
+
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.spamReport.Poster']}
+ </f:facet>
+
+ <h:outputLink value="#{wikiURLRenderer.renderUserProfileURL(report.comment.createdBy)}">
+ <h:outputText value="#{report.comment.createdBy}"/>
+ </h:outputLink>
+ </h:column>
+
+ </h:dataTable>
+ </div>
+
</div>
<div class="formControls wideLabels">
Modified: branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml 2010-07-26 09:39:06 UTC (rev 13508)
@@ -231,6 +231,27 @@
<ui:param name="titlePlural" value="#{messages['lacewiki.label.commentsDisplay.Comments']}"/>
<ui:define name="controls">
+ <s:fragment rendered="#{not commentHome.showForm and s:hasPermission('Comment', 'reportSpam', currentDocument)}">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.commentsDisplay.ReportCommentAsSpam']}"/>
+ <ui:param name="linkClass" value="buttonReport"/>
+ <ui:param name="jsFunctionName" value="reportCommentAsSpamId#{c.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToReport']
+ .concat(' ')
+ .concat(c.ownedByRegularUser ? c.createdBy.fullname : c.fromUserName)
+ .concat(' ')
+ .concat(messages['lacewiki.label.AsSpam'])
+ .concat('?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="commentDisplayForm, messageBoxContainer"
+ action="#{commentHome.reportAsSpam(c.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </s:fragment>
+
<h:panelGroup>
<s:fragment rendered="#{not commentHome.showForm and s:hasPermission('Comment', 'create', documentHome.instance)}">
Modified: branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css 2010-07-26 09:39:06 UTC (rev 13508)
@@ -448,6 +448,13 @@
font-size: 10px;
}
+.buttonReport {
+ background: #fff url(../img/btn.report.bg.gif) 0 0 repeat-x;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+ font-size: 10px;
+}
+
.buttonLabel{
color: #fff;
font-weight: bold;
Added: branches/community/Seam_2_2/examples/wiki/view/themes/default/img/btn.report.bg.gif
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_2/examples/wiki/view/themes/default/img/btn.report.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2010-07-26 09:39:06 UTC (rev 13508)
@@ -465,6 +465,12 @@
margin: 0 5px 0 5px;
}
+.buttonReport {
+ background: #fff url(../img/btn.report.bg.gif) 0 0 repeat-x;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.buttonLabel{
color: #fff;
font-weight: bold;
Added: branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/img/btn.report.bg.gif
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/img/btn.report.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2010-07-26 09:39:06 UTC (rev 13508)
@@ -555,6 +555,12 @@
margin: 0 5px 0 5px;
}
+.buttonReport {
+ background: #fff url(../img/btn.report.bg.gif) 0 0 repeat-x;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.buttonLabel{
color: #fff;
font-weight: bold;
Added: branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/img/btn.report.bg.gif
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/img/btn.report.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 5 months