mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-05 07:03:24 +01:00
Add wisemapping support for import.
This commit is contained in:
parent
88b0efa859
commit
79b009e29e
@ -1,63 +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 org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Usage: http://localhost:8080/wisemapping/c/cooker?action=edit&mapId=12
|
|
||||||
*/
|
|
||||||
public class MindmapCooker extends BaseMultiActionController {
|
|
||||||
|
|
||||||
public static final String MINDMAP_ID_PARAMETER = "mapId";
|
|
||||||
public static final String MAP_XML_PARAM = "mapXml";
|
|
||||||
|
|
||||||
public ModelAndView edit(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
|
||||||
|
|
||||||
final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER);
|
|
||||||
final int mapId = Integer.parseInt(mindmapId);
|
|
||||||
final MindMap mindmap = getMindmapService().getMindmapById(mapId);
|
|
||||||
|
|
||||||
// Mark as try mode...
|
|
||||||
final ModelAndView view = new ModelAndView("mindmapCooker", "mindmap", mindmap);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView save(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
|
||||||
|
|
||||||
final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER);
|
|
||||||
final int mapId = Integer.parseInt(mindmapId);
|
|
||||||
final MindMap mindmap = getMindmapService().getMindmapById(mapId);
|
|
||||||
|
|
||||||
String xml = httpServletRequest.getParameter("xml");
|
|
||||||
mindmap.setXmlStr(xml);
|
|
||||||
|
|
||||||
getMindmapService().updateMindmap(mindmap, false);
|
|
||||||
|
|
||||||
// Mark as try mode...
|
|
||||||
final ModelAndView view = new ModelAndView("mindmapCooker", "mindmap", mindmap);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +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.filter.UserAgent;
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
import com.wisemapping.security.Utils;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
|
||||||
import org.springframework.web.servlet.view.RedirectView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
public class MindmapEditorController extends BaseMultiActionController {
|
|
||||||
|
|
||||||
public static final String MINDMAP_ID_PARAMETER = "mapId";
|
|
||||||
public static final String MAP_XML_PARAM = "mapXml";
|
|
||||||
|
|
||||||
public ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
|
||||||
return new ModelAndView(new RedirectView("maps/"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView open(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
|
||||||
|
|
||||||
ModelAndView view;
|
|
||||||
|
|
||||||
final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER);
|
|
||||||
final int mapId = Integer.parseInt(mindmapId);
|
|
||||||
|
|
||||||
UserAgent userAgent = UserAgent.create(httpServletRequest);
|
|
||||||
if(userAgent.needsGCF()){
|
|
||||||
view = new ModelAndView("gcfPluginNeeded");
|
|
||||||
view.addObject(MINDMAP_ID_PARAMETER, mindmapId);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
final MindMap mindmap = getMindmapService().getMindmapById(mapId);
|
|
||||||
|
|
||||||
// Mark as try mode...
|
|
||||||
view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
|
|
||||||
view.addObject("editorTryMode", false);
|
|
||||||
final boolean showHelp = isWelcomeMap(mindmap);
|
|
||||||
view.addObject("showHelp", showHelp);
|
|
||||||
view.addObject("user", Utils.getUser());
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isWelcomeMap(MindMap map) {
|
|
||||||
return map.getTitle().startsWith("Welcome ");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +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 org.springframework.web.servlet.ModelAndView;
|
|
||||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
|
|
||||||
public class PublicViewController extends BaseMultiActionController {
|
|
||||||
|
|
||||||
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
final MindMap mindmap = super.getMindmapFromRequest(httpServletRequest);
|
|
||||||
|
|
||||||
final ModelAndView view = new ModelAndView("mindmapPublicView");
|
|
||||||
view.addObject("mindmap", mindmap);
|
|
||||||
view.addObject("viewTitle","'"+mindmap.getTitle()+"' Map View");
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,7 @@
|
|||||||
package com.wisemapping.dao;
|
package com.wisemapping.dao;
|
||||||
|
|
||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.*;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.hibernate.criterion.SimpleExpression;
|
import org.hibernate.criterion.SimpleExpression;
|
||||||
@ -35,10 +36,10 @@ public class MindmapManagerImpl
|
|||||||
|
|
||||||
public Collaborator getCollaboratorBy(final String email) {
|
public Collaborator getCollaboratorBy(final String email) {
|
||||||
final Collaborator collaborator;
|
final Collaborator collaborator;
|
||||||
final List colaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email);
|
final List<Collaborator> collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email);
|
||||||
if (colaborators != null && !colaborators.isEmpty()) {
|
if (collaborators != null && !collaborators.isEmpty()) {
|
||||||
assert colaborators.size() == 1 : "More than one user with the same username!";
|
assert collaborators.size() == 1 : "More than one user with the same username!";
|
||||||
collaborator = (Collaborator) colaborators.get(0);
|
collaborator = collaborators.get(0);
|
||||||
} else {
|
} else {
|
||||||
collaborator = null;
|
collaborator = null;
|
||||||
}
|
}
|
||||||
@ -46,23 +47,21 @@ public class MindmapManagerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<MindMap> search(MindMapCriteria criteria) {
|
public List<MindMap> search(MindMapCriteria criteria) {
|
||||||
return search(criteria,-1);
|
return search(criteria, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MindMapHistory> getHistoryFrom(int mindmapId)
|
public List<MindMapHistory> getHistoryFrom(int mindmapId) {
|
||||||
{
|
|
||||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
||||||
hibernateCriteria.add(Restrictions.eq("mindmapId",mindmapId));
|
hibernateCriteria.add(Restrictions.eq("mindmapId", mindmapId));
|
||||||
hibernateCriteria.addOrder( Order.desc("creationTime"));
|
hibernateCriteria.addOrder(Order.desc("creationTime"));
|
||||||
// Mientras no haya paginacion solo los 10 primeros
|
// Mientras no haya paginacion solo los 10 primeros
|
||||||
// This line throws errors in some environments, so getting all history and taking firsts 10 records
|
// This line throws errors in some environments, so getting all history and taking firsts 10 records
|
||||||
// hibernateCriteria.setMaxResults(10);
|
// hibernateCriteria.setMaxResults(10);
|
||||||
List list = hibernateCriteria.list();
|
List list = hibernateCriteria.list();
|
||||||
return list.subList(0,(10<list.size()?10:list.size()));
|
return list.subList(0, (10 < list.size() ? 10 : list.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindMapHistory getHistory(int historyId)
|
public MindMapHistory getHistory(int historyId) {
|
||||||
{
|
|
||||||
return (MindMapHistory) getHibernateTemplate().get(MindMapHistory.class, historyId);
|
return (MindMapHistory) getHibernateTemplate().get(MindMapHistory.class, historyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,8 +160,7 @@ public class MindmapManagerImpl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addView(int mapId)
|
public void addView(int mapId) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,11 +173,10 @@ public class MindmapManagerImpl
|
|||||||
getSession().save(mindMap);
|
getSession().save(mindMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) {
|
public void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory) {
|
||||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||||
getHibernateTemplate().saveOrUpdate(mindMap);
|
getHibernateTemplate().saveOrUpdate(mindMap);
|
||||||
if (saveHistory)
|
if (saveHistory) {
|
||||||
{
|
|
||||||
saveHistory(mindMap);
|
saveHistory(mindMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,8 +185,7 @@ public class MindmapManagerImpl
|
|||||||
getHibernateTemplate().delete(mindMap);
|
getHibernateTemplate().delete(mindMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveHistory(MindMap mindMap)
|
public void saveHistory(MindMap mindMap) {
|
||||||
{
|
|
||||||
final MindMapHistory history = new MindMapHistory();
|
final MindMapHistory history = new MindMapHistory();
|
||||||
|
|
||||||
history.setXml(mindMap.getXml());
|
history.setXml(mindMap.getXml());
|
||||||
|
@ -211,7 +211,10 @@ public class MindMap {
|
|||||||
this.creationTime = creationTime;
|
this.creationTime = creationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwner(User owner) {
|
public void setOwner(@NotNull User owner) {
|
||||||
|
if (owner == null) {
|
||||||
|
throw new IllegalArgumentException("Owner can not be null");
|
||||||
|
}
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +244,10 @@ public class MindMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
|
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
|
||||||
|
if(collaborator==null){
|
||||||
|
throw new IllegalStateException("Collaborator can not be null");
|
||||||
|
}
|
||||||
|
|
||||||
CollaboratorProperties collaboratorProperties = this.findUserProperty(collaborator);
|
CollaboratorProperties collaboratorProperties = this.findUserProperty(collaborator);
|
||||||
if (collaboratorProperties == null) {
|
if (collaboratorProperties == null) {
|
||||||
collaboratorProperties = new CollaboratorProperties(collaborator, this);
|
collaboratorProperties = new CollaboratorProperties(collaborator, this);
|
||||||
|
@ -174,12 +174,6 @@ public class MindmapController extends BaseController {
|
|||||||
saveMindmap(minor, mindMap, user);
|
saveMindmap(minor, mindMap, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException {
|
|
||||||
final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), "");
|
|
||||||
result.rejectValue(fieldName, "error.not-specified", null, message);
|
|
||||||
return new ValidationException(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
@ -261,16 +255,17 @@ public class MindmapController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveMindmap(boolean minor, @NotNull final MindMap mindMap, @NotNull final User user) throws WiseMappingException {
|
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json", "application/wisemapping+xml"})
|
||||||
final Calendar now = Calendar.getInstance();
|
|
||||||
mindMap.setLastModificationTime(now);
|
|
||||||
mindMap.setLastModifierUser(user.getUsername());
|
|
||||||
mindmapService.updateMindmap(mindMap, minor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json"})
|
|
||||||
@ResponseStatus(value = HttpStatus.CREATED)
|
@ResponseStatus(value = HttpStatus.CREATED)
|
||||||
public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
|
||||||
|
|
||||||
|
// Overwrite title and description if they where specified by parameter.
|
||||||
|
if (title != null && !title.isEmpty()) {
|
||||||
|
restMindmap.setTitle(title);
|
||||||
|
}
|
||||||
|
if (description != null && !description.isEmpty()) {
|
||||||
|
restMindmap.setDescription(description);
|
||||||
|
}
|
||||||
|
|
||||||
// Validate ...
|
// Validate ...
|
||||||
final BindingResult result = new BeanPropertyBindingResult(restMindmap, "");
|
final BindingResult result = new BeanPropertyBindingResult(restMindmap, "");
|
||||||
@ -279,19 +274,16 @@ public class MindmapController extends BaseController {
|
|||||||
throw new ValidationException(result);
|
throw new ValidationException(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some basic validations ...
|
|
||||||
final User user = Utils.getUser();
|
|
||||||
|
|
||||||
// If the user has not specified the xml content, add one ...
|
// If the user has not specified the xml content, add one ...
|
||||||
final MindMap delegated = restMindmap.getDelegated();
|
final MindMap delegated = restMindmap.getDelegated();
|
||||||
String xml = restMindmap.getXml();
|
String xml = restMindmap.getXml();
|
||||||
if (xml == null || xml.isEmpty()) {
|
if (xml == null || xml.isEmpty()) {
|
||||||
xml = MindMap.getDefaultMindmapXml(restMindmap.getTitle());
|
xml = MindMap.getDefaultMindmapXml(restMindmap.getTitle());
|
||||||
}
|
}
|
||||||
delegated.setOwner(user);
|
|
||||||
delegated.setXmlStr(xml);
|
delegated.setXmlStr(xml);
|
||||||
|
|
||||||
// Add new mindmap ...
|
// Add new mindmap ...
|
||||||
|
final User user = Utils.getUser();
|
||||||
mindmapService.addMindmap(delegated, user);
|
mindmapService.addMindmap(delegated, user);
|
||||||
|
|
||||||
// Return the new created map ...
|
// Return the new created map ...
|
||||||
@ -306,11 +298,11 @@ public class MindmapController extends BaseController {
|
|||||||
// Convert map ...
|
// Convert map ...
|
||||||
final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND);
|
final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND);
|
||||||
final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml);
|
final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml);
|
||||||
final MindMap mindMap = importer.importMap(title, description, stream);
|
final MindMap mindMap = importer.importMap(title, "", stream);
|
||||||
|
|
||||||
// Save new map ...
|
// Save new map ...
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
createMap(new RestMindmap(mindMap, user), response);
|
createMap(new RestMindmap(mindMap, user), response, title, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"})
|
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"})
|
||||||
@ -340,4 +332,17 @@ public class MindmapController extends BaseController {
|
|||||||
response.setHeader("Location", "/service/maps/" + clonedMap.getId());
|
response.setHeader("Location", "/service/maps/" + clonedMap.getId());
|
||||||
response.setHeader("ResourceId", Integer.toString(clonedMap.getId()));
|
response.setHeader("ResourceId", Integer.toString(clonedMap.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveMindmap(boolean minor, @NotNull final MindMap mindMap, @NotNull final User user) throws WiseMappingException {
|
||||||
|
final Calendar now = Calendar.getInstance();
|
||||||
|
mindMap.setLastModificationTime(now);
|
||||||
|
mindMap.setLastModifierUser(user.getUsername());
|
||||||
|
mindmapService.updateMindmap(mindMap, minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException {
|
||||||
|
final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), "");
|
||||||
|
result.rejectValue(fieldName, "error.not-specified", null, message);
|
||||||
|
return new ValidationException(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.wisemapping.rest.model;
|
|||||||
import com.wisemapping.model.Collaborator;
|
import com.wisemapping.model.Collaborator;
|
||||||
import com.wisemapping.model.MindMap;
|
import com.wisemapping.model.MindMap;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
|
import com.wisemapping.security.Utils;
|
||||||
import org.codehaus.jackson.annotate.*;
|
import org.codehaus.jackson.annotate.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -38,7 +39,7 @@ public class RestMindmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RestMindmap() {
|
public RestMindmap() {
|
||||||
this(new MindMap(), null);
|
this(new MindMap(), Utils.getUser());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,6 @@ public class RestMindmap {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return mindmap.getDescription();
|
return mindmap.getDescription();
|
||||||
}
|
}
|
||||||
@ -161,8 +161,10 @@ public class RestMindmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStarred(boolean value) {
|
public void setStarred(boolean value) {
|
||||||
|
if (collaborator != null) {
|
||||||
mindmap.setStarred(collaborator, value);
|
mindmap.setStarred(collaborator, value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public MindMap getDelegated() {
|
public MindMap getDelegated() {
|
||||||
|
@ -41,6 +41,7 @@ final public class Utils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static User getUser() {
|
public static User getUser() {
|
||||||
User result = null;
|
User result = null;
|
||||||
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
@ -51,6 +52,10 @@ final public class Utils {
|
|||||||
result = ((UserDetails)principal).getUser();
|
result = ((UserDetails)principal).getUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(result==null){
|
||||||
|
throw new IllegalStateException("User could not be retrieved");
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,7 @@ public abstract class BaseSecurityAdvice {
|
|||||||
|
|
||||||
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException {
|
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException {
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
final Object argument = methodInvocation.getArguments()[0];
|
final Object argument = methodInvocation.getArguments()[0];
|
||||||
|
|
||||||
boolean isAllowed;
|
boolean isAllowed;
|
||||||
|
|
||||||
if (argument instanceof MindMap) {
|
if (argument instanceof MindMap) {
|
||||||
|
@ -24,11 +24,11 @@ import com.wisemapping.model.MindMap;
|
|||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class UpdateSecurityAdvise
|
public class UpdateSecurityAdvise
|
||||||
extends BaseSecurityAdvice
|
extends BaseSecurityAdvice
|
||||||
implements MethodInterceptor
|
implements MethodInterceptor {
|
||||||
{
|
|
||||||
|
|
||||||
private UserRole grantedRole = UserRole.COLLABORATOR;
|
private UserRole grantedRole = UserRole.COLLABORATOR;
|
||||||
|
|
||||||
@ -37,13 +37,18 @@ public class UpdateSecurityAdvise
|
|||||||
return methodInvocation.proceed();
|
return methodInvocation.proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAllowed(User user, MindMap map)
|
protected boolean isAllowed(@NotNull User user, @NotNull MindMap map) {
|
||||||
{
|
boolean result;
|
||||||
return getMindmapService().isAllowedToView(user,map,grantedRole);
|
if (map.getOwner() == null) {
|
||||||
|
// This means that the map is new and is an add operation.
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = getMindmapService().isAllowedToView(user, map, grantedRole);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAllowed(User user, int mapId)
|
protected boolean isAllowed(User user, int mapId) {
|
||||||
{
|
return getMindmapService().isAllowedToView(user, mapId, grantedRole);
|
||||||
return getMindmapService().isAllowedToView(user,mapId,grantedRole);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public interface MindmapService {
|
|||||||
|
|
||||||
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||||
|
|
||||||
public void addCollaborators(MindMap mindmap, String[] colaboratorEmails, UserRole role, ColaborationEmail email)
|
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, UserRole role, ColaborationEmail email)
|
||||||
throws InvalidColaboratorException;
|
throws InvalidColaboratorException;
|
||||||
|
|
||||||
public void addTags(MindMap mindmap, String tags);
|
public void addTags(MindMap mindmap, String tags);
|
||||||
@ -60,7 +60,7 @@ public interface MindmapService {
|
|||||||
|
|
||||||
public boolean isAllowedToView(User user, int mapId, UserRole allowedRole);
|
public boolean isAllowedToView(User user, int mapId, UserRole allowedRole);
|
||||||
|
|
||||||
public boolean isAllowedToColaborate(User user, int mapId, UserRole grantedRole);
|
public boolean isAllowedToCollaborate(User user, int mapId, UserRole grantedRole);
|
||||||
|
|
||||||
public boolean isAllowedToCollaborate(User user, MindMap map, UserRole grantedRole);
|
public boolean isAllowedToCollaborate(User user, MindMap map, UserRole grantedRole);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class MindmapServiceImpl
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
private Mailer mailer;
|
private Mailer mailer;
|
||||||
|
|
||||||
public boolean isAllowedToColaborate(User user, int mapId, UserRole grantedRole) {
|
public boolean isAllowedToCollaborate(@NotNull User user, int mapId, @NotNull UserRole grantedRole) {
|
||||||
final MindMap map = mindmapManager.getMindmapById(mapId);
|
final MindMap map = mindmapManager.getMindmapById(mapId);
|
||||||
return isAllowedToCollaborate(user, map, grantedRole);
|
return isAllowedToCollaborate(user, map, grantedRole);
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public class MindmapServiceImpl
|
|||||||
return isAllowedToView(user, map, grantedRole);
|
return isAllowedToView(user, map, grantedRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowedToView(User user, MindMap map, UserRole grantedRole) {
|
public boolean isAllowedToView(@NotNull User user, @NotNull MindMap map, @NotNull UserRole grantedRole) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
if (map.isPublic()) {
|
if (map.isPublic()) {
|
||||||
@ -162,16 +162,16 @@ public class MindmapServiceImpl
|
|||||||
final MindmapUser mindmapUser = new MindmapUser(UserRole.OWNER.ordinal(), dbUser, map);
|
final MindmapUser mindmapUser = new MindmapUser(UserRole.OWNER.ordinal(), dbUser, map);
|
||||||
map.getMindmapUsers().add(mindmapUser);
|
map.getMindmapUsers().add(mindmapUser);
|
||||||
|
|
||||||
mindmapManager.addMindmap(user, map);
|
mindmapManager.addMindmap(dbUser, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCollaborators(MindMap mindmap, String[] colaboratorEmails, UserRole role, ColaborationEmail email)
|
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, UserRole role, ColaborationEmail email)
|
||||||
throws InvalidColaboratorException {
|
throws InvalidColaboratorException {
|
||||||
if (colaboratorEmails != null && colaboratorEmails.length > 0) {
|
if (collaboratorEmails != null && collaboratorEmails.length > 0) {
|
||||||
final Collaborator owner = mindmap.getOwner();
|
final Collaborator owner = mindmap.getOwner();
|
||||||
final Set<MindmapUser> mindmapUsers = mindmap.getMindmapUsers();
|
final Set<MindmapUser> mindmapUsers = mindmap.getMindmapUsers();
|
||||||
|
|
||||||
for (String colaboratorEmail : colaboratorEmails) {
|
for (String colaboratorEmail : collaboratorEmails) {
|
||||||
if (owner.getEmail().equals(colaboratorEmail)) {
|
if (owner.getEmail().equals(colaboratorEmail)) {
|
||||||
throw new InvalidColaboratorException("The user " + owner.getEmail() + " is the owner");
|
throw new InvalidColaboratorException("The user " + owner.getEmail() + " is the owner");
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import com.wisemapping.model.MindMap;
|
|||||||
import com.wisemapping.model.MindmapUser;
|
import com.wisemapping.model.MindmapUser;
|
||||||
import com.wisemapping.model.UserRole;
|
import com.wisemapping.model.UserRole;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
|
import com.wisemapping.security.Utils;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -57,6 +58,10 @@ public class MindMapBean {
|
|||||||
return mindMap.getId();
|
return mindMap.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isStarred() {
|
||||||
|
return mindMap.isStarred(Utils.getUser());
|
||||||
|
}
|
||||||
|
|
||||||
public List<ColaboratorBean> getViewers() {
|
public List<ColaboratorBean> getViewers() {
|
||||||
return viewers;
|
return viewers;
|
||||||
}
|
}
|
||||||
|
@ -231,11 +231,9 @@ UNEXPECTED_ERROR_SERVER_ERROR=We're sorry, an error has occurred and we can't pr
|
|||||||
NO_ENOUGH_PERMISSIONS=Outch!!. This map is not available anymore.
|
NO_ENOUGH_PERMISSIONS=Outch!!. This map is not available anymore.
|
||||||
NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted.
|
NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted.
|
||||||
SHARING=Sharing
|
SHARING=Sharing
|
||||||
IMPORT_MINDMAP=Import map
|
IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 maps and WiseMapping maps to your list of maps. Select the file you want to import.
|
||||||
IMPORT_MINDMAP_DETAILS=Do you already have maps created with FreeMind?.No problem, Import them!.
|
|
||||||
IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 version maps to WiseMapping. Please, select the FreeMind map that want to import. <br/>Fields marked with an asterisk <span class="fieldRequired">*</span> are required.
|
|
||||||
PRINT=Print
|
PRINT=Print
|
||||||
FREE_MIND_FILE=FreeMind File
|
MIND_FILE=File
|
||||||
IMPORT_MAP_ERROR=FreeMind file could not be imported. {0}
|
IMPORT_MAP_ERROR=FreeMind file could not be imported. {0}
|
||||||
MAP_TITLE_ALREADY_EXISTS=A map already exists with this name.
|
MAP_TITLE_ALREADY_EXISTS=A map already exists with this name.
|
||||||
EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post!
|
EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post!
|
||||||
|
@ -215,9 +215,8 @@ NO_ENOUGH_PERMISSIONS_DETAILS=No tiene suficiente permisos de acceso para ver es
|
|||||||
SHARING=Colaboración
|
SHARING=Colaboración
|
||||||
IMPORT_MINDMAP=Importar mapa
|
IMPORT_MINDMAP=Importar mapa
|
||||||
IMPORT_MINDMAP_DETAILS=Tiene mapas creados con FreeMind?. Ningun problema, los puede importar!.
|
IMPORT_MINDMAP_DETAILS=Tiene mapas creados con FreeMind?. Ningun problema, los puede importar!.
|
||||||
IMPORT_MINDMAP_INFO=Ahora puedes importar mapas de FreeMind a WiseMapping. Por favor, seleccione el mapa FreeMind que desea importar. <br/>Los campos marcados con un asterisco <span class="fieldRequired">*</span> son requeridos.
|
|
||||||
PRINT=Imprimir
|
PRINT=Imprimir
|
||||||
FREE_MIND_FILE=Archivo FreeMind
|
FREE_MIND_FILE=Archivo de mapa mentaa
|
||||||
IMPORT_MAP_ERROR=El archivo importado no parece ser un archivo FreeMind válido
|
IMPORT_MAP_ERROR=El archivo importado no parece ser un archivo FreeMind válido
|
||||||
MAP_TITLE_ALREADY_EXISTS=Nombre de mapa ya existente.
|
MAP_TITLE_ALREADY_EXISTS=Nombre de mapa ya existente.
|
||||||
EMBEDDED_VIEWER=Incluya un visor de mapa en su sitio web, blog o post.
|
EMBEDDED_VIEWER=Incluya un visor de mapa en su sitio web, blog o post.
|
||||||
|
@ -230,9 +230,7 @@ NO_ENOUGH_PERMISSIONS_DETAILS = Vous ne pouvez pas acc\u00e9der \u00e0 cette car
|
|||||||
SHARING = Partager
|
SHARING = Partager
|
||||||
IMPORT_MINDMAP = Importer une carte
|
IMPORT_MINDMAP = Importer une carte
|
||||||
IMPORT_MINDMAP_DETAILS = Vous avez d\u00e9j\u00e0 cr\u00e9\u00e9 des cartes sur FreeMind ou FreePlane? Pas de probl\u00e9me, importez-les!
|
IMPORT_MINDMAP_DETAILS = Vous avez d\u00e9j\u00e0 cr\u00e9\u00e9 des cartes sur FreeMind ou FreePlane? Pas de probl\u00e9me, importez-les!
|
||||||
IMPORT_MINDMAP_INFO=Vous pouvez importer les cartes FreeMind dans WiseMapping. Choisissez la carte que vous souhaiez importer. <br/>Les champs avec une ast\u00e9risque sont requis.
|
|
||||||
PRINT = Imprimer
|
PRINT = Imprimer
|
||||||
FREE_MIND_FILE = Fichier FreeMind
|
|
||||||
IMPORT_MAP_ERROR = Le fichier import\u00e9 ne semble pas \u00eatre un fichier FreeMind valide.
|
IMPORT_MAP_ERROR = Le fichier import\u00e9 ne semble pas \u00eatre un fichier FreeMind valide.
|
||||||
MAP_TITLE_ALREADY_EXISTS = Le titre de la carte existe d\u00e9j\u00e0.
|
MAP_TITLE_ALREADY_EXISTS = Le titre de la carte existe d\u00e9j\u00e0.
|
||||||
EMBEDDED_VIEWER = Int\u00e9grer un visualiseur de carte dans votre propre site internet, blog ou billet.
|
EMBEDDED_VIEWER = Int\u00e9grer un visualiseur de carte dans votre propre site internet, blog ou billet.
|
||||||
|
@ -164,9 +164,7 @@
|
|||||||
<put name="body" value="/jsp/keyboard.jsp"/>
|
<put name="body" value="/jsp/keyboard.jsp"/>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="mindmapImport" extends="pageTemplate">
|
<definition name="mindmapImport" extends="dialogTemplate">
|
||||||
<put name="title" value="IMPORT_MINDMAP"/>
|
|
||||||
<put name="details" value="IMPORT_MINDMAP_INFO"/>
|
|
||||||
<put name="body" value="/jsp/mindmapImport.jsp"/>
|
<put name="body" value="/jsp/mindmapImport.jsp"/>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
|
@ -27,12 +27,6 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<bean id="cookerController" class="com.wisemapping.controller.MindmapCooker">
|
|
||||||
<property name="methodNameResolver" ref="paramResolverByAction"/>
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
<property name="userService" ref="userService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="loginController" class="com.wisemapping.controller.LoginController">
|
<bean id="loginController" class="com.wisemapping.controller.LoginController">
|
||||||
<property name="methodNameResolver" ref="paramResolverByAction"/>
|
<property name="methodNameResolver" ref="paramResolverByAction"/>
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
<property name="mindmapService" ref="mindmapService"/>
|
||||||
@ -131,11 +125,6 @@
|
|||||||
<property name="userService" ref="userService"/>
|
<property name="userService" ref="userService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="publicView" class="com.wisemapping.controller.PublicViewController">
|
|
||||||
<property name="methodNameResolver" ref="paramResolverByAction"/>
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
||||||
<property name="interceptors">
|
<property name="interceptors">
|
||||||
<list>
|
<list>
|
||||||
@ -145,9 +134,6 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="mappings">
|
<property name="mappings">
|
||||||
<props>
|
<props>
|
||||||
<!-- Review -->
|
|
||||||
<prop key="publicView">publicView</prop>
|
|
||||||
|
|
||||||
<!-- Forms based -->
|
<!-- Forms based -->
|
||||||
<prop key="userRegistration">userController</prop>
|
<prop key="userRegistration">userController</prop>
|
||||||
<prop key="sharing">sharingController</prop>
|
<prop key="sharing">sharingController</prop>
|
||||||
@ -155,7 +141,6 @@
|
|||||||
<prop key="forgotPassword">forgotPasswordController</prop>
|
<prop key="forgotPassword">forgotPasswordController</prop>
|
||||||
<prop key="activation">activationController</prop>
|
<prop key="activation">activationController</prop>
|
||||||
<prop key="changePassword">changePasswordController</prop>
|
<prop key="changePassword">changePasswordController</prop>
|
||||||
<prop key="cooker">cookerController</prop>
|
|
||||||
<prop key="settings">settingsController</prop>
|
<prop key="settings">settingsController</prop>
|
||||||
<prop key="editProfile">editProfileController</prop>
|
<prop key="editProfile">editProfileController</prop>
|
||||||
<prop key="history">historyController</prop>
|
<prop key="history">historyController</prop>
|
||||||
|
@ -161,6 +161,8 @@ jQuery.fn.dialogForm = function(options) {
|
|||||||
dialogElem.modal('hide');
|
dialogElem.modal('hide');
|
||||||
$('#messagesPanel div').text(errorThrown).parent().show();
|
$('#messagesPanel div').text(errorThrown).parent().show();
|
||||||
}
|
}
|
||||||
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
|
acceptBtn.button('reset');
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -348,10 +350,6 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#importBtn").click(function() {
|
|
||||||
window.location = 'c/maps/import';
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#duplicateBtn").click(function() {
|
$("#duplicateBtn").click(function() {
|
||||||
// Map to be cloned ...
|
// Map to be cloned ...
|
||||||
var tableElem = $('#mindmapListTable');
|
var tableElem = $('#mindmapListTable');
|
||||||
@ -433,40 +431,36 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#infoBtn").click(function() {
|
$("#infoBtn").click(function() {
|
||||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
showEmbeddedDialog("c/maps/{mapId}/details", 'info-dialog-modal');
|
||||||
if (mapIds.length > 0) {
|
|
||||||
$('#info-dialog-modal .modal-body').load("c/maps/" + mapIds[0] + "/details", function() {
|
|
||||||
$('#info-dialog-modal').modal();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#publishBtn").click(function() {
|
$("#publishBtn").click(function() {
|
||||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
showEmbeddedDialog("c/maps/{mapId}/publish", "publish-dialog-modal");
|
||||||
if (mapIds.length > 0) {
|
|
||||||
$('#publish-dialog-modal .modal-body').load("c/maps/" + mapIds[0] + "/publish",
|
|
||||||
function() {
|
|
||||||
$('#publish-dialog-modal .btn-accept').click(function() {
|
|
||||||
submitDialogForm();
|
|
||||||
});
|
|
||||||
$('#publish-dialog-modal').modal();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#exportBtn").click(function() {
|
$("#exportBtn").click(function() {
|
||||||
|
showEmbeddedDialog("c/maps/{mapId}/export", 'export-dialog-modal');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#importBtn").click(function() {
|
||||||
|
showEmbeddedDialog("c/maps/import", 'import-dialog-modal', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var showEmbeddedDialog = function(urlTemplate, dialogElemId, ignore) {
|
||||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||||
if (mapIds.length > 0) {
|
if (mapIds.length > 0 || ignore) {
|
||||||
$('#export-dialog-modal .modal-body').load("c/maps/" + mapIds[0] + "/export",
|
var mapId = mapIds[0];
|
||||||
|
$('#' + dialogElemId + ' .modal-body').load(urlTemplate.replace("{mapId}", mapId),
|
||||||
function() {
|
function() {
|
||||||
$('#export-dialog-modal .btn-accept').click(function() {
|
$('#' + dialogElemId + ' .btn-accept').click(function() {
|
||||||
submitDialogForm();
|
submitDialogForm();
|
||||||
});
|
});
|
||||||
$('#export-dialog-modal').modal();
|
$('#' + dialogElemId).modal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
|
||||||
$("#actionButtons .shareMap").click(function() {
|
$("#actionButtons .shareMap").click(function() {
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
<%@ include file="/jsp/init.jsp" %>
|
<%@ include file="/jsp/init.jsp" %>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript" language="javascript">
|
||||||
|
$(function() {
|
||||||
|
$('.btn-primary').click(function() {
|
||||||
|
$(this).button("loading");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div id="loginContent">
|
<div id="loginContent">
|
||||||
<div class="loginNews">
|
<div class="loginNews">
|
||||||
<h1>What is New: </h1>
|
<h1>What is New: </h1>
|
||||||
@ -38,8 +47,9 @@
|
|||||||
</c:if>
|
</c:if>
|
||||||
|
|
||||||
<div class="form-inline">
|
<div class="form-inline">
|
||||||
<input type="submit" class="btn btn-primary" value="<spring:message code="SIGN_IN"/>"
|
<button class="btn btn-primary" data-loading-text="<spring:message code="SIGN_IN"/> ...">
|
||||||
data-toggle="button">
|
<spring:message code="SIGN_IN"/></button>
|
||||||
|
|
||||||
<input type="checkbox" id="rememberme" name="_spring_security_remember_me"/>
|
<input type="checkbox" id="rememberme" name="_spring_security_remember_me"/>
|
||||||
<label for="rememberme"><spring:message code="REMEMBER_ME"/></label>
|
<label for="rememberme"><spring:message code="REMEMBER_ME"/></label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,68 +1,98 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
<%@ include file="/jsp/init.jsp" %>
|
||||||
|
|
||||||
<div class="fform">
|
<div id="messagePanel" class="alert alert-error">
|
||||||
<h1>
|
|
||||||
<spring:message code="${requestScope.title}"/>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<p><spring:message code="${requestScope.details}"/></p>
|
</div>
|
||||||
|
|
||||||
<form method="post" enctype="multipart/form-data" action="#">
|
<div>
|
||||||
|
|
||||||
|
<p class="well"><spring:message code="IMPORT_MINDMAP_INFO"/></p>
|
||||||
|
|
||||||
|
<form method="POST" enctype="multipart/form-data" action="#" id="dialogMainForm" class="form-horizontal">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="title"><spring:message code="NAME"/></label>
|
<div class="control-group">
|
||||||
<input type="text" id="title" required="required"/>
|
<label for="mapFile" class="control-label"><spring:message code="MIND_FILE"/>: </label>
|
||||||
|
<input type="file" name="mapFile" id="mapFile" required="required" class="control"/>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label for="title" class="control-label"><spring:message code="NAME"/>: </label>
|
||||||
|
<input type="text" id="title" required="required" placeholder="Name of the new map to create"
|
||||||
|
class="control"/>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
|
||||||
<label for="description"><spring:message code="DESCRIPTION"/></label>
|
<label for="description" class="control-label"><spring:message code="DESCRIPTION"/>: </label>
|
||||||
<input type="text" name="description" id="description"/>
|
<textarea type="text" name="description" id="description"
|
||||||
|
placeholder="Some description for your map" class="control"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label><spring:message code="DESCRIPTION"/> </label>
|
|
||||||
<input type="radio" name="type" value="mm"/> Freemind (0.9)
|
|
||||||
<input type="radio" name="type" value="wxml"/> WiseMapping
|
|
||||||
|
|
||||||
<label for="mapFile"><spring:message code="FREE_MIND_FILE"/></label>
|
|
||||||
<input type="file" name="mapFile" id="mapFile"/>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<input type="button" id="acceptButton" value="<spring:message code="IMPORT"/>" class="btn btn-primary"/>
|
|
||||||
<input type="button" id="cancelButton" value="<spring:message code="CANCEL"/>" class="btn">
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
// @Todo: Pending: report errors, manage corrupted mapsmanage case,escape url parameters, import with same title tries to save in post XML, explanation.
|
||||||
|
|
||||||
|
$('#messagePanel').hide();
|
||||||
|
|
||||||
// Save status on click ...
|
// Save status on click ...
|
||||||
|
var contentType = null;
|
||||||
|
var fileContent = null;
|
||||||
|
|
||||||
$('#cancelButton').click(function() {
|
$('#cancelButton').click(function() {
|
||||||
window.location = '/c/maps/';
|
window.location = '/c/maps/';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#dialogMainForm').submit(function(event) {
|
||||||
|
// Load form parameters ...
|
||||||
|
var title = $('#dialogMainForm #title').attr('value');
|
||||||
|
title = title == undefined ? "" : title;
|
||||||
|
|
||||||
$('#acceptButton').click(function(event) {
|
var description = $('#dialogMainForm #description').attr('value');
|
||||||
|
description = description == undefined ? "" : description;
|
||||||
|
|
||||||
// http://www.html5rocks.com/en/tutorials/file/dndfiles/
|
// Save status on click ...
|
||||||
var content;
|
jQuery.ajax("service/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
|
||||||
if (window.FileReader) {
|
{
|
||||||
reader = new FileReader();
|
|
||||||
reader.onloadend = function (e) {
|
|
||||||
content = e.target.result;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.ajax("service/maps", {
|
|
||||||
async:false,
|
async:false,
|
||||||
dataType: 'application/freemind',
|
data: fileContent,
|
||||||
data: "",
|
type: 'POST',
|
||||||
type: 'PUT',
|
dataType: 'json',
|
||||||
contentType:"text/plain",
|
contentType:contentType,
|
||||||
success : function(data, textStatus, jqXHR) {
|
success : function(data, textStatus, jqXHR) {
|
||||||
|
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||||
|
window.location = "c/maps/" + resourceId + "/edit";
|
||||||
},
|
},
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
$('#messagePanel').text(textStatus);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#dialogMainForm #mapFile').change(function(event) {
|
||||||
|
var file = event.target.files[0];
|
||||||
|
var reader = new FileReader();
|
||||||
|
|
||||||
|
var title = file.name;
|
||||||
|
title = title.substring(0, title.lastIndexOf("."));
|
||||||
|
$('#dialogMainForm #title').attr('value', jQuery.camelCase(title));
|
||||||
|
|
||||||
|
// Closure to capture the file information.
|
||||||
|
reader.onload = (function(event) {
|
||||||
|
fileContent = event.target.result;
|
||||||
|
contentType = file.name.lastIndexOf(".wxml") != -1 ? "application/xml" : "application/freemind";
|
||||||
|
});
|
||||||
|
|
||||||
|
// Read in the image file as a data URL.
|
||||||
|
reader.readAsBinaryString(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hook for interaction with the main parent window ...
|
// Hook for interaction with the main parent window ...
|
||||||
var submitDialogForm = function() {
|
var submitDialogForm = function() {
|
||||||
$('#dialogMainForm').submit();
|
$('#dialogMainForm').submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
@ -40,6 +40,7 @@
|
|||||||
<div id="mindmapListContainer">
|
<div id="mindmapListContainer">
|
||||||
<div id="messagesPanel" class="alert alert-error alert-block fade in hide" style="margin-top: 10px">
|
<div id="messagesPanel" class="alert alert-error alert-block fade in hide" style="margin-top: 10px">
|
||||||
<strong><spring:message code="UNEXPECTED_ERROR"/></strong>
|
<strong><spring:message code="UNEXPECTED_ERROR"/></strong>
|
||||||
|
|
||||||
<p><spring:message code="UNEXPECTED_ERROR_SERVER_ERROR"/></p>
|
<p><spring:message code="UNEXPECTED_ERROR_SERVER_ERROR"/></p>
|
||||||
|
|
||||||
<div></div>
|
<div></div>
|
||||||
@ -264,6 +265,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Export Dialog Config -->
|
||||||
|
<div id="import-dialog-modal" class="modal fade" style="display: none">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button class="close" data-dismiss="modal">x</button>
|
||||||
|
<h3>Import</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary btn-accept" data-loading-text="Importing...">Import</button>
|
||||||
|
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript" language="javascript" src="js/jquery-1.7.2.min.js"></script>
|
<script type="text/javascript" language="javascript" src="js/jquery-1.7.2.min.js"></script>
|
||||||
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
|
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
|
||||||
|
<script src="js/less.js" type="text/javascript"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user