Fix major update integrating with external wisemapping frond end

This commit is contained in:
Paulo Gustavo Veiga
2021-12-24 18:03:23 -08:00
parent 76ff1cc83d
commit b3e26caee4
1042 changed files with 1160 additions and 73432 deletions

View File

@@ -58,13 +58,13 @@ public interface MindmapManager {
void removeCollaboration(Collaboration collaboration);
public List<Mindmap> search(MindMapCriteria criteria);
List<Mindmap> search(MindMapCriteria criteria);
public List<Mindmap> search(MindMapCriteria criteria, int maxResult);
List<Mindmap> search(MindMapCriteria criteria, int maxResult);
public List<MindMapHistory> getHistoryFrom(int mindmapId);
List<MindMapHistory> getHistoryFrom(int mindmapId);
public MindMapHistory getHistory(int historyId);
MindMapHistory getHistory(int historyId);
void updateCollaboration(@NotNull Collaboration collaboration);

View File

@@ -20,20 +20,20 @@ package com.wisemapping.dao;
import com.wisemapping.model.*;
import com.wisemapping.util.ZipUtils;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Junction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.SimpleExpression;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.SimpleExpression;
import org.hibernate.criterion.Junction;
import org.hibernate.criterion.Order;
import org.hibernate.Criteria;
import java.io.IOException;
import java.util.List;
import java.util.Calendar;
import java.util.List;
public class MindmapManagerImpl
extends HibernateDaoSupport

View File

@@ -18,9 +18,9 @@
package com.wisemapping.dao;
import com.wisemapping.model.AccessAuditory;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.User;
import com.wisemapping.model.AccessAuditory;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -31,7 +31,7 @@ public interface UserManager {
User getUserBy(String email);
public User getUserBy(long id);
User getUserBy(long id);
void createUser(User user);
@@ -41,10 +41,10 @@ public interface UserManager {
User getUserByActivationCode(long code);
public Collaborator getCollaboratorBy(String email);
Collaborator getCollaboratorBy(String email);
public User createUser(User user, Collaborator col);
User createUser(User user, Collaborator col);
public void removeUser(@NotNull User user);
void removeUser(@NotNull User user);
}

View File

@@ -18,10 +18,12 @@
package com.wisemapping.dao;
import com.wisemapping.model.AccessAuditory;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.User;
import com.wisemapping.model.AccessAuditory;
import com.wisemapping.security.DefaultPasswordEncoderFactories;
import com.wisemapping.security.LegacyPasswordEncoder;
import org.hibernate.ObjectNotFoundException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -130,7 +132,14 @@ public class UserManagerImpl
public void updateUser(@NotNull User user) {
assert user != null : "user is null";
user.setPassword(passwordEncoder.encode(user.getPassword()));
// Does the password need to be encrypted ?
final String password = user.getPassword();
if(password!=null && (!password.startsWith(LegacyPasswordEncoder.ENC_PREFIX) && !password.startsWith( "{"+ DefaultPasswordEncoderFactories.ENCODING_ID)))
{
user.setPassword(passwordEncoder.encode(user.getPassword()));
}
getHibernateTemplate().update(user);
}

View File

@@ -6,7 +6,7 @@ import org.springframework.context.MessageSource;
import java.util.Locale;
abstract public class ClientException extends WiseMappingException {
private Severity severity;
private final Severity severity;
public ClientException(@NotNull String message, @NotNull Severity severity) {
super(message);

View File

@@ -18,11 +18,23 @@
package com.wisemapping.exceptions;
import com.wisemapping.service.InvalidUserEmailException;
import org.jetbrains.annotations.NotNull;
public class EmailNotExistsException
extends Exception
extends ClientException
{
public EmailNotExistsException(Exception e)
private static final String MSG_KEY = "RESET_PASSWORD_INVALID_EMAIL";
public EmailNotExistsException(@NotNull InvalidUserEmailException e)
{
super(e);
super(e.getMessage(),Severity.INFO);
}
@NotNull
@Override
protected String getMsgBundleKey() {
return MSG_KEY;
}
}

View File

@@ -1,23 +0,0 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.exceptions;
public class GoogleChromeFrameRequiredException extends Exception {
}

View File

@@ -18,7 +18,8 @@
package com.wisemapping.exceptions;
import org.jetbrains.annotations.NotNull;
import javax.validation.constraints.NotNull;
public class MapCouldNotFoundException
extends ClientException

View File

@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
public class SessionExpiredException
extends ClientException {
private static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
private User lastUpdater;
private final User lastUpdater;
public SessionExpiredException(@NotNull String debugInfo, @NotNull User lastUpdater) {
super(debugInfo, Severity.FATAL);

View File

@@ -1,23 +0,0 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.exceptions;
public class UnsupportedBrowserException extends Exception {
}

View File

@@ -34,8 +34,8 @@ public enum ExportFormat {
WISEMAPPING("application/wisemapping+xml", "wxml");
private String contentType;
private String fileExtension;
private final String contentType;
private final String fileExtension;
ExportFormat(String contentType, String fileExtension) {
this.contentType = contentType;

View File

@@ -19,7 +19,7 @@
package com.wisemapping.exporter;
public class ExportProperties {
private ExportFormat format;
private final ExportFormat format;
private String version;
public ExportFormat getFormat() {
@@ -71,7 +71,7 @@ public class ExportProperties {
public enum Size {
SMALL(100), MEDIUM(800), XMEDIUM(1024), LARGE(2048);
private int width;
private final int width;
Size(int width) {
this.width = width;

View File

@@ -24,6 +24,6 @@ import org.jetbrains.annotations.NotNull;
import java.io.OutputStream;
public interface Exporter {
public void export(@NotNull byte[] xml, @NotNull OutputStream outputStream) throws ExportException;
public void export(Mindmap map, OutputStream outputStream) throws ExportException;
void export(@NotNull byte[] xml, @NotNull OutputStream outputStream) throws ExportException;
void export(Mindmap map, OutputStream outputStream) throws ExportException;
}

View File

@@ -64,7 +64,7 @@ public class ExporterFactory {
private static final String IMAGE_NODE_NAME = "image";
private static final int MANGING = 50;
private static final String UTF_8_CHARSET_NAME = "UTF-8";
private File baseImgDir;
private final File baseImgDir;
public ExporterFactory(@NotNull final ServletContext servletContext) {
this.baseImgDir = new File(servletContext.getRealPath("/"));
@@ -157,12 +157,12 @@ public class ExporterFactory {
case FREEMIND: {
final FreemindExporter exporter = new FreemindExporter();
exporter.setVersion(new VersionNumber(properties.getVersion()));
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
exporter.export(xml.getBytes(StandardCharsets.UTF_8), output);
break;
}
case MINDJET: {
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.MINDJET);
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
exporter.export(xml.getBytes(StandardCharsets.UTF_8), output);
break;
}
default:

View File

@@ -22,15 +22,14 @@ package com.wisemapping.exporter;
import com.wisemapping.importer.VersionNumber;
import com.wisemapping.importer.freemind.FreemindConstant;
import com.wisemapping.importer.freemind.FreemindIconConverter;
import com.wisemapping.jaxb.freemind.Font;
import com.wisemapping.jaxb.freemind.*;
import com.wisemapping.jaxb.wisemap.Icon;
import com.wisemapping.jaxb.wisemap.Note;
import com.wisemapping.jaxb.wisemap.RelationshipType;
import com.wisemapping.jaxb.wisemap.TopicType;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.ShapeStyle;
import com.wisemapping.util.JAXBUtils;
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;
@@ -40,11 +39,11 @@ import javax.xml.bind.JAXBException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -214,7 +213,7 @@ public class FreemindExporter
htmlContent.append("</body></html>");
DocumentBuilder db = getInstanceBuilder();
byte[] bytes = htmlContent.toString().getBytes("UTF-8");
byte[] bytes = htmlContent.toString().getBytes(StandardCharsets.UTF_8);
Document document = db.parse(new ByteArrayInputStream(bytes), "UTF-8");
richcontent.setHtml(document.getDocumentElement());
return richcontent;
@@ -338,7 +337,7 @@ public class FreemindExporter
// 8 Normal
// 10 Large
// 15 Huge
static private Map<Integer, Integer> wiseToFreeFontSize = new HashMap<Integer, Integer>();
static private final Map<Integer, Integer> wiseToFreeFontSize = new HashMap<Integer, Integer>();
static {
wiseToFreeFontSize.put(6, 10);

View File

@@ -9,11 +9,15 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.CharArrayReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
public class XSLTExporter implements Exporter {
private Type type;
private final Type type;
public XSLTExporter(@NotNull Type type) {
this.type = type;
@@ -38,10 +42,10 @@ public class XSLTExporter implements Exporter {
final Source xslt = new StreamSource(xsltis);
Transformer transformer = factory.newTransformer(xslt);
final CharArrayReader reader = new CharArrayReader(mmos.toString("iso-8859-1").toCharArray());
final CharArrayReader reader = new CharArrayReader(mmos.toString(StandardCharsets.ISO_8859_1).toCharArray());
final Source mmSource = new StreamSource(reader);
transformer.transform(mmSource, new StreamResult(outputStream));
} catch (TransformerException | UnsupportedEncodingException e) {
} catch (TransformerException e) {
throw new ExportException(e);
}
@@ -57,7 +61,7 @@ public class XSLTExporter implements Exporter {
return new XSLTExporter(type);
}
public static enum Type {
public enum Type {
TEXT("mm2text.xsl"),
WORD("mm2wordml_utf8.xsl"),
CSV("mm2csv.xsl"),
@@ -70,7 +74,7 @@ public class XSLTExporter implements Exporter {
return xsltName;
}
private String xsltName;
private final String xsltName;
Type(@NotNull String xstFile) {
this.xsltName = xstFile;

View File

@@ -1,75 +0,0 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.filter;
import com.wisemapping.exceptions.GoogleChromeFrameRequiredException;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Set;
public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
private Set<String> exclude;
private static final String USER_AGENT = "wisemapping.user_agent";
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
final String requestUri = request.getRequestURI();
if (exclude != null && !exclude.contains(requestUri)) {
final HttpSession session = request.getSession(false);
// Try to loaded from the request ...
SupportedUserAgent userAgent = null;
if (session != null) {
userAgent = (SupportedUserAgent) session.getAttribute(USER_AGENT);
}
// I could not loaded. I will create a new one...
if (userAgent == null) {
userAgent = SupportedUserAgent.create(request);
if (session != null) {
session.setAttribute(USER_AGENT, userAgent);
}
}
return true;
// // It's a supported browser ?.
// if (!userAgent.isBrowserSupported()) {
// throw new UnsupportedBrowserException();
// }
//
// // Is a Explorer 9 or less without Google Chrome Frame ?.
// if (userAgent.needsGCF()) {
// throw new GoogleChromeFrameRequiredException();
// }
}
return true;
}
public void setExclude(Set<String> exclude) {
this.exclude = exclude;
}
}

View File

@@ -33,6 +33,12 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
@Value("${google.analytics.account}")
private String analyticsAccount;
@Value("${google.recaptcha2.enabled}")
private Boolean recaptcha2Enabled;
@Value("${google.recaptcha2.siteKey}")
private String recaptcha2SiteKey;
@Value("${google.ads.enabled}")
private Boolean adsEnabled;
@@ -50,10 +56,13 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
request.setAttribute("google.analytics.enabled", analyticsEnabled);
request.setAttribute("google.analytics.account", analyticsAccount);
request.setAttribute("google.ads.enabled", adsEnabled);
request.setAttribute("google.recaptcha2.enabled", recaptcha2Enabled);
request.setAttribute("google.recaptcha2.siteKey", recaptcha2SiteKey);
request.setAttribute("site.homepage", siteHomepage);
request.setAttribute("security.type", securityType);
// If the property could not be resolved, try to infer one from the request...
if ("${site.baseurl}".equals(siteUrl)) {
siteUrl = request.getRequestURL().toString().replace(request.getRequestURI(), request.getContextPath());

View File

@@ -18,7 +18,9 @@
package com.wisemapping.filter;
import com.wisemapping.util.*;
import com.wisemapping.util.Browser;
import com.wisemapping.util.UserAgent;
import com.wisemapping.util.Version;
import org.jetbrains.annotations.NotNull;
import javax.servlet.http.HttpServletRequest;
@@ -27,7 +29,7 @@ import java.io.Serializable;
public class SupportedUserAgent implements Serializable {
public static final String USER_AGENT_HEADER = "User-Agent";
transient private UserAgent userAgent;
private String header;
private final String header;
private SupportedUserAgent(@NotNull final String header) {
this.header = header;

View File

@@ -21,11 +21,8 @@ package com.wisemapping.filter;
import com.wisemapping.model.User;
import com.wisemapping.security.Utils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.propertyeditors.LocaleEditor;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.support.RequestContextUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@@ -24,5 +24,5 @@ import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
public interface Importer {
public Mindmap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException;
Mindmap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException;
}

View File

@@ -67,7 +67,7 @@ public class JaxbCDATAMarshaller {
final Map<Integer, Integer> sortedToUnsorted = new HashMap<Integer, Integer>();
final Map<Integer, Integer> unsortedToSorted = new HashMap<Integer, Integer>();
private Attributes delegated;
private final Attributes delegated;
SortedAttributesDecorator(final Attributes delegated) {
this.delegated = delegated;

View File

@@ -20,7 +20,8 @@ package com.wisemapping.importer;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
public class VersionNumber
implements Comparable<VersionNumber> {

View File

@@ -3,32 +3,33 @@ package com.wisemapping.importer.freemind;
import com.wisemapping.importer.VersionNumber;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
public interface FreemindConstant {
public static final String LAST_SUPPORTED_FREEMIND_VERSION = "1.0.1";
public static final VersionNumber SUPPORTED_FREEMIND_VERSION = new VersionNumber(LAST_SUPPORTED_FREEMIND_VERSION);
public static final String CODE_VERSION = "tango";
String LAST_SUPPORTED_FREEMIND_VERSION = "1.0.1";
VersionNumber SUPPORTED_FREEMIND_VERSION = new VersionNumber(LAST_SUPPORTED_FREEMIND_VERSION);
String CODE_VERSION = "tango";
public static final int SECOND_LEVEL_TOPIC_HEIGHT = 25;
public static final int ROOT_LEVEL_TOPIC_HEIGHT = SECOND_LEVEL_TOPIC_HEIGHT;
public static final int CENTRAL_TO_TOPIC_DISTANCE = 200;
public static final int TOPIC_TO_TOPIC_DISTANCE = 90;
int SECOND_LEVEL_TOPIC_HEIGHT = 25;
int ROOT_LEVEL_TOPIC_HEIGHT = SECOND_LEVEL_TOPIC_HEIGHT;
int CENTRAL_TO_TOPIC_DISTANCE = 200;
int TOPIC_TO_TOPIC_DISTANCE = 90;
public static final int FONT_SIZE_HUGE = 15;
public static final int FONT_SIZE_LARGE = 10;
public static final int FONT_SIZE_NORMAL = 8;
public static final int FONT_SIZE_SMALL = 6;
int FONT_SIZE_HUGE = 15;
int FONT_SIZE_LARGE = 10;
int FONT_SIZE_NORMAL = 8;
int FONT_SIZE_SMALL = 6;
public static final String NODE_TYPE = "NODE";
public static final String BOLD = "bold";
public static final String ITALIC = "italic";
public static final String EMPTY_FONT_STYLE = ";;;;;";
public static final String EMPTY_NOTE = "";
String NODE_TYPE = "NODE";
String BOLD = "bold";
String ITALIC = "italic";
String EMPTY_FONT_STYLE = ";;;;;";
String EMPTY_NOTE = "";
public static final String POSITION_LEFT = "left";
public static final String POSITION_RIGHT = "right";
String POSITION_LEFT = "left";
String POSITION_RIGHT = "right";
public final static Charset UTF_8_CHARSET = Charset.forName("UTF-8");
Charset UTF_8_CHARSET = StandardCharsets.UTF_8;
}

View File

@@ -18,13 +18,16 @@
package com.wisemapping.importer.freemind;
import com.wisemapping.model.IconFamily;
import com.wisemapping.model.MindmapIcon;
import com.wisemapping.model.MindmapIcons;
import com.wisemapping.model.IconFamily;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
final public class FreemindIconConverter {

View File

@@ -21,15 +21,14 @@ package com.wisemapping.importer.freemind;
import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.VersionNumber;
import com.wisemapping.jaxb.freemind.*;
import com.wisemapping.jaxb.wisemap.Link;
import com.wisemapping.jaxb.wisemap.RelationshipType;
import com.wisemapping.jaxb.wisemap.TopicType;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.ShapeStyle;
import com.wisemapping.util.JAXBUtils;
import com.wisemapping.jaxb.freemind.*;
import com.wisemapping.jaxb.freemind.Map;
import com.wisemapping.jaxb.freemind.Node;
import com.wisemapping.jaxb.wisemap.RelationshipType;
import com.wisemapping.jaxb.wisemap.TopicType;
import com.wisemapping.jaxb.wisemap.Link;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jsoup.Jsoup;
@@ -37,18 +36,23 @@ import org.jsoup.nodes.Document;
import org.w3c.dom.Element;
import javax.xml.bind.JAXBException;
import javax.xml.transform.*;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class FreemindImporter
implements Importer {
final private Logger logger = Logger.getLogger(FreemindImporter.class);
private com.wisemapping.jaxb.wisemap.ObjectFactory mindmapObjectFactory;
private java.util.Map<String, TopicType> nodesMap = null;
@@ -56,7 +60,7 @@ public class FreemindImporter
private int currentId;
public static void main(String argv[]) {
public static void main(String[] argv) {
// Now, calculate the order it belongs to ...
@@ -130,12 +134,13 @@ public class FreemindImporter
addRelationships(mindmapMap);
JAXBUtils.saveMap(mindmapMap, baos);
wiseXml = new String(baos.toByteArray(), FreemindConstant.UTF_8_CHARSET);
wiseXml = baos.toString(FreemindConstant.UTF_8_CHARSET);
result.setXmlStr(wiseXml);
result.setTitle(mapName);
result.setDescription(description);
} catch (JAXBException | TransformerException e) {
logger.debug(e);
throw new ImporterException(e);
}
return result;
@@ -314,12 +319,12 @@ public class FreemindImporter
final String endarrow = arrow.getENDARROW();
if (endarrow != null) {
relt.setEndArrow(!endarrow.toLowerCase().equals("none"));
relt.setEndArrow(!endarrow.equalsIgnoreCase("none"));
}
final String startarrow = arrow.getSTARTARROW();
if (startarrow != null) {
relt.setStartArrow(!startarrow.toLowerCase().equals("none"));
relt.setStartArrow(!startarrow.equalsIgnoreCase("none"));
}
relt.setLineType("3");
relationships.add(relt);
@@ -591,8 +596,8 @@ public class FreemindImporter
}
static private class Coord {
private int y;
private int x;
private final int y;
private final int x;
private Coord(@NotNull String pos) {
final String[] split = pos.split(",");

View File

@@ -21,7 +21,7 @@ package com.wisemapping.mail;
import com.wisemapping.util.VelocityEngineUtils;
import com.wisemapping.util.VelocityEngineWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.NotNull;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
@@ -35,9 +35,9 @@ public final class Mailer {
private JavaMailSender mailSender;
private VelocityEngineWrapper velocityEngineWrapper;
private String serverFromEmail;
private String supportEmail;
private String errorReporterEmail;
private final String serverFromEmail;
private final String supportEmail;
private final String errorReporterEmail;
//~ Methods ..............................................................................................

View File

@@ -41,7 +41,7 @@ final public class NotificationService {
@Autowired
private Mailer mailer;
private NotifierFilter notificationFilter;
private final NotifierFilter notificationFilter;
private String baseUrl;

View File

@@ -14,7 +14,7 @@ import java.util.Set;
public class NotifyingExceptionResolver extends SimpleMappingExceptionResolver {
final private Logger logger = Logger.getLogger("com.wisemapping");
final private Logger logger = Logger.getLogger(NotifyingExceptionResolver.class);
private Set<String> exclude = new HashSet<String>();
private NotificationService notificationService;

View File

@@ -111,9 +111,7 @@ public class Collaboration {
if (id != that.id) return false;
if (collaborator != null ? !collaborator.equals(that.collaborator) : that.collaborator != null) return false;
if (mindMap != null ? !mindMap.equals(that.mindMap) : that.mindMap != null) return false;
if (role != that.role) return false;
return true;
return role == that.role;
}
@Override

View File

@@ -84,9 +84,7 @@ public class Collaborator implements Serializable {
Collaborator that = (Collaborator) o;
if (id != that.getId()) return false;
if (email != null ? !email.equals(that.getEmail()) : that.getEmail() != null) return false;
return true;
return email != null ? email.equals(that.getEmail()) : that.getEmail() == null;
}
@Override
@@ -105,9 +103,7 @@ public class Collaborator implements Serializable {
if (that == null) return false;
if (id != that.getId()) return false;
if (email != null ? !email.equals(that.getEmail()) : that.getEmail() != null) return false;
return true;
return email != null ? email.equals(that.getEmail()) : that.getEmail() == null;
}

View File

@@ -27,7 +27,7 @@ public enum Font {
TAHOMA("Tahoma"),
ARIAL("Arial");
private String fontName;
private final String fontName;
Font (String name)
{

View File

@@ -18,8 +18,8 @@
package com.wisemapping.model;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
public class MindMapCriteria {
private String title;

View File

@@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -69,11 +70,7 @@ public class Mindmap {
}
public void setXmlStr(@NotNull String xml) {
try {
this.setUnzipXml(xml.getBytes(UTF_8));
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
this.setUnzipXml(xml.getBytes(StandardCharsets.UTF_8));
}
@NotNull
@@ -92,7 +89,7 @@ public class Mindmap {
@NotNull
public String getXmlStr() throws UnsupportedEncodingException {
return new String(this.getUnzipXml(), UTF_8);
return new String(this.getUnzipXml(), StandardCharsets.UTF_8);
}
@NotNull
@@ -170,7 +167,6 @@ public class Mindmap {
this.isPublic = isPublic;
}
@NotNull
public Calendar getLastModificationTime() {
return lastModificationTime;
}

View File

@@ -19,8 +19,8 @@
package com.wisemapping.model;
public class MindmapIcon implements Comparable{
private String name;
private IconFamily family;
private final String name;
private final IconFamily family;
MindmapIcon(IconFamily family, String name) {
this.name = name;

View File

@@ -20,9 +20,11 @@ package com.wisemapping.model;
import org.jetbrains.annotations.NotNull;
import java.lang.IllegalStateException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@SuppressWarnings({"UnusedDeclaration"})
public class MindmapIcons {

View File

@@ -26,7 +26,7 @@ public enum ShapeStyle
ELLIPSE("elipse"),
IMAGE("image");
private String style;
private final String style;
ShapeStyle(String style)
{

View File

@@ -77,7 +77,6 @@ public class User
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

View File

@@ -18,17 +18,16 @@
package com.wisemapping.rest;
import com.mangofactory.swagger.annotations.ApiIgnore;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestLogItem;
import com.wisemapping.rest.model.RestUser;
import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService;
import com.wisemapping.service.UserService;
import com.wordnik.swagger.annotations.Api;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +42,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Api(value="UserApi",description = "Account Account Related Objects.")
@Controller
public class AccountController extends BaseController {
@Qualifier("userService")
@@ -57,7 +55,7 @@ public class AccountController extends BaseController {
@Autowired
private NotificationService notificationService;
final Logger logger = Logger.getLogger("com.wisemapping");
final Logger logger = Logger.getLogger(AccountController.class);
@RequestMapping(method = RequestMethod.PUT, value = "account/password", consumes = {"text/plain"})
@@ -72,6 +70,12 @@ public class AccountController extends BaseController {
userService.changePassword(user);
}
@RequestMapping(method = RequestMethod.GET, value = "/account", produces = {"application/json", "application/xml"})
public RestUser fetchAccount() {
final User user = Utils.getUser(true);
return new RestUser(user);
}
@RequestMapping(method = RequestMethod.PUT, value = "account/firstname", consumes = {"text/plain"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changeFirstname(@RequestBody String firstname) {
@@ -124,7 +128,6 @@ public class AccountController extends BaseController {
}
@ApiIgnore
@RequestMapping(method = RequestMethod.POST, value = "/logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void logError(@RequestBody RestLogItem item, @NotNull HttpServletRequest request) {

View File

@@ -26,21 +26,12 @@ import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestUser;
import com.wisemapping.service.MindmapService;
import com.wisemapping.service.UserService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -49,7 +40,6 @@ import java.util.Calendar;
import java.util.List;
import java.util.regex.Pattern;
@Api(value = "AdminApi", description = "Administrative Related Objects.")
@Controller
public class AdminController extends BaseController {
@Qualifier("userService")
@@ -60,10 +50,9 @@ public class AdminController extends BaseController {
@Autowired
private MindmapService mindmapService;
@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "application/xml"})
@ResponseBody
public RestUser getUserById(@PathVariable @ApiParam(required = true, value = "User Id", allowableValues = "range[1," + Long.MAX_VALUE + "]") long id) throws IOException {
public RestUser getUserById(@PathVariable long id) throws IOException {
final User userBy = userService.getUserBy(id);
if (userBy == null) {
throw new IllegalArgumentException("User could not be found");
@@ -71,7 +60,6 @@ public class AdminController extends BaseController {
return new RestUser(userBy);
}
@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email:.+}", produces = {"application/json", "application/xml"})
@ResponseBody
public RestUser getUserByEmail(@PathVariable String email) throws IOException {
@@ -82,10 +70,9 @@ public class AdminController extends BaseController {
return new RestUser(user);
}
@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"}, produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.CREATED)
public void createUser(@RequestBody @ApiParam(required = true) RestUser user, HttpServletResponse response) throws WiseMappingException {
public void createUser(@RequestBody RestUser user, HttpServletResponse response) throws WiseMappingException {
if (user == null) {
throw new IllegalArgumentException("User could not be found");
}
@@ -108,16 +95,21 @@ public class AdminController extends BaseController {
throw new IllegalArgumentException("firstname can not be null");
}
final String password = delegated.getPassword();
if (password == null || password.isEmpty()) {
throw new IllegalArgumentException("password can not be null");
}
// Finally create the user ...
delegated.setAuthenticationType(AuthenticationType.DATABASE);
userService.createUser(delegated, false, true);
response.setHeader("Location", "/service/admin/users/" + user.getId());
}
@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = {"text/plain"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changePassword(@RequestBody @ApiParam(required = true) String password, @PathVariable @ApiParam(required = true, value = "User Id", allowableValues = "range[1," + Long.MAX_VALUE + "]") long id) throws WiseMappingException {
public void changePassword(@RequestBody String password, @PathVariable long id) throws WiseMappingException {
if (password == null) {
throw new IllegalArgumentException("Password can not be null");
}
@@ -130,7 +122,6 @@ public class AdminController extends BaseController {
userService.changePassword(user);
}
@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteUserByEmail(@PathVariable long id) throws WiseMappingException {
@@ -148,7 +139,6 @@ public class AdminController extends BaseController {
userService.removeUser(user);
}
@ApiOperation("Note: Administration permissions required.")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge")
public void purgeDB(@RequestParam(required = true) Integer minUid, @RequestParam(required = true) Integer maxUid, @RequestParam(required = true) Boolean apply) throws WiseMappingException, UnsupportedEncodingException {
@@ -202,7 +192,6 @@ public class AdminController extends BaseController {
}
}
@ApiOperation("Note: Administration permissions required.")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge/history")
public void purgeHistory(@RequestParam(required = true) Integer mapId) throws WiseMappingException, IOException {

View File

@@ -25,6 +25,7 @@ import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestErrors;
import com.wisemapping.security.Utils;
import com.wisemapping.service.RegistrationException;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +44,7 @@ import java.util.Locale;
public class BaseController {
final private Logger logger = Logger.getLogger("com.wisemapping.rest");
final private Logger logger = Logger.getLogger(BaseController.class);
@Qualifier("messageSource")
@Autowired
@@ -110,9 +111,15 @@ public class BaseController {
public RestErrors handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) {
final User user = Utils.getUser(false);
notificationService.reportJavaException(ex, user, request);
ex.printStackTrace();
logger.error(ex);
return new RestErrors(ex.getMessage(), Severity.SEVERE);
}
@ExceptionHandler(RegistrationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public RestErrors handleRegistrationErrors(@NotNull RegistrationException exception) {
return new RestErrors(exception, messageSource);
}
}

View File

@@ -18,7 +18,6 @@
package com.wisemapping.rest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
@@ -49,8 +48,8 @@ public class DebugMappingJacksonHttpMessageConverter extends MappingJackson2Http
class WrapHttpInputMessage implements HttpInputMessage {
private InputStream body;
private HttpHeaders headers;
private final InputStream body;
private final HttpHeaders headers;
WrapHttpInputMessage(InputStream is, HttpHeaders headers) {
this.body = is;

View File

@@ -1,18 +1,13 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.LabelCouldNotFoundException;
import com.wisemapping.exceptions.MapCouldNotFoundException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.Label;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestLabel;
import com.wisemapping.rest.model.RestLabelList;
import com.wisemapping.rest.model.RestMindmapInfo;
import com.wisemapping.rest.model.RestMindmapList;
import com.wisemapping.security.Utils;
import com.wisemapping.service.LabelService;
import com.wisemapping.service.MindmapService;
import com.wisemapping.validator.LabelValidator;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,12 +16,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

View File

@@ -18,41 +18,16 @@
package com.wisemapping.rest;
import com.mangofactory.swagger.annotations.ApiIgnore;
import com.wisemapping.exceptions.ImportUnexpectedException;
import com.wisemapping.exceptions.LabelCouldNotFoundException;
import com.wisemapping.exceptions.MapCouldNotFoundException;
import com.wisemapping.exceptions.MultipleSessionsOpenException;
import com.wisemapping.exceptions.SessionExpiredException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.exceptions.*;
import com.wisemapping.importer.ImportFormat;
import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.ImporterFactory;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.CollaborationProperties;
import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.Label;
import com.wisemapping.model.MindMapHistory;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestCollaboration;
import com.wisemapping.rest.model.RestCollaborationList;
import com.wisemapping.rest.model.RestLabel;
import com.wisemapping.rest.model.RestMindmap;
import com.wisemapping.rest.model.RestMindmapHistory;
import com.wisemapping.rest.model.RestMindmapHistoryList;
import com.wisemapping.rest.model.RestMindmapInfo;
import com.wisemapping.rest.model.RestMindmapList;
import com.wisemapping.model.*;
import com.wisemapping.rest.model.*;
import com.wisemapping.security.Utils;
import com.wisemapping.service.CollaborationException;
import com.wisemapping.service.LabelService;
import com.wisemapping.service.LockInfo;
import com.wisemapping.service.LockManager;
import com.wisemapping.service.MindmapService;
import com.wisemapping.service.*;
import com.wisemapping.validator.MapInfoValidator;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiParam;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,32 +36,20 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Api(value = "mindmap", description = "User Mindmap Objects.")
@Controller
public class MindmapController extends BaseController {
final Logger logger = Logger.getLogger("com.wisemapping");
final Logger logger = Logger.getLogger(MindmapController.class);
private static final String LATEST_HISTORY_REVISION = "latest";
@@ -118,14 +81,13 @@ public class MindmapController extends BaseController {
return new ModelAndView("transformViewWise", values);
}
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm","version"})
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"})
@ResponseBody
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id, @RequestParam(value = "version") String version) throws IOException, MapCouldNotFoundException {
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException, MapCouldNotFoundException {
final Mindmap mindMap = findMindmapById(id);
final Map<String, Object> values = new HashMap<String, Object>();
values.put("content", mindMap.getXmlStr());
values.put("filename", mindMap.getTitle());
values.put("version", version);
return new ModelAndView("transformViewFreemind", values);
}
@@ -257,7 +219,6 @@ public class MindmapController extends BaseController {
return result;
}
@ApiIgnore
@RequestMapping(method = RequestMethod.GET, value = {"/maps/{id}/document/xml", "/maps/{id}/document/xml-pub"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"})
@ResponseBody
public byte[] retrieveDocument(@PathVariable int id, @NotNull HttpServletResponse response) throws WiseMappingException, IOException {
@@ -267,7 +228,6 @@ public class MindmapController extends BaseController {
return xmlStr.getBytes(StandardCharsets.UTF_8);
}
@ApiIgnore
@RequestMapping(method = RequestMethod.PUT, value = {"/maps/{id}/document/xml"}, consumes = {"text/plain"})
@ResponseBody
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException, IOException {
@@ -395,7 +355,7 @@ public class MindmapController extends BaseController {
mindmapService.updateMindmap(mindMap, false);
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"})
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/collabs/", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException {
final Mindmap mindMap = findMindmapById(id);
@@ -435,6 +395,57 @@ public class MindmapController extends BaseController {
}
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs/", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException {
final Mindmap mindMap = findMindmapById(id);
// Only owner can change collaborators...
final User user = Utils.getUser();
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
throw new IllegalArgumentException("No enough permissions");
}
// Has any role changed ?. Just removed it.
final Map<String, Collaboration> mapsByEmail = mindMap
.getCollaborations()
.stream()
.collect(Collectors.toMap(collaboration -> collaboration.getCollaborator().getEmail(), collaboration -> collaboration));
restCollabs
.getCollaborations()
.forEach(collab->{
final String email = collab.getEmail();
if(mapsByEmail.containsKey(email)){
try {
mindmapService.removeCollaboration(mindMap, mapsByEmail.get(email));
} catch (CollaborationException e) {
logger.error(e);
}
}
});
// Great, let's add all the collabs again ...
for (RestCollaboration restCollab : restCollabs.getCollaborations()) {
final Collaboration collaboration = mindMap.findCollaboration(restCollab.getEmail());
// Validate role format ...
String roleStr = restCollab.getRole();
if (roleStr == null) {
throw new IllegalArgumentException(roleStr + " is not a valid role");
}
// Is owner ?
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
if (role == CollaborationRole.OWNER) {
throw new IllegalArgumentException("Owner can not be added as part of the collaboration list.");
}
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role, restCollabs.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "application/xml"})
public RestCollaborationList retrieveList(@PathVariable int id) throws MapCouldNotFoundException {
final Mindmap mindMap = findMindmapById(id);
@@ -489,10 +500,36 @@ public class MindmapController extends BaseController {
mindmapService.removeMindmap(mindmap, user);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}/collabs")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteCollabByEmail(@PathVariable int id, @RequestParam(required = false) String email) throws IOException, WiseMappingException {
logger.debug("Deleting permission for email:" + email);
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
// Only owner can change collaborators...
if (!mindmap.hasPermissions(user, CollaborationRole.OWNER)) {
throw new IllegalArgumentException("No enough permissions");
}
final Collaboration collab = mindmap.findCollaboration(email);
if(collab!=null) {
CollaborationRole role = collab.getRole();
// Owner collab can not be removed ...
if (role == CollaborationRole.OWNER) {
throw new IllegalArgumentException("Can not remove owner collab");
}
mindmapService.removeCollaboration(mindmap, collab);
}
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/starred", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateStarredState(@RequestBody @ApiParam(defaultValue = "false", allowableValues = "true,false") String value, @PathVariable int id) throws WiseMappingException {
public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
logger.debug("Update starred:" + value);
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
@@ -506,7 +543,6 @@ public class MindmapController extends BaseController {
mindmapService.updateCollaboration(user, collaboration);
}
@ApiIgnore
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateMapLock(@RequestBody String value, @PathVariable int id) throws IOException, WiseMappingException {
@@ -522,12 +558,11 @@ public class MindmapController extends BaseController {
}
}
@ApiIgnore
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void batchDelete(@RequestParam(required = true) String ids) throws IOException, WiseMappingException {
public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException {
final User user = Utils.getUser();
final String[] mapsIds = ",".split(ids);
final String[] mapsIds = ids.split(",");
for (final String mapId : mapsIds) {
final Mindmap mindmap = findMindmapById(Integer.parseInt(mapId));
mindmapService.removeMindmap(mindmap, user);
@@ -536,7 +571,11 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json", "application/wisemapping+xml"})
@ResponseStatus(value = HttpStatus.CREATED)
public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
public void createMap(@RequestBody(required = false) RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
// If a default maps has not been defined, just create one ...
if(restMindmap==null){
restMindmap = new RestMindmap();
}
// Overwrite title and description if they where specified by parameter.
if (title != null && !title.isEmpty()) {
@@ -544,6 +583,8 @@ public class MindmapController extends BaseController {
}
if (description != null && !description.isEmpty()) {
restMindmap.setDescription(description);
}else {
restMindmap.setDescription("");
}
// Validate ...

View File

@@ -33,24 +33,28 @@ public abstract class MindmapFilter {
return true;
}
};
public static final MindmapFilter MY_MAPS = new MindmapFilter("my_maps") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return mindmap.getCreator().identityEquality(user);
}
};
public static final MindmapFilter STARRED = new MindmapFilter("starred") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return mindmap.isStarred(user);
}
};
public static final MindmapFilter SHARED_WITH_ME = new MindmapFilter("shared_with_me") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return !MY_MAPS.accept(mindmap, user);
}
};
public static final MindmapFilter PUBLIC = new MindmapFilter("public") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
@@ -59,7 +63,7 @@ public abstract class MindmapFilter {
};
protected String id;
private static MindmapFilter[] values = {ALL, MY_MAPS, PUBLIC, STARRED, SHARED_WITH_ME};
private static final MindmapFilter[] values = {ALL, MY_MAPS, PUBLIC, STARRED, SHARED_WITH_ME};
private MindmapFilter(@NotNull String id) {
this.id = id;

View File

@@ -24,7 +24,10 @@ import com.wisemapping.exporter.ExportProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
@@ -107,7 +110,7 @@ public class TransformerController extends BaseController {
// Obtains transformation type based on the last part of the URL ...
final String requestURI = request.getRequestURI();
final String format = requestURI.substring(requestURI.lastIndexOf(".") + 1, requestURI.length());
final String format = requestURI.substring(requestURI.lastIndexOf(".") + 1);
final ExportFormat exportFormat = ExportFormat.valueOf(format.toUpperCase());
ModelAndView result;
@@ -124,9 +127,6 @@ public class TransformerController extends BaseController {
case SVG:
result = this.transformSvg(svg);
break;
case FREEMIND:
result = this.transformFreemind(mapXml);
break;
default:
throw new IllegalArgumentException("Unsupported export format");

View File

@@ -0,0 +1,119 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.rest;
import com.wisemapping.exceptions.EmailNotExistsException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestUserRegistration;
import com.wisemapping.service.*;
import com.wisemapping.validator.Messages;
import com.wisemapping.validator.UserValidator;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Controller
@CrossOrigin
public class UserController extends BaseController {
@Qualifier("userService")
@Autowired
private UserService userService;
@Autowired
private RecaptchaService captchaService;
@Value("${google.recaptcha2.enabled}")
private Boolean recatchaEnabled;
private static final Logger logger = Logger.getLogger(UserController.class);
private static final String REAL_IP_ADDRESS_HEADER = "X-Real-IP";
@RequestMapping(method = RequestMethod.POST, value = "/users", produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.CREATED)
public void registerUser(@RequestBody RestUserRegistration registration, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws WiseMappingException, BindException {
logger.info("Register new user:" + registration.getEmail());
// If tomcat is behind a reverse proxy, ip needs to be found in other header.
String remoteIp = request.getHeader(REAL_IP_ADDRESS_HEADER);
if(remoteIp==null || remoteIp.isEmpty()){
remoteIp = request.getRemoteAddr();
}
logger.debug("Remote address" + remoteIp);
verify(registration, remoteIp);
final User user = new User();
user.setEmail(registration.getEmail().trim());
user.setFirstname(registration.getFirstname());
user.setLastname(registration.getLastname());
user.setPassword(registration.getPassword());
user.setAuthenticationType(AuthenticationType.DATABASE);
userService.createUser(user, false, true);
response.setHeader("Location", "/service/users/" + user.getId());
}
@RequestMapping(method = RequestMethod.PUT, value = "/users/resetPassword", produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.OK)
public void resetPassword(@RequestParam String email) throws InvalidAuthSchemaException, EmailNotExistsException {
try {
userService.resetPassword(email);
}catch (InvalidUserEmailException e){
throw new EmailNotExistsException(e);
}
}
private void verify(@NotNull final RestUserRegistration registration, @NotNull String remoteAddress) throws BindException {
final BindException errors = new RegistrationException(registration, "registration");
final UserValidator validator = new UserValidator();
validator.setUserService(userService);
validator.validate(registration, errors);
// If captcha is enabled, generate it ...
if (recatchaEnabled) {
final String recaptcha = registration.getRecaptcha();
if (recaptcha != null) {
final String reCaptchaResponse = captchaService.verifyRecaptcha(remoteAddress,recaptcha);
if (!reCaptchaResponse.isEmpty()) {
errors.rejectValue("recaptcha", reCaptchaResponse);
}
} else {
errors.rejectValue("recaptcha", Messages.CAPTCHA_LOADING_ERROR);
}
}else {
logger.warn("captchaEnabled is enabled.Recommend to enable it for production environments.");
}
if (errors.hasErrors()) {
throw errors;
}
}
}

View File

@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.validation.Errors;
public class ValidationException extends WiseMappingException{
private Errors errors;
private final Errors errors;
public ValidationException(@NotNull Errors errors) {
super("Validation Exceptions:"+errors);

View File

@@ -26,9 +26,10 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "collaboration")
@XmlRootElement(name = "collaborations")
@XmlAccessorType(XmlAccessType.PROPERTY)
@JsonAutoDetect(
fieldVisibility = JsonAutoDetect.Visibility.NONE,

View File

@@ -39,7 +39,7 @@ import java.util.Calendar;
public class RestCollaborator {
@JsonIgnore
private Collaborator collaborator;
private final Collaborator collaborator;
public RestCollaborator(@NotNull Collaborator collaborator) {

View File

@@ -80,13 +80,13 @@ public class RestErrors {
public RestErrors(@NotNull String errorMsg, @NotNull Severity severity, @Nullable String debugInfo) {
this._debugInfo = debugInfo;
this.gErrors = new ArrayList<String>();
this.gErrors = new ArrayList<>();
this.gErrors.add(errorMsg);
this.gSeverity = severity;
}
private List<String> processGlobalErrors(@NotNull Errors errors) {
final List<String> result = new ArrayList<String>();
final List<String> result = new ArrayList<>();
final List<ObjectError> globalErrors = errors.getGlobalErrors();
for (ObjectError globalError : globalErrors) {
result.add(globalError.getObjectName());
@@ -100,7 +100,7 @@ public class RestErrors {
public Map<String, String> getFieldErrors() {
Locale locale = LocaleContextHolder.getLocale();
final Map<String, String> result = new HashMap<String, String>();
final Map<String, String> result = new HashMap<>();
if (errors != null) {
final List<FieldError> fieldErrors = errors.getFieldErrors();
for (FieldError fieldError : fieldErrors) {

View File

@@ -26,7 +26,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
public class RestLabel {
@JsonIgnore
private Label label;
private final Label label;
public RestLabel() {
this(new Label());

View File

@@ -23,11 +23,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.CollaborationProperties;
import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.model.*;
import com.wisemapping.util.TimeUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,9 +45,9 @@ import java.util.Calendar;
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestMindmap {
@JsonIgnore
private Collaborator collaborator;
private final Collaborator collaborator;
@JsonIgnore
private Mindmap mindmap;
private final Mindmap mindmap;
@Nullable
private String properties;

View File

@@ -44,10 +44,10 @@ import java.util.TimeZone;
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestMindmapHistory {
static private SimpleDateFormat sdf;
private int id;
private Calendar creation;
private String creator;
static private final SimpleDateFormat sdf;
private final int id;
private final Calendar creation;
private final String creator;
static {
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

View File

@@ -37,7 +37,7 @@ import java.util.List;
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
public class RestMindmapHistoryList {
private List<RestMindmapHistory> changes;
private final List<RestMindmapHistory> changes;
public RestMindmapHistoryList() {
changes = new ArrayList<RestMindmapHistory>();

View File

@@ -22,11 +22,7 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.Label;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.model.*;
import com.wisemapping.security.Utils;
import com.wisemapping.util.TimeUtils;
import org.jetbrains.annotations.NotNull;
@@ -39,7 +35,7 @@ import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.Set;
@XmlRootElement(name = "map")
@XmlRootElement(name = "mapinfo")
@XmlAccessorType(XmlAccessType.PROPERTY)
@JsonAutoDetect(
fieldVisibility = JsonAutoDetect.Visibility.NONE,
@@ -51,8 +47,8 @@ import java.util.Set;
public class RestMindmapInfo {
@JsonIgnore
private Mindmap mindmap;
private Collaborator collaborator;
private final Mindmap mindmap;
private final Collaborator collaborator;
public RestMindmapInfo() {
this(new Mindmap(), null);
@@ -152,7 +148,7 @@ public class RestMindmapInfo {
public void setLastModificationTime(String value) {
}
public boolean isPublic() {
public boolean getPublic() {
return mindmap.isPublic();
}

View File

@@ -19,9 +19,9 @@
package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.Mindmap;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import org.jetbrains.annotations.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
@@ -29,7 +29,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -44,7 +43,7 @@ public class RestMindmapList {
private List<RestMindmapInfo> mindmapsInfo;
public RestMindmapList() {
this(Collections.<Mindmap>emptyList(), null);
this(Collections.emptyList(), null);
}
public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {

View File

@@ -22,6 +22,7 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
@@ -29,7 +30,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Calendar;
import java.util.Set;
@XmlRootElement(name = "user")
@@ -39,9 +39,10 @@ import java.util.Set;
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestUser {
private User user;
private final User user;
private String password;
public RestUser() {
@@ -50,20 +51,14 @@ public class RestUser {
public RestUser(@NotNull User user) {
this.user = user;
this.password = user.getPassword();
}
@JsonIgnore
public Calendar getCreationDate() {
return user.getCreationDate();
}
public void setTags(Set<String> tags) {
user.setTags(tags);
}
public Set<String> getTags() {
return user.getTags();
public String getLocale() {
return user.getLocale();
}
public String getFirstname() {
@@ -104,7 +99,7 @@ public class RestUser {
}
public String getPassword() {
return this.password;
return password;
}
@JsonIgnore

View File

@@ -0,0 +1,76 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.model.User;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "user")
@XmlAccessorType(XmlAccessType.PROPERTY)
@JsonAutoDetect(
fieldVisibility = JsonAutoDetect.Visibility.NONE,
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestUserRegistration {
private String email;
private String firstname;
private String lastname;
private String password;
private String recaptcha;
@JsonIgnore
public User build() {
final User user = new User();
user.setFirstname(firstname);
user.setLastname(lastname);
user.setEmail(email);
user.setPassword(password);
return user;
}
public String getEmail() {
return email;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
public String getPassword() {
return password;
}
public String getRecaptcha() {
return recaptcha;
}
}

View File

@@ -32,12 +32,13 @@ import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
public class ImportTransformationView extends AbstractView {
private String contentType;
private Importer importer;
private final String contentType;
private final Importer importer;
public ImportTransformationView(@NotNull final String contentType) throws ImporterException {
ImporterFactory exporterFactory = ImporterFactory.getInstance();
@@ -51,7 +52,7 @@ public class ImportTransformationView extends AbstractView {
final String filename = (String) viewMap.get("filename");
// Convert to map ...
final InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
final InputStream is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
final Mindmap mindMap = importer.importMap("filename", "filename", is);
// Set file name...:http://stackoverflow.com/questions/5325322/java-servlet-download-filename-special-characters/13359949#13359949

View File

@@ -41,9 +41,9 @@ public class TransformView extends AbstractView {
@NonNls
private static final String DEFAULT_ENCODING = "UTF-8";
private String contentType;
private ExportFormat exportFormat;
private NotificationService notificationService;
private final String contentType;
private final ExportFormat exportFormat;
private final NotificationService notificationService;
@Autowired
private Jaxb2Marshaller jaxbMarshaller;

View File

@@ -13,7 +13,7 @@ import java.io.IOException;
public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
private RequestCache cache;
private final RequestCache cache;
public AuthenticationSuccessHandler() {
cache = new HttpSessionRequestCache();

View File

@@ -9,7 +9,7 @@ import java.util.Map;
public class DefaultPasswordEncoderFactories {
private static final String ENCODING_ID = "bcrypt";
public static final String ENCODING_ID = "bcrypt";
static PasswordEncoder createDelegatingPasswordEncoder() {

View File

@@ -22,27 +22,16 @@ import org.apache.log4j.Logger;
import org.springframework.security.crypto.codec.Base64;
import org.springframework.security.crypto.codec.Hex;
import org.springframework.security.crypto.codec.Utf8;
import org.springframework.security.crypto.password.MessageDigestPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.util.Assert;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.springframework.security.crypto.codec.Base64;
import org.springframework.security.crypto.codec.Hex;
import org.springframework.security.crypto.codec.Utf8;
import org.springframework.util.Assert;
public class LegacyPasswordEncoder implements PasswordEncoder {
final private static Logger logger = Logger.getLogger("com.wisemapping.security.LegacyPasswordEncoder");
final private static Logger logger = Logger.getLogger(LegacyPasswordEncoder.class);
private static final String ENC_PREFIX = "ENC:";
public static final String ENC_PREFIX = "ENC:";
private final ShaPasswordEncoder sha1Encoder = new ShaPasswordEncoder();
@Override
@@ -67,7 +56,7 @@ public class LegacyPasswordEncoder implements PasswordEncoder {
class ShaPasswordEncoder {
private final String algorithm;
private boolean encodeHashAsBase64;
private final boolean encodeHashAsBase64;
/**

View File

@@ -27,8 +27,8 @@ import java.util.ArrayList;
import java.util.Collection;
public class UserDetails implements org.springframework.security.core.userdetails.UserDetails {
private com.wisemapping.model.User user;
private boolean isAdmin;
private final com.wisemapping.model.User user;
private final boolean isAdmin;
public UserDetails(@NotNull final com.wisemapping.model.User user, boolean isAdmin) {
this.user = user;

View File

@@ -18,13 +18,12 @@
package com.wisemapping.security.aop;
import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService;
import com.wisemapping.service.MindmapServiceImpl;
import org.aopalliance.intercept.MethodInvocation;
import org.jetbrains.annotations.Nullable;

View File

@@ -21,7 +21,6 @@ package com.wisemapping.security.aop;
import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jetbrains.annotations.NotNull;

View File

@@ -18,11 +18,11 @@
package com.wisemapping.security.aop;
import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -18,8 +18,8 @@
package com.wisemapping.service;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class HibernateAppListener implements ServletContextListener {

View File

@@ -17,7 +17,7 @@ public interface LabelService {
@Nullable
Label getLabelById(int id, @NotNull final User user);
public Label getLabelByTitle(@NotNull String title, @NotNull final User user);
Label getLabelByTitle(@NotNull String title, @NotNull final User user);
void removeLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
}

View File

@@ -28,7 +28,7 @@ public class LockInfo {
final private User user;
private Calendar timeout;
private long session;
private static int EXPIRATION_MIN = 30;
private static final int EXPIRATION_MIN = 30;
private long timestamp = -1;
private long previousTimestamp;

View File

@@ -50,7 +50,7 @@ class LockManagerImpl implements LockManager {
public static final int ONE_MINUTE_MILLISECONDS = 1000 * 60;
final Map<Integer, LockInfo> lockInfoByMapId;
final static Timer expirationTimer = new Timer();
final private static Logger logger = Logger.getLogger("com.wisemapping.service.LockManager");
final private static Logger logger = Logger.getLogger(LockManagerImpl.class);
@Override
public boolean isLocked(@NotNull Mindmap mindmap) {

View File

@@ -18,8 +18,8 @@
package com.wisemapping.service;
import com.wisemapping.model.*;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,7 +28,7 @@ import java.util.List;
public interface MindmapService {
static final String TAG_SEPARATOR = " ";
String TAG_SEPARATOR = " ";
@Nullable
Mindmap findMindmapById(int id);

View File

@@ -7,6 +7,7 @@ import org.apache.http.client.fluent.Form;
import org.apache.http.client.fluent.Request;
import org.apache.log4j.Logger;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
@@ -22,21 +23,20 @@ public class RecaptchaService {
private final static ObjectMapper objectMapper = new ObjectMapper();
private String recaptchaSecret;
public String verifyRecaptcha(String ip, String recaptchaResponse) {
public String verifyRecaptcha(@NotNull String ip, @NotNull String recaptcha) {
final List<NameValuePair> build = Form.form()
.add("secret", recaptchaSecret)
.add("response", recaptchaResponse)
.add("response", recaptcha)
.add("remoteip", ip)
.build();
// Add logs ...
logger.debug("Response from remoteip: " + ip);
logger.debug("Response from recaptchaSecret: " + recaptchaSecret);
logger.debug("Response from recaptchaResponse: " + recaptchaResponse);
logger.debug("Response from recaptcha: " + recaptcha);
String result = StringUtils.EMPTY;
HashMap bodyJson;
try {
final byte[] body = Request
.Post(GOOGLE_RECAPTCHA_VERIFY_URL)
@@ -45,16 +45,13 @@ public class RecaptchaService {
.returnContent()
.asBytes();
bodyJson = objectMapper
.readValue(body, HashMap.class);
final Map responseBody = objectMapper.readValue(body, HashMap.class);
logger.warn("Response from recaptcha after parse: " + responseBody);
logger.debug("Response from recaptcha after parse: " + bodyJson);
final Boolean success = (Boolean) bodyJson.get("success");
if (!success) {
final List<String> errorCodes = (List<String>) bodyJson
.get("error-codes");
result = RecaptchaUtil.RECAPTCHA_ERROR_CODE.get(errorCodes.get(0));
final Boolean success = (Boolean) responseBody.get("success");
if (success!=null && !success) {
final List<String> errorCodes = (List<String>) responseBody.get("error-codes");
result = RecaptchaUtil.codeToDescription(errorCodes.get(0));
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
@@ -73,9 +70,14 @@ public class RecaptchaService {
class RecaptchaUtil {
static final Map<String, String>
private static final Map<String, String>
RECAPTCHA_ERROR_CODE = new HashMap<>();
static String codeToDescription(final String code)
{
return RECAPTCHA_ERROR_CODE.getOrDefault(code,"Unexpected error validating code. Please, refresh the page and try again.");
}
static {
RECAPTCHA_ERROR_CODE.put("missing-input-secret",
"The secret parameter is missing");
@@ -87,5 +89,7 @@ class RecaptchaUtil {
"The response parameter is invalid or malformed");
RECAPTCHA_ERROR_CODE.put("bad-request",
"The request is invalid or malformed");
RECAPTCHA_ERROR_CODE.put("timeout-or-duplicate",
"Please, refresh the page and try again.");
}
}

View File

@@ -0,0 +1,9 @@
package com.wisemapping.service;
import org.springframework.validation.BindException;
public class RegistrationException extends BindException {
public RegistrationException(Object target, String objectName) {
super(target, objectName);
}
}

View File

@@ -18,29 +18,29 @@
package com.wisemapping.service;
import com.wisemapping.model.User;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
public interface UserService {
public void activateAccount(long code) throws InvalidActivationCodeException;
void activateAccount(long code) throws InvalidActivationCodeException;
public User createUser(@NotNull User user, boolean emailConfirmEnabled,boolean welcomeEmail) throws WiseMappingException;
User createUser(@NotNull User user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException;
public void changePassword(@NotNull User user);
void changePassword(@NotNull User user);
public User getUserBy(String email);
User getUserBy(String email);
public User getUserBy(long id);
User getUserBy(long id);
public void updateUser(User user);
void updateUser(User user);
public void resetPassword(@NotNull String email) throws InvalidUserEmailException, InvalidAuthSchemaException;
void resetPassword(@NotNull String email) throws InvalidUserEmailException, InvalidAuthSchemaException;
public void removeUser(@NotNull User user);
void removeUser(@NotNull User user);
public void auditLogin(@NotNull User user);
void auditLogin(@NotNull User user);
public User getCasUserBy(String uid);
User getCasUserBy(String uid);
}

View File

@@ -78,7 +78,7 @@ public class UserServiceImpl
private String randomstring(int lo, int hi) {
int n = rand(lo, hi);
byte b[] = new byte[n];
byte[] b = new byte[n];
for (int i = 0; i < n; i++)
b[i] = (byte) rand('@', 'Z');
return new String(b);

View File

@@ -84,8 +84,8 @@ public enum Application {
private final ApplicationType applicationType;
private final Manufacturer manufacturer;
private Application(Manufacturer manufacturer, int versionId, String name,
String[] aliases, ApplicationType applicationType) {
Application(Manufacturer manufacturer, int versionId, String name,
String[] aliases, ApplicationType applicationType) {
this.id = (short) ((manufacturer.getId() << 8) + (byte) versionId);
this.name = name;
this.aliases = aliases;

View File

@@ -50,9 +50,9 @@ public enum ApplicationType {
WEBMAIL("Webmail client"),
UNKNOWN("unknown");
private String name;
private final String name;
private ApplicationType(String name) {
ApplicationType(String name) {
this.name = name;
}

View File

@@ -168,10 +168,10 @@ public enum Browser {
private final Manufacturer manufacturer;
private final RenderingEngine renderingEngine;
private final Browser parent;
private List<Browser> children;
private final List<Browser> children;
private Pattern versionRegEx;
private Browser(Manufacturer manufacturer, Browser parent, int versionId, String name, String[] aliases, String[] exclude, BrowserType browserType, RenderingEngine renderingEngine, String versionRegexString) {
Browser(Manufacturer manufacturer, Browser parent, int versionId, String name, String[] aliases, String[] exclude, BrowserType browserType, RenderingEngine renderingEngine, String versionRegexString) {
this.id = (short) ((manufacturer.getId() << 8) + (byte) versionId);
this.name = name;
this.parent = parent;

View File

@@ -70,9 +70,9 @@ public enum BrowserType {
TOOL("Downloading tool"),
UNKNOWN("unknown");
private String name;
private final String name;
private BrowserType(String name) {
BrowserType(String name) {
this.name = name;
}

View File

@@ -60,7 +60,7 @@ public enum DeviceType {
String name;
private DeviceType(String name) {
DeviceType(String name) {
this.name = name;
}

View File

@@ -123,7 +123,7 @@ public enum Manufacturer {
private final byte id;
private final String name;
private Manufacturer(int id, String name) {
Manufacturer(int id, String name) {
this.id = (byte) id;
this.name = name;
}

View File

@@ -148,11 +148,11 @@ public enum OperatingSystem {
private final Manufacturer manufacturer;
private final DeviceType deviceType;
private final OperatingSystem parent;
private List<OperatingSystem> children;
private final List<OperatingSystem> children;
private Pattern versionRegEx;
private OperatingSystem(Manufacturer manufacturer, OperatingSystem parent, int versionId, String name, String[] aliases,
String[] exclude, DeviceType deviceType, String versionRegexString) {
OperatingSystem(Manufacturer manufacturer, OperatingSystem parent, int versionId, String name, String[] aliases,
String[] exclude, DeviceType deviceType, String versionRegexString) {
this.manufacturer = manufacturer;
this.parent = parent;
this.children = new ArrayList<OperatingSystem>();

View File

@@ -78,7 +78,7 @@ public enum RenderingEngine {
String name;
private RenderingEngine(String name) {
RenderingEngine(String name) {
this.name = name;
}

View File

@@ -8,7 +8,7 @@ import java.util.TimeZone;
final public class TimeUtils
{
private static SimpleDateFormat sdf;
private static final SimpleDateFormat sdf;
static {
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));

View File

@@ -215,11 +215,8 @@ public class UserAgent {
if (id != other.id)
return false;
if (operatingSystem == null) {
if (other.operatingSystem != null)
return false;
} else if (!operatingSystem.equals(other.operatingSystem))
return false;
return true;
return other.operatingSystem == null;
} else return operatingSystem.equals(other.operatingSystem);
}
}

View File

@@ -2,10 +2,11 @@ package com.wisemapping.util;
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import org.jetbrains.annotations.NotNull;
public class VelocityEngineWrapper {
private VelocityEngine velocityEngine;
private final VelocityEngine velocityEngine;
public VelocityEngineWrapper() {
ExtendedProperties extendedProperties = new ExtendedProperties();
@@ -15,6 +16,12 @@ public class VelocityEngineWrapper {
this.velocityEngine = new VelocityEngine();
velocityEngine.setExtendedProperties(extendedProperties);
// Configure velocity to use log4j.
velocityEngine.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
velocityEngine.setProperty("runtime.log.logsystem.log4j.category", "org.apache.velocity");
}
@NotNull

View File

@@ -104,11 +104,8 @@ public class Version {
} else if (!minorVersion.equals(other.minorVersion))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
return other.version == null;
} else return version.equals(other.version);
}

View File

@@ -18,9 +18,9 @@
package com.wisemapping.validator;
import com.wisemapping.model.Constants;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.model.Constants;
import com.wisemapping.service.MindmapService;
import com.wisemapping.view.MindMapInfoBean;
import org.jetbrains.annotations.NotNull;

View File

@@ -25,6 +25,6 @@ public interface Messages {
String IMPORT_MAP_ERROR = "IMPORT_MAP_ERROR";
String MAP_TITLE_ALREADY_EXISTS = "MAP_TITLE_ALREADY_EXISTS";
String LABEL_TITLE_ALREADY_EXISTS = "LABEL_TITLE_ALREADY_EXISTS";
String PASSWORD_MISSMATCH = "PASSWORD_MISSMATCH";
String PASSWORD_MISMATCH = "PASSWORD_MISMATCH";
String CAPTCHA_LOADING_ERROR = "CAPTCHA_LOADING_ERROR";
}

View File

@@ -18,10 +18,10 @@
package com.wisemapping.validator;
import com.wisemapping.service.RecaptchaService;
import com.wisemapping.model.Constants;
import com.wisemapping.rest.model.RestUserRegistration;
import com.wisemapping.service.UserService;
import com.wisemapping.view.UserBean;
import com.wisemapping.model.Constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.validation.Errors;
@@ -32,15 +32,12 @@ public class UserValidator
implements Validator {
private UserService userService;
private RecaptchaService captchaService;
public boolean supports(final Class clazz) {
return clazz.equals(UserBean.class);
}
public void validate(@Nullable Object obj, @NotNull Errors errors) {
UserBean user = (UserBean) obj;
RestUserRegistration user = (RestUserRegistration) obj;
if (user == null) {
errors.rejectValue("user", "error.not-specified");
} else {
@@ -59,7 +56,6 @@ public class UserValidator
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstname", Messages.FIELD_REQUIRED);
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastname", Messages.FIELD_REQUIRED);
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", Messages.FIELD_REQUIRED);
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "retypePassword", Messages.FIELD_REQUIRED);
ValidatorUtils.rejectIfExceeded(errors,
"firstname",
"The firstname must have less than " + Constants.MAX_USER_FIRSTNAME_LENGTH + " characters.",
@@ -75,28 +71,10 @@ public class UserValidator
"The password must have less than " + Constants.MAX_USER_PASSWORD_LENGTH + " characters.",
user.getPassword(),
Constants.MAX_USER_PASSWORD_LENGTH);
ValidatorUtils.rejectIfExceeded(errors,
"retypePassword",
"The retypePassword must have less than " + Constants.MAX_USER_PASSWORD_LENGTH + " characters.",
user.getRetypePassword(),
Constants.MAX_USER_PASSWORD_LENGTH);
final String password = user.getPassword();
if (password != null && !password.equals(user.getRetypePassword())) {
errors.rejectValue("password", Messages.PASSWORD_MISSMATCH);
}
}
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public void setCaptchaService(@NotNull final RecaptchaService captchaService) {
this.captchaService = captchaService;
}
public RecaptchaService getCaptchaService() {
return captchaService;
}
}

View File

@@ -22,13 +22,13 @@ import org.jetbrains.annotations.Nullable;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
final public class Utils {
//Set the email emailPattern string
static private Pattern emailPattern = Pattern.compile(".+@.+\\.[a-z]+");
static private final Pattern emailPattern = Pattern.compile(".+@.+\\.[a-z]+");
private Utils() {

View File

@@ -23,9 +23,9 @@ import com.wisemapping.model.Collaborator;
import com.wisemapping.model.User;
public class CollaboratorBean {
private CollaborationRole collaborationRole;
private boolean isUser;
private Collaborator collaborator;
private final CollaborationRole collaborationRole;
private final boolean isUser;
private final Collaborator collaborator;
public CollaboratorBean(Collaborator collaborator, CollaborationRole role) {
this.collaborator = collaborator;

View File

@@ -31,10 +31,10 @@ import java.util.List;
import java.util.Set;
public class MindMapBean {
private Mindmap mindmap;
private List<CollaboratorBean> viewers;
private List<CollaboratorBean> collaborators;
private Collaborator collaborator;
private final Mindmap mindmap;
private final List<CollaboratorBean> viewers;
private final List<CollaboratorBean> collaborators;
private final Collaborator collaborator;
public MindMapBean(@NotNull final Mindmap mindmap, @Nullable final Collaborator collaborator) {
this.mindmap = mindmap;

View File

@@ -19,29 +19,19 @@ package com.wisemapping.webmvc;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.PropertySourcesPropertyResolver;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.core.io.support.ResourcePropertySource;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.support.ServletContextResource;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Objects;
public class ApplicationContextInitializer implements org.springframework.context.ApplicationContextInitializer<ConfigurableWebApplicationContext> {
public void initialize(@NotNull ConfigurableWebApplicationContext ctx) {
try {
final Resource resource = new ServletContextResource(ctx.getServletContext(), "/WEB-INF/app.properties");
final Resource resource = new ServletContextResource(Objects.requireNonNull(ctx.getServletContext()), "/WEB-INF/app.properties");
final ResourcePropertySource resourcePropertySource = new ResourcePropertySource(resource);
ctx.getEnvironment().getPropertySources().addFirst(resourcePropertySource);
} catch (IOException e) {

View File

@@ -1,43 +0,0 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.webmvc;
import com.wisemapping.service.MindmapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class ExtensionsController {
@Qualifier("mindmapService")
@Autowired
private MindmapService mindmapService;
@RequestMapping(value = "privacyPolicy")
public ModelAndView privacyPolicy() {
return new ModelAndView("privacyPolicy");
}
@RequestMapping(value = "faq")
public ModelAndView faq() {
return new ModelAndView("faq");
}
}

View File

@@ -44,17 +44,4 @@ public class LoginController {
}
return result;
}
// @RequestMapping(value = "loginopenid", method = RequestMethod.GET)
// protected ModelAndView showLoginOpenIdPage() {
// final User user = Utils.getUser(false);
// ModelAndView result;
// if (user != null) {
// result = new ModelAndView("forward:/c/maps/");
// } else {
// result = new ModelAndView("loginopenid");
// }
// return result;
// }
}

View File

@@ -40,8 +40,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Locale;
@Controller
@@ -52,19 +50,6 @@ public class MindmapController {
@Autowired
private MindmapService mindmapService;
@RequestMapping(value = "maps/import")
public String showImportPage() {
return "mindmapImport";
}
@RequestMapping(value = "maps/{id}/details")
public String showDetails(@PathVariable int id, @NotNull Model model, @NotNull HttpServletRequest request) throws MapCouldNotFoundException {
final MindMapBean mindmap = findMindmapBean(id);
model.addAttribute("mindmap", mindmap);
model.addAttribute("baseUrl", request.getAttribute("site.baseurl"));
return "mindmapDetail";
}
@RequestMapping(value = "maps/{id}/print")
public String showPrintPage(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException {
final MindMapBean mindmap = findMindmapBean(id);
@@ -75,19 +60,6 @@ public class MindmapController {
return "mindmapPrint";
}
@RequestMapping(value = "maps/{id}/export")
public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException, MapCouldNotFoundException {
final Mindmap mindmap = findMindmap(id);
model.addAttribute("mindmap", mindmap);
return "mindmapExport";
}
@RequestMapping(value = "maps/{id}/exportf")
public String showExportPageFull(@PathVariable int id, @NotNull Model model) throws IOException, MapCouldNotFoundException {
showExportPage(id, model);
return "mindmapExportFull";
}
@RequestMapping(value = "maps/{id}/share")
public String showSharePage(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException {
final Mindmap mindmap = findMindmap(id);
@@ -101,41 +73,8 @@ public class MindmapController {
return "mindmapShareFull";
}
@RequestMapping(value = "maps/{id}/publish")
public String showPublishPage(@PathVariable int id, @NotNull Model model, @NotNull HttpServletRequest request) throws MapCouldNotFoundException {
final Mindmap mindmap = findMindmap(id);
model.addAttribute("mindmap", mindmap);
model.addAttribute("baseUrl", request.getAttribute("site.baseurl"));
return "mindmapPublish";
}
@RequestMapping(value = "maps/{id}/publishf")
public String showPublishPageFull(@PathVariable int id, @NotNull Model model, @NotNull HttpServletRequest request) throws MapCouldNotFoundException {
showPublishPage(id, model, request);
return "mindmapPublishFull";
}
@RequestMapping(value = "maps/{id}/history", method = RequestMethod.GET)
public String showHistoryPage(@PathVariable int id, @NotNull Model model) {
model.addAttribute("mindmapId", id);
return "mindmapHistory";
}
@RequestMapping(value = "maps/{id}/historyf", method = RequestMethod.GET)
public String showHistoryPageFull(@PathVariable int id, @NotNull Model model) {
showHistoryPage(id, model);
return "mindmapHistoryFull";
}
@RequestMapping(value = "maps/")
public String showListPage(@NotNull Model model) {
final Locale locale = LocaleContextHolder.getLocale();
// @Todo: This should be more flexible ...
String localeStr = locale.toString().toLowerCase();
if ("es".equals(locale.getLanguage()) || "pt".equals(locale.getLanguage())) {
localeStr = locale.getLanguage();
}
model.addAttribute("locale", localeStr);
return "mindmapList";
}

View File

@@ -32,22 +32,6 @@ public class PublicPagesController {
@Autowired
private MindmapService mindmapService;
@RequestMapping(value = "aboutUs")
public String aboutUs() {
return "aboutUs";
}
@RequestMapping(value = "termsOfUse")
public String showTermsOfUse() {
return "termsOfUse";
}
@RequestMapping(value = "crew")
public String crew() {
return "crew";
}
@RequestMapping(value = "keyboard")
public String newsPage() {
return "keyboard";

Some files were not shown because too many files have changed in this diff Show More