Finish mindmapHistory rest service.
This commit is contained in:
@@ -1,71 +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.model.MindMap;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public abstract class BaseMultiActionController
|
||||
extends MultiActionController {
|
||||
|
||||
private MindmapService mindmapService;
|
||||
private UserService userService;
|
||||
|
||||
protected MindMap getMindmapFromRequest(HttpServletRequest request) {
|
||||
final String mapIdStr = request.getParameter(MAP_ID_PARAMNAME);
|
||||
assert mapIdStr != null : "mapId parameter can not be null";
|
||||
logger.info("MapIdStr:" + mapIdStr);
|
||||
MindMap map = null;
|
||||
int mapId;
|
||||
try {
|
||||
mapId = Integer.parseInt(mapIdStr);
|
||||
map = mindmapService.getMindmapById(mapId);
|
||||
} catch (Exception e) {
|
||||
logger.debug("An error ocurred trying to get mapId " + mapIdStr + "'", e);
|
||||
}
|
||||
|
||||
if (map == null) {
|
||||
throw new IllegalStateException("Map with id '" + mapIdStr + "' can not be found");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public MindmapService getMindmapService() {
|
||||
return mindmapService;
|
||||
}
|
||||
|
||||
public void setMindmapService(MindmapService mindmapService) {
|
||||
this.mindmapService = mindmapService;
|
||||
}
|
||||
|
||||
public UserService getUserService() {
|
||||
return userService;
|
||||
}
|
||||
|
||||
public void setUserService(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public static final String MAP_ID_PARAMNAME = "mapId";
|
||||
public static final String MINDMAP_EMAILS_PARAMNAME = "userEmails";
|
||||
}
|
@@ -46,17 +46,10 @@ public class BaseSimpleFormController extends SimpleFormController
|
||||
return mindmapService;
|
||||
}
|
||||
|
||||
public void setMindmapService(MindmapService mindmapService) {
|
||||
this.mindmapService = mindmapService;
|
||||
}
|
||||
|
||||
public String getErrorView() {
|
||||
return errorView;
|
||||
}
|
||||
|
||||
public void setErrorView(String errorView) {
|
||||
this.errorView = errorView;
|
||||
}
|
||||
|
||||
@Override protected org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, org.springframework.validation.BindException bindException) throws java.lang.Exception
|
||||
{
|
||||
@@ -69,15 +62,6 @@ public class BaseSimpleFormController extends SimpleFormController
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
/* TODO codigo repetido en BaseMultiActionController */
|
||||
protected MindMap getMindmapFromRequest(HttpServletRequest request) {
|
||||
final String mapIdStr = request.getParameter(BaseMultiActionController.MAP_ID_PARAMNAME);
|
||||
assert mapIdStr != null : "mapId parameter can not be null";
|
||||
logger.info("MapIdStr:" + mapIdStr);
|
||||
int mapId = Integer.parseInt(mapIdStr);
|
||||
return mindmapService.getMindmapById(mapId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,82 +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.model.MindMap;
|
||||
import com.wisemapping.model.MindMapHistory;
|
||||
import com.wisemapping.view.HistoryBean;
|
||||
import com.wisemapping.view.MindMapBean;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HistoryController
|
||||
extends BaseMultiActionController
|
||||
{
|
||||
private static final String HISTORY_ID = "historyId";
|
||||
|
||||
public ModelAndView list(HttpServletRequest request, HttpServletResponse response)
|
||||
throws java.lang.Exception {
|
||||
|
||||
final MindMap map = getMindmapFromRequest(request);
|
||||
final List<HistoryBean> historyBeanList = createHistoryBeanList(map);
|
||||
|
||||
final Map<String,Object> attr = new HashMap<String,Object>();
|
||||
attr.put("minmap",new MindMapBean(map));
|
||||
attr.put("goToMindmapList",request.getParameter("goToMindmapList"));
|
||||
attr.put("historyBeanList",historyBeanList);
|
||||
return new ModelAndView("mindmapHistory",attr);
|
||||
}
|
||||
|
||||
public ModelAndView revert(HttpServletRequest request, HttpServletResponse response)
|
||||
throws java.lang.Exception {
|
||||
|
||||
final MindMap map = getMindmapFromRequest(request);
|
||||
final int revertId = Integer.parseInt(request.getParameter(HISTORY_ID));
|
||||
getMindmapService().revertMapToHistory(map, revertId);
|
||||
final StringBuilder redirectionTo = new StringBuilder("redirect:");
|
||||
|
||||
String goToMindmapList = request.getParameter("goToMindmapList");
|
||||
if (goToMindmapList != null)
|
||||
{
|
||||
redirectionTo.append("maps/");
|
||||
}
|
||||
else
|
||||
{
|
||||
redirectionTo.append("editor?mapId=");
|
||||
redirectionTo.append(map.getId());
|
||||
redirectionTo.append("&action=open");
|
||||
}
|
||||
return new ModelAndView(redirectionTo.toString());
|
||||
}
|
||||
|
||||
private List<HistoryBean> createHistoryBeanList(MindMap map) {
|
||||
final List<MindMapHistory> list = getMindmapService().getMindMapHistory(map.getId());
|
||||
final List<HistoryBean> historyBeanList = new ArrayList<HistoryBean>(list.size());
|
||||
for (MindMapHistory mindMapHistory : list) {
|
||||
historyBeanList.add(new HistoryBean(mindMapHistory.getMindmapId(),mindMapHistory.getId(),mindMapHistory.getCreator(),mindMapHistory.getCreationTime()));
|
||||
}
|
||||
return historyBeanList;
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMeth
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class SettingsController extends BaseMultiActionController {
|
||||
public class SettingsController {
|
||||
|
||||
public ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
|
||||
throws Exception {
|
||||
|
@@ -37,7 +37,7 @@ public class TagsController
|
||||
//~ Methods ..............................................................................................
|
||||
protected Object formBackingObject(HttpServletRequest httpServletRequest) throws Exception {
|
||||
|
||||
final MindMap mindmap = getMindmapFromRequest(httpServletRequest);
|
||||
final MindMap mindmap = null;
|
||||
final User user = Utils.getUser(httpServletRequest);
|
||||
final User dbUser = getUserService().getUserBy(user.getId());
|
||||
|
||||
|
@@ -47,7 +47,7 @@ public interface MindmapManager {
|
||||
|
||||
void saveMindmap(MindMap mindMap);
|
||||
|
||||
void updateMindmap(MindMap mindMap, boolean saveHistory);
|
||||
void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory);
|
||||
|
||||
void removeCollaborator(@NotNull Collaborator collaborator);
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
@@ -20,11 +19,8 @@
|
||||
package com.wisemapping.ncontroller;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.filter.UserAgent;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.view.MindMapBean;
|
||||
@@ -32,77 +28,100 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class MindmapController {
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
@Qualifier("mindmapService")
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@RequestMapping(value = "maps/{id}/export")
|
||||
public ModelAndView showExportPage(@PathVariable int id) throws IOException {
|
||||
final MindMapBean modelObject = findMindmapBean(id);
|
||||
return new ModelAndView("mindmapExport", "mindmap", modelObject);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/import")
|
||||
public ModelAndView showImportPAge() throws IOException {
|
||||
return new ModelAndView("mindmapImport");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/exportf")
|
||||
public ModelAndView showExportPageFull(@PathVariable int id) throws IOException {
|
||||
final MindMapBean modelObject = findMindmapBean(id);
|
||||
return new ModelAndView("mindmapExportFull", "mindmap", modelObject);
|
||||
public String showImportPage() {
|
||||
return "mindmapImport";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/details")
|
||||
public ModelAndView showDetails(@PathVariable int id) {
|
||||
final MindMapBean modelObject = findMindmapBean(id);
|
||||
final ModelAndView view = new ModelAndView("mindmapDetail", "wisemapDetail", modelObject);
|
||||
view.addObject("user", Utils.getUser());
|
||||
return view;
|
||||
public String showDetails(@PathVariable int id, @NotNull Model model) {
|
||||
final MindMapBean mindmap = findMindmapBean(id);
|
||||
model.addAttribute("mindmap", mindmap);
|
||||
return "mindmapDetail";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/print")
|
||||
public ModelAndView showPrintPage(@PathVariable int id) {
|
||||
public String showPrintPage(@PathVariable int id, @NotNull Model model) {
|
||||
final MindMap mindmap = findMindmap(id);
|
||||
return new ModelAndView("mindmapPrint", "mindmap", mindmap);
|
||||
model.addAttribute("mindmap", mindmap);
|
||||
return "mindmapPrint";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/view")
|
||||
public String showViewPage(@PathVariable int id, @NotNull Model model) {
|
||||
final MindMap mindmap = findMindmap(id);
|
||||
model.addAttribute("mindmap", mindmap);
|
||||
return "mindmapPrint";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/export")
|
||||
public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException {
|
||||
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 {
|
||||
showExportPage(id, model);
|
||||
return "mindmapExportFull";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/share")
|
||||
public ModelAndView showSharePage(@PathVariable int id) {
|
||||
public String showSharePage(@PathVariable int id, @NotNull Model model) {
|
||||
final MindMap mindmap = findMindmap(id);
|
||||
return new ModelAndView("mindmapShare", "mindmap", mindmap);
|
||||
model.addAttribute("mindmap", mindmap);
|
||||
return "mindmapShare";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/sharef")
|
||||
public ModelAndView showSharePageFull(@PathVariable int id) {
|
||||
final MindMap mindmap = findMindmap(id);
|
||||
return new ModelAndView("mindmapShareFull", "mindmap", mindmap);
|
||||
public String showSharePageFull(@PathVariable int id, @NotNull Model model) {
|
||||
showSharePage(id, model);
|
||||
return "mindmapShareFull";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/publish")
|
||||
public ModelAndView showPublishPage(@PathVariable int id) {
|
||||
public String showPublishPage(@PathVariable int id, @NotNull Model model) {
|
||||
final MindMap mindmap = findMindmap(id);
|
||||
return new ModelAndView("mindmapPublish", "mindmap", mindmap);
|
||||
model.addAttribute("mindmap", mindmap);
|
||||
return "mindmapPublish";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/publishf")
|
||||
public ModelAndView showPublishPageFull(@PathVariable int id) {
|
||||
final MindMap mindmap = findMindmap(id);
|
||||
return new ModelAndView("mindmapPublishFull", "mindmap", mindmap);
|
||||
public String showPublishPageFull(@PathVariable int id, @NotNull Model model) {
|
||||
showPublishPage(id, model);
|
||||
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() {
|
||||
return "mindmapList";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/edit")
|
||||
@@ -114,7 +133,7 @@ public class MindmapController {
|
||||
// view.addObject(MINDMAP_ID_PARAMETER, mindmapId);
|
||||
} else {
|
||||
|
||||
final MindMap mindmap = mindmapService.getMindmapById(id);
|
||||
final MindMapBean mindmap = findMindmapBean(id);
|
||||
view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
|
||||
view.addObject("editorTryMode", false);
|
||||
final boolean showHelp = isWelcomeMap(mindmap);
|
||||
@@ -125,9 +144,8 @@ public class MindmapController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/embed")
|
||||
public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom, @NotNull HttpServletRequest request) {
|
||||
public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom) {
|
||||
ModelAndView view;
|
||||
final UserAgent userAgent = UserAgent.create(request);
|
||||
final MindMap mindmap = mindmapService.getMindmapById(id);
|
||||
view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap);
|
||||
view.addObject("user", Utils.getUser());
|
||||
@@ -135,64 +153,6 @@ public class MindmapController {
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "collaborator")
|
||||
public ModelAndView showCollaborator(@RequestParam(required = true) long mapId) {
|
||||
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||
return new ModelAndView("mindmapCollaborator", "mindmap", modelObject);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "viewer")
|
||||
public ModelAndView viewer(@RequestParam(required = true) long mapId) {
|
||||
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||
return new ModelAndView("mindmapViewer", "wisemapsList", modelObject);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "changeStatus")
|
||||
public ModelAndView changeStatus(@RequestParam(required = true) long mapId) throws WiseMappingException {
|
||||
final MindMap mindmap = findMindmap(mapId);
|
||||
boolean isPublic = !mindmap.isPublic();
|
||||
mindmap.setPublic(isPublic);
|
||||
mindmapService.updateMindmap(mindmap, false);
|
||||
return new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindmap));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/")
|
||||
public ModelAndView list(@NotNull HttpServletRequest request) {
|
||||
final HttpSession session = request.getSession(false);
|
||||
|
||||
// Try to loaded from the request ...
|
||||
UserAgent userAgent = null;
|
||||
if (session != null) {
|
||||
userAgent = (UserAgent) session.getAttribute(USER_AGENT);
|
||||
}
|
||||
|
||||
// I could not loaded. I will create a new one...
|
||||
if (userAgent == null) {
|
||||
userAgent = UserAgent.create(request);
|
||||
if (session != null) {
|
||||
session.setAttribute(USER_AGENT, userAgent);
|
||||
}
|
||||
}
|
||||
|
||||
// It's a supported browser ?.
|
||||
final UserAgent.OS os = userAgent.getOs();
|
||||
|
||||
final User user = Utils.getUser();
|
||||
final ModelAndView view = new ModelAndView("mindmapList", "wisemapsList", findMindMapBeanList(user));
|
||||
view.addObject("isMAC", os == UserAgent.OS.MAC);
|
||||
view.addObject("user", user);
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "updateMindmap")
|
||||
public ModelAndView updateMindmap(@RequestParam(required = true) long mapId, @RequestParam(required = true) String title, @RequestParam(required = true) String description, @NotNull HttpServletRequest request) throws WiseMappingException {
|
||||
final MindMap mindmap = findMindmap(mapId);
|
||||
mindmap.setTitle(title);
|
||||
mindmap.setDescription(description);
|
||||
|
||||
mindmapService.updateMindmap(mindmap, false);
|
||||
return list(request);
|
||||
}
|
||||
|
||||
private MindMap findMindmap(long mapId) {
|
||||
final MindMap mindmap = mindmapService.getMindmapById((int) mapId);
|
||||
@@ -202,24 +162,11 @@ public class MindmapController {
|
||||
return mindmap;
|
||||
}
|
||||
|
||||
private List<MindMapBean> findMindMapBeanList(@NotNull User user) {
|
||||
final List<Collaboration> userMindmaps = mindmapService.getCollaborationsBy(user);
|
||||
|
||||
final List<MindMapBean> mindMapBeans = new ArrayList<MindMapBean>(userMindmaps.size());
|
||||
for (Collaboration mindmap : userMindmaps) {
|
||||
mindMapBeans.add(new MindMapBean(mindmap.getMindMap()));
|
||||
}
|
||||
return mindMapBeans;
|
||||
}
|
||||
|
||||
private MindMapBean findMindmapBean(long mapId) {
|
||||
return new MindMapBean(findMindmap(mapId));
|
||||
}
|
||||
|
||||
private boolean isWelcomeMap(MindMap map) {
|
||||
private boolean isWelcomeMap(MindMapBean map) {
|
||||
return map.getTitle().startsWith("Welcome ");
|
||||
}
|
||||
|
||||
|
||||
private static final String USER_AGENT = "wisemapping.userAgent";
|
||||
}
|
||||
|
@@ -105,13 +105,12 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"})
|
||||
public ModelAndView retrieveHistory(@PathVariable int id) throws IOException {
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||
final RestCollaborationList result = new RestCollaborationList();
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
result.addCollaboration(new RestCollaboration(collaboration));
|
||||
final List<MindMapHistory> histories = mindmapService.getMindMapHistory(id);
|
||||
final RestMindmapHistoryList result = new RestMindmapHistoryList();
|
||||
for (MindMapHistory history : histories) {
|
||||
result.addHistory(new RestMindmapHistory(history));
|
||||
}
|
||||
return new ModelAndView("collabView", "list", result);
|
||||
return new ModelAndView("historyView", "list", result);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@@ -410,7 +409,7 @@ public class MindmapController extends BaseController {
|
||||
final Calendar now = Calendar.getInstance();
|
||||
mindMap.setLastModificationTime(now);
|
||||
mindMap.setLastModifierUser(user.getUsername());
|
||||
mindmapService.updateMindmap(mindMap, minor);
|
||||
mindmapService.updateMindmap(mindMap, !minor);
|
||||
}
|
||||
|
||||
private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException {
|
||||
|
@@ -0,0 +1,76 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindMapHistory;
|
||||
import com.wisemapping.security.Utils;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@XmlRootElement(name = "history")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
|
||||
)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestMindmapHistory {
|
||||
|
||||
static private SimpleDateFormat sdf;
|
||||
private int id;
|
||||
private Calendar creation;
|
||||
private String creator;
|
||||
|
||||
static {
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public RestMindmapHistory(@NotNull MindMapHistory history) {
|
||||
this.id = history.getId();
|
||||
this.creation = history.getCreationTime();
|
||||
this.creator = history.getCreator();
|
||||
}
|
||||
|
||||
public String getCreationTime() {
|
||||
return this.toISO8601(creation.getTime());
|
||||
}
|
||||
|
||||
public void setCreationTime() {
|
||||
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator() {
|
||||
// Do nothing ...
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
}
|
||||
|
||||
private String toISO8601(@NotNull Date date) {
|
||||
return sdf.format(date) + "Z";
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "history")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestMindmapHistoryList {
|
||||
|
||||
private List<RestMindmapHistory> changes;
|
||||
|
||||
public RestMindmapHistoryList() {
|
||||
changes = new ArrayList<RestMindmapHistory>();
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.changes.size();
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "changes")
|
||||
public List<RestMindmapHistory> getChanges() {
|
||||
return changes;
|
||||
}
|
||||
|
||||
public void addHistory(@NotNull RestMindmapHistory history) {
|
||||
changes.add(history);
|
||||
}
|
||||
}
|
@@ -88,7 +88,6 @@ public class MindmapServiceImpl
|
||||
if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) {
|
||||
throw new WiseMappingException("The tile can not be empty");
|
||||
}
|
||||
|
||||
mindmapManager.updateMindmap(mindMap, saveHistory);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ import java.util.regex.Matcher;
|
||||
|
||||
import com.wisemapping.controller.Messages;
|
||||
|
||||
public class Utils {
|
||||
final public class Utils {
|
||||
//Set the email emailPattern string
|
||||
|
||||
static private Pattern emailPattern = Pattern.compile(".+@.+\\.[a-z]+");
|
||||
|
@@ -24,6 +24,7 @@ import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -34,12 +35,8 @@ public class MindMapBean {
|
||||
|
||||
public MindMapBean(final MindMap mindmap) {
|
||||
this.mindMap = mindmap;
|
||||
this.colaborators = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
|
||||
this.viewers = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
|
||||
}
|
||||
|
||||
public MindMap getMindMap() {
|
||||
return mindMap;
|
||||
this.colaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
|
||||
this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
|
||||
}
|
||||
|
||||
public boolean getPublic() {
|
||||
@@ -86,7 +83,7 @@ public class MindMapBean {
|
||||
return mindMap.getTags();
|
||||
}
|
||||
|
||||
private List<CollaboratorBean> getColaboratorBy(Set<Collaboration> source, CollaborationRole role) {
|
||||
private List<CollaboratorBean> filterCollaboratorBy(Set<Collaboration> source, CollaborationRole role) {
|
||||
List<CollaboratorBean> col = new ArrayList<CollaboratorBean>();
|
||||
if (source != null) {
|
||||
for (Collaboration mu : source) {
|
||||
@@ -98,7 +95,7 @@ public class MindMapBean {
|
||||
return col;
|
||||
}
|
||||
|
||||
public int getCountColaborators() {
|
||||
public int getCountCollaborators() {
|
||||
return colaborators != null ? colaborators.size() : 0;
|
||||
}
|
||||
|
||||
@@ -107,7 +104,7 @@ public class MindMapBean {
|
||||
}
|
||||
|
||||
public int getCountShared() {
|
||||
return getCountColaborators() + getCountViewers();
|
||||
return getCountCollaborators() + getCountViewers();
|
||||
}
|
||||
|
||||
public boolean isShared() {
|
||||
@@ -122,7 +119,20 @@ public class MindMapBean {
|
||||
mindMap.setDescription(d);
|
||||
}
|
||||
|
||||
public String getXmlAsJsLiteral() throws IOException {
|
||||
return this.mindMap.getXmlAsJsLiteral();
|
||||
}
|
||||
|
||||
public String getProperties() {
|
||||
return this.mindMap.getProperties();
|
||||
}
|
||||
|
||||
public User getCreator() {
|
||||
return mindMap.getCreator();
|
||||
}
|
||||
|
||||
public boolean isOwner() {
|
||||
return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.OWNER);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user