shopizer-developers
Changes
.project 17(+17 -0)
.settings/org.eclipse.m2e.core.prefs 4(+4 -0)
pom.xml 2(+1 -1)
sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/CacheManagerImpl.java 64(+61 -3)
sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StaticContentCacheManagerImpl.java 31(+17 -14)
sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StoreCacheManagerImpl.java 25(+2 -23)
sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/VendorCacheManager.java 4(+3 -1)
sm-shop/SALESMANAGER.h2.db 0(+0 -0)
Details
.project 17(+17 -0)
diff --git a/.project b/.project
new file mode 100644
index 0000000..9ece14e
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>shopizer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
.settings/org.eclipse.m2e.core.prefs 4(+4 -0)
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
pom.xml 2(+1 -1)
diff --git a/pom.xml b/pom.xml
index 806a595..8966524 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,7 +37,7 @@
<c3p0-version>0.9.5.2</c3p0-version>
<org.elasticsearch-version>2.4.1</org.elasticsearch-version>
<infinispan.version>6.0.2.Final</infinispan.version>
- <mysql-jdbc-version>5.1.40</mysql-jdbc-version>
+ <mysql-jdbc-version>6.0.5</mysql-jdbc-version>
<simple-json-version>1.1.1</simple-json-version>
</properties>
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/CacheManagerImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/CacheManagerImpl.java
index 4fc2489..bf1583d 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/CacheManagerImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/CacheManagerImpl.java
@@ -1,6 +1,16 @@
package com.salesmanager.core.business.modules.cms.impl;
+import java.util.List;
+import java.util.Properties;
+
import org.infinispan.Cache;
+import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
+import org.infinispan.configuration.cache.PersistenceConfigurationBuilder;
+import org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder;
+import org.infinispan.configuration.cache.StoreConfiguration;
+import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.tree.TreeCache;
import org.infinispan.tree.TreeCacheFactory;
@@ -11,11 +21,13 @@ public abstract class CacheManagerImpl implements CacheManager {
private static final Logger LOGGER = LoggerFactory.getLogger(CacheManagerImpl.class);
+ private static final String LOCATION_PROPERTIES = "location";
+
@SuppressWarnings("rawtypes")
private TreeCache treeCache = null;
@SuppressWarnings("unchecked")
- protected void init(String namedCache) {
+ protected void init(String namedCache, String location) {
try {
@@ -23,11 +35,57 @@ public abstract class CacheManagerImpl implements CacheManager {
//manager = new DefaultCacheManager(repositoryFileName);
- VendorCacheManager cacheManager = VendorCacheManager.getInstance();
+ VendorCacheManager manager = VendorCacheManager.getInstance();
+
+ if(manager==null) {
+ LOGGER.error("CacheManager is null");
+ return;
+ }
+
+
+ //final EmbeddedCacheManager manager = new DefaultCacheManager();
+ final PersistenceConfigurationBuilder persistConfig = new ConfigurationBuilder().persistence();
+ persistConfig.passivation(false);
+ final SingleFileStoreConfigurationBuilder fileStore = new SingleFileStoreConfigurationBuilder(persistConfig).location(location);
+ fileStore.invocationBatching().enable();
+ fileStore.eviction().maxEntries(15);
+ fileStore.eviction().strategy(EvictionStrategy.LRU);
+ fileStore.jmxStatistics().disable();
+ final Configuration config = persistConfig.addStore(fileStore).build();
+ config.compatibility().enabled();
+ manager.getManager().defineConfiguration(namedCache, config);
+
+ final Cache<String, String> cache = manager.getManager().getCache(namedCache);
+ //c.addListener(new CacheListener());
+
+ /*
@SuppressWarnings("rawtypes")
Cache cache = cacheManager.getManager().getCache(namedCache);
cache.getCacheConfiguration().invocationBatching().enabled();
+
+ Configuration c = cacheManager.getManager().getCacheConfiguration(namedCache);
+ if(c!=null) {
+ List<StoreConfiguration> l =c.persistence().stores();
+ StoreConfiguration sc = null;
+ int i = 0;
+ for(StoreConfiguration conf : l) {
+ if(conf.properties()!=null && conf.properties().containsKey(LOCATION_PROPERTIES)) {
+ sc = conf;
+ continue;
+ }
+ i++;
+ }
+ if(sc!=null) {
+ sc.properties().setProperty(LOCATION_PROPERTIES, location);
+
+ c.persistence().stores().set(i, sc);
+
+ }
+
+
+ }*/
+
TreeCacheFactory f = new TreeCacheFactory();
@@ -59,7 +117,7 @@ public abstract class CacheManagerImpl implements CacheManager {
public TreeCache getTreeCache() {
return treeCache;
}
-
+
}
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StaticContentCacheManagerImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StaticContentCacheManagerImpl.java
index 732be46..2517294 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StaticContentCacheManagerImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StaticContentCacheManagerImpl.java
@@ -3,6 +3,8 @@
*/
package com.salesmanager.core.business.modules.cms.impl;
+import com.google.api.client.util.Value;
+
/**
* Cache manager to handle static content data in Infinispan cache.
* static content data can be of following type
@@ -18,25 +20,26 @@ package com.salesmanager.core.business.modules.cms.impl;
*/
public class StaticContentCacheManagerImpl extends CacheManagerImpl
{
- private static StaticContentCacheManagerImpl cacheManager = null;
- private final static String NAMED_CACHE = "FilesRepository";
+
+ private final static String NAMED_CACHE = "FilesRepository";
+
+ @Value(("${config.cms.files.location}"))
+ private String location = null;
- private StaticContentCacheManagerImpl() {
+ public StaticContentCacheManagerImpl(String location) {
- super.init(NAMED_CACHE);
+ super.init(NAMED_CACHE,location);
}
- public static StaticContentCacheManagerImpl getInstance() {
-
- if(cacheManager==null) {
- cacheManager = new StaticContentCacheManagerImpl();
- }
-
- return cacheManager;
-
-
- }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
}
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StoreCacheManagerImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StoreCacheManagerImpl.java
index b2e43b0..80caefa 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StoreCacheManagerImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/StoreCacheManagerImpl.java
@@ -1,7 +1,5 @@
package com.salesmanager.core.business.modules.cms.impl;
-
-
/**
* Used for managing images
* @author casams1
@@ -10,30 +8,11 @@ package com.salesmanager.core.business.modules.cms.impl;
public class StoreCacheManagerImpl extends CacheManagerImpl {
- private static StoreCacheManagerImpl cacheManager = null;
private final static String NAMED_CACHE = "StoreRepository";
-
-
-
-
- private StoreCacheManagerImpl() {
-
- super.init(NAMED_CACHE);
-
-
- }
-
- public static StoreCacheManagerImpl getInstance() {
-
- if(cacheManager==null) {
- cacheManager = new StoreCacheManagerImpl();
- }
-
- return cacheManager;
-
-
+ public StoreCacheManagerImpl(String location) {
+ super.init(NAMED_CACHE,location);
}
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/VendorCacheManager.java b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/VendorCacheManager.java
index b0cd687..af923e8 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/VendorCacheManager.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/modules/cms/impl/VendorCacheManager.java
@@ -1,5 +1,6 @@
package com.salesmanager.core.business.modules.cms.impl;
+import org.infinispan.configuration.cache.Configuration;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.slf4j.Logger;
@@ -17,7 +18,8 @@ public class VendorCacheManager {
private VendorCacheManager(){
try {
- manager = new DefaultCacheManager(repositoryFileName);
+ //manager = new DefaultCacheManager(repositoryFileName);
+ manager = new DefaultCacheManager();
} catch (Exception e) {
LOGGER.error("Cannot start manager " + e.toString());
}
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/modules/utils/GeoLocationImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/modules/utils/GeoLocationImpl.java
index 1be944f..5e8c470 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/modules/utils/GeoLocationImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/modules/utils/GeoLocationImpl.java
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.model.CityResponse;
+import com.salesmanager.core.business.exception.ServiceException;
import com.salesmanager.core.model.common.Address;
import com.salesmanager.core.modules.utils.GeoLocation;
@@ -36,6 +37,7 @@ public class GeoLocationImpl implements GeoLocation {
Address address = new Address();
+ try {
CityResponse response = reader.city(InetAddress.getByName(ipAddress));
@@ -44,7 +46,11 @@ public class GeoLocationImpl implements GeoLocation {
address.setZone(response.getMostSpecificSubdivision().getIsoCode());
address.setCity(response.getCity().getName());
-
+ } catch(com.maxmind.geoip2.exception.AddressNotFoundException ne) {
+ LOGGER.debug("Address not fount in DB " + ne.getMessage());
+ } catch(Exception e) {
+ throw new ServiceException(e);
+ }
return address;
diff --git a/sm-core/src/main/resources/profiles/gcp/shopizer-core.properties b/sm-core/src/main/resources/profiles/gcp/shopizer-core.properties
new file mode 100644
index 0000000..6809877
--- /dev/null
+++ b/sm-core/src/main/resources/profiles/gcp/shopizer-core.properties
@@ -0,0 +1,21 @@
+#Must be 16 digits (replace with your own creation !)
+secretKey=7070200000000007
+
+
+
+#Elastic Search configurations
+elasticsearch.cluster.name=shopizer
+elasticsearch.mode=remote
+elasticsearch.server.host=http://localhost
+elasticsearch.server.port=9200
+elasticsearch.server.proxy.user=
+elasticsearch.server.proxy.password=
+
+
+#Infinispan configuration
+config.cms.store.location=/tmp/store
+config.cms.files.location=/tmp/repos
+
+shippingDistancePreProcessor.apiKey=AIzaSyCFqjgSH_6_ktwKLcVi-IRojLx2iRWlcig
+
+
diff --git a/sm-core/src/main/resources/shopizer-core.properties b/sm-core/src/main/resources/shopizer-core.properties
new file mode 100644
index 0000000..9ee6e76
--- /dev/null
+++ b/sm-core/src/main/resources/shopizer-core.properties
@@ -0,0 +1,20 @@
+#Must be 16 digits (replace with your own creation !)
+secretKey=7070200000000007
+
+
+
+#Elastic Search configurations
+elasticsearch.cluster.name=shopizer
+elasticsearch.mode=remote
+elasticsearch.server.host=http://localhost
+elasticsearch.server.port=9200
+elasticsearch.server.proxy.user=
+elasticsearch.server.proxy.password=
+
+#Infinispan configuration
+config.cms.store.location=./files/store
+config.cms.files.location=./files/repos
+
+shippingDistancePreProcessor.apiKey=AIzaSyCFqjgSH_6_ktwKLcVi-IRojLx2iRWlcig
+
+
diff --git a/sm-core/src/main/resources/spring/shopizer-core-config.xml b/sm-core/src/main/resources/spring/shopizer-core-config.xml
index d8f95a2..8069f51 100644
--- a/sm-core/src/main/resources/spring/shopizer-core-config.xml
+++ b/sm-core/src/main/resources/spring/shopizer-core-config.xml
@@ -114,11 +114,9 @@
<!--
properties files
-
-
-
-
+
-->
+
<beans:beans profile="default">
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="ignoreUnresolvablePlaceholders" value="false"/>
@@ -126,13 +124,27 @@
<beans:list>
<beans:value>classpath:database.properties</beans:value>
<beans:value>classpath:email.properties</beans:value>
- <beans:value>classpath:configs.properties</beans:value>
+ <beans:value>classpath:shopizer-core.properties</beans:value>
<beans:value>classpath:authentication.properties</beans:value>
</beans:list>
</beans:property>
</beans:bean>
</beans:beans>
+ <beans:beans profile="gcp">
+ <beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <beans:property name="ignoreUnresolvablePlaceholders" value="false"/>
+ <beans:property name="locations">
+ <beans:list>
+ <beans:value>classpath:profiles/gcp/database.properties</beans:value>
+ <beans:value>classpath:email.properties</beans:value>
+ <beans:value>classpath:profiles/gcp/shopizer-core.properties</beans:value>
+ <beans:value>classpath:authentication.properties</beans:value>
+ </beans:list>
+ </beans:property>
+ </beans:bean>
+ </beans:beans>
+
<beans:beans profile="docker">
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="ignoreUnresolvablePlaceholders" value="false"/>
@@ -140,7 +152,7 @@
<beans:list>
<beans:value>classpath:profiles/docker/database.properties</beans:value>
<beans:value>classpath:email.properties</beans:value>
- <beans:value>classpath:configs.properties</beans:value>
+ <beans:value>classpath:profiles/docker/shopizer-core.properties</beans:value>
<beans:value>classpath:authentication.properties</beans:value>
</beans:list>
</beans:property>
diff --git a/sm-core/src/main/resources/spring/shopizer-core-modules.xml b/sm-core/src/main/resources/spring/shopizer-core-modules.xml
index 5339980..a0ed900 100644
--- a/sm-core/src/main/resources/spring/shopizer-core-modules.xml
+++ b/sm-core/src/main/resources/spring/shopizer-core-modules.xml
@@ -136,9 +136,6 @@
<!--<beans:property name="rootName" value="/Applications/MAMP/htdocs/bam-images"/>-->
</beans:bean>
-
-
-
<!-- Static content files manager (images, pdf...) -->
<beans:bean id="staticContentFileManager" class="com.salesmanager.core.business.modules.cms.content.StaticContentFileManagerImpl">
<beans:property name="uploadFile">
@@ -164,9 +161,7 @@
<!--<beans:property name="rootName" value="/Applications/MAMP/htdocs/bam-images/"/>-->
</beans:bean>
-
-
-
+
<!-- product downloads -->
<beans:bean id="productDownloadsFileManager" class="com.salesmanager.core.business.modules.cms.content.StaticContentFileManagerImpl">
<beans:property name="uploadFile">
@@ -194,8 +189,10 @@
<!-- Store Cache Manager (infinispan) -->
<beans:bean id="localCacheManager"
- class="com.salesmanager.core.business.modules.cms.impl.StoreCacheManagerImpl" factory-method="getInstance" >
+ class="com.salesmanager.core.business.modules.cms.impl.StoreCacheManagerImpl">
+ <beans:constructor-arg value="${config.cms.store.location}"/>
</beans:bean>
+ <!-- factory-method="getInstance" -->
<!-- Local cache manager (for apache httpd)-->
@@ -204,20 +201,23 @@
class="com.salesmanager.core.business.modules.cms.impl.LocalCacheManagerImpl" factory-method="getInstance" >
</beans:bean>
-->
-
-
-
-
<!-- Cache manager to handle static content data which includes
1. CSS Files
2. JS Files
2. Digital data -->
<beans:bean id="filesCacheManager"
- class="com.salesmanager.core.business.modules.cms.impl.StaticContentCacheManagerImpl" factory-method="getInstance" >
+ class="com.salesmanager.core.business.modules.cms.impl.StaticContentCacheManagerImpl" >
+ <beans:constructor-arg value="${config.cms.files.location}"/>
</beans:bean>
+
+ <!-- factory-method="getInstance" -->
+
+ <!--
+ *** End CMS configuration ***
+ -->
<!--Encryption-->
<beans:bean id="encryption"
sm-shop/SALESMANAGER.h2.db 0(+0 -0)
diff --git a/sm-shop/SALESMANAGER.h2.db b/sm-shop/SALESMANAGER.h2.db
index 25199cb..c3f2fb3 100644
Binary files a/sm-shop/SALESMANAGER.h2.db and b/sm-shop/SALESMANAGER.h2.db differ
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java b/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java
index 8216d5f..dd94f7d 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/filter/StoreFilter.java
@@ -125,7 +125,6 @@ public class StoreFilter extends HandlerInterceptorAdapter {
* exit from here !
*/
//System.out.println("****** " + request.getRequestURL().toString());
- //System.out.println("****** " + request.getRequestURI().toString());
if(request.getRequestURL().toString().toLowerCase().contains(SERVICES_URL_PATTERN)
|| request.getRequestURL().toString().toLowerCase().contains(REFERENCE_URL_PATTERN)
) {
diff --git a/sm-shop/src/main/resources/database.properties b/sm-shop/src/main/resources/database.properties
index 89a1fe1..f407533 100644
--- a/sm-shop/src/main/resources/database.properties
+++ b/sm-shop/src/main/resources/database.properties
@@ -1,12 +1,11 @@
##
-## configuration base de donnees
+## db config
##
#Need to run these commands before running shopizer - choose your username and password
#mysql>CREATE DATABASE SALESMANAGER;
-#mysql>GRANT USAGE, SELECT ON *.* TO test@localhost IDENTIFIED BY 'password' with grant option;
-#mysql>GRANT ALL ON SALESMANAGER.* TO test@localhost;
-#mysql>GRANT FILE ON *.* TO test@localhost;
+#mysql>CREATE USER shopizer IDENTIFIED BY 'very-long-shopizer-password';
+#mysql>GRANT ALL ON SALESMANAGER.* TO shopizer;
#mysql>FLUSH PRIVILEGES;
#MYSQL
diff --git a/sm-shop/src/main/resources/profiles/docker/database.properties b/sm-shop/src/main/resources/profiles/docker/database.properties
index 97cb23a..e207dcd 100644
--- a/sm-shop/src/main/resources/profiles/docker/database.properties
+++ b/sm-shop/src/main/resources/profiles/docker/database.properties
@@ -1,20 +1,3 @@
-##
-## configuration base de donnees
-##
-
-#Need to run these commands before running shopizer - choose your username and password
-#mysql>CREATE DATABASE SALESMANAGER;
-#mysql>GRANT USAGE, SELECT ON *.* TO test@localhost IDENTIFIED BY 'password' with grant option;
-#mysql>GRANT ALL ON SALESMANAGER.* TO test@localhost;
-#mysql>GRANT FILE ON *.* TO test@localhost;
-#mysql>FLUSH PRIVILEGES;
-
-#MYSQL
-#db.jdbcUrl=jdbc:mysql://localhost:3306/SALESMANAGER?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
-#db.user=root
-#db.password=password
-#db.driverClass=com.mysql.jdbc.Driver
-#hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
#H2
db.jdbcUrl=jdbc\:h2\:file\:/tmp/SALESMANAGER;AUTOCOMMIT=OFF;;mv_store=false;INIT\=CREATE SCHEMA IF NOT EXISTS SALESMANAGER
diff --git a/sm-shop/src/main/resources/profiles/gcp/database.properties b/sm-shop/src/main/resources/profiles/gcp/database.properties
new file mode 100644
index 0000000..28ae9d5
--- /dev/null
+++ b/sm-shop/src/main/resources/profiles/gcp/database.properties
@@ -0,0 +1,28 @@
+
+#Need to run these commands before running shopizer - choose your username and password
+#mysql>CREATE DATABASE SALESMANAGER;
+#mysql>CREATE USER shopizer IDENTIFIED BY 'very-long-shopizer-password';
+#mysql>GRANT ALL ON SALESMANAGER.* TO shopizer;
+#mysql>FLUSH PRIVILEGES;
+
+#MYSQL
+db.jdbcUrl=jdbc:mysql://35.203.108.46:3306/SALESMANAGER?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
+db.user=shopizer
+db.password=ZAxsCD101068
+db.driverClass=com.mysql.jdbc.Driver
+hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
+
+
+
+db.preferredTestQuery=SELECT 1
+db.schema=SALESMANAGER
+hibernate.hbm2ddl.auto=update
+
+
+
+##
+## db pool config
+##
+db.initialPoolSize=4
+db.minPoolSize=4
+db.maxPoolSize=8
\ No newline at end of file