Posts

Showing posts with the label Spring Framework

Access application Google Drive account from javascript without client side authorization dialog

Use case We want to create a regular Google Drive account owned by an application. The application enables users to upload or view files within that account. Since Google Drive API provides javascript library the goal is to use javascript for all the logic (upload and view files) with minimum engagement of server side processing. For the purpose of creating an application owned account Google provides two options: SERVICE ACCOUNT Application is authorized by .pk12 certificate; the drawback is that only the application can see documents it created - documents cannot be viewed for example through Google Drive UI. REGULAR GOOGLE ACCOUNT used by the application only This option is our choice because we want to access stored files using Google Drive UI too. More information about the two options is available in Google Drive SDK documentation . To access a Google account using Google API we have to ensure correct handling of authentication and authorization procedures - Google A...

Hibernate schema export with Hibernate Validator constraints accepted and Spring configured persistence

What is the goal: using Spring Framework for configuration of persistence settings (JPA 2.0 with Hibernate provider) using the configuration for Hibernate schema export tool apply Hibernate Validator constraints to generated schema Spring persistence configuration // define datasource - hsqldb for testing purposes - it requires hsqldb to be on classpath EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase database = builder.setType(EmbeddedDatabaseType.HSQL).build(); // standard way how to configure persistence in Spring (usually included as a part of some configuration class) LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean(); lcemfb.setPersistenceXmlLocation("classpath:example/path/to/persistence.xml"); lcemfb.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); lcemfb.setDataSource(database); lcemfb.afterPropertiesSet(); Create Hibernate configuration from Spring configured persistence Ej...