Merge branch 'master' into db-purge

Conflicts:
	mindplot/src/main/javascript/MainTopic.js
	wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java
	wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java
This commit is contained in:
Paulo Gustavo Veiga
2012-11-04 01:38:52 -03:00
31 changed files with 1690 additions and 300 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright [2012] [wisemapping]
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
@@ -28,6 +28,7 @@ import com.wisemapping.jaxb.freemind.*;
import com.wisemapping.jaxb.wisemap.RelationshipType;
import com.wisemapping.jaxb.wisemap.TopicType;
import com.wisemapping.jaxb.wisemap.Icon;
import org.apache.commons.lang.StringEscapeUtils;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -164,11 +165,13 @@ public class FreemindExporter
}
// Formated text have a different representation ....
if (!text.contains("\n")) {
freemindNode.setTEXT(text);
} else {
final Richcontent richcontent = buildRichContent(text, "NODE");
freemindNode.getArrowlinkOrCloudOrEdge().add(richcontent);
if (text != null) {
if (!text.contains("\n")) {
freemindNode.setTEXT(text);
} else {
final Richcontent richcontent = buildRichContent(text, "NODE");
freemindNode.getArrowlinkOrCloudOrEdge().add(richcontent);
}
}
freemindNode.setBACKGROUNDCOLOR(mindmapTopic.getBgColor());
@@ -202,7 +205,8 @@ public class FreemindExporter
final StringBuilder htmlContent = new StringBuilder("<html><head></head><body>");
for (String line : text.split("\n")) {
htmlContent.append("<p>").append(line.trim()).append("</p>");
line = StringEscapeUtils.escapeXml(line);
htmlContent.append("<p>").append(line).append("</p>");
}
htmlContent.append("</body></html>");

View File

@@ -357,7 +357,7 @@ public class FreemindImporter
* 3 -> 2
* 4 -> 4
*/
private int calcFirstLevelOrder(@NotNull List<Object> freeChilden, @NotNull Node freeChild) {
private int calcFirstLevelOrder(@NotNull List<Object> freeChilden, @Nullable Node freeChild) {
final List<Node> nodes = new ArrayList<Node>();
int result;

View File

@@ -123,7 +123,8 @@ final public class NotificationService {
private void handleException(Exception e) {
System.err.println("An expected error has occurred trying to send an email notification. Usually, the main reason for this is that the SMTP server properties has not been configured properly. Edit the WEB-INF/app.properties file and verify the SMTP server configuration properties.");
e.printStackTrace();
System.err.println("Cause:" + e.getMessage());
}
public void setBaseUrl(String baseUrl) {

View File

@@ -52,9 +52,6 @@ public class UsersController {
@Autowired
private UserService userService;
@Value("${registration.email.enabled}")
boolean emailConfirmEnabled;
@Autowired
private ReCaptcha captchaService;
@@ -111,11 +108,13 @@ public class UsersController {
user.setFirstname(userBean.getFirstname());
user.setLastname(userBean.getLastname());
user.setPassword(userBean.getPassword());
userService.createUser(user, emailConfirmEnabled);
boolean confirmRegistrationByEmail = false;
userService.createUser(user, confirmRegistrationByEmail);
// Forward to the success view ...
result = new ModelAndView("userRegistrationSuccess");
result.addObject("confirmByEmail", emailConfirmEnabled);
result.addObject("confirmByEmail", confirmRegistrationByEmail);
}
return result;
}

View File

@@ -18,6 +18,7 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.ClientException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestUser;

View File

@@ -1,5 +1,5 @@
/*
* Copyright [2012] [wisemapping]
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
@@ -25,7 +25,6 @@ import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestErrors;
import com.wisemapping.security.Utils;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -43,8 +42,6 @@ import java.util.Locale;
public class BaseController {
final protected static Logger logger = Logger.getLogger("com.wisemapping.rest");
@Qualifier("messageSource")
@Autowired
private ResourceBundleMessageSource messageSource;
@@ -59,8 +56,8 @@ public class BaseController {
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public RestErrors handleClientErrors(@NotNull IllegalArgumentException ex) {
ex.printStackTrace();
return new RestErrors(ex.getMessage(), Severity.SEVERE);
System.err.println(ex.getMessage());
return new RestErrors(ex.getMessage(),Severity.WARNING);
}
@ExceptionHandler(Exception.class)

View File

@@ -52,7 +52,6 @@ public class RestMindmap {
public RestMindmap() throws WiseMappingException {
this(new Mindmap(), null);
}
public RestMindmap(@NotNull Mindmap mindmap, @Nullable Collaborator collaborator) throws WiseMappingException {

View File

@@ -84,7 +84,7 @@ public class TransformView extends AbstractView {
// Write the conversion content ...
final ServletOutputStream outputStream = response.getOutputStream();
if (exportFormat == ExportFormat.FREEMIND) {
response.setCharacterEncoding("iso-8859-1");
response.setCharacterEncoding("ASCII");
factory.export(properties, content, outputStream, null);
} else if (exportFormat == ExportFormat.WISEMAPPING) {
response.setCharacterEncoding("UTF-8");

View File

@@ -9,13 +9,17 @@
#database.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
#database.username=wisemapping
#database.password=password
#database.validation.enabled=true
#database.validation.query=SELECT 1
# HSQL Configuration properties
database.url=jdbc:hsqldb:file:target/db/wisemapping
database.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
database.driver=org.hsqldb.jdbc.JDBCDriver
database.hibernate.dialect=org.hibernate.dialect.HSQLDialect
database.username=sa
database.password=
database.validation.enabled=false
database.validation.query=
##################################################################################
# Mail configuration. Must be configured to enable user registration confirmation.
@@ -60,9 +64,6 @@ mail.errorReporterEmail=
# Users Registration Configuration
##################################################################################
# Enable/Disable user registration confirmation by e-mail. If it's enabled, mail must be configured.
registration.email.enabled = false
# Enable captcha confirmation
google.recaptcha.enabled = true

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="viewSecurityAdvisor"
class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">

View File

@@ -1,74 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
<bean id="wiseDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${database.driver}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
</bean>
<!--Descoment this lines for production environments -->
<!--<bean id="wiseDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">-->
<!--<property name="jndiName">-->
<!--<value>java:comp/env/jdbc/wisemapping</value>-->
<!--</property>-->
<!--</bean>-->
<bean id="mindmapSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="wiseDataSource"/>
<property name="mappingResources">
<list>
<value>com/wisemapping/model/Collaborator.hbm.xml</value>
<value>com/wisemapping/model/Mindmap.hbm.xml</value>
<value>com/wisemapping/model/Collaboration.hbm.xml</value>
<value>com/wisemapping/model/CollaborationProperties.hbm.xml</value>
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value>
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${database.hibernate.dialect}</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="mindmapSessionFactory"/>
</property>
</bean>
<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource" ref="wiseDataSource"/>
</bean>
<!-- Hibernate Template Defintion -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="mindmapSessionFactory"/>
<property name="jdbcExceptionTranslator" ref="jdbcExceptionTranslator"/>
</bean>
<bean id="txAttributes"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="txInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributeSource" ref="txAttributes"/>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder location="/WEB-INF/app.properties"/>
<bean id="wiseDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${database.driver}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="testOnBorrow" value="${database.validation.enabled}"/>
<property name="validationQuery" value="${database.validation.query}"/>
</bean>
<!--Descoment this lines for production environments -->
<!--<bean id="wiseDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">-->
<!--<property name="jndiName">-->
<!--<value>java:comp/env/jdbc/wisemapping</value>-->
<!--</property>-->
<!--</bean>-->
<bean id="mindmapSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="wiseDataSource"/>
<property name="mappingResources">
<list>
<value>com/wisemapping/model/Collaborator.hbm.xml</value>
<value>com/wisemapping/model/Mindmap.hbm.xml</value>
<value>com/wisemapping/model/Collaboration.hbm.xml</value>
<value>com/wisemapping/model/CollaborationProperties.hbm.xml</value>
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value>
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${database.hibernate.dialect}</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="mindmapSessionFactory"/>
</property>
</bean>
<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource" ref="wiseDataSource"/>
</bean>
<!-- Hibernate Template Defintion -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="mindmapSessionFactory"/>
<property name="jdbcExceptionTranslator" ref="jdbcExceptionTranslator"/>
</bean>
<bean id="txAttributes"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="txInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributeSource" ref="txAttributes"/>
</bean>
</beans>

View File

@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<beans>
<bean id="userManager" class="com.wisemapping.dao.UserManagerImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"/>
<property name="encoder" ref="encoder"/>
</bean>
<beans>
<bean id="userManager" class="com.wisemapping.dao.UserManagerImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"/>
<property name="encoder" ref="encoder"/>
</bean>
<bean id="mindmapManager" class="com.wisemapping.dao.MindmapManagerImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="mindmapManager" class="com.wisemapping.dao.MindmapManagerImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
</beans>
</beans>

View File

@@ -2,16 +2,16 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties"/>
</bean>
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="/WEB-INF/app.properties"/>
<bean id="encoder"
class="com.wisemapping.security.CustomPasswordEncoder"/>
@@ -73,10 +73,8 @@
<property name="adminUser" value="${admin.user}"/>
</bean>
<beans profile="production">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/prod.properties" />
</bean>
<beans profile="heroku">
<context:property-placeholder location="/WEB-INF/heroku.properties"/>
</beans>
</beans>

View File

@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<beans>
<bean id="mailer" class="com.wisemapping.mail.Mailer" singleton="true">
<bean id="mailer" class="com.wisemapping.mail.Mailer" scope ="singleton">
<constructor-arg index="0" value="${mail.serverSendEmail}"/>
<constructor-arg index="1" value="${mail.supportEmail}"/>
<constructor-arg index="2" value="${mail.errorReporterEmail}"/>
@@ -74,7 +76,7 @@
</property>
</bean>
<bean id="notificationService" class="com.wisemapping.mail.NotificationService" singleton="true">
<bean id="notificationService" class="com.wisemapping.mail.NotificationService" scope ="singleton">
<property name="baseUrl" value="${site.baseurl}"/>
<property name="mailer" ref="mailer"/>
</bean>

View File

@@ -14,11 +14,9 @@
<context:component-scan base-package="com.wisemapping.ncontroller"/>
<context:annotation-config/>
<mvc:annotation-driven/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties"/>
</bean>
<context:property-placeholder
location="/WEB-INF/app.properties"
/>
<!-- Interceptors Registration -->
<mvc:interceptors>
@@ -114,8 +112,8 @@
</bean>
<beans profile="heroku">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/heroku.properties" />
</bean>
<context:property-placeholder
location="/WEB-INF/heroku.properties"
/>
</beans>
</beans>