You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(39) |
Dec
(10) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(19) |
Feb
(150) |
Mar
(10) |
Apr
|
May
(8) |
Jun
(11) |
Jul
(27) |
Aug
(52) |
Sep
(35) |
Oct
(30) |
Nov
(18) |
Dec
(4) |
2008 |
Jan
(76) |
Feb
(121) |
Mar
(39) |
Apr
(55) |
May
(18) |
Jun
(49) |
Jul
(32) |
Aug
(4) |
Sep
(10) |
Oct
|
Nov
(3) |
Dec
(33) |
2009 |
Jan
(19) |
Feb
(87) |
Mar
(69) |
Apr
(38) |
May
(47) |
Jun
(20) |
Jul
(5) |
Aug
(76) |
Sep
(145) |
Oct
(34) |
Nov
(8) |
Dec
(68) |
2010 |
Jan
(150) |
Feb
(379) |
Mar
(191) |
Apr
(100) |
May
(525) |
Jun
(269) |
Jul
(127) |
Aug
(190) |
Sep
(190) |
Oct
(29) |
Nov
(147) |
Dec
(83) |
2011 |
Jan
(188) |
Feb
(81) |
Mar
(43) |
Apr
(97) |
May
(63) |
Jun
(129) |
Jul
(17) |
Aug
(124) |
Sep
(6) |
Oct
(20) |
Nov
(67) |
Dec
(23) |
2012 |
Jan
(6) |
Feb
(14) |
Mar
(181) |
Apr
(64) |
May
(102) |
Jun
(47) |
Jul
(26) |
Aug
(3) |
Sep
(1) |
Oct
(14) |
Nov
(13) |
Dec
(23) |
2013 |
Jan
(4) |
Feb
(14) |
Mar
(18) |
Apr
(14) |
May
(27) |
Jun
(27) |
Jul
(5) |
Aug
(2) |
Sep
(74) |
Oct
(79) |
Nov
(21) |
Dec
(97) |
2014 |
Jan
(6) |
Feb
(3) |
Mar
(8) |
Apr
|
May
(5) |
Jun
|
Jul
(9) |
Aug
(6) |
Sep
(3) |
Oct
(10) |
Nov
(6) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
(25) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fg...@us...> - 2007-09-20 10:16:18
|
Revision: 445 http://openutils.svn.sourceforge.net/openutils/?rev=445&view=rev Author: fgiust Date: 2007-09-20 03:16:22 -0700 (Thu, 20 Sep 2007) Log Message: ----------- update slf4j dependencies Modified Paths: -------------- trunk/openutils-bshd5/pom.xml trunk/openutils-deployment/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-09-20 10:16:01 UTC (rev 444) +++ trunk/openutils-bshd5/pom.xml 2007-09-20 10:16:22 UTC (rev 445) @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -15,24 +16,59 @@ </properties> <dependencies> <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> + <!-- replaces commons-logging --> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-hibernate3</artifactId> <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.1.ga</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.7.0</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>commons-lang</groupId> @@ -40,11 +76,6 @@ <version>2.3</version> </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> Modified: trunk/openutils-deployment/pom.xml =================================================================== --- trunk/openutils-deployment/pom.xml 2007-09-20 10:16:01 UTC (rev 444) +++ trunk/openutils-deployment/pom.xml 2007-09-20 10:16:22 UTC (rev 445) @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -26,13 +27,9 @@ <optional>true</optional> <exclusions> <exclusion> - <groupId>logkit</groupId> - <artifactId>logkit</artifactId> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> </exclusion> - <exclusion> - <groupId>avalon-framework</groupId> - <artifactId>avalon-framework</artifactId> - </exclusion> </exclusions> </dependency> <dependency> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-20 10:16:02
|
Revision: 444 http://openutils.svn.sourceforge.net/openutils/?rev=444&view=rev Author: fgiust Date: 2007-09-20 03:16:01 -0700 (Thu, 20 Sep 2007) Log Message: ----------- update slf4j dependencies Modified Paths: -------------- trunk/openutils-testing-testng/pom.xml Modified: trunk/openutils-testing-testng/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2007-09-20 10:10:04 UTC (rev 443) +++ trunk/openutils-testing-testng/pom.xml 2007-09-20 10:16:01 UTC (rev 444) @@ -18,29 +18,47 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> + <version>1.4.1</version> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.13</version> - <scope>test</scope> + <!-- replaces commons-logging --> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-hibernate3</artifactId> <version>${spring.version}</version> <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>commons-lang</groupId> @@ -52,6 +70,12 @@ <artifactId>dbunit</artifactId> <version>2.2</version> <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.testng</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-20 10:10:04
|
Revision: 443 http://openutils.svn.sourceforge.net/openutils/?rev=443&view=rev Author: fgiust Date: 2007-09-20 03:10:04 -0700 (Thu, 20 Sep 2007) Log Message: ----------- you can now setup a custom documentReaderClass for spring initialization (needed for mule 2.0) Modified Paths: -------------- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java =================================================================== --- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2007-09-20 08:55:37 UTC (rev 442) +++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2007-09-20 10:10:04 UTC (rev 443) @@ -17,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.testng.annotations.BeforeClass; @@ -35,7 +36,7 @@ /** * Default Spring context initilization file used for tests. */ - private static final String DEFAULT_TEST_CONTEXT_FILE = "/spring-tests.xml"; + public static final String DEFAULT_TEST_CONTEXT_FILE = "/spring-tests.xml"; /** * Spring application context. @@ -58,10 +59,30 @@ if (ctx == null) { // load Spring's BeanFactory - String[] paths = {DEFAULT_TEST_CONTEXT_FILE}; - ctx = new ClassPathXmlApplicationContext(paths); + String[] paths = {DEFAULT_TEST_CONTEXT_FILE }; + ctx = new ClassPathXmlApplicationContext(paths) + { + + /** + * {@inheritDoc} + */ + @Override + protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) + { + initAppContextBeanDefinitionReader(beanDefinitionReader); + } + }; } + } + /** + * You can override this method if you need to pass a custom documentReaderClass to the spring bean definition + * reader. + * @param beanDefinitionReader XmlBeanDefinitionReader instance + */ + protected void initAppContextBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) + { + // you can subclass this method if needed } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mup...@us...> - 2007-09-20 08:55:33
|
Revision: 442 http://openutils.svn.sourceforge.net/openutils/?rev=442&view=rev Author: muppet68 Date: 2007-09-20 01:55:37 -0700 (Thu, 20 Sep 2007) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-bshd5/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-09-20 08:55:32 UTC (rev 441) +++ trunk/openutils-bshd5/pom.xml 2007-09-20 08:55:37 UTC (rev 442) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-bshd5</artifactId> <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>1.0.8</version> + <version>1.0.9-SNAPSHOT</version> <description>openutils base Spring-Hibernate DAO for java 5.0</description> <properties> <spring.version>2.0.6</spring.version> @@ -51,10 +51,4 @@ <optional>true</optional> </dependency> </dependencies> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.8</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.8</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-1.0.8</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mup...@us...> - 2007-09-20 08:55:30
|
Revision: 441 http://openutils.svn.sourceforge.net/openutils/?rev=441&view=rev Author: muppet68 Date: 2007-09-20 01:55:32 -0700 (Thu, 20 Sep 2007) Log Message: ----------- [maven-release-plugin] copy for tag openutils-bshd5-1.0.8 Added Paths: ----------- tags/openutils-bshd5-1.0.8/ tags/openutils-bshd5-1.0.8/pom.xml Removed Paths: ------------- tags/openutils-bshd5-1.0.8/pom.xml Copied: tags/openutils-bshd5-1.0.8 (from rev 439, trunk/openutils-bshd5) Deleted: tags/openutils-bshd5-1.0.8/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-09-20 07:42:19 UTC (rev 439) +++ tags/openutils-bshd5-1.0.8/pom.xml 2007-09-20 08:55:32 UTC (rev 441) @@ -1,54 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>3</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-bshd5</artifactId> - <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>1.0.8-SNAPSHOT</version> - <description>openutils base Spring-Hibernate DAO for java 5.0</description> - <properties> - <spring.version>2.0.6</spring.version> - </properties> - <dependencies> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-hibernate3</artifactId> - <version>${spring.version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-aop</artifactId> - <version>${spring.version}</version> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate</artifactId> - <version>3.2.1.ga</version> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - <version>1.7.0</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <optional>true</optional> - </dependency> - </dependencies> -</project> \ No newline at end of file Copied: tags/openutils-bshd5-1.0.8/pom.xml (from rev 440, trunk/openutils-bshd5/pom.xml) =================================================================== --- tags/openutils-bshd5-1.0.8/pom.xml (rev 0) +++ tags/openutils-bshd5-1.0.8/pom.xml 2007-09-20 08:55:32 UTC (rev 441) @@ -0,0 +1,60 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>3</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-bshd5</artifactId> + <name>openutils base Spring-Hibernate DAO for java 5.0</name> + <version>1.0.8</version> + <description>openutils base Spring-Hibernate DAO for java 5.0</description> + <properties> + <spring.version>2.0.6</spring.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-hibernate3</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.1.ga</version> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.7.0</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <optional>true</optional> + </dependency> + </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.8</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.8</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-1.0.8</url> + </scm> +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mup...@us...> - 2007-09-20 08:55:17
|
Revision: 440 http://openutils.svn.sourceforge.net/openutils/?rev=440&view=rev Author: muppet68 Date: 2007-09-20 01:55:20 -0700 (Thu, 20 Sep 2007) Log Message: ----------- [maven-release-plugin] prepare release openutils-bshd5-1.0.8 Modified Paths: -------------- trunk/openutils-bshd5/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-09-20 07:42:19 UTC (rev 439) +++ trunk/openutils-bshd5/pom.xml 2007-09-20 08:55:20 UTC (rev 440) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-bshd5</artifactId> <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>1.0.8-SNAPSHOT</version> + <version>1.0.8</version> <description>openutils base Spring-Hibernate DAO for java 5.0</description> <properties> <spring.version>2.0.6</spring.version> @@ -51,4 +51,10 @@ <optional>true</optional> </dependency> </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.8</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.8</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-1.0.8</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mup...@us...> - 2007-09-20 07:42:19
|
Revision: 439 http://openutils.svn.sourceforge.net/openutils/?rev=439&view=rev Author: muppet68 Date: 2007-09-20 00:42:19 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Added evict method to remove object from hibernate session Modified Paths: -------------- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java Modified: trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java 2007-09-19 09:51:54 UTC (rev 438) +++ trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java 2007-09-20 07:42:19 UTC (rev 439) @@ -80,6 +80,12 @@ void refresh(T obj); /** + * Remove the given object from the Session cache. + * @param obj Object + */ + void evict(T obj); + + /** * Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent * instance currently associated with the session, it will be loaded. Return the persistent instance. If the given * instance is unsaved, save a copy of and return it as a newly persistent instance. The given instance does not Modified: trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-09-19 09:51:54 UTC (rev 438) +++ trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-09-20 07:42:19 UTC (rev 439) @@ -26,528 +26,521 @@ import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - /** * Base Hibernate DAO. + * * @author Fabrizio Giustina * @version $Id$ - * @param <T> Persistence class - * @param <K> Object Key + * @param <T> + * Persistence class + * @param <K> + * Object Key */ -public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport - implements - HibernateDAO<T, K> -{ +public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> + extends HibernateDaoSupport implements HibernateDAO<T, K> { - /** - * @author carone - * @version $Id$ - */ - private final class HibernateCallbackForExecution implements HibernateCallback - { + /** + * @author carone + * @version $Id$ + */ + private final class HibernateCallbackForExecution implements + HibernateCallback { - /** - * - */ - private final T filter; + /** + * + */ + private final T filter; - /** - * - */ - private final int page; + /** + * + */ + private final int page; - /** - * - */ - private final int maxResults; + /** + * + */ + private final int maxResults; - /** - * - */ - private final Map<String, FilterMetadata> metadata; + /** + * + */ + private final Map<String, FilterMetadata> metadata; - /** - * - */ - private final Order[] orderProperties; + /** + * + */ + private final Order[] orderProperties; - private List<Criterion> additionalCriteria; + private List<Criterion> additionalCriteria; - /** - * @param filter - * @param page - * @param maxResults - * @param metadata - * @param orderProperties - */ - private HibernateCallbackForExecution( - T filter, - int page, - int maxResults, - Map<String, FilterMetadata> metadata, - Order[] orderProperties, - List<Criterion> additionalCriteria) - { - this.filter = filter; - this.page = page; - this.maxResults = maxResults; - this.metadata = metadata; - this.orderProperties = orderProperties; - this.additionalCriteria = additionalCriteria; - } + /** + * @param filter + * @param page + * @param maxResults + * @param metadata + * @param orderProperties + */ + private HibernateCallbackForExecution(T filter, int page, + int maxResults, Map<String, FilterMetadata> metadata, + Order[] orderProperties, List<Criterion> additionalCriteria) { + this.filter = filter; + this.page = page; + this.maxResults = maxResults; + this.metadata = metadata; + this.orderProperties = orderProperties; + this.additionalCriteria = additionalCriteria; + } - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(filter.getClass()); - crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); - crit.setMaxResults(maxResults); - crit.setFirstResult(maxResults * page); + public Object doInHibernate(Session ses) throws HibernateException { + Criteria crit = ses.createCriteria(filter.getClass()); + crit + .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); + crit.setMaxResults(maxResults); + crit.setFirstResult(maxResults * page); - if (orderProperties != null && orderProperties.length > 0) - { - for (Order order : orderProperties) - { - if (order != null) - { - crit.addOrder(order); - } - } - } - EnhancedExample.create(crit, filter, metadata); - if (additionalCriteria != null && !additionalCriteria.isEmpty()) - { - for (Criterion criterion : additionalCriteria) - { - crit.add(criterion); - } - } - return crit.list(); - } - } + if (orderProperties != null && orderProperties.length > 0) { + for (Order order : orderProperties) { + if (order != null) { + crit.addOrder(order); + } + } + } + EnhancedExample.create(crit, filter, metadata); + if (additionalCriteria != null && !additionalCriteria.isEmpty()) { + for (Criterion criterion : additionalCriteria) { + crit.add(criterion); + } + } + return crit.list(); + } + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> find(String query) - { - return getHibernateTemplate().find(query); - } + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> find(String query) { + return getHibernateTemplate().find(query); + } - /** - * {@inheritDoc} - */ - public List<T> findAll() - { - return findAll(getDefaultOrder()); - } + /** + * {@inheritDoc} + */ + public List<T> findAll() { + return findAll(getDefaultOrder()); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findAll(final Order[] orderProperties) - { - return getThis().findAll(orderProperties, new ArrayList<Criterion>()); - } + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findAll(final Order[] orderProperties) { + return getThis().findAll(orderProperties, new ArrayList<Criterion>()); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findAll(final Order[] orderProperties, final List<Criterion> criteria) - { - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findAll(final Order[] orderProperties, + final List<Criterion> criteria) { + return (List<T>) getHibernateTemplate().execute( + new HibernateCallback() { - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(getReferenceClass()); - if (null != orderProperties) - { - for (int j = 0; j < orderProperties.length; j++) - { - crit.addOrder(orderProperties[j]); - } + public Object doInHibernate(Session ses) + throws HibernateException { + Criteria crit = ses.createCriteria(getReferenceClass()); + if (null != orderProperties) { + for (int j = 0; j < orderProperties.length; j++) { + crit.addOrder(orderProperties[j]); + } - } - if (criteria != null) - { - for (Criterion criterion : criteria) - { - crit.add(criterion); - } - } - return crit.list(); - } - }); - } + } + if (criteria != null) { + for (Criterion criterion : criteria) { + crit.add(criterion); + } + } + return crit.list(); + } + }); + } - /** - * {@inheritDoc} - */ - public List<T> find(String query, Object obj, Type type) - { - return find(query, new Object[]{obj }, new Type[]{type }); - } + /** + * {@inheritDoc} + */ + public List<T> find(String query, Object obj, Type type) { + return find(query, new Object[] { obj }, new Type[] { type }); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> find(final String query, final Object[] obj, final Type[] type) - { - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> find(final String query, final Object[] obj, + final Type[] type) { + return (List<T>) getHibernateTemplate().execute( + new HibernateCallback() { - public Object doInHibernate(Session ses) throws HibernateException - { - // hibernate 3 - return ses.createQuery(query).setParameters(obj, type).list(); - } - }); - } + public Object doInHibernate(Session ses) + throws HibernateException { + // hibernate 3 + return ses.createQuery(query).setParameters(obj, type) + .list(); + } + }); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T load(K key) - { - T result = (T) getHibernateTemplate().load(getReferenceClass(), key); - Hibernate.initialize(result); - return result; - } + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T load(K key) { + T result = (T) getHibernateTemplate().load(getReferenceClass(), key); + Hibernate.initialize(result); + return result; + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T loadIfAvailable(K key) - { - T result; - try - { - result = (T) getHibernateTemplate().load(getReferenceClass(), key); - Hibernate.initialize(result); - } - catch (ObjectNotFoundException e) - { - // during lazy initialization - return null; - } - catch (HibernateObjectRetrievalFailureException e) - { - // during load - if (e.getCause() instanceof ObjectNotFoundException) - { - return null; - } - throw e; - } - return result; - } + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T loadIfAvailable(K key) { + T result; + try { + result = (T) getHibernateTemplate().load(getReferenceClass(), key); + Hibernate.initialize(result); + } catch (ObjectNotFoundException e) { + // during lazy initialization + return null; + } catch (HibernateObjectRetrievalFailureException e) { + // during load + if (e.getCause() instanceof ObjectNotFoundException) { + return null; + } + throw e; + } + return result; + } - /** - * {@inheritDoc} - */ - public void saveOrUpdate(final T obj) - { - getHibernateTemplate().saveOrUpdate(obj); - } + /** + * {@inheritDoc} + */ + public void saveOrUpdate(final T obj) { + getHibernateTemplate().saveOrUpdate(obj); + } - /** - * {@inheritDoc} - */ - public void update(T obj) - { - getHibernateTemplate().update(obj); - } + /** + * {@inheritDoc} + */ + public void update(T obj) { + getHibernateTemplate().update(obj); + } - /** - * {@inheritDoc} - */ - public boolean delete(final K key) - { + /** + * {@inheritDoc} + */ + public boolean delete(final K key) { - return (Boolean) getHibernateTemplate().execute(new HibernateCallback() - { + return (Boolean) getHibernateTemplate().execute( + new HibernateCallback() { - public Object doInHibernate(Session ses) throws HibernateException - { - ses.delete(ses.load(getReferenceClass(), key)); - return true; - } - }); + public Object doInHibernate(Session ses) + throws HibernateException { + ses.delete(ses.load(getReferenceClass(), key)); + return true; + } + }); - } + } - /** - * {@inheritDoc} - */ - public void refresh(T obj) - { - getHibernateTemplate().refresh(obj); - } + /** + * {@inheritDoc} + */ + public void refresh(T obj) { + getHibernateTemplate().refresh(obj); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T merge(final T obj) - { - return (T) getHibernateTemplate().execute(new HibernateCallback() - { + /** + * {@inheritDoc} + */ + public void evict(T obj) { + getHibernateTemplate().evict(obj); + } - public Object doInHibernate(Session ses) throws HibernateException - { - return ses.merge(obj); - } - }); + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T merge(final T obj) { + return (T) getHibernateTemplate().execute(new HibernateCallback() { - } + public Object doInHibernate(Session ses) throws HibernateException { + return ses.merge(obj); + } + }); - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public K save(T obj) - { - return (K) getHibernateTemplate().save(obj); - } + } - /** - * {@inheritDoc} - */ - public T findFilteredFirst(final T filter) - { - return getFirstInCollection(findFiltered(filter, 1, 0)); - } + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public K save(T obj) { + return (K) getHibernateTemplate().save(obj); + } - /** - * {@inheritDoc} - */ - public T findFilteredFirst(final T filter, List<Criterion> criteria) - { - return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria)); - } + /** + * {@inheritDoc} + */ + public T findFilteredFirst(final T filter) { + return getFirstInCollection(findFiltered(filter, 1, 0)); + } - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter) - { - return findFiltered(filter, getDefaultFilterMetadata()); - } + /** + * {@inheritDoc} + */ + public T findFilteredFirst(final T filter, List<Criterion> criteria) { + return getFirstInCollection(findFiltered(filter, null, + getDefaultFilterMetadata(), 1, 0, criteria)); + } - /** - * @return - * This is needed as for http://opensource.atlassian.com/projects/spring/browse/SPR-2226 - */ - @SuppressWarnings("unchecked") - private HibernateDAO<T, K> getThis() - { - try - { - return (HibernateDAO<T, K>) AopContext.currentProxy(); - } - catch (AspectException exc) - { - logger.debug("Not running inside an AOP proxy, so no proxy can be returned: " + exc.getMessage()); - return this; - } - } + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter) { + return findFiltered(filter, getDefaultFilterMetadata()); + } - /** - * {@inheritDoc} - */ - public List<T> findFiltered(T filter, Order[] orderProperties) - { - return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0); - } + /** + * @return This is needed as for + * http://opensource.atlassian.com/projects/spring/browse/SPR-2226 + */ + @SuppressWarnings("unchecked") + private HibernateDAO<T, K> getThis() { + try { + return (HibernateDAO<T, K>) AopContext.currentProxy(); + } catch (AspectException exc) { + logger + .debug("Not running inside an AOP proxy, so no proxy can be returned: " + + exc.getMessage()); + return this; + } + } - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata) - { - return findFiltered(filter, metadata, Integer.MAX_VALUE, 0); - } + /** + * {@inheritDoc} + */ + public List<T> findFiltered(T filter, Order[] orderProperties) { + return findFiltered(filter, orderProperties, + getDefaultFilterMetadata(), Integer.MAX_VALUE, 0); + } - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final int maxResults, final int page) - { - return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page); - } + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, + final Map<String, FilterMetadata> metadata) { + return findFiltered(filter, metadata, Integer.MAX_VALUE, 0); + } - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults, - final int page) - { - return findFiltered(filter, null, metadata, maxResults, page); - } + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final int maxResults, + final int page) { + return findFiltered(filter, getDefaultFilterMetadata(), maxResults, + page); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, - final int maxResults, final int page) - { - return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, new ArrayList<Criterion>()); - } + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, + final Map<String, FilterMetadata> metadata, final int maxResults, + final int page) { + return findFiltered(filter, null, metadata, maxResults, page); + } - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findFiltered(T filter, Order[] customOrder, Map<String, FilterMetadata> metadata, int maxResults, - int page, List<Criterion> additionalCriteria) - { - final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this - .getDefaultOrder(); + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findFiltered(final T filter, final Order[] customOrder, + final Map<String, FilterMetadata> metadata, final int maxResults, + final int page) { + return getThis().findFiltered(filter, customOrder, metadata, + maxResults, page, new ArrayList<Criterion>()); + } - return (List<T>) getHibernateTemplate().execute( - new HibernateCallbackForExecution(filter, page, maxResults, metadata, orderProperties, additionalCriteria)); - } + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findFiltered(T filter, Order[] customOrder, + Map<String, FilterMetadata> metadata, int maxResults, int page, + List<Criterion> additionalCriteria) { + final Order[] orderProperties = customOrder != null + && customOrder.length > 0 ? customOrder : this + .getDefaultOrder(); - /** - * Return the specific Object class that will be used for class-specific implementation of this DAO. - * @return the reference Class - */ - protected abstract Class<T> getReferenceClass(); + return (List<T>) getHibernateTemplate().execute( + new HibernateCallbackForExecution(filter, page, maxResults, + metadata, orderProperties, additionalCriteria)); + } - /** - * Return a list of <code>Order</code> object to be used for the default ordering of the collection. - * @return the property name - */ - protected Order[] getDefaultOrder() - { - return new Order[0]; - } + /** + * Return the specific Object class that will be used for class-specific + * implementation of this DAO. + * + * @return the reference Class + */ + protected abstract Class<T> getReferenceClass(); - /** - * Obtain an instance of Query for a named query string defined in the mapping file. - * @param name the name of a query defined externally - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final int maxResults) - { - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { + /** + * Return a list of <code>Order</code> object to be used for the default + * ordering of the collection. + * + * @return the property name + */ + protected Order[] getDefaultOrder() { + return new Order[0]; + } - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - return q.list(); - } - }); - } + /** + * Obtain an instance of Query for a named query string defined in the + * mapping file. + * + * @param name + * the name of a query defined externally + * @param maxResults + * max number of results + * @return Query + */ + protected List<?> getNamedQuery(final String name, final int maxResults) { + return (List<?>) getHibernateTemplate().execute( + new HibernateCallback() { - /** - * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. - * @param name the name of a query defined externally - * @param params the parameter array - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final Serializable[] params, final int maxResults) - { + public Object doInHibernate(Session ses) + throws HibernateException { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + return q.list(); + } + }); + } - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { + /** + * Obtain an instance of Query for a named query string defined in the + * mapping file. Use the parameters given. + * + * @param name + * the name of a query defined externally + * @param params + * the parameter array + * @param maxResults + * max number of results + * @return Query + */ + protected List<?> getNamedQuery(final String name, + final Serializable[] params, final int maxResults) { - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - if (null != params) - { - for (int i = 0; i < params.length; i++) - { - q.setParameter(i, params[i]); - } - } - return q.list(); - } - }); - } + return (List<?>) getHibernateTemplate().execute( + new HibernateCallback() { - /** - * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. - * @param name the name of a query defined externally - * @param params the parameter Map - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final Map<String, Object> params, final int maxResults) - { - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { + public Object doInHibernate(Session ses) + throws HibernateException { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + if (null != params) { + for (int i = 0; i < params.length; i++) { + q.setParameter(i, params[i]); + } + } + return q.list(); + } + }); + } - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - if (params != null) - { - for (Map.Entry<String, Object> entry : params.entrySet()) - { - setParameterValue(q, entry.getKey(), entry.getValue()); - } - } - return q.list(); - } - }); - } + /** + * Obtain an instance of Query for a named query string defined in the + * mapping file. Use the parameters given. + * + * @param name + * the name of a query defined externally + * @param params + * the parameter Map + * @param maxResults + * max number of results + * @return Query + */ + protected List<?> getNamedQuery(final String name, + final Map<String, Object> params, final int maxResults) { + return (List<?>) getHibernateTemplate().execute( + new HibernateCallback() { - /** - * Convenience method to set paramers in the query given based on the actual object type in passed in as the value. - * You may need to add more functionaly to this as desired (or not use this at all). - * @param query the Query to set - * @param key the key name - * @param value the object to set as the parameter - */ - protected void setParameterValue(Query query, String key, Object value) - { - if (null == key || null == value) - { - return; - } - query.setParameter(key, value); - } + public Object doInHibernate(Session ses) + throws HibernateException { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + if (params != null) { + for (Map.Entry<String, Object> entry : params + .entrySet()) { + setParameterValue(q, entry.getKey(), entry + .getValue()); + } + } + return q.list(); + } + }); + } - /** - * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't - * set any default filter, subclasses may override this. - * @return map of property name - filter metadata - */ - protected Map<String, FilterMetadata> getDefaultFilterMetadata() - { - return new HashMap<String, FilterMetadata>(0); - } + /** + * Convenience method to set paramers in the query given based on the actual + * object type in passed in as the value. You may need to add more + * functionaly to this as desired (or not use this at all). + * + * @param query + * the Query to set + * @param key + * the key name + * @param value + * the object to set as the parameter + */ + protected void setParameterValue(Query query, String key, Object value) { + if (null == key || null == value) { + return; + } + query.setParameter(key, value); + } - /** - * Returns the first object in the collection or null if the collection is null or empty. - * @param list collection - * @return first element in the list - */ - @SuppressWarnings("unchecked") - private T getFirstInCollection(Collection<T> list) - { - if (list != null && !list.isEmpty()) - { - Object result = list.iterator().next(); - Hibernate.initialize(result); - return (T) result; - } - return null; - } + /** + * Returns the default set of FilterMetadata that will be applied to any + * query. The default implementation doesn't set any default filter, + * subclasses may override this. + * + * @return map of property name - filter metadata + */ + protected Map<String, FilterMetadata> getDefaultFilterMetadata() { + return new HashMap<String, FilterMetadata>(0); + } + /** + * Returns the first object in the collection or null if the collection is + * null or empty. + * + * @param list + * collection + * @return first element in the list + */ + @SuppressWarnings("unchecked") + private T getFirstInCollection(Collection<T> list) { + if (list != null && !list.isEmpty()) { + Object result = list.iterator().next(); + Hibernate.initialize(result); + return (T) result; + } + return null; + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-19 09:51:51
|
Revision: 438 http://openutils.svn.sourceforge.net/openutils/?rev=438&view=rev Author: fgiust Date: 2007-09-19 02:51:54 -0700 (Wed, 19 Sep 2007) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-deployment/pom.xml Modified: trunk/openutils-deployment/pom.xml =================================================================== --- trunk/openutils-deployment/pom.xml 2007-09-19 09:51:36 UTC (rev 437) +++ trunk/openutils-deployment/pom.xml 2007-09-19 09:51:54 UTC (rev 438) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-deployment</artifactId> <name>openutils deployment tools</name> - <version>1.0.9</version> + <version>1.0.10-SNAPSHOT</version> <description /> <properties> <spring.version>2.0.6</spring.version> @@ -72,10 +72,4 @@ <scope>test</scope> </dependency> </dependencies> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-deployment-1.0.9</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-deployment-1.0.9</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-deployment-1.0.9</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-19 09:51:32
|
Revision: 437 http://openutils.svn.sourceforge.net/openutils/?rev=437&view=rev Author: fgiust Date: 2007-09-19 02:51:36 -0700 (Wed, 19 Sep 2007) Log Message: ----------- [maven-release-plugin] copy for tag openutils-deployment-1.0.9 Added Paths: ----------- tags/openutils-deployment-1.0.9/ tags/openutils-deployment-1.0.9/pom.xml Removed Paths: ------------- tags/openutils-deployment-1.0.9/pom.xml Copied: tags/openutils-deployment-1.0.9 (from rev 435, trunk/openutils-deployment) Deleted: tags/openutils-deployment-1.0.9/pom.xml =================================================================== --- trunk/openutils-deployment/pom.xml 2007-09-19 09:50:22 UTC (rev 435) +++ tags/openutils-deployment-1.0.9/pom.xml 2007-09-19 09:51:36 UTC (rev 437) @@ -1,76 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>3</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-deployment</artifactId> - <name>openutils deployment tools</name> - <version>1.0.9-SNAPSHOT</version> - <description /> - <properties> - <spring.version>2.0.6</spring.version> - </properties> - <dependencies> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - <version>${spring.version}</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>logkit</groupId> - <artifactId>logkit</artifactId> - </exclusion> - <exclusion> - <groupId>avalon-framework</groupId> - <artifactId>avalon-framework</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-jdbc</artifactId> - <version>${spring.version}</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.4.1</version> - </dependency> - <dependency> - <!-- replaces commons-logging --> - <groupId>org.slf4j</groupId> - <artifactId>jcl104-over-slf4j</artifactId> - <version>1.4.1</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.4</version> - <scope>provided</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.0</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> \ No newline at end of file Copied: tags/openutils-deployment-1.0.9/pom.xml (from rev 436, trunk/openutils-deployment/pom.xml) =================================================================== --- tags/openutils-deployment-1.0.9/pom.xml (rev 0) +++ tags/openutils-deployment-1.0.9/pom.xml 2007-09-19 09:51:36 UTC (rev 437) @@ -0,0 +1,81 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>3</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-deployment</artifactId> + <name>openutils deployment tools</name> + <version>1.0.9</version> + <description /> + <properties> + <spring.version>2.0.6</spring.version> + </properties> + <dependencies> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.version}</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>logkit</groupId> + <artifactId>logkit</artifactId> + </exclusion> + <exclusion> + <groupId>avalon-framework</groupId> + <artifactId>avalon-framework</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-jdbc</artifactId> + <version>${spring.version}</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> + <!-- replaces commons-logging --> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> + <scope>provided</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.0</version> + <scope>test</scope> + </dependency> + </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-deployment-1.0.9</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-deployment-1.0.9</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-deployment-1.0.9</url> + </scm> +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-19 09:51:10
|
Revision: 436 http://openutils.svn.sourceforge.net/openutils/?rev=436&view=rev Author: fgiust Date: 2007-09-19 02:51:10 -0700 (Wed, 19 Sep 2007) Log Message: ----------- [maven-release-plugin] prepare release openutils-deployment-1.0.9 Modified Paths: -------------- trunk/openutils-deployment/pom.xml Modified: trunk/openutils-deployment/pom.xml =================================================================== --- trunk/openutils-deployment/pom.xml 2007-09-19 09:50:22 UTC (rev 435) +++ trunk/openutils-deployment/pom.xml 2007-09-19 09:51:10 UTC (rev 436) @@ -1,5 +1,4 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -9,7 +8,7 @@ </parent> <artifactId>openutils-deployment</artifactId> <name>openutils deployment tools</name> - <version>1.0.9-SNAPSHOT</version> + <version>1.0.9</version> <description /> <properties> <spring.version>2.0.6</spring.version> @@ -73,4 +72,10 @@ <scope>test</scope> </dependency> </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-deployment-1.0.9</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-deployment-1.0.9</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-deployment-1.0.9</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-19 09:50:22
|
Revision: 435 http://openutils.svn.sourceforge.net/openutils/?rev=435&view=rev Author: fgiust Date: 2007-09-19 02:50:22 -0700 (Wed, 19 Sep 2007) Log Message: ----------- replaces commons-logging with jcl104-over-slf4j Modified Paths: -------------- trunk/openutils-deployment/pom.xml Modified: trunk/openutils-deployment/pom.xml =================================================================== --- trunk/openutils-deployment/pom.xml 2007-09-19 09:47:56 UTC (rev 434) +++ trunk/openutils-deployment/pom.xml 2007-09-19 09:50:22 UTC (rev 435) @@ -43,21 +43,23 @@ <optional>true</optional> <exclusions> <exclusion> - <groupId>logkit</groupId> - <artifactId>logkit</artifactId> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> </exclusion> - <exclusion> - <groupId>avalon-framework</groupId> - <artifactId>avalon-framework</artifactId> - </exclusion> </exclusions> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> + <version>1.4.1</version> </dependency> <dependency> + <!-- replaces commons-logging --> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-09-19 09:47:57
|
Revision: 434 http://openutils.svn.sourceforge.net/openutils/?rev=434&view=rev Author: fgiust Date: 2007-09-19 02:47:56 -0700 (Wed, 19 Sep 2007) Log Message: ----------- also expose ${server.name} to allow usage in log4j config files Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java 2007-09-13 13:53:59 UTC (rev 433) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java 2007-09-19 09:47:56 UTC (rev 434) @@ -24,17 +24,8 @@ { String[] propertiesLocation = StringUtils.split(commaSeparatedListOfPaths, ','); - String servername = null; + String servername = resolveServerName(); - try - { - servername = StringUtils.lowerCase(InetAddress.getLocalHost().getHostName()); - } - catch (UnknownHostException e) - { - System.err.println(e.getMessage()); - } - String rootPath = StringUtils.replace(context.getRealPath("/"), "\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ String webapp = StringUtils.substringAfterLast(rootPath, "/"); //$NON-NLS-1$ @@ -59,7 +50,31 @@ MessageFormat .format( "No configuration found using location list {0}. [servername] is [{1}], [webapp] is [{2}] and base path is [{3}]", //$NON-NLS-1$ - new Object[]{ArrayUtils.toString(propertiesLocation), servername, webapp, rootPath})); + new Object[]{ArrayUtils.toString(propertiesLocation), servername, webapp, rootPath })); } + + /** + * Resolve the current server name. + * @return server name, all lowercase, without domain + */ + public static String resolveServerName() + { + String servername = null; + + try + { + servername = StringUtils.lowerCase(InetAddress.getLocalHost().getHostName()); + if (StringUtils.contains(servername, ".")) + { + servername = StringUtils.substringBefore(servername, "."); + } + + } + catch (UnknownHostException e) + { + System.err.println(e.getMessage()); + } + return servername; + } } Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java 2007-09-13 13:53:59 UTC (rev 433) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java 2007-09-19 09:47:56 UTC (rev 434) @@ -41,6 +41,12 @@ if (exposeWebAppRoot(servletContext)) { WebUtils.setWebAppRootSystemProperty(servletContext); + + String servername = DeploymentResolver.resolveServerName(); + if (servername != null) + { + System.setProperty("server.name", servername); + } } String locationList = servletContext.getInitParameter("log4jConfigLocation"); @@ -65,12 +71,10 @@ servletContext.log("Initializing Log4J from [" + location + "]"); try { - // if (!ResourceUtils.isUrl(location)) - // { - // location = WebUtils.getRealPath(servletContext, location); - // } + String intervalString = servletContext.getInitParameter("log4jRefreshInterval"); if (intervalString != null) + { try { long refreshInterval = Long.parseLong(intervalString); @@ -81,6 +85,7 @@ throw new IllegalArgumentException("Invalid 'log4jRefreshInterval' parameter: " + ex.getMessage()); } + } else { Log4jConfigurer.initLogging(location); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mol...@us...> - 2007-09-13 13:53:55
|
Revision: 433 http://openutils.svn.sourceforge.net/openutils/?rev=433&view=rev Author: molaschi Date: 2007-09-13 06:53:59 -0700 (Thu, 13 Sep 2007) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-testing-junit-dwr/pom.xml Modified: trunk/openutils-testing-junit-dwr/pom.xml =================================================================== --- trunk/openutils-testing-junit-dwr/pom.xml 2007-09-13 13:53:54 UTC (rev 432) +++ trunk/openutils-testing-junit-dwr/pom.xml 2007-09-13 13:53:59 UTC (rev 433) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-testing-junit-dwr</artifactId> <name>openutils test utils (junit) for dwr</name> - <version>1.1</version> + <version>1.2-SNAPSHOT</version> <description>openutils test utils for dwr</description> <dependencies> <dependency> @@ -104,10 +104,4 @@ <version>1.6R6-candidate2</version> </dependency> </dependencies> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/1.1</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/1.1</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/1.1</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mol...@us...> - 2007-09-13 13:53:50
|
Revision: 432 http://openutils.svn.sourceforge.net/openutils/?rev=432&view=rev Author: molaschi Date: 2007-09-13 06:53:54 -0700 (Thu, 13 Sep 2007) Log Message: ----------- [maven-scm] copy for tag 1.1 Added Paths: ----------- tags/1.1/ tags/1.1/pom.xml Removed Paths: ------------- tags/1.1/pom.xml Copied: tags/1.1 (from rev 430, trunk/openutils-testing-junit-dwr) Deleted: tags/1.1/pom.xml =================================================================== --- trunk/openutils-testing-junit-dwr/pom.xml 2007-09-10 09:37:30 UTC (rev 430) +++ tags/1.1/pom.xml 2007-09-13 13:53:54 UTC (rev 432) @@ -1,107 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>3</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-testing-junit-dwr</artifactId> - <name>openutils test utils (junit) for dwr</name> - <version>1.1-SNAPSHOT</version> - <description>openutils test utils for dwr</description> - <dependencies> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.13</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - </dependency> - <dependency> - <groupId>httpunit</groupId> - <artifactId>httpunit</artifactId> - <version>1.6.2</version> - <exclusions> - <exclusion> - <groupId>xerces</groupId> - <artifactId>xmlParserAPIs</artifactId> - </exclusion> - <exclusion> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - </exclusion> - <exclusion> - <groupId>nekohtml</groupId> - <artifactId>nekohtml</artifactId> - </exclusion> - <exclusion> - <groupId>rhino</groupId> - <artifactId>js</artifactId> - </exclusion> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-compiler-jdt</artifactId> - <version>5.5.12</version> - </dependency> - <dependency> - <groupId>tomcat</groupId> - <artifactId>naming-resources</artifactId> - <version>5.5.15</version> - </dependency> - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-runtime</artifactId> - <version>5.5.12</version> - </dependency> - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-compiler</artifactId> - <version>5.5.12</version> - </dependency> - <dependency> - <groupId>tomcat</groupId> - <artifactId>naming-factory</artifactId> - <version>5.5.15</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>jstl</artifactId> - <version>1.1.2</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>jsp-api</artifactId> - <version>2.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>commons-el</groupId> - <artifactId>commons-el</artifactId> - <version>1.0</version> - </dependency> - <dependency> - <groupId>rhino</groupId> - <artifactId>js</artifactId> - <version>1.6R6-candidate2</version> - </dependency> - </dependencies> -</project> \ No newline at end of file Copied: tags/1.1/pom.xml (from rev 431, trunk/openutils-testing-junit-dwr/pom.xml) =================================================================== --- tags/1.1/pom.xml (rev 0) +++ tags/1.1/pom.xml 2007-09-13 13:53:54 UTC (rev 432) @@ -0,0 +1,113 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>3</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-testing-junit-dwr</artifactId> + <name>openutils test utils (junit) for dwr</name> + <version>1.1</version> + <description>openutils test utils for dwr</description> + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.13</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + </dependency> + <dependency> + <groupId>httpunit</groupId> + <artifactId>httpunit</artifactId> + <version>1.6.2</version> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xmlParserAPIs</artifactId> + </exclusion> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + <exclusion> + <groupId>nekohtml</groupId> + <artifactId>nekohtml</artifactId> + </exclusion> + <exclusion> + <groupId>rhino</groupId> + <artifactId>js</artifactId> + </exclusion> + <exclusion> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </exclusion> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>jasper-compiler-jdt</artifactId> + <version>5.5.12</version> + </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>naming-resources</artifactId> + <version>5.5.15</version> + </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>jasper-runtime</artifactId> + <version>5.5.12</version> + </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>jasper-compiler</artifactId> + <version>5.5.12</version> + </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>naming-factory</artifactId> + <version>5.5.15</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jstl</artifactId> + <version>1.1.2</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jsp-api</artifactId> + <version>2.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-el</groupId> + <artifactId>commons-el</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>rhino</groupId> + <artifactId>js</artifactId> + <version>1.6R6-candidate2</version> + </dependency> + </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/1.1</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/1.1</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/1.1</url> + </scm> +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mol...@us...> - 2007-09-13 13:53:42
|
Revision: 431 http://openutils.svn.sourceforge.net/openutils/?rev=431&view=rev Author: molaschi Date: 2007-09-13 06:53:45 -0700 (Thu, 13 Sep 2007) Log Message: ----------- [maven-release-plugin] prepare release 1.1 Modified Paths: -------------- trunk/openutils-testing-junit-dwr/pom.xml Modified: trunk/openutils-testing-junit-dwr/pom.xml =================================================================== --- trunk/openutils-testing-junit-dwr/pom.xml 2007-09-10 09:37:30 UTC (rev 430) +++ trunk/openutils-testing-junit-dwr/pom.xml 2007-09-13 13:53:45 UTC (rev 431) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-testing-junit-dwr</artifactId> <name>openutils test utils (junit) for dwr</name> - <version>1.1-SNAPSHOT</version> + <version>1.1</version> <description>openutils test utils for dwr</description> <dependencies> <dependency> @@ -104,4 +104,10 @@ <version>1.6R6-candidate2</version> </dependency> </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/1.1</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/1.1</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/1.1</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-09-10 09:37:33
|
Revision: 430 http://openutils.svn.sourceforge.net/openutils/?rev=430&view=rev Author: fcarone Date: 2007-09-10 02:37:30 -0700 (Mon, 10 Sep 2007) Log Message: ----------- use generics for methods Modified Paths: -------------- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java 2007-09-03 08:31:00 UTC (rev 429) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java 2007-09-10 09:37:30 UTC (rev 430) @@ -125,7 +125,7 @@ * Sets the securedDAOs. * @param securedDAOs the securedDAOs to set */ - public void setSecuredDAOs(List securedDAOs) + public void setSecuredDAOs(List<String> securedDAOs) { this.securedDAOs = securedDAOs; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-09-03 15:44:36
|
Revision: 428 http://openutils.svn.sourceforge.net/openutils/?rev=428&view=rev Author: fcarone Date: 2007-09-03 01:24:39 -0700 (Mon, 03 Sep 2007) Log Message: ----------- give a non-null criteria list in inter dao calls Modified Paths: -------------- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java Modified: trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-09-03 08:05:11 UTC (rev 427) +++ trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-09-03 08:24:39 UTC (rev 428) @@ -4,6 +4,7 @@ import it.openutils.hibernate.example.FilterMetadata; import java.io.Serializable; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -147,7 +148,7 @@ @SuppressWarnings("unchecked") public List<T> findAll(final Order[] orderProperties) { - return getThis().findAll(orderProperties, null); + return getThis().findAll(orderProperties, new ArrayList<Criterion>()); } /** @@ -397,7 +398,7 @@ public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, final int maxResults, final int page) { - return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, null); + return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, new ArrayList<Criterion>()); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-09-03 09:11:25
|
Revision: 427 http://openutils.svn.sourceforge.net/openutils/?rev=427&view=rev Author: fcarone Date: 2007-09-03 01:05:11 -0700 (Mon, 03 Sep 2007) Log Message: ----------- getThis method added to catch the proxy again. This change is needed for security reason, since after the first proxy method is called, the target is directly invoked (and we lose control). Modified Paths: -------------- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java Modified: trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-08-31 17:03:23 UTC (rev 426) +++ trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-09-03 08:05:11 UTC (rev 427) @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; +import org.aopalliance.aop.AspectException; import org.hibernate.Criteria; import org.hibernate.Hibernate; import org.hibernate.HibernateException; @@ -19,6 +20,7 @@ import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import org.hibernate.type.Type; +import org.springframework.aop.framework.AopContext; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @@ -145,24 +147,7 @@ @SuppressWarnings("unchecked") public List<T> findAll(final Order[] orderProperties) { - - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(getReferenceClass()); - if (null != orderProperties) - { - for (int j = 0; j < orderProperties.length; j++) - { - crit.addOrder(orderProperties[j]); - } - - } - return crit.list(); - } - }); + return getThis().findAll(orderProperties, null); } /** @@ -196,6 +181,7 @@ } }); } + /** * {@inheritDoc} */ @@ -342,7 +328,7 @@ */ public T findFilteredFirst(final T filter, List<Criterion> criteria) { - return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria)); + return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria)); } /** @@ -354,6 +340,24 @@ } /** + * @return + * This is needed as for http://opensource.atlassian.com/projects/spring/browse/SPR-2226 + */ + @SuppressWarnings("unchecked") + private HibernateDAO<T, K> getThis() + { + try + { + return (HibernateDAO<T, K>) AopContext.currentProxy(); + } + catch (AspectException exc) + { + logger.debug("Not running inside an AOP proxy, so no proxy can be returned: " + exc.getMessage()); + return this; + } + } + + /** * {@inheritDoc} */ public List<T> findFiltered(T filter, Order[] orderProperties) @@ -393,7 +397,7 @@ public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, final int maxResults, final int page) { - return findFiltered(filter, customOrder, metadata, maxResults, page, null); + return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, null); } /** @@ -435,6 +439,7 @@ { return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session ses) throws HibernateException { Query q = ses.getNamedQuery(name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-09-03 09:00:57
|
Revision: 429 http://openutils.svn.sourceforge.net/openutils/?rev=429&view=rev Author: fcarone Date: 2007-09-03 01:31:00 -0700 (Mon, 03 Sep 2007) Log Message: ----------- AOP security sample application works Modified Paths: -------------- trunk/openutils-hibernate-security/pom.xml trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDaoImpl.java trunk/openutils-hibernate-security/src/test/resources/spring-database.xml trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml trunk/openutils-hibernate-security/src/test/resources/spring-security.xml Removed Paths: ------------- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java Modified: trunk/openutils-hibernate-security/pom.xml =================================================================== --- trunk/openutils-hibernate-security/pom.xml 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/pom.xml 2007-09-03 08:31:00 UTC (rev 429) @@ -92,7 +92,7 @@ <dependency> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils-bshd5</artifactId> - <version>1.0.7</version> + <version>1.0.8-SNAPSHOT</version> </dependency> <dependency> <groupId>net.sourceforge.openutils</groupId> Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java 2007-09-03 08:31:00 UTC (rev 429) @@ -3,11 +3,20 @@ */ package it.openutils.hibernate.security.aop; +import it.openutils.hibernate.security.dataobject.SecurityRule; +import it.openutils.hibernate.security.services.SecurityRuleManager; + +import java.util.ArrayList; import java.util.List; +import org.acegisecurity.Authentication; +import org.acegisecurity.GrantedAuthority; +import org.acegisecurity.context.SecurityContextHolder; +import org.apache.commons.lang.StringUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; +import org.hibernate.Filter; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.slf4j.Logger; @@ -27,23 +36,107 @@ */ private Logger log = LoggerFactory.getLogger(AOPSecurity.class); + private SecurityRuleManager securityRuleManager; + + private List<String> securedDAOs; + + private boolean enabled; + /** * @param pjp The proceeding joinpoint * @param filter The entity we are going to filter - * @param additionalCriteria The additional criteria list + * @param additionalCriteria The additional criteria list, cannot be null * @return The execution invocation result * @throws Throwable Any exception occurring in the invoked method */ -// @Around("execution(* findFiltered(Object, .., java.util.List<org.hibernate.criterion.Criterion>)) && " + // -// " args(filter, .., additionalCriteria)") - @Around("execution(* it.openutils.dao.hibernate.*.*(Object, .., java.util.List<org.hibernate.criterion.Criterion>)) && " + // - " args(filter, .., additionalCriteria)") - public Object applySecurityRules(ProceedingJoinPoint pjp, Object filter, List<Criterion> additionalCriteria) + @Around("execution(* it.openutils.dao.hibernate.*.*(Object, .., java.util.List<org.hibernate.criterion.Criterion>)) && " + + // + " args(filter, .., additionalCriteria)") + public Object applySecurityRules(ProceedingJoinPoint pjp, Object filter, List<Criterion> additionalCriteria) throws Throwable { - log.debug("applying rules for {} with criteria {}", filter.toString(), additionalCriteria); - additionalCriteria.add(Restrictions.sqlRestriction("INTVALUE = 1")); + if (!enabled) + { + log.debug("DAO security disabled, proceeding."); + return pjp.proceed(); + } + + if (!securedDAOs.contains(pjp.getTarget().getClass().getCanonicalName())) + { + log.debug("The intercepted DAO {} is not secured, proceeding.", pjp.getTarget().toString()); + return pjp.proceed(); + } + + log.debug("applying security rules for {} with criteria {}", filter.toString(), additionalCriteria); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null) + { + throw new SecurityException("Authentication is not valid"); + } + GrantedAuthority[] authorities = authentication.getAuthorities(); + List<String> roles = new ArrayList<String>(); + for (int i = 0; i < authorities.length; i++) + { + roles.add(authorities[i].getAuthority()); + } + + String entity = filter.getClass().getCanonicalName(); + List<SecurityRule> rules = securityRuleManager.getRulesForRoles(entity, roles); + + if (rules.isEmpty()) + { + String grantedRoles = StringUtils.EMPTY; + for (int i = 0; i < authorities.length; i++) + { + grantedRoles += authorities[i].getAuthority() + " "; + } + log.warn("Access is denied on " + entity + ", for user {} with roles {}", SecurityContextHolder + .getContext() + .getAuthentication() + .getPrincipal() + .toString(), grantedRoles); + + throw new SecurityException("Access denied"); + } + + Filter hibernateFilter = securityRuleManager.getEntityFilterFromRules(entity, rules); + + Criterion sqlCriterion = Restrictions.sqlRestriction(hibernateFilter + .getFilterDefinition() + .getDefaultFilterCondition()); + + log.debug("Adding sql restriction: {}", sqlCriterion.toString()); + additionalCriteria.add(sqlCriterion); + Object result = pjp.proceed(); return result; } + + /** + * Sets the securityRuleManager. + * @param securityRuleManager the securityRuleManager to set + */ + public void setSecurityRuleManager(SecurityRuleManager securityRuleManager) + { + this.securityRuleManager = securityRuleManager; + } + + /** + * Sets the securedDAOs. + * @param securedDAOs the securedDAOs to set + */ + public void setSecuredDAOs(List securedDAOs) + { + this.securedDAOs = securedDAOs; + } + + + /** + * Sets the enabled. + * @param enabled the enabled to set + */ + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } } Deleted: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java 2007-09-03 08:31:00 UTC (rev 429) @@ -1,139 +0,0 @@ -/* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it - */ -package it.openutils.hibernate.security.aop; - -import it.openutils.hibernate.security.dataobject.SecurityRule; -import it.openutils.hibernate.security.services.SecurityRuleManager; - -import java.util.ArrayList; -import java.util.List; - -import org.acegisecurity.GrantedAuthority; -import org.acegisecurity.context.SecurityContextHolder; -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.lang.StringUtils; -import org.hibernate.Filter; -import org.hibernate.SessionFactory; -import org.hibernate.criterion.Criterion; -import org.hibernate.criterion.Restrictions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * This is a Hibernate Read-Update-Delete security interceptor. This enforces a DENY_ALL default policy. - * @author fcarone - * @version $Id: $ - */ -public class HibernateDAOSecurityInterceptor implements MethodInterceptor -{ - - /** - * Logger. - */ - private Logger log = LoggerFactory.getLogger(HibernateDAOSecurityInterceptor.class); - - private SecurityRuleManager securityRuleManager; - - private SessionFactory sessionFactory; - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public Object invoke(MethodInvocation invocation) throws Throwable - { - log.debug("Applying security rules"); - Object[] arguments = invocation.getArguments(); - Object checkArgument = arguments[arguments.length - 1]; - if (!StringUtils.equals(invocation.getMethod().getName(), "findFiltered")) - { - return invocation.proceed(); - } - if (!(checkArgument instanceof List)) - { - return invocation.proceed(); - } - - String entity = StringUtils.EMPTY; - for (int i = 0; i < arguments.length; i++) - { - Object argument = arguments[i]; - if (sessionFactory.getClassMetadata(argument.getClass()) != null) - { - entity = argument.getClass().getCanonicalName(); - break; - } - } - - // the current invocation is not about any session managed entity - if (StringUtils.isEmpty(entity)) - { - return invocation.proceed(); - } - - if (SecurityContextHolder.getContext().getAuthentication() == null) - { - throw new SecurityException("Authentication is not valid"); - } - - GrantedAuthority[] authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities(); - List<String> roles = new ArrayList<String>(); - for (int i = 0; i < authorities.length; i++) - { - roles.add(authorities[i].getAuthority()); - } - List<SecurityRule> rules = securityRuleManager.getRulesForRoles(entity, roles); - - if (rules.isEmpty()) - { - String grantedRoles = StringUtils.EMPTY; - for (int i = 0; i < authorities.length; i++) - { - grantedRoles += authorities[i].getAuthority() + " "; - } - log.warn("Access is denied on " + entity + ", for user {} with roles {}", SecurityContextHolder - .getContext() - .getAuthentication() - .getPrincipal() - .toString(), grantedRoles); - - throw new SecurityException("Access denied"); - } - - Filter filter = securityRuleManager.getEntityFilterFromRules(entity, rules); - - Criterion sqlCriterion = Restrictions.sqlRestriction(filter.getFilterDefinition().getDefaultFilterCondition()); - - if (StringUtils.equals(invocation.getMethod().getName(), "findFiltered")) - { - Object argument = arguments[arguments.length - 1]; - ((List) argument).add(sqlCriterion); - } - - Object result = invocation.proceed(); - - return result; - } - - /** - * Sets the securityRuleManager. - * @param securityRuleManager the securityRuleManager to set - */ - public void setSecurityRuleManager(SecurityRuleManager securityRuleManager) - { - this.securityRuleManager = securityRuleManager; - } - - /** - * Sets the sessionFactory. - * @param sessionFactory the sessionFactory to set - */ - public void setSessionFactory(SessionFactory sessionFactory) - { - this.sessionFactory = sessionFactory; - } - -} Modified: trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java =================================================================== --- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java 2007-09-03 08:31:00 UTC (rev 429) @@ -19,6 +19,7 @@ /** * {@inheritDoc} + * Needed to fix Boolean type recognition for HSQLDB */ @Override public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException Modified: trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDaoImpl.java =================================================================== --- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDaoImpl.java 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDaoImpl.java 2007-09-03 08:31:00 UTC (rev 429) @@ -20,6 +20,6 @@ protected Class<DummyDataobject> getReferenceClass() { return DummyDataobject.class; + } - } Modified: trunk/openutils-hibernate-security/src/test/resources/spring-database.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-database.xml 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/test/resources/spring-database.xml 2007-09-03 08:31:00 UTC (rev 429) @@ -1,10 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> -<!-- - # ATTENZIONE: queste proprietà sono utilizzate solo per gli unit tests - # i file per la configurazione del db utilizzati dall'applicazione web sono in - # src/main/web-app/WEB-INF ---> + <beans> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> Modified: trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml 2007-09-03 08:31:00 UTC (rev 429) @@ -42,6 +42,7 @@ <prop key="clean*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> - </property> + </property> + <property name="exposeProxy" value="true" /> </bean> </beans> \ No newline at end of file Modified: trunk/openutils-hibernate-security/src/test/resources/spring-security.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-security.xml 2007-09-03 08:24:39 UTC (rev 428) +++ trunk/openutils-hibernate-security/src/test/resources/spring-security.xml 2007-09-03 08:31:00 UTC (rev 429) @@ -2,31 +2,16 @@ <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - - <aop:aspectj-autoproxy/> - - <bean id="securityAspect" class="it.openutils.hibernate.security.aop.AOPSecurity" /> - - <bean id="securityInterceptor" class="it.openutils.hibernate.security.aop.HibernateDAOSecurityInterceptor"> + <aop:aspectj-autoproxy /> + <bean id="securityAspect" class="it.openutils.hibernate.security.aop.AOPSecurity"> <property name="securityRuleManager" ref="securityRuleManager" /> - <property name="sessionFactory" ref="sessionFactory" /> - </bean> - -<!-- - <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> - <property name="beanNames"> + <property name="enabled" value="true" /> + <property name="securedDAOs"> <list> - <idref bean="dummyDAO" /> + <value>it.openutils.hibernate.security.apptest.DummyDaoImpl</value> </list> </property> - <property name="interceptorNames"> - <list> - <value>securityInterceptor</value> - </list> - </property> </bean> - --> - <bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.ShaPasswordEncoder" /> <bean id="userDetailsService" class="it.openutils.usermanagement.acegi.HibernateUserDetailsServiceImpl" autowire="byType"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-08-31 17:03:28
|
Revision: 426 http://openutils.svn.sourceforge.net/openutils/?rev=426&view=rev Author: fcarone Date: 2007-08-31 10:03:23 -0700 (Fri, 31 Aug 2007) Log Message: ----------- Trying to inject security with an aop advice Modified Paths: -------------- trunk/openutils-hibernate-security/pom.xml trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml trunk/openutils-hibernate-security/src/test/resources/database.properties trunk/openutils-hibernate-security/src/test/resources/log4j.xml trunk/openutils-hibernate-security/src/test/resources/spring-security.xml Added Paths: ----------- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java Modified: trunk/openutils-hibernate-security/pom.xml =================================================================== --- trunk/openutils-hibernate-security/pom.xml 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/pom.xml 2007-08-31 17:03:23 UTC (rev 426) @@ -1,20 +1,20 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> +<?xml version="1.0"?> +<project> <parent> + <artifactId>openutils</artifactId> <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> <version>3</version> <relativePath>..</relativePath> </parent> + <modelVersion>4.0.0</modelVersion> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils-hibernate-security</artifactId> - <packaging>jar</packaging> <name>openutils-hibernate-security</name> <version>0.0.1-SNAPSHOT</version> <description>Hibernate Security classes</description> <properties> <spring.version>2.0.6</spring.version> + <aspectj.version>1.5.3</aspectj.version> </properties> <dependencies> <dependency> @@ -38,6 +38,48 @@ <version>${spring.version}</version> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-hibernate3</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <!-- already imported cglib-nodep by spring --> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>${aspectj.version}</version> + </dependency> + <dependency> + <groupId>aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>${aspectj.version}</version> + </dependency> + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>2.1_3</version> + </dependency> + <dependency> + <groupId>asm</groupId> + <artifactId>asm</artifactId> + <version>2.2.3</version> + </dependency> + <dependency> + <groupId>asm</groupId> + <artifactId>asm-attrs</artifactId> + <version>2.2.3</version> + </dependency> + <dependency> + <groupId>asm</groupId> + <artifactId>asm-commons</artifactId> + <version>2.2.3</version> + </dependency> + <dependency> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils-usermanagement</artifactId> <version>1.1.1</version> @@ -67,11 +109,25 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.3.ga</version> + <exclusions> + <exclusion> + <!-- already imported cglib-nodep by spring --> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.2.1.ga</version> + <exclusions> + <exclusion> + <!-- already imported cglib-nodep by spring --> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>commons-dbcp</groupId> @@ -100,34 +156,28 @@ <version>1.0.3</version> <exclusions> <exclusion> + <artifactId>spring-remoting</artifactId> <groupId>org.springframework</groupId> - <artifactId>spring-remoting</artifactId> </exclusion> <exclusion> + <artifactId>spring-jdbc</artifactId> <groupId>org.springframework</groupId> - <artifactId>spring-jdbc</artifactId> </exclusion> <exclusion> + <artifactId>spring-support</artifactId> <groupId>org.springframework</groupId> - <artifactId>spring-support</artifactId> </exclusion> <exclusion> + <artifactId>logkit</artifactId> <groupId>logkit</groupId> - <artifactId>logkit</artifactId> </exclusion> <exclusion> + <artifactId>avalon-framework</artifactId> <groupId>avalon-framework</groupId> - <artifactId>avalon-framework</artifactId> </exclusion> </exclusions> </dependency> <dependency> - <groupId>org.apache.derby</groupId> - <artifactId>derby</artifactId> - <version>10.2.2.0</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.7</version> Added: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java (rev 0) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/AOPSecurity.java 2007-08-31 17:03:23 UTC (rev 426) @@ -0,0 +1,49 @@ +/* + * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + */ +package it.openutils.hibernate.security.aop; + +import java.util.List; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author fcarone + * @version $Id: $ + */ +@Aspect +public class AOPSecurity +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(AOPSecurity.class); + + /** + * @param pjp The proceeding joinpoint + * @param filter The entity we are going to filter + * @param additionalCriteria The additional criteria list + * @return The execution invocation result + * @throws Throwable Any exception occurring in the invoked method + */ +// @Around("execution(* findFiltered(Object, .., java.util.List<org.hibernate.criterion.Criterion>)) && " + // +// " args(filter, .., additionalCriteria)") + @Around("execution(* it.openutils.dao.hibernate.*.*(Object, .., java.util.List<org.hibernate.criterion.Criterion>)) && " + // + " args(filter, .., additionalCriteria)") + public Object applySecurityRules(ProceedingJoinPoint pjp, Object filter, List<Criterion> additionalCriteria) + throws Throwable + { + log.debug("applying rules for {} with criteria {}", filter.toString(), additionalCriteria); + additionalCriteria.add(Restrictions.sqlRestriction("INTVALUE = 1")); + Object result = pjp.proceed(); + return result; + } +} Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java 2007-08-31 17:03:23 UTC (rev 426) @@ -45,6 +45,7 @@ @SuppressWarnings("unchecked") public Object invoke(MethodInvocation invocation) throws Throwable { + log.debug("Applying security rules"); Object[] arguments = invocation.getArguments(); Object checkArgument = arguments[arguments.length - 1]; if (!StringUtils.equals(invocation.getMethod().getName(), "findFiltered")) @@ -93,7 +94,12 @@ { grantedRoles += authorities[i].getAuthority() + " "; } - log.error("Access is denied for entity {}, and roles {}", entity, grantedRoles); + log.warn("Access is denied on " + entity + ", for user {} with roles {}", SecurityContextHolder + .getContext() + .getAuthentication() + .getPrincipal() + .toString(), grantedRoles); + throw new SecurityException("Access denied"); } @@ -130,5 +136,4 @@ this.sessionFactory = sessionFactory; } - } Modified: trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java =================================================================== --- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java 2007-08-31 17:03:23 UTC (rev 426) @@ -50,21 +50,24 @@ return connection; } + private void authenticate(String username, String password) + { + AuthenticationProvider authenticationProvider = (AuthenticationProvider) ctx.getBean("authenticationProvider"); + Authentication authentication = new UsernamePasswordAuthenticationToken(username, password); + authentication = authenticationProvider.authenticate(authentication); + SecurityContextImpl sci = new SecurityContextImpl(); + sci.setAuthentication(authentication); + SecurityContextHolder.setContext(sci); + } - /** * @throws Exception Any exception */ @Test - public void testRulesApplication() throws Exception + public void testFindFiltered() throws Exception { // emulate authentication - AuthenticationProvider authenticationProvider = (AuthenticationProvider) ctx.getBean("authenticationProvider"); - Authentication authentication = new UsernamePasswordAuthenticationToken("UserUno", "password"); - authentication = authenticationProvider.authenticate(authentication); - SecurityContextImpl sci = new SecurityContextImpl(); - sci.setAuthentication(authentication); - SecurityContextHolder.setContext(sci); + authenticate("UserUno", "password"); // test securedObject = (DummyDAO) ctx.getBean("dummyDAO"); @@ -77,6 +80,12 @@ 0, new ArrayList<Criterion>()); Assert.assertNotNull(dummyObjects); + Assert.assertEquals(1, dummyObjects.size()); + + dummyObjects = securedObject.findFiltered(filter); + Assert.assertNotNull(dummyObjects); + Assert.assertEquals(1, dummyObjects.size()); + } } Modified: trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml 2007-08-31 17:03:23 UTC (rev 426) @@ -9,6 +9,7 @@ <column>EMAIL</column> <row> <value>UserUno</value> + <!-- sha1 for 'password' --> <value>5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8</value> <value>1</value> <value>Gino</value> @@ -17,7 +18,8 @@ </row> <row> <value>UserDue</value> - <value>password</value> + <!-- sha1 for 'password' --> + <value>5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8</value> <value>1</value> <value>Mario</value> <value>Verdi</value> Modified: trunk/openutils-hibernate-security/src/test/resources/database.properties =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/database.properties 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/src/test/resources/database.properties 2007-08-31 17:03:23 UTC (rev 426) @@ -10,3 +10,4 @@ hibernate.connection.password= hibernate.connection.url=jdbc:hsqldb:mem:hibernate-security hibernate.hbm2ddl.auto=create-drop +hibernate.show_sql=true Modified: trunk/openutils-hibernate-security/src/test/resources/log4j.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/log4j.xml 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/src/test/resources/log4j.xml 2007-08-31 17:03:23 UTC (rev 426) @@ -37,6 +37,9 @@ </category> <category name="it.openutils.dbupdate.DbSetupManagerImpl"> <priority value="INFO" /> + </category> + <category name="it.openutils.hibernate.security.aop"> + <priority value="DEBUG" /> </category> <root> <priority value="debug" /> Modified: trunk/openutils-hibernate-security/src/test/resources/spring-security.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-security.xml 2007-08-31 12:29:23 UTC (rev 425) +++ trunk/openutils-hibernate-security/src/test/resources/spring-security.xml 2007-08-31 17:03:23 UTC (rev 426) @@ -1,25 +1,33 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" -"http://www.springframework.org/dtd/spring-beans.dtd"> -<beans> - <bean id="securityInterceptor" class="it.openutils.hibernate.security.aop.HibernateDAOSecurityInterceptor"> - <property name="securityRuleManager" ref="securityRuleManager" /> - <property name="sessionFactory" ref="sessionFactory" /> - </bean> - <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> - <property name="beanNames"> - <list> - <idref bean="dummyDAO" /> - </list> - </property> - <property name="interceptorNames"> - <list> - <value>securityInterceptor</value> - </list> - </property> +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:aop="http://www.springframework.org/schema/aop" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> + + <aop:aspectj-autoproxy/> + + <bean id="securityAspect" class="it.openutils.hibernate.security.aop.AOPSecurity" /> + + <bean id="securityInterceptor" class="it.openutils.hibernate.security.aop.HibernateDAOSecurityInterceptor"> + <property name="securityRuleManager" ref="securityRuleManager" /> + <property name="sessionFactory" ref="sessionFactory" /> </bean> - - <bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.ShaPasswordEncoder" /> + +<!-- + <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> + <property name="beanNames"> + <list> + <idref bean="dummyDAO" /> + </list> + </property> + <property name="interceptorNames"> + <list> + <value>securityInterceptor</value> + </list> + </property> + </bean> + --> + + <bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.ShaPasswordEncoder" /> <bean id="userDetailsService" class="it.openutils.usermanagement.acegi.HibernateUserDetailsServiceImpl" autowire="byType"> <property name="userDao" ref="userDAO" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-08-31 12:29:38
|
Revision: 425 http://openutils.svn.sourceforge.net/openutils/?rev=425&view=rev Author: fcarone Date: 2007-08-31 05:29:23 -0700 (Fri, 31 Aug 2007) Log Message: ----------- Sample test application works Modified Paths: -------------- trunk/openutils-hibernate-security/pom.xml trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDataobject.java trunk/openutils-hibernate-security/src/test/resources/database.properties trunk/openutils-hibernate-security/src/test/resources/hibernate.cfg.xml trunk/openutils-hibernate-security/src/test/resources/spring-dao.xml trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml trunk/openutils-hibernate-security/src/test/resources/spring-security.xml trunk/openutils-hibernate-security/src/test/resources/spring-tests.xml Added Paths: ----------- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml Modified: trunk/openutils-hibernate-security/pom.xml =================================================================== --- trunk/openutils-hibernate-security/pom.xml 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/pom.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -50,12 +50,12 @@ <dependency> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils-bshd5</artifactId> - <version>1.0.5</version> + <version>1.0.7</version> </dependency> <dependency> <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-testing</artifactId> - <version>1.0</version> + <artifactId>openutils-testing-junit</artifactId> + <version>1.1.2</version> <scope>test</scope> </dependency> <dependency> @@ -128,6 +128,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>hsqldb</groupId> + <artifactId>hsqldb</artifactId> + <version>1.8.0.7</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.0</version> Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/aop/HibernateDAOSecurityInterceptor.java 2007-08-31 12:29:23 UTC (rev 425) @@ -39,14 +39,10 @@ private SessionFactory sessionFactory; - public HibernateDAOSecurityInterceptor() - { - super(); - } - /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") public Object invoke(MethodInvocation invocation) throws Throwable { Object[] arguments = invocation.getArguments(); @@ -77,6 +73,11 @@ return invocation.proceed(); } + if (SecurityContextHolder.getContext().getAuthentication() == null) + { + throw new SecurityException("Authentication is not valid"); + } + GrantedAuthority[] authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities(); List<String> roles = new ArrayList<String>(); for (int i = 0; i < authorities.length; i++) @@ -129,4 +130,5 @@ this.sessionFactory = sessionFactory; } + } Added: trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java =================================================================== --- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java (rev 0) +++ trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/HsqlDatatypeFactory.java 2007-08-31 12:29:23 UTC (rev 425) @@ -0,0 +1,32 @@ +/* + * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + */ +package it.openutils.hibernate.security; + +import java.sql.Types; + +import org.dbunit.dataset.datatype.DataType; +import org.dbunit.dataset.datatype.DataTypeException; +import org.dbunit.dataset.datatype.DefaultDataTypeFactory; + + +/** + * @author fcarone + * @version $Id: $ + */ +public class HsqlDatatypeFactory extends DefaultDataTypeFactory +{ + + /** + * {@inheritDoc} + */ + @Override + public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException + { + if (sqlType == Types.BOOLEAN) + { + return DataType.BOOLEAN; + } + return super.createDataType(sqlType, sqlTypeName); + } +} Modified: trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java =================================================================== --- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/SecurityIntegrationTest.java 2007-08-31 12:29:23 UTC (rev 425) @@ -1,14 +1,28 @@ package it.openutils.hibernate.security; +import it.openutils.hibernate.example.FilterMetadata; import it.openutils.hibernate.security.apptest.DummyDAO; import it.openutils.hibernate.security.apptest.DummyDataobject; -import it.openutils.testing.junit.SpringTestCase; +import it.openutils.testing.junit.DbUnitTestCase; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import org.acegisecurity.Authentication; +import org.acegisecurity.context.SecurityContextHolder; +import org.acegisecurity.context.SecurityContextImpl; +import org.acegisecurity.providers.AuthenticationProvider; +import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.dbunit.database.DatabaseConfig; +import org.dbunit.database.IDatabaseConnection; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Order; import org.junit.Assert; import org.junit.Test; + /* * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it */ @@ -17,20 +31,51 @@ * @author fcarone * @version $Id: $ */ -public class SecurityIntegrationTest extends SpringTestCase +public class SecurityIntegrationTest extends DbUnitTestCase { private DummyDAO securedObject; + + /** + * {@inheritDoc} + */ + @Override + protected IDatabaseConnection createConnection() throws SQLException + { + IDatabaseConnection connection = super.createConnection(); + DatabaseConfig config = connection.getConfig(); + config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqlDatatypeFactory()); + return connection; + } + + + + /** * @throws Exception Any exception */ @Test public void testRulesApplication() throws Exception { + // emulate authentication + AuthenticationProvider authenticationProvider = (AuthenticationProvider) ctx.getBean("authenticationProvider"); + Authentication authentication = new UsernamePasswordAuthenticationToken("UserUno", "password"); + authentication = authenticationProvider.authenticate(authentication); + SecurityContextImpl sci = new SecurityContextImpl(); + sci.setAuthentication(authentication); + SecurityContextHolder.setContext(sci); + + // test securedObject = (DummyDAO) ctx.getBean("dummyDAO"); DummyDataobject filter = new DummyDataobject(); - List<DummyDataobject> dummyObjects = securedObject.findFiltered(filter); + List<DummyDataobject> dummyObjects = securedObject.findFiltered( + filter, + new Order[0], + new HashMap<String, FilterMetadata>(), + 500, + 0, + new ArrayList<Criterion>()); Assert.assertNotNull(dummyObjects); } Modified: trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDataobject.java =================================================================== --- trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDataobject.java 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/java/it/openutils/hibernate/security/apptest/DummyDataobject.java 2007-08-31 12:29:23 UTC (rev 425) @@ -4,13 +4,17 @@ package it.openutils.hibernate.security.apptest; import javax.persistence.Column; +import javax.persistence.Entity; import javax.persistence.Id; +import javax.persistence.Table; /** * @author fcarone * @version $Id: $ */ +@Entity +@Table(name = "DUMMYDATAOBJECT") public class DummyDataobject { Added: trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml (rev 0) +++ trunk/openutils-hibernate-security/src/test/resources/SecurityIntegrationTest-load.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -0,0 +1,127 @@ +<!DOCTYPE dataset SYSTEM "dataset.dtd"> +<dataset> + <table name="APP_USER"> + <column>ID_USER</column> + <column>PASSWORD</column> + <column>ENABLED</column> + <column>NAME</column> + <column>SURNAME</column> + <column>EMAIL</column> + <row> + <value>UserUno</value> + <value>5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8</value> + <value>1</value> + <value>Gino</value> + <value>Rossi</value> + <value>ro...@ba...</value> + </row> + <row> + <value>UserDue</value> + <value>password</value> + <value>1</value> + <value>Mario</value> + <value>Verdi</value> + <value>ve...@ba...</value> + </row> + </table> + <table name="APP_GROUP"> + <column>ID_GROUP</column> + <column>DESCRIPTION</column> + <column>ENABLED</column> + <row> + <value>GRUPPOUNO</value> + <value>descrizione</value> + <value>1</value> + </row> + <row> + <value>GRUPPODUE</value> + <value>descrizione</value> + <value>1</value> + </row> + </table> + <table name="APP_ROLE"> + <column>ID_ROLE</column> + <column>DESCRIPTION</column> + <row> + <value>RoleUno</value> + <value>descr</value> + </row> + <row> + <value>RoleDue</value> + <value>descr2</value> + </row> + <row> + <value>RoleTre</value> + <value>descr3</value> + </row> + </table> + <table name="APP_USER_GROUP"> + <column>ID_USER</column> + <column>ID_GROUP</column> + <row> + <value>UserUno</value> + <value>GRUPPOUNO</value> + </row> + <row> + <value>UserUno</value> + <value>GRUPPODUE</value> + </row> + </table> + <table name="APP_GROUP_ROLE"> + <column>ID_GROUP</column> + <column>ID_ROLE</column> + <row> + <value>GRUPPOUNO</value> + <value>RoleUno</value> + </row> + <row> + <value>GRUPPOUNO</value> + <value>RoleDue</value> + </row> + <row> + <value>GRUPPODUE</value> + <value>RoleTre</value> + </row> + </table> + + <table name="SECURITY_RULE"> + <column>ID_SECURITY_RULE</column> + <column>ROLE</column> + <column>ENTITY</column> + <column>PROPERTY</column> + <column>VALUE</column> + <column>MODIFIER</column> + <row> + <value>1</value> + <value>RoleUno</value> + <value>it.openutils.hibernate.security.apptest.DummyDataobject</value> + <value>intValue</value> + <value>1</value> + <value>EQUALS</value> + </row> + </table> + <table name="SECRULE_PERMISSION"> + <column>ID_SECURITY_RULE</column> + <column>PERMISSION</column> + <row> + <value>1</value> + <value>LOAD</value> + </row> + </table> + <table name="DUMMYDATAOBJECT"> + <column>ID</column> + <column>INTVALUE</column> + <column>STRINGVALUE</column> + <row> + <value>0</value> + <value>0</value> + <value>ABC</value> + </row> + <row> + <value>1</value> + <value>1</value> + <value>DEF</value> + </row> + </table> +</dataset> + Modified: trunk/openutils-hibernate-security/src/test/resources/database.properties =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/database.properties 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/resources/database.properties 2007-08-31 12:29:23 UTC (rev 425) @@ -2,10 +2,11 @@ # i file per la configurazione del db utilizzati dall'applicazione web sono in # src/main/web-app/WEB-INF -hibernate.connection.driver=org.apache.derby.jdbc.EmbeddedDriver -hibernate.dialect=org.hibernate.dialect.DerbyDialect -hibernate.connection.username=ikam +#hibernate.connection.driver=org.apache.derby.jdbc.EmbeddedDriver +#hibernate.dialect=org.hibernate.dialect.DerbyDialect +hibernate.connection.driver=org.hsqldb.jdbcDriver +hibernate.dialect=org.hibernate.dialect.HSQLDialect +hibernate.connection.username=sa hibernate.connection.password= -hibernate.connection.url=jdbc:derby:target/db/openutils-usermanagement-db-test;create=true -hibernate.hbm2ddl.auto=update - +hibernate.connection.url=jdbc:hsqldb:mem:hibernate-security +hibernate.hbm2ddl.auto=create-drop Modified: trunk/openutils-hibernate-security/src/test/resources/hibernate.cfg.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/hibernate.cfg.xml 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/resources/hibernate.cfg.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -4,6 +4,9 @@ <hibernate-configuration> <session-factory> <mapping class="it.openutils.hibernate.security.dataobject.SecurityRule" /> - <mapping class="it.openutils.hibernate.security.apptest.DummyDataobject" /> + <mapping class="it.openutils.hibernate.security.apptest.DummyDataobject" /> + <mapping class="it.openutils.usermanagement.dataobjects.User" /> + <mapping class="it.openutils.usermanagement.dataobjects.Group" /> + <mapping class="it.openutils.usermanagement.dataobjects.Role" /> </session-factory> </hibernate-configuration> \ No newline at end of file Modified: trunk/openutils-hibernate-security/src/test/resources/spring-dao.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-dao.xml 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/resources/spring-dao.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -1,7 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> -<beans> +<beans> + <bean id="userDAO" parent="txProxyTemplate"> + <property name="target"> + <bean class="it.openutils.usermanagement.dao.UserDAOImpl"> + <property name="sessionFactory" ref="sessionFactory" /> + </bean> + </property> + </bean> <bean id="securityRuleDAO" parent="txProxyTemplate"> <property name="target"> <bean class="it.openutils.hibernate.security.dao.impl.SecurityRuleDAOImpl"> Modified: trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/resources/spring-hibernate.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -19,7 +19,7 @@ <prop key="hibernate.generate_statistics">false</prop> <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop> <prop key="hibernate.show_sql">false</prop> - <prop key="hibernate.use_sql_comments">false</prop> + <prop key="hibernate.use_sql_comments">true</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> </props> </property> Modified: trunk/openutils-hibernate-security/src/test/resources/spring-security.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-security.xml 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/resources/spring-security.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -17,5 +17,28 @@ <value>securityInterceptor</value> </list> </property> - </bean> + </bean> + + <bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.ShaPasswordEncoder" /> + <bean id="userDetailsService" class="it.openutils.usermanagement.acegi.HibernateUserDetailsServiceImpl" + autowire="byType"> + <property name="userDao" ref="userDAO" /> + </bean> + <bean id="authenticationProvider" class="org.springframework.aop.framework.ProxyFactoryBean" lazy-init="true"> + <property name="targetName" value="authenticationProviderDB" /> + </bean> + <bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter" /> + <bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased"> + <property name="allowIfAllAbstainDecisions" value="false" /> + <property name="decisionVoters"> + <list> + <ref bean="roleVoter" /> + </list> + </property> + </bean> + <bean id="authenticationProviderDB" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider" + lazy-init="true"> + <property name="userDetailsService" ref="userDetailsService" /> + <property name="passwordEncoder" ref="passwordEncoder" /> + </bean> </beans> Modified: trunk/openutils-hibernate-security/src/test/resources/spring-tests.xml =================================================================== --- trunk/openutils-hibernate-security/src/test/resources/spring-tests.xml 2007-08-31 12:28:50 UTC (rev 424) +++ trunk/openutils-hibernate-security/src/test/resources/spring-tests.xml 2007-08-31 12:29:23 UTC (rev 425) @@ -6,6 +6,4 @@ <import resource="classpath:spring-dao.xml" /> <import resource="classpath:spring-managers.xml" /> <import resource="classpath:spring-security.xml" /> - - </beans> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-08-31 12:28:50
|
Revision: 424 http://openutils.svn.sourceforge.net/openutils/?rev=424&view=rev Author: fcarone Date: 2007-08-31 05:28:50 -0700 (Fri, 31 Aug 2007) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-bshd5/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-08-31 12:28:45 UTC (rev 423) +++ trunk/openutils-bshd5/pom.xml 2007-08-31 12:28:50 UTC (rev 424) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-bshd5</artifactId> <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>1.0.7</version> + <version>1.0.8-SNAPSHOT</version> <description>openutils base Spring-Hibernate DAO for java 5.0</description> <properties> <spring.version>2.0.6</spring.version> @@ -51,10 +51,4 @@ <optional>true</optional> </dependency> </dependencies> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.7</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.7</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-1.0.7</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-08-31 12:28:46
|
Revision: 423 http://openutils.svn.sourceforge.net/openutils/?rev=423&view=rev Author: fcarone Date: 2007-08-31 05:28:45 -0700 (Fri, 31 Aug 2007) Log Message: ----------- [maven-release-plugin] copy for tag openutils-bshd5-1.0.7 Added Paths: ----------- tags/openutils-bshd5-1.0.7/ tags/openutils-bshd5-1.0.7/pom.xml tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java Removed Paths: ------------- tags/openutils-bshd5-1.0.7/pom.xml tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java Copied: tags/openutils-bshd5-1.0.7 (from rev 412, trunk/openutils-bshd5) Deleted: tags/openutils-bshd5-1.0.7/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-08-30 15:40:19 UTC (rev 412) +++ tags/openutils-bshd5-1.0.7/pom.xml 2007-08-31 12:28:45 UTC (rev 423) @@ -1,55 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>3</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-bshd5</artifactId> - <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>1.0.6-SNAPSHOT</version> - <description>openutils base Spring-Hibernate DAO for java 5.0</description> - <properties> - <spring.version>2.0.6</spring.version> - </properties> - <dependencies> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-hibernate3</artifactId> - <version>${spring.version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-aop</artifactId> - <version>${spring.version}</version> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate</artifactId> - <version>3.2.1.ga</version> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - <version>1.7.0</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <optional>true</optional> - </dependency> - </dependencies> -</project> \ No newline at end of file Copied: tags/openutils-bshd5-1.0.7/pom.xml (from rev 422, trunk/openutils-bshd5/pom.xml) =================================================================== --- tags/openutils-bshd5-1.0.7/pom.xml (rev 0) +++ tags/openutils-bshd5-1.0.7/pom.xml 2007-08-31 12:28:45 UTC (rev 423) @@ -0,0 +1,60 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>3</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-bshd5</artifactId> + <name>openutils base Spring-Hibernate DAO for java 5.0</name> + <version>1.0.7</version> + <description>openutils base Spring-Hibernate DAO for java 5.0</description> + <properties> + <spring.version>2.0.6</spring.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-hibernate3</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.1.ga</version> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.7.0</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <optional>true</optional> + </dependency> + </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.7</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.7</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-1.0.7</url> + </scm> +</project> \ No newline at end of file Deleted: tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-08-30 15:40:19 UTC (rev 412) +++ tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-08-31 12:28:45 UTC (rev 423) @@ -1,509 +0,0 @@ -package it.openutils.dao.hibernate; - -import it.openutils.hibernate.example.EnhancedExample; -import it.openutils.hibernate.example.FilterMetadata; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.hibernate.Criteria; -import org.hibernate.Hibernate; -import org.hibernate.HibernateException; -import org.hibernate.ObjectNotFoundException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.criterion.CriteriaSpecification; -import org.hibernate.criterion.Criterion; -import org.hibernate.criterion.Order; -import org.hibernate.type.Type; -import org.springframework.orm.hibernate3.HibernateCallback; -import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - - -/** - * Base Hibernate DAO. - * @author Fabrizio Giustina - * @version $Id$ - * @param <T> Persistence class - * @param <K> Object Key - */ -public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport - implements - HibernateDAO<T, K> -{ - - /** - * @author carone - * @version $Id$ - */ - private final class HibernateCallbackForExecution implements HibernateCallback - { - - /** - * - */ - private final T filter; - - /** - * - */ - private final int page; - - /** - * - */ - private final int maxResults; - - /** - * - */ - private final Map<String, FilterMetadata> metadata; - - /** - * - */ - private final Order[] orderProperties; - - private List<Criterion> additionalCriteria; - - /** - * @param filter - * @param page - * @param maxResults - * @param metadata - * @param orderProperties - */ - private HibernateCallbackForExecution( - T filter, - int page, - int maxResults, - Map<String, FilterMetadata> metadata, - Order[] orderProperties, - List<Criterion> additionalCriteria) - { - this.filter = filter; - this.page = page; - this.maxResults = maxResults; - this.metadata = metadata; - this.orderProperties = orderProperties; - this.additionalCriteria = additionalCriteria; - } - - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(filter.getClass()); - crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); - crit.setMaxResults(maxResults); - crit.setFirstResult(maxResults * page); - - if (orderProperties != null && orderProperties.length > 0) - { - for (Order order : orderProperties) - { - if (order != null) - { - crit.addOrder(order); - } - } - } - EnhancedExample.create(crit, filter, metadata); - if (additionalCriteria != null && !additionalCriteria.isEmpty()) - { - for (Criterion criterion : additionalCriteria) - { - crit.add(criterion); - } - } - return crit.list(); - } - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> find(String query) - { - return getHibernateTemplate().find(query); - } - - /** - * {@inheritDoc} - */ - public List<T> findAll() - { - return findAll(getDefaultOrder()); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findAll(final Order[] orderProperties) - { - - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(getReferenceClass()); - if (null != orderProperties) - { - for (int j = 0; j < orderProperties.length; j++) - { - crit.addOrder(orderProperties[j]); - } - - } - return crit.list(); - } - }); - } - - /** - * {@inheritDoc} - */ - public List<T> find(String query, Object obj, Type type) - { - return find(query, new Object[]{obj }, new Type[]{type }); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> find(final String query, final Object[] obj, final Type[] type) - { - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - // hibernate 3 - return ses.createQuery(query).setParameters(obj, type).list(); - } - }); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T load(K key) - { - T result = (T) getHibernateTemplate().load(getReferenceClass(), key); - Hibernate.initialize(result); - return result; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T loadIfAvailable(K key) - { - T result; - try - { - result = (T) getHibernateTemplate().load(getReferenceClass(), key); - Hibernate.initialize(result); - } - catch (ObjectNotFoundException e) - { - // during lazy initialization - return null; - } - catch (HibernateObjectRetrievalFailureException e) - { - // during load - if (e.getCause() instanceof ObjectNotFoundException) - { - return null; - } - throw e; - } - return result; - } - - /** - * {@inheritDoc} - */ - public void saveOrUpdate(final T obj) - { - getHibernateTemplate().saveOrUpdate(obj); - } - - /** - * {@inheritDoc} - */ - public void update(T obj) - { - getHibernateTemplate().update(obj); - } - - /** - * {@inheritDoc} - */ - public boolean delete(final K key) - { - - return (Boolean) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - ses.delete(ses.load(getReferenceClass(), key)); - return true; - } - }); - - } - - /** - * {@inheritDoc} - */ - public void refresh(T obj) - { - getHibernateTemplate().refresh(obj); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T merge(final T obj) - { - return (T) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - return ses.merge(obj); - } - }); - - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public K save(T obj) - { - return (K) getHibernateTemplate().save(obj); - } - - /** - * {@inheritDoc} - */ - public T findFilteredFirst(final T filter) - { - return getFirstInCollection(findFiltered(filter, 1, 0)); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter) - { - return findFiltered(filter, getDefaultFilterMetadata()); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(T filter, Order[] orderProperties) - { - return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata) - { - return findFiltered(filter, metadata, Integer.MAX_VALUE, 0); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final int maxResults, final int page) - { - return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults, - final int page) - { - return findFiltered(filter, null, metadata, maxResults, page); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, - final int maxResults, final int page) - { - return findFiltered(filter, customOrder, metadata, maxResults, page, null); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findFiltered(T filter, Order[] customOrder, Map<String, FilterMetadata> metadata, int maxResults, - int page, List<Criterion> additionalCriteria) - { - final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this - .getDefaultOrder(); - - return (List<T>) getHibernateTemplate().execute( - new HibernateCallbackForExecution(filter, page, maxResults, metadata, orderProperties, additionalCriteria)); - } - - /** - * Return the specific Object class that will be used for class-specific implementation of this DAO. - * @return the reference Class - */ - protected abstract Class<T> getReferenceClass(); - - /** - * Return a list of <code>Order</code> object to be used for the default ordering of the collection. - * @return the property name - */ - protected Order[] getDefaultOrder() - { - return new Order[0]; - } - - /** - * Obtain an instance of Query for a named query string defined in the mapping file. - * @param name the name of a query defined externally - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final int maxResults) - { - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - return q.list(); - } - }); - } - - /** - * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. - * @param name the name of a query defined externally - * @param params the parameter array - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final Serializable[] params, final int maxResults) - { - - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - if (null != params) - { - for (int i = 0; i < params.length; i++) - { - q.setParameter(i, params[i]); - } - } - return q.list(); - } - }); - } - - /** - * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. - * @param name the name of a query defined externally - * @param params the parameter Map - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final Map<String, Object> params, final int maxResults) - { - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - if (params != null) - { - for (Map.Entry<String, Object> entry : params.entrySet()) - { - setParameterValue(q, entry.getKey(), entry.getValue()); - } - } - return q.list(); - } - }); - } - - /** - * Convenience method to set paramers in the query given based on the actual object type in passed in as the value. - * You may need to add more functionaly to this as desired (or not use this at all). - * @param query the Query to set - * @param key the key name - * @param value the object to set as the parameter - */ - protected void setParameterValue(Query query, String key, Object value) - { - if (null == key || null == value) - { - return; - } - query.setParameter(key, value); - } - - /** - * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't - * set any default filter, subclasses may override this. - * @return map of property name - filter metadata - */ - protected Map<String, FilterMetadata> getDefaultFilterMetadata() - { - return new HashMap<String, FilterMetadata>(0); - } - - /** - * Returns the first object in the collection or null if the collection is null or empty. - * @param list collection - * @return first element in the list - */ - @SuppressWarnings("unchecked") - private T getFirstInCollection(Collection<T> list) - { - if (list != null && !list.isEmpty()) - { - Object result = list.iterator().next(); - Hibernate.initialize(result); - return (T) result; - } - return null; - } - -} \ No newline at end of file Copied: tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java (from rev 417, trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java) =================================================================== --- tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java (rev 0) +++ tags/openutils-bshd5-1.0.7/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2007-08-31 12:28:45 UTC (rev 423) @@ -0,0 +1,547 @@ +package it.openutils.dao.hibernate; + +import it.openutils.hibernate.example.EnhancedExample; +import it.openutils.hibernate.example.FilterMetadata; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.Criteria; +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.ObjectNotFoundException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.criterion.CriteriaSpecification; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Order; +import org.hibernate.type.Type; +import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + + +/** + * Base Hibernate DAO. + * @author Fabrizio Giustina + * @version $Id$ + * @param <T> Persistence class + * @param <K> Object Key + */ +public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport + implements + HibernateDAO<T, K> +{ + + /** + * @author carone + * @version $Id$ + */ + private final class HibernateCallbackForExecution implements HibernateCallback + { + + /** + * + */ + private final T filter; + + /** + * + */ + private final int page; + + /** + * + */ + private final int maxResults; + + /** + * + */ + private final Map<String, FilterMetadata> metadata; + + /** + * + */ + private final Order[] orderProperties; + + private List<Criterion> additionalCriteria; + + /** + * @param filter + * @param page + * @param maxResults + * @param metadata + * @param orderProperties + */ + private HibernateCallbackForExecution( + T filter, + int page, + int maxResults, + Map<String, FilterMetadata> metadata, + Order[] orderProperties, + List<Criterion> additionalCriteria) + { + this.filter = filter; + this.page = page; + this.maxResults = maxResults; + this.metadata = metadata; + this.orderProperties = orderProperties; + this.additionalCriteria = additionalCriteria; + } + + public Object doInHibernate(Session ses) throws HibernateException + { + Criteria crit = ses.createCriteria(filter.getClass()); + crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); + crit.setMaxResults(maxResults); + crit.setFirstResult(maxResults * page); + + if (orderProperties != null && orderProperties.length > 0) + { + for (Order order : orderProperties) + { + if (order != null) + { + crit.addOrder(order); + } + } + } + EnhancedExample.create(crit, filter, metadata); + if (additionalCriteria != null && !additionalCriteria.isEmpty()) + { + for (Criterion criterion : additionalCriteria) + { + crit.add(criterion); + } + } + return crit.list(); + } + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> find(String query) + { + return getHibernateTemplate().find(query); + } + + /** + * {@inheritDoc} + */ + public List<T> findAll() + { + return findAll(getDefaultOrder()); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findAll(final Order[] orderProperties) + { + + return (List<T>) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Criteria crit = ses.createCriteria(getReferenceClass()); + if (null != orderProperties) + { + for (int j = 0; j < orderProperties.length; j++) + { + crit.addOrder(orderProperties[j]); + } + + } + return crit.list(); + } + }); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findAll(final Order[] orderProperties, final List<Criterion> criteria) + { + return (List<T>) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Criteria crit = ses.createCriteria(getReferenceClass()); + if (null != orderProperties) + { + for (int j = 0; j < orderProperties.length; j++) + { + crit.addOrder(orderProperties[j]); + } + + } + if (criteria != null) + { + for (Criterion criterion : criteria) + { + crit.add(criterion); + } + } + return crit.list(); + } + }); + } + /** + * {@inheritDoc} + */ + public List<T> find(String query, Object obj, Type type) + { + return find(query, new Object[]{obj }, new Type[]{type }); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> find(final String query, final Object[] obj, final Type[] type) + { + return (List<T>) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + // hibernate 3 + return ses.createQuery(query).setParameters(obj, type).list(); + } + }); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T load(K key) + { + T result = (T) getHibernateTemplate().load(getReferenceClass(), key); + Hibernate.initialize(result); + return result; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T loadIfAvailable(K key) + { + T result; + try + { + result = (T) getHibernateTemplate().load(getReferenceClass(), key); + Hibernate.initialize(result); + } + catch (ObjectNotFoundException e) + { + // during lazy initialization + return null; + } + catch (HibernateObjectRetrievalFailureException e) + { + // during load + if (e.getCause() instanceof ObjectNotFoundException) + { + return null; + } + throw e; + } + return result; + } + + /** + * {@inheritDoc} + */ + public void saveOrUpdate(final T obj) + { + getHibernateTemplate().saveOrUpdate(obj); + } + + /** + * {@inheritDoc} + */ + public void update(T obj) + { + getHibernateTemplate().update(obj); + } + + /** + * {@inheritDoc} + */ + public boolean delete(final K key) + { + + return (Boolean) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + ses.delete(ses.load(getReferenceClass(), key)); + return true; + } + }); + + } + + /** + * {@inheritDoc} + */ + public void refresh(T obj) + { + getHibernateTemplate().refresh(obj); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T merge(final T obj) + { + return (T) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + return ses.merge(obj); + } + }); + + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public K save(T obj) + { + return (K) getHibernateTemplate().save(obj); + } + + /** + * {@inheritDoc} + */ + public T findFilteredFirst(final T filter) + { + return getFirstInCollection(findFiltered(filter, 1, 0)); + } + + /** + * {@inheritDoc} + */ + public T findFilteredFirst(final T filter, List<Criterion> criteria) + { + return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria)); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter) + { + return findFiltered(filter, getDefaultFilterMetadata()); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(T filter, Order[] orderProperties) + { + return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata) + { + return findFiltered(filter, metadata, Integer.MAX_VALUE, 0); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final int maxResults, final int page) + { + return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults, + final int page) + { + return findFiltered(filter, null, metadata, maxResults, page); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, + final int maxResults, final int page) + { + return findFiltered(filter, customOrder, metadata, maxResults, page, null); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findFiltered(T filter, Order[] customOrder, Map<String, FilterMetadata> metadata, int maxResults, + int page, List<Criterion> additionalCriteria) + { + final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this + .getDefaultOrder(); + + return (List<T>) getHibernateTemplate().execute( + new HibernateCallbackForExecution(filter, page, maxResults, metadata, orderProperties, additionalCriteria)); + } + + /** + * Return the specific Object class that will be used for class-specific implementation of this DAO. + * @return the reference Class + */ + protected abstract Class<T> getReferenceClass(); + + /** + * Return a list of <code>Order</code> object to be used for the default ordering of the collection. + * @return the property name + */ + protected Order[] getDefaultOrder() + { + return new Order[0]; + } + + /** + * Obtain an instance of Query for a named query string defined in the mapping file. + * @param name the name of a query defined externally + * @param maxResults max number of results + * @return Query + */ + protected List< ? > getNamedQuery(final String name, final int maxResults) + { + return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() + { + public Object doInHibernate(Session ses) throws HibernateException + { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + return q.list(); + } + }); + } + + /** + * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. + * @param name the name of a query defined externally + * @param params the parameter array + * @param maxResults max number of results + * @return Query + */ + protected List< ? > getNamedQuery(final String name, final Serializable[] params, final int maxResults) + { + + return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + if (null != params) + { + for (int i = 0; i < params.length; i++) + { + q.setParameter(i, params[i]); + } + } + return q.list(); + } + }); + } + + /** + * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. + * @param name the name of a query defined externally + * @param params the parameter Map + * @param maxResults max number of results + * @return Query + */ + protected List< ? > getNamedQuery(final String name, final Map<String, Object> params, final int maxResults) + { + return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + if (params != null) + { + for (Map.Entry<String, Object> entry : params.entrySet()) + { + setParameterValue(q, entry.getKey(), entry.getValue()); + } + } + return q.list(); + } + }); + } + + /** + * Convenience method to set paramers in the query given based on the actual object type in passed in as the value. + * You may need to add more functionaly to this as desired (or not use this at all). + * @param query the Query to set + * @param key the key name + * @param value the object to set as the parameter + */ + protected void setParameterValue(Query query, String key, Object value) + { + if (null == key || null == value) + { + return; + } + query.setParameter(key, value); + } + + /** + * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't + * set any default filter, subclasses may override this. + * @return map of property name - filter metadata + */ + protected Map<String, FilterMetadata> getDefaultFilterMetadata() + { + return new HashMap<String, FilterMetadata>(0); + } + + /** + * Returns the first object in the collection or null if the collection is null or empty. + * @param list collection + * @return first element in the list + */ + @SuppressWarnings("unchecked") + private T getFirstInCollection(Collection<T> list) + { + if (list != null && !list.isEmpty()) + { + Object result = list.iterator().next(); + Hibernate.initialize(result); + return (T) result; + } + return null; + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-08-31 12:28:34
|
Revision: 422 http://openutils.svn.sourceforge.net/openutils/?rev=422&view=rev Author: fcarone Date: 2007-08-31 05:28:35 -0700 (Fri, 31 Aug 2007) Log Message: ----------- [maven-release-plugin] prepare release openutils-bshd5-1.0.7 Modified Paths: -------------- trunk/openutils-bshd5/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2007-08-31 12:27:24 UTC (rev 421) +++ trunk/openutils-bshd5/pom.xml 2007-08-31 12:28:35 UTC (rev 422) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-bshd5</artifactId> <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>1.0.7-SNAPSHOT</version> + <version>1.0.7</version> <description>openutils base Spring-Hibernate DAO for java 5.0</description> <properties> <spring.version>2.0.6</spring.version> @@ -51,4 +51,10 @@ <optional>true</optional> </dependency> </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.7</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-1.0.7</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-1.0.7</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2007-08-31 12:27:27
|
Revision: 421 http://openutils.svn.sourceforge.net/openutils/?rev=421&view=rev Author: fcarone Date: 2007-08-31 05:27:24 -0700 (Fri, 31 Aug 2007) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-testing-junit/pom.xml Modified: trunk/openutils-testing-junit/pom.xml =================================================================== --- trunk/openutils-testing-junit/pom.xml 2007-08-31 12:27:18 UTC (rev 420) +++ trunk/openutils-testing-junit/pom.xml 2007-08-31 12:27:24 UTC (rev 421) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-testing-junit</artifactId> <name>openutils test utils (junit)</name> - <version>1.1.2</version> + <version>1.1.3-SNAPSHOT</version> <description>openutils test utils</description> <properties> <spring.version>2.0.6</spring.version> @@ -58,10 +58,4 @@ <version>3.8.1</version> </dependency> </dependencies> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-1.1.2</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-1.1.2</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-junit-1.1.2</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |