diff options
author | Martin Stockhammer <martin_s@apache.org> | 2017-05-18 21:47:01 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2017-05-20 23:15:10 +0200 |
commit | acc02bf9620de9e82ae36fbb3867e84a1bd1ccf1 (patch) | |
tree | 583ef9e1a7756264f465d8e74eaf5a50cb69ae61 /archiva-modules/archiva-web/archiva-web-common/src | |
parent | 053315826d996288174fb65f51e2f0b04ef88cde (diff) | |
parent | dd311845e13f46062251744f7cc2cfd21e2e5cf4 (diff) | |
download | archiva-acc02bf9620de9e82ae36fbb3867e84a1bd1ccf1.tar.gz archiva-acc02bf9620de9e82ae36fbb3867e84a1bd1ccf1.zip |
[MRM-1942] Merge branch 'jpa' into master
Removing JDO and add JPA backend.
Diffstat (limited to 'archiva-modules/archiva-web/archiva-web-common/src')
9 files changed, 91 insertions, 12 deletions
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java index 70f75be15..9ea05cb56 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java @@ -78,7 +78,7 @@ public class ArchivaConfigurableUsersManager setUserManagerImpl( userManagerImpl ); userManagerPerId.put( id, userManagerImpl ); } - + this.usersCache.clear(); this.useUsersCache = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().isUseUsersCache(); } catch ( RepositoryAdminException e ) @@ -333,7 +333,7 @@ public class ArchivaConfigurableUsersManager @Override public String getId() { - return null; + return "archiva-configurable"; } @Override diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java index 143f3c21b..6b2eb9e8f 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java @@ -98,6 +98,8 @@ public class ArchivaRbacManager List<String> rbacManagerIds = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls(); + clearCaches(); + if ( rbacManagerIds.isEmpty() ) { rbacManagerIds.add( RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL ); @@ -113,6 +115,7 @@ public class ArchivaRbacManager rbacManagersPerId.put( id, rbacManager ); } + } catch ( RepositoryAdminException e ) { @@ -122,12 +125,23 @@ public class ArchivaRbacManager } } + private void clearCaches() { + resourcesCache.clear(); + operationsCache.clear(); + permissionsCache.clear(); + rolesCache.clear(); + userAssignmentsCache.clear(); + userPermissionsCache.clear(); + effectiveRoleSetCache.clear(); + } + protected RBACManager getRbacManagerForWrite() { for ( RBACManager rbacManager : this.rbacManagersPerId.values() ) { if ( !rbacManager.isReadOnly() ) { + log.debug("Writable Rbac manager {}", rbacManager.getDescriptionKey()); return rbacManager; } } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java index 0a74e395b..b1cbc9cf8 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java @@ -209,6 +209,7 @@ public class ArchivaUserManagerAuthenticator { log.warn( "Login for user {} and userManager {} failed, message: {}", source.getUsername(), userManager.getId(), e.getMessage() ); + e.printStackTrace(); resultException = e; authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_RUNTIME_EXCEPTION, "Login for user " + source.getUsername() diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml index f3f50bf8d..1a981c78c 100755 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml @@ -34,7 +34,7 @@ default-lazy-init="true"> <context:annotation-config/> - <context:component-scan base-package="org.apache.archiva.web.startup, org.apache.archiva.web.runtime, org.apache.archiva.web.api,, org.apache.archiva.web.security"/> + <context:component-scan base-package="org.apache.archiva.redback.keys,org.apache.archiva.web.startup, org.apache.archiva.web.runtime, org.apache.archiva.web.api,, org.apache.archiva.web.security"/> <util:properties id="archivaRuntimeProperties" location="classpath:application.properties" /> diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 122db4f3d..eb4dc0351 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -687,7 +687,7 @@ rest.csrffilter.enabled.help.content=If true, validation of REST requests will b archiva.redback.rbacmanager.ldap=LDAP RBac Manager archiva.redback.rbacmanager.jdo=Database RBac Manager -archiva.redback.rbackmanager.jpa=Database JPA RBac Manager +archiva.redback.rbacmanager.jpa=Database JPA RBac Manager archiva.redback.rbacmanager.cached=Cached RBac Manager redback.runtime.rbac-managers.impls.chose=RbacManager(s) chosen redback.runtime.rbac-managers.impls.available=Available RbacManagers diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java index eec7ae9d9..410d6c1a3 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java @@ -37,7 +37,7 @@ import org.apache.archiva.redback.users.UserManagerException; import org.apache.archiva.redback.users.UserManagerListener; import org.apache.archiva.redback.users.UserNotFoundException; import org.apache.archiva.redback.users.UserQuery; -import org.apache.archiva.redback.users.jdo.JdoUser; +import org.apache.archiva.redback.users.jpa.model.JpaUser; import java.util.ArrayList; import java.util.Date; @@ -75,7 +75,7 @@ public class SecuritySystemStub { result = new AuthenticationResult( true, source.getUsername(), null ); - User user = new JdoUser(); + User user = new JpaUser(); user.setUsername( source.getUsername() ); user.setPassword( users.get( source.getUsername() ) ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml index 08974cf01..570eeb588 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml @@ -30,7 +30,6 @@ <context:property-placeholder system-properties-mode="OVERRIDE"/> - <bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"> <property name="properties"> <value> diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml index 8f8085e74..9bc51d7b2 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml @@ -20,16 +20,16 @@ --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" + xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd" + http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-lazy-init="true"> <context:annotation-config/> <context:component-scan - base-package="org.apache.archiva.rest.services.utils"/> + base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils"/> <bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler"> <property name="properties"> @@ -84,4 +84,36 @@ <alias name="userConfiguration#archiva" alias="userConfiguration#default"/> <alias name="authorizer#rbac" alias="authorizer#default"/> <alias name="userManager#configurable" alias="userManager#default"/> + + <!-- *** + JPA settings + *** --> + <bean name="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> + <property name="jpaVendorAdapter" > + <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter" /> + </property> + <property name="persistenceXmlLocation" value="classpath:META-INF/persistence-hsqldb.xml" /> + <property name="jpaPropertyMap"> + <map> + <entry key="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:redback_database" /> + <entry key="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" /> + <entry key="openjpa.ConnectionUserName" value="sa" /> + <entry key="openjpa.ConnectionPassword" value="" /> + <entry key="openjpa.Log" value="DefaultLevel=TRACE, Runtime=TRACE, Tool=INFO, SQL=TRACE" /> + <entry key="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" /> + <entry key="openjpa.jdbc.MappingDefaults" + value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict"/> + </map> + </property> + + </bean> + + <bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" > + <property name="entityManagerFactory" ref="entityManagerFactory" /> + </bean> + + <tx:annotation-driven /> + <!-- *** + End of JPA settings + *** --> </beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml index c9ff7946c..5a1171022 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml @@ -21,11 +21,11 @@ <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" + xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd" + http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-lazy-init="true"> <bean id="repository" class="org.apache.jackrabbit.core.RepositoryImpl" destroy-method="shutdown"> @@ -58,4 +58,37 @@ <alias name="userConfiguration#archiva" alias="userConfiguration#default"/> <alias name="authorizer#rbac" alias="authorizer#default"/> <alias name="userManager#configurable" alias="userManager#default"/> + + <!-- *** + JPA settings + *** --> + <bean name="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> + <property name="jpaVendorAdapter" > + <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter" /> + </property> + <property name="persistenceXmlLocation" value="classpath:META-INF/persistence-hsqldb.xml" /> + <property name="jpaPropertyMap"> + <map> + <entry key="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:redback_database" /> + <entry key="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" /> + <entry key="openjpa.ConnectionUserName" value="sa" /> + <entry key="openjpa.ConnectionPassword" value="" /> + <entry key="openjpa.Log" value="DefaultLevel=TRACE, Runtime=TRACE, Tool=INFO, SQL=TRACE" /> + <entry key="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" /> + <entry key="openjpa.jdbc.MappingDefaults" + value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict"/> + </map> + </property> + + </bean> + + <bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" > + <property name="entityManagerFactory" ref="entityManagerFactory" /> + </bean> + + <tx:annotation-driven /> + <!-- *** + End of JPA settings + *** --> + </beans> |