adapt dependencies, not finished yet
authorKatja Luther <k.luther@bgbm.org>
Mon, 11 Jan 2016 13:41:11 +0000 (14:41 +0100)
committerKatja Luther <k.luther@bgbm.org>
Mon, 11 Jan 2016 13:41:11 +0000 (14:41 +0100)
eu.etaxonomy.taxeditor.cdmlib/pom.xml
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacher.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/service/CdmAuthenticatedHttpInvokerRequestExecutor.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java

index 1ce986570da6ac9e4cc5ae9ee85672e66503451e..444633d7245b90ad1fbbe9f3867771731434a63a 100644 (file)
       </id>\r
       <url>http://repository.springsource.com/maven/bundles/external\r
       </url>\r
+    </repository>\r
+        <repository>\r
+        <id>repository.springsource.release</id>\r
+        <name>SpringSource GA Repository</name>\r
+        <url>http://repo.springsource.org/release</url>\r
     </repository>\r
   </repositories>\r
   <dependencies>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.context</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-context</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.context.support</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-context-support</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.aspects</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-aspects</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.test</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-test</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.beans</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-beans</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.transaction</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-tx</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
-      <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.web</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
-    </dependency>\r
-    <dependency>\r
-      <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.core</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
-    </dependency>\r
+               <groupId>org.springframework</groupId>\r
+               <artifactId>spring-web</artifactId>\r
+               <version>4.2.4.RELEASE</version>\r
+       </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.aop</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-core</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.expression</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
+      <artifactId>spring-aop</artifactId>\r
+      <version>4.2.4.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
-      <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.orm</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
-    </dependency>\r
+               <groupId>org.springframework</groupId>\r
+               <artifactId>spring-expression</artifactId>\r
+               <version>4.2.4.RELEASE</version>\r
+       </dependency>\r
+   <dependency>\r
+               <groupId>org.springframework</groupId>\r
+               <artifactId>spring-orm</artifactId>\r
+               <version>4.2.4.RELEASE</version>\r
+       </dependency>\r
     <dependency>\r
-      <groupId>org.springframework</groupId>\r
-      <artifactId>org.springframework.jdbc</artifactId>\r
-      <version>3.2.2.RELEASE</version>\r
-    </dependency>\r
+               <groupId>org.springframework</groupId>\r
+               <artifactId>spring-jdbc</artifactId>\r
+               <version>4.2.4.RELEASE</version>\r
+       </dependency>\r
     <dependency>\r
       <groupId>org.springframework.security</groupId>\r
       <artifactId>spring-security-core</artifactId>\r
-      <version>3.1.3.RELEASE</version>\r
+      <version>4.0.3.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework.security</groupId>\r
       <artifactId>spring-security-config</artifactId>\r
-      <version>3.1.3.RELEASE</version>\r
+      <version>4.0.3.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.springframework.security</groupId>\r
       <artifactId>spring-security-remoting</artifactId>\r
-      <version>3.1.3.RELEASE</version>\r
+      <version>4.0.3.RELEASE</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>org.jboss.logging</groupId>\r
index 47757c9863f8fc05198f383250ff08ddeeb690a9..cdb3a1cdbe9ea76e5aff5e9a489a18c8a21d056b 100644 (file)
@@ -19,7 +19,7 @@ import org.apache.log4j.Logger;
 import org.springframework.beans.BeansException;\r
 import org.springframework.context.ApplicationContext;\r
 import org.springframework.context.ApplicationContextAware;\r
-import org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor;\r
+import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor;\r
 import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;\r
 import org.springframework.security.access.AccessDecisionVoter;\r
 import org.springframework.security.authentication.AuthenticationProvider;\r
@@ -128,7 +128,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
         this.remoteSource = remoteSource;\r
     }\r
 \r
-    private Object getService(Class<?> clazz, String serviceSuffix, CommonsHttpInvokerRequestExecutor executor) {\r
+    private Object getService(Class<?> clazz, String serviceSuffix, HttpComponentsHttpInvokerRequestExecutor executor) {\r
         if(serviceMap.containsKey(clazz)) {\r
             return serviceMap.get(clazz);\r
         }\r
@@ -140,7 +140,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
     public static Object getService(Class<?> clazz,\r
             String serviceSuffix,\r
             ICdmRemoteSource remoteSource,\r
-            CommonsHttpInvokerRequestExecutor executor) {\r
+            HttpComponentsHttpInvokerRequestExecutor executor) {\r
 \r
         String baseUrl;\r
         if(remoteSource.getContextPath() == null || remoteSource.getContextPath().equals("")) {\r
@@ -305,16 +305,16 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
 \r
 \r
     public static IUserService getUserService(ICdmRemoteSource remoteSource) {\r
-        return (IUserService) getService(IUserService.class, "/remoting-public/user.service", remoteSource, new CommonsHttpInvokerRequestExecutor());\r
+        return (IUserService) getService(IUserService.class, "/remoting-public/user.service", remoteSource, new HttpComponentsHttpInvokerRequestExecutor());\r
     }\r
 \r
     @Override\r
     public IMetadataService getMetadataService() {\r
-        return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new CommonsHttpInvokerRequestExecutor());\r
+        return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new HttpComponentsHttpInvokerRequestExecutor());\r
     }\r
 \r
     public static IMetadataService getMetadataService(ICdmRemoteSource remoteSource) {\r
-        return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", remoteSource, new CommonsHttpInvokerRequestExecutor());\r
+        return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", remoteSource, new HttpComponentsHttpInvokerRequestExecutor());\r
     }\r
 \r
     @Override\r
@@ -426,7 +426,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
         if(cdmPermissionEvaluator != null) {\r
             return cdmPermissionEvaluator;\r
         }\r
-        List<AccessDecisionVoter> decisionVoters = new ArrayList<AccessDecisionVoter>();\r
+        List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<AccessDecisionVoter<? extends Object>>();\r
         decisionVoters.add(new GrantAlwaysVoter());\r
         decisionVoters.add(new TaxonNodeVoter());\r
         decisionVoters.add(new TaxonBaseVoter());\r
index cf53ea5e15a68465ca9b868c427c3625072950bf..997526936ece9d196fa916bbd964fa0cf18a60ba 100644 (file)
@@ -17,12 +17,20 @@ import net.sf.ehcache.Element;
 
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Platform;
+import org.hibernate.SessionFactory;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.mapping.Property;
-import org.hibernate.property.Getter;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.property.access.spi.Getter;
 import org.osgi.framework.Bundle;
 
+import org.hibernate.boot.Metadata;
+
 
 public class CdmModelCacher {
 
@@ -63,22 +71,39 @@ public class CdmModelCacher {
 
 
     public Map<String, CdmModelFieldPropertyFromClass> generateModelClassMap() {
-
-        Configuration configuration = buildConfiguration(HB_CONFIG_FILE_PATH);
-        Iterator<PersistentClass> classMappingIterator =   configuration.getClassMappings();
-
-        Map<String, CdmModelFieldPropertyFromClass> modelClassMap = new HashMap<String, CdmModelFieldPropertyFromClass>();
-
-        while(classMappingIterator.hasNext()) {
-            PersistentClass persistentClass = classMappingIterator.next();
-            Class mappedClass = persistentClass.getMappedClass();
-            String mappedClassName = mappedClass.getName();
-
-            CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
-            System.out.println("Adding class : " + mappedClassName + " to cache");
-            addGetters(persistentClass, cmgmfc);
-            modelClassMap.put(mappedClassName, cmgmfc);
-        }
+       
+       // A SessionFactory is set up once for an application!
+       final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
+                       .configure(HB_CONFIG_FILE_PATH) // configures settings from hibernate.cfg.xml
+                       .build();
+       SessionFactory sessionFactory = null;
+       Map<String, CdmModelFieldPropertyFromClass> modelClassMap = new HashMap<String, CdmModelFieldPropertyFromClass>();
+       try {
+               sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
+               Configuration configuration = buildConfiguration(HB_CONFIG_FILE_PATH);
+               Map<String, ClassMetadata> classMetaDataMap = sessionFactory.getAllClassMetadata();
+               Metadata metadata = new MetadataSources( registry ).getMetadataBuilder().applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ).build();
+           
+
+            for(ClassMetadata classMetaData :classMetaDataMap.values()) {
+               Class mappedClass = classMetaData.getMappedClass();
+               
+                String mappedClassName = mappedClass.getName();
+               
+                PersistentClass persistentClass =metadata.getEntityBinding(mappedClassName);
+                CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
+                System.out.println("Adding class : " + mappedClassName + " to cache");
+                addGetters(persistentClass, cmgmfc);
+                modelClassMap.put(mappedClassName, cmgmfc);
+            }
+       }
+       catch (Exception e) {
+               // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
+               // so destroy it manually.
+               StandardServiceRegistryBuilder.destroy( registry );
+       }
+       
+       
         return modelClassMap;
     }
 
index 692a3bae15d3e80490d891f3748ee1431e713575..f46b81ae5f33d8844b33b8a7a0741aeef16e42f6 100644 (file)
@@ -13,7 +13,8 @@ import java.io.IOException;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.httpclient.methods.PostMethod;
-import org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor;
+import org.apache.http.client.methods.HttpPost;
+import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor;
 import org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContext;
@@ -25,11 +26,11 @@ import eu.etaxonomy.cdm.api.application.CdmApplicationState;
  * @date 27 Jan 2015
  *
  */
-public class CdmAuthenticatedHttpInvokerRequestExecutor extends CommonsHttpInvokerRequestExecutor {
+public class CdmAuthenticatedHttpInvokerRequestExecutor extends HttpComponentsHttpInvokerRequestExecutor {
 
     @Override
-    protected PostMethod createPostMethod(HttpInvokerClientConfiguration config) throws IOException {
-        PostMethod postMethod = super.createPostMethod(config);
+    protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException {
+       HttpPost postMethod = super.createHttpPost(config);
 
         SecurityContext securityContext = CdmApplicationState.getCurrentSecurityContext();
         if(securityContext != null) {
@@ -37,7 +38,7 @@ public class CdmAuthenticatedHttpInvokerRequestExecutor extends CommonsHttpInvok
             if ((auth != null) && (auth.getName() != null) &&
                     (auth.getCredentials() != null)) {
                 String base64 = auth.getName() + ":" + auth.getCredentials().toString();
-                postMethod.setRequestHeader("Authorization", "Basic " +
+                postMethod.setHeader("Authorization", "Basic " +
                         new String(Base64.encodeBase64(base64.getBytes())));
             }
         }
index f2debccfeaae80793d8ff61b1984d24efa5c8c38..2224ce5adfc9af922311acd7cb6154026121c040 100644 (file)
@@ -236,11 +236,11 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                if ( isTempSession ) {
                        // TODO: On the next major release, add an
                        // 'isJTA' or 'getTransactionFactory' method to Session.
-                       isJTA = session.getTransactionCoordinator()
+                       /*isJTA = session.getTransactionCoordinator()
                                        .getTransactionContext().getTransactionEnvironment()
                                        .getTransactionFactory()
-                                       .compatibleWithJtaSynchronization();
-
+                                       .compatibleWithJtaSynchronization();*/
+                       isJTA = session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta();
                        if ( !isJTA ) {
                                // Explicitly handle the transactions only if we're not in
                                // a JTA environment.  A lazy loading temporary session can
index 591594804851422ea9f6ed3ebc1fb14fd54020f0..f9920b67822dd9f39d97619af4c6024a749053e5 100644 (file)
@@ -203,10 +203,12 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
 
                                // TODO: On the next major release, add an
                                // 'isJTA' or 'getTransactionFactory' method to Session.
-                               boolean isJTA = session.getTransactionCoordinator()
+                               /*boolean isJTA = session.getTransactionCoordinator()
                                                .getTransactionContext().getTransactionEnvironment()
                                                .getTransactionFactory()
                                                .compatibleWithJtaSynchronization();
+                               */
+                               boolean isJTA = session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta();
 
                                if ( !isJTA ) {
                                        // Explicitly handle the transactions only if we're not in