- Remove old ExportController

- Add support for simple REST transformation
This commit is contained in:
Paulo Gustavo Veiga 2012-02-19 21:07:24 -03:00
parent e033e8552c
commit 81538f049b
11 changed files with 115 additions and 422 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

View File

@ -1,214 +0,0 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "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.controller;
import com.wisemapping.exporter.ExportException;
import com.wisemapping.exporter.ExportFormat;
import com.wisemapping.exporter.ExporterFactory;
import com.wisemapping.model.MindMap;
import com.wisemapping.service.MindmapService;
import com.wisemapping.view.MindMapBean;
import com.wisemapping.exporter.ExportProperties;
import com.wisemapping.filter.UserAgent;
import org.apache.batik.transcoder.TranscoderException;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
import org.xml.sax.SAXException;
import sun.misc.BASE64Encoder;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.TransformerException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class ExportController extends BaseMultiActionController {
private static final String IMG_EXPORT_FORMAT = "IMG_EXPORT_FORMAT";
private static final String MAP_ID_PARAMETER = "mapId";
private static final String MAP_SVG_PARAMETER = "mapSvg";
private static final String EXPORT_FORMAT_PARAMETER = "exportFormat";
private static final String IMG_SIZE_PARAMETER = "imgSize";
private static final String MAP_XML_PARAM = "mapXml";
public ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
logger.info("Mindmap Controller: EXPORT action");
final MindMap mindmap = getMindmapFromRequest(httpServletRequest);
return new ModelAndView("mindmapExport", "mindmap", new MindMapBean(mindmap));
}
public ModelAndView export(HttpServletRequest request, HttpServletResponse response) throws TranscoderException, IOException, JAXBException {
logger.info("Export Controller: exporting WiseMap action");
final String mapIdStr = request.getParameter(MAP_ID_PARAMETER);
if (mapIdStr != null) {
final String mapSvg = request.getParameter(MAP_SVG_PARAMETER);
try {
int mindmapId = Integer.parseInt(mapIdStr);
logger.debug("SVG Map to export:" + mapSvg);
if (mapSvg == null || mapSvg.isEmpty()) {
throw new IllegalArgumentException("SVG map could not be null");
}
String formatStr = request.getParameter(EXPORT_FORMAT_PARAMETER);
if (IMG_EXPORT_FORMAT.endsWith(formatStr)) {
formatStr = request.getParameter("imgFormat");
}
final MindmapService service = getMindmapService();
final MindMap mindMap = service.getMindmapById(mindmapId);
// Build format properties ...
final ExportFormat format = ExportFormat.valueOf(formatStr);
final ExportProperties properties = ExportProperties.create(format);
if (properties instanceof ExportProperties.ImageProperties) {
final String sizeStr = request.getParameter(IMG_SIZE_PARAMETER);
final ExportProperties.ImageProperties imageProperties = (ExportProperties.ImageProperties) properties;
if (sizeStr != null) {
final ExportProperties.ImageProperties.Size size = ExportProperties.ImageProperties.Size.valueOf(sizeStr);
imageProperties.setSize(size);
} else {
imageProperties.setSize(ExportProperties.ImageProperties.Size.LARGE);
}
}
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
// Change image link URL.
setBaseBaseImgUrl(format, properties);
ExporterFactory.export(properties, mindMap.getUnzippedXml(), bos, mapSvg);
// If the export goes ok, write the map to the stream ...
// Set format content type...
final String contentType = format.getContentType();
response.setContentType(contentType);
// Set file name...
final String fileName = mindMap.getTitle() + "." + format.getFileExtension();
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
// Write content ...
final ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(bos.toByteArray());
} catch (Throwable e) {
logger.error("Unexpexted error during export process", e);
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
logger.error("map: " + mapSvg);
}
} else {
logger.warn("mapIdStr is null.Image could not be imported. UserAgent:" + request.getHeaders(UserAgent.USER_AGENT_HEADER));
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
return null;
}
private void setBaseBaseImgUrl(@NotNull ExportFormat format, @NotNull ExportProperties properties) {
final String baseUrl;
if (format == ExportFormat.SVG) {
baseUrl = "http://www.wisemapping.com/images";
} else {
final ServletContext servletContext = this.getServletContext();
baseUrl = "file://" + servletContext.getRealPath("/icons/") + "/";
}
properties.setBaseImagePath(baseUrl);
}
public ModelAndView print(HttpServletRequest request, HttpServletResponse response) throws TranscoderException, IOException, JAXBException {
logger.info("Export Controller: printing WiseMap action");
final String mapIdStr = request.getParameter(MAP_ID_PARAMETER);
int mindmapId = Integer.parseInt(mapIdStr);
final MindmapService service = getMindmapService();
final MindMap mindmap = service.getMindmapById(mindmapId);
final String mapSvg = request.getParameter(MAP_SVG_PARAMETER);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
exportImage(response, mapSvg, bos, false);
} catch (Throwable e) {
logger.error("Unexpexted error generating the image", e);
logger.error("map: " + mapSvg);
}
BASE64Encoder encoder = new BASE64Encoder();
String content = encoder.encode(bos.toByteArray());
final String exportContent = "data:image/png;base64," + content;
bos.close();
ModelAndView view = new ModelAndView("mindmapPrint", "mindmap", new MindMapBean(mindmap));
final String xmlMap = mindmap.getNativeXmlAsJsLiteral();
view.addObject(MAP_XML_PARAM, xmlMap);
view.addObject(MAP_SVG_PARAMETER, exportContent);
return view;
}
public ModelAndView image(HttpServletRequest request, HttpServletResponse response) throws TranscoderException, IOException, JAXBException {
logger.info("Export Controller: generating image WiseMap action");
final String mapIdStr = request.getParameter(MAP_ID_PARAMETER);
final String mapSvg = request.getParameter(MAP_SVG_PARAMETER);
try {
final ServletOutputStream outputStream = response.getOutputStream();
exportImage(response, mapSvg, outputStream, true);
} catch (Throwable e) {
logger.error("Unexpexted error generating the image", e);
logger.error("map: " + mapSvg);
}
return null;
}
private void exportImage(HttpServletResponse response, String mapSvg, OutputStream outputStream, boolean setOutput) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException {
//Image Format
ExportFormat imageFormat = ExportFormat.PNG;
// Build format properties ...
final ExportProperties.ImageProperties imageProperties = new ExportProperties.ImageProperties(imageFormat);
imageProperties.setSize(ExportProperties.ImageProperties.Size.XMEDIUM);
// Change image link URL.
setBaseBaseImgUrl(imageFormat, imageProperties);
// Set format content type...
if (setOutput)
response.setContentType(imageFormat.getContentType());
// Write content ...
ExporterFactory.export(imageProperties, null, outputStream, mapSvg);
}
}

View File

@ -4,9 +4,8 @@ package com.wisemapping.rest;
import com.wisemapping.model.MindMap; import com.wisemapping.model.MindMap;
import com.wisemapping.model.MindmapUser; import com.wisemapping.model.MindmapUser;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestMindMap; import com.wisemapping.rest.model.RestMindmap;
import com.wisemapping.service.MindmapService; import com.wisemapping.service.MindmapService;
import com.wisemapping.validator.Utils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -16,21 +15,18 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Controller @Controller
public class MindmapController { public class MindmapController {
@Autowired @Autowired
private MindmapService mindmapService; private MindmapService mindmapService;
@RequestMapping(method = RequestMethod.GET, value = "/map/{id}", produces = {"text/xml", "application/json", "text/html"})
@RequestMapping(method = RequestMethod.GET, value = "/map/{id}")
@ResponseBody @ResponseBody
public ModelAndView getMindmap(@PathVariable int id) throws IOException { public ModelAndView getMindmap(@PathVariable int id) throws IOException {
final MindMap mindMap = mindmapService.getMindmapById(id); final MindMap mindMap = mindmapService.getMindmapById(id);
final RestMindMap map = new RestMindMap(mindMap); final RestMindmap map = new RestMindmap(mindMap);
return new ModelAndView("mapView", "map", map); return new ModelAndView("mapView", "map", map);
} }
@ -39,7 +35,7 @@ public class MindmapController {
final User user = com.wisemapping.security.Utils.getUser(); final User user = com.wisemapping.security.Utils.getUser();
final List<MindmapUser> list = mindmapService.getMindmapUserByUser(user); final List<MindmapUser> list = mindmapService.getMindmapUserByUser(user);
// final RestMindMap map = new RestMindMap(mindMap); // final RestMindMap map = new RestMindmap(mindMap);
// return new ModelAndView("mapView", "map", map); // return new ModelAndView("mapView", "map", map);
return null; return null;
} }

View File

@ -1,12 +1,16 @@
package com.wisemapping.rest; package com.wisemapping.rest;
import com.wisemapping.exporter.ExportFormat;
import com.wisemapping.exporter.ExportProperties; import com.wisemapping.exporter.ExportProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -14,6 +18,10 @@ import java.util.Map;
@Controller @Controller
public class TransformerController { public class TransformerController {
private static final String PARAM_SVG_XML = "svgXml";
private static final String PARAM_WISE_MAP_XML = "mapXml";
private static final String PARAM_FILENAME = "filename";
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/pdf"}, consumes = {"image/svg+xml"}) @RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/pdf"}, consumes = {"image/svg+xml"})
@ResponseBody @ResponseBody
public ModelAndView transformPdf(@RequestBody @Nullable final String content) throws IOException { public ModelAndView transformPdf(@RequestBody @Nullable final String content) throws IOException {
@ -26,6 +34,18 @@ public class TransformerController {
return new ModelAndView("transformViewPdf", values); return new ModelAndView("transformViewPdf", values);
} }
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"image/svg+xml"}, consumes = {"image/svg+xml"})
@ResponseBody
public ModelAndView transformSvg(@RequestBody @Nullable final String content) throws IOException {
final Map<String, Object> values = new HashMap<String, Object>();
if (content == null || content.length() == 0) {
throw new IllegalArgumentException("Body can not be null.");
}
values.put("content", content);
return new ModelAndView("transformViewSvg", values);
}
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"image/png"}, consumes = {"image/svg+xml"}) @RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"image/png"}, consumes = {"image/svg+xml"})
@ResponseBody @ResponseBody
public ModelAndView transformPng(@RequestBody @Nullable final String content) throws IOException { public ModelAndView transformPng(@RequestBody @Nullable final String content) throws IOException {
@ -47,7 +67,7 @@ public class TransformerController {
} }
values.put("content", content); values.put("content", content);
values.put("imageSize", ExportProperties.ImageProperties.Size.LARGE); values.put("imageSize", ExportProperties.ImageProperties.Size.LARGE);
return new ModelAndView("transformViewJpg", values); return new ModelAndView("transformViewJpeg", values);
} }
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/freemind"}, consumes = {"text/xml"}) @RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/freemind"}, consumes = {"text/xml"})
@ -60,4 +80,42 @@ public class TransformerController {
values.put("content", content); values.put("content", content);
return new ModelAndView("transformViewFreemind", values); return new ModelAndView("transformViewFreemind", values);
} }
@RequestMapping(method = RequestMethod.POST, value = "/transform", consumes = {"application/x-www-form-urlencoded"})
public ModelAndView transform(@NotNull HttpServletRequest request,
@NotNull HttpServletResponse response) throws IOException {
final String svg = request.getParameter(PARAM_SVG_XML);
final String mapXml = request.getParameter(PARAM_WISE_MAP_XML);
final String filename = request.getParameter(PARAM_FILENAME);
// 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 ExportFormat exportFormat = ExportFormat.valueOf(format.toUpperCase());
ModelAndView result;
switch (exportFormat) {
case PNG:
result = this.transformPng(svg);
break;
case JPEG:
result = this.transformJpeg(svg);
break;
case PDF:
result = this.transformPdf(svg);
break;
case SVG:
result = this.transformSvg(svg);
break;
case FREEMIND:
result = this.transformFreemind(mapXml);
break;
default:
throw new IllegalArgumentException("Unsupported export format");
}
result.getModelMap().put("filename", filename);
return result;
}
} }

View File

@ -17,17 +17,17 @@ import java.util.Date;
@XmlRootElement(name = "map") @XmlRootElement(name = "map")
@XmlAccessorType(XmlAccessType.PROPERTY) @XmlAccessorType(XmlAccessType.PROPERTY)
public class RestMindMap { public class RestMindmap {
@JsonIgnore @JsonIgnore
private MindMap mindmap; private MindMap mindmap;
public RestMindMap() { public RestMindmap() {
this(null); this(null);
} }
public RestMindMap(@NotNull MindMap mindmap) { public RestMindmap(@NotNull MindMap mindmap) {
this.mindmap = mindmap; this.mindmap = mindmap;
} }

View File

@ -28,6 +28,7 @@ public class TransformView extends AbstractView {
protected void renderMergedOutputModel(@NotNull Map<String, Object> viewMap, @NotNull HttpServletRequest request, @NotNull final HttpServletResponse response) throws Exception { protected void renderMergedOutputModel(@NotNull Map<String, Object> viewMap, @NotNull HttpServletRequest request, @NotNull final HttpServletResponse response) throws Exception {
final String content = (String) viewMap.get("content"); final String content = (String) viewMap.get("content");
final String filename = (String) viewMap.get("filename");
// Build format properties ... // Build format properties ...
final ExportProperties properties = ExportProperties.create(exportFormat); final ExportProperties properties = ExportProperties.create(exportFormat);
@ -57,7 +58,7 @@ public class TransformView extends AbstractView {
response.setContentType(contentType); response.setContentType(contentType);
// Set file name... // Set file name...
final String fileName = "map" + "." + exportFormat.getFileExtension(); final String fileName = (filename != null ? filename : "map" + ".") + exportFormat.getFileExtension();
response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
// Write content ... // Write content ...

View File

@ -1,167 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
<property name="filterInvocationDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
</value>
</property>
</bean>
<bean id="shaPasswordEncoder" class="org.acegisecurity.providers.encoding.ShaPasswordEncoder"/>
<bean id="encoder" class="com.wisemapping.security.CustomPasswordEncoder">
<property name="delegatedEncoder" ref="shaPasswordEncoder"/>
</bean>
<bean id="httpSessionContextIntegrationFilter"
class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/>
<bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter">
<property name="filterProcessesUrl" value="/c/logout.htm"/>
<constructor-arg value="/c/login.htm"/>
<!-- URL redirected to after logout -->
<constructor-arg>
<list>
<ref bean="rememberMeServices"/>
<bean class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/>
</list>
</constructor-arg>
</bean>
<bean id="ssoCustomAuthenticationHandler" class="com.wisemapping.security.DefaultAuthenticationHandler"/>
<bean id="authenticationProcessingFilter" class="com.wisemapping.security.WiseAuthenticationProcessingFilter">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="authenticationFailureUrl" value="/c/login.htm?login_error=1"/>
<property name="defaultTargetUrl" value="/c/login.htm"/>
<property name="filterProcessesUrl" value="/c/j_acegi_security_check"/>
<property name="rememberMeServices" ref="rememberMeServices"/>
<property name="authenticationHandler" ref="ssoCustomAuthenticationHandler"/>
<property name="exceptionMappings">
<props>
<prop key="org.acegisecurity.BadCredentialsException">/c/login.htm?login_error=2</prop>
<prop key="org.acegisecurity.LockedException">/c/login.htm?login_error=3</prop>
</props>
</property>
</bean>
<bean id="securityContextHolderAwareRequestFilter"
class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter"/>
<bean id="rememberMeProcessingFilter" class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="rememberMeServices" ref="rememberMeServices"/>
</bean>
<bean id="anonymousProcessingFilter" class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
<property name="key" value="changeThis"/>
<property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS"/>
</bean>
<bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
<property name="authenticationEntryPoint">
<bean class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<property name="loginFormUrl" value="/c/login.htm"/>
<property name="forceHttps" value="false"/>
</bean>
</property>
<property name="accessDeniedHandler">
<bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
<property name="errorPage" value="/accessDenied.jsp"/>
</bean>
</property>
</bean>
<bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager">
<bean class="org.acegisecurity.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions" value="false"/>
<property name="decisionVoters">
<list>
<bean class="org.acegisecurity.vote.RoleVoter"/>
<bean class="org.acegisecurity.vote.AuthenticatedVoter"/>
</list>
</property>
</bean>
</property>
<property name="objectDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/index.jsp=IS_AUTHENTICATED_ANONYMOUSLY
/c/login*=IS_AUTHENTICATED_ANONYMOUSLY
/c/userregistration*=IS_AUTHENTICATED_ANONYMOUSLY
/c/activation.htm=IS_AUTHENTICATED_ANONYMOUSLY
/c/forgotpassword*=IS_AUTHENTICATED_ANONYMOUSLY
/c/captcha*=IS_AUTHENTICATED_ANONYMOUSLY
/c/home.htm=IS_AUTHENTICATED_ANONYMOUSLY
/c/try.htm=IS_AUTHENTICATED_ANONYMOUSLY
/c/search.htm=IS_AUTHENTICATED_ANONYMOUSLY
/c/keyboard.htm=IS_AUTHENTICATED_ANONYMOUSLY
/css/*=IS_AUTHENTICATED_ANONYMOUSLY
/js/**=IS_AUTHENTICATED_ANONYMOUSLY
/ws/**=IS_AUTHENTICATED_ANONYMOUSLY
/images/*=IS_AUTHENTICATED_ANONYMOUSLY
/c/embeddedview.htm=IS_AUTHENTICATED_ANONYMOUSLY
/c/export.htm=IS_AUTHENTICATED_ANONYMOUSLY
/c/publicview.htm=IS_AUTHENTICATED_ANONYMOUSLY
/dwr/engine.js=IS_AUTHENTICATED_ANONYMOUSLY
/dwr/interface/loggerservice.js=IS_AUTHENTICATED_ANONYMOUSLY
/dwr/call/plaincall/loggerservice.logerror.dwr=IS_AUTHENTICATED_ANONYMOUSLY
/**=IS_AUTHENTICATED_REMEMBERED
</value>
</property>
</bean>
<bean id="rememberMeServices" class="com.wisemapping.security.CustomTokenBasedRememberMeServices">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="key" value="changeThis"/>
</bean>
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
<property name="providers">
<list>
<ref local="daoAuthenticationProvider"/>
<bean class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
<property name="key" value="changeThis"/>
</bean>
<bean class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">
<property name="key" value="changeThis"/>
</bean>
</list>
</property>
</bean>
<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<!-- @Todo: Check if this still required. this was removed in the new spring version.-->
<!--<property name="userCache">-->
<!--<bean class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">-->
<!--<property name="cache">-->
<!--<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">-->
<!--<property name="cacheManager">-->
<!--<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>-->
<!--</property>-->
<!--<property name="cacheName" value="userCache"/>-->
<!--</bean>-->
<!--</property>-->
<!--</bean>-->
<!--</property>-->
<property name="encoder" ref="encoder"/>
</bean>
<bean id="userDetailsService" class="com.wisemapping.security.UserDetailService">
<property name="userManager" ref="userManager"/>
</bean>
<!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
<bean id="loggerListener" class="org.acegisecurity.event.authentication.LoggerListener"/>
</beans>

View File

@ -15,15 +15,10 @@
<context:annotation-config/> <context:annotation-config/>
<mvc:annotation-driven/> <mvc:annotation-driven/>
<!-- To enable @RequestMapping process on type level and method level -->
<!--<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>-->
<!--<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>-->
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound"> <property name="classesToBeBound">
<list> <list>
<value>com.wisemapping.rest.model.RestMindMap</value> <value>com.wisemapping.rest.model.RestMindmap</value>
</list> </list>
</property> </property>
</bean> </bean>
@ -33,11 +28,14 @@
<property name="favorPathExtension" value="true"/> <property name="favorPathExtension" value="true"/>
<property name="mediaTypes"> <property name="mediaTypes">
<map> <map>
<entry key="xml" value="text/xml"/>
<entry key="html" value="text/html"/> <entry key="html" value="text/html"/>
<entry key="xml" value="text/xml"/>
<entry key="json" value="application/json"/> <entry key="json" value="application/json"/>
<entry key="freemind" value="application/freemind"/>
<entry key="pdf" value="application/pdf"/> <entry key="pdf" value="application/pdf"/>
<entry key="png" value="application/png"/> <entry key="png" value="image/png"/>
<entry key="jpeg" value="image/jpg"/>
<entry key="svg" value="image/svg+xml"/>
</map> </map>
</property> </property>
<property name="viewResolvers"> <property name="viewResolvers">
@ -76,5 +74,7 @@
<constructor-arg value="application/freemind"/> <constructor-arg value="application/freemind"/>
</bean> </bean>
<bean id="transformViewSvg" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="image/svg+xml"/>
</bean>
</beans> </beans>

View File

@ -30,9 +30,11 @@
<sec:http pattern="/dwr/interface/loggerservice.js" security="none"/> <sec:http pattern="/dwr/interface/loggerservice.js" security="none"/>
<sec:http pattern="/dwr/call/plaincall/loggerservice.logerror.dwr" security="none"/> <sec:http pattern="/dwr/call/plaincall/loggerservice.logerror.dwr" security="none"/>
<sec:http pattern="/service/transform.*" security="none"/>
<sec:http use-expressions="true" create-session="stateless" entry-point-ref="digestEntryPoint" <sec:http use-expressions="true" create-session="stateless" entry-point-ref="digestEntryPoint"
pattern="/service/**"> pattern="/service/**">
<sec:intercept-url pattern="/service/**" access="isAuthenticated()"/> <sec:intercept-url pattern="/service/**" access="isAuthenticated()"/>
<sec:http-basic/> <sec:http-basic/>
<sec:custom-filter ref="digestFilter" after="BASIC_AUTH_FILTER"/> <sec:custom-filter ref="digestFilter" after="BASIC_AUTH_FILTER"/>
</sec:http> </sec:http>

View File

@ -107,11 +107,7 @@
<property name="userService" ref="userService"/> <property name="userService" ref="userService"/>
</bean> </bean>
<bean id="exportController" class="com.wisemapping.controller.ExportController">
<property name="methodNameResolver" ref="paramResolverByAction"/>
<property name="mindmapService" ref="mindmapService"/>
<property name="userService" ref="userService"/>
</bean>
<bean id="publishController" class="com.wisemapping.controller.MindmapPublishController"> <bean id="publishController" class="com.wisemapping.controller.MindmapPublishController">
<property name="methodNameResolver" ref="paramResolverByAction2"/> <property name="methodNameResolver" ref="paramResolverByAction2"/>
<property name="mindmapService" ref="mindmapService"/> <property name="mindmapService" ref="mindmapService"/>
@ -303,7 +299,6 @@
<prop key="/c/editor.htm">editorController</prop> <prop key="/c/editor.htm">editorController</prop>
<prop key="/c/cooker.htm">cookerController</prop> <prop key="/c/cooker.htm">cookerController</prop>
<prop key="/c/settings.htm">settingsController</prop> <prop key="/c/settings.htm">settingsController</prop>
<prop key="/c/export.htm">exportController</prop>
<prop key="/c/publish.htm">publishController</prop> <prop key="/c/publish.htm">publishController</prop>
<prop key="/c/editProfile.htm">editProfileController</prop> <prop key="/c/editProfile.htm">editProfileController</prop>
<prop key="/c/tags.htm">tagsController</prop> <prop key="/c/tags.htm">tagsController</prop>

View File

@ -1,13 +1,13 @@
<%@ include file="/jsp/init.jsp" %> <%@ include file="/jsp/init.jsp" %>
<h1> <h1>
<spring:message code="EXPORT"/> <spring:message code="EXPORT"/>'${mindmap.title}'</h1>
'${mindmap.title}'</h1>
<div> <div>
<form method="post" id="exportForm" name="exportForm" action="<c:url value="export.htm"/>" style="height:100%;"> <form method="POST" id="exportForm" name="exportForm" action="<c:url value="/service/transform"/>"
<input type="hidden" name="action" value="export"/> style="height:100%;" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="mapId" value="${mindmap.id}"/> <input name="svgXml" value="" type="hidden"/>
<input type="hidden" name="mapSvg" value=""/> <input name="mapXml" value="" type="hidden"/>
<input name="filename" value="${mindmap.title}" type="hidden"/>
<table> <table>
<tbody> <tbody>
<tr> <tr>
@ -85,14 +85,36 @@
}); });
$('ok').addEvent('click', function(event) { $('ok').addEvent('click', function(event) {
$('exportForm').submit();
var form = $('exportForm');
// Look for the selected format and append export suffix...
var value = $$('input[name=exportFormat]:checked')[0].get('value');
var suffix;
if (value == 'IMG_EXPORT_FORMAT') {
var selected = $('imgFormat');
suffix = selected.options[selected.selectedIndex].value;
} else {
suffix = value;
}
suffix = suffix.toLowerCase();
form.action = form.action + "." + suffix;
// Store SVG o native map...
if (suffix == "freemind") {
var mindmap = designer.getMindmap();
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
var domMap = serializer.toXML(mindmap);
form.mapXml.value = core.Utils.innerXML(domMap);
} else {
form.svgXml.value = $("workspaceContainer").innerHTML;
}
// Finally, submit map ...
form.submit();
MooDialog.Request.active.close(); MooDialog.Request.active.close();
}); });
$('cancel').addEvent('click', function(event) {
MooDialog.Request.active.close();
});
document.exportForm.mapSvg.value = $("workspaceContainer").innerHTML;
</script> </script>