mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Get Collaboration list completed.
This commit is contained in:
parent
6c8664ada4
commit
aeb0ef0668
@ -1,92 +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.ColaborationEmail;
|
|
||||||
import com.wisemapping.model.CollaborationRole;
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.security.Utils;
|
|
||||||
import com.wisemapping.service.InvalidColaboratorException;
|
|
||||||
import com.wisemapping.view.MindMapBean;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
public class MindmapSharingController extends BaseMultiActionController {
|
|
||||||
private static final String COLABORATOR_ID = "colaboratorId";
|
|
||||||
|
|
||||||
public ModelAndView addCollaborator(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws InvalidColaboratorException {
|
|
||||||
logger.info("Sharing Controller: add collaborators action");
|
|
||||||
addColaborator(request, CollaborationRole.EDITOR);
|
|
||||||
return new ModelAndView("closeDialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView addViewer(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws InvalidColaboratorException {
|
|
||||||
logger.info("Sharing Controller: add viewer action");
|
|
||||||
addColaborator(request, CollaborationRole.VIEWER);
|
|
||||||
return new ModelAndView("closeDialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView removeCollaborator(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
logger.info("Sharing Controller: remove collaborator action");
|
|
||||||
final MindMap mindmap = removeColaborator(request);
|
|
||||||
return new ModelAndView("mindmapCollaborator", "mindmap", new MindMapBean(mindmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
private MindMap removeColaborator(HttpServletRequest request) {
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
final String colaboratorId = request.getParameter(COLABORATOR_ID);
|
|
||||||
long colaborator = Long.parseLong(colaboratorId);
|
|
||||||
getMindmapService().removeCollaboratorFromMindmap(mindmap, colaborator);
|
|
||||||
return mindmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getEmailsToAdd(final HttpServletRequest request) {
|
|
||||||
final String[] result;
|
|
||||||
String collaboratorEmails = request.getParameter(MINDMAP_EMAILS_PARAMNAME);
|
|
||||||
if (collaboratorEmails != null && collaboratorEmails.trim().length() > 0) {
|
|
||||||
result = collaboratorEmails.split("\\s*[,|\\;|\\s]\\s*");
|
|
||||||
} else {
|
|
||||||
result = null;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MindMapBean addColaborator(HttpServletRequest request, CollaborationRole role) throws InvalidColaboratorException {
|
|
||||||
final MindMap mindMap = getMindmapFromRequest(request);
|
|
||||||
User user = Utils.getUser();
|
|
||||||
if (!mindMap.getOwner().equals(user)) {
|
|
||||||
throw new IllegalStateException("No enought right to execute this operation");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final String[] emails = getEmailsToAdd(request);
|
|
||||||
|
|
||||||
final ColaborationEmail email = new ColaborationEmail();
|
|
||||||
email.setSubject(request.getParameter("subject"));
|
|
||||||
email.setMessage(request.getParameter("message"));
|
|
||||||
getMindmapService().addCollaborators(mindMap, emails, role, email);
|
|
||||||
|
|
||||||
return new MindMapBean(mindMap);
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,12 +19,13 @@
|
|||||||
package com.wisemapping.dao;
|
package com.wisemapping.dao;
|
||||||
|
|
||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.*;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MindmapManager {
|
public interface MindmapManager {
|
||||||
|
|
||||||
Collaborator getCollaboratorBy(String email);
|
Collaborator getCollaboratorBy(@NotNull String email);
|
||||||
|
|
||||||
Collaborator getCollaboratorBy(long id);
|
Collaborator getCollaboratorBy(long id);
|
||||||
|
|
||||||
@ -48,11 +49,11 @@ public interface MindmapManager {
|
|||||||
|
|
||||||
void updateMindmap(MindMap mindMap, boolean saveHistory);
|
void updateMindmap(MindMap mindMap, boolean saveHistory);
|
||||||
|
|
||||||
void removeCollaborator(Collaborator collaborator);
|
void removeCollaborator(@NotNull Collaborator collaborator);
|
||||||
|
|
||||||
void removeMindmap(MindMap mindap);
|
void removeMindmap(MindMap mindap);
|
||||||
|
|
||||||
void removeMindmapUser(Collaboration collaboration);
|
void removeCollaboration(Collaboration collaboration);
|
||||||
|
|
||||||
public List<MindMap> search(MindMapCriteria criteria);
|
public List<MindMap> search(MindMapCriteria criteria);
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ public class MindmapManagerImpl
|
|||||||
public List<Collaboration> getMindmapUserByRole(final CollaborationRole collaborationRole) {
|
public List<Collaboration> getMindmapUserByRole(final CollaborationRole collaborationRole) {
|
||||||
return getHibernateTemplate().find("from com.wisemapping.model.Collaboration mindmapUser where roleId=?", collaborationRole.ordinal());
|
return getHibernateTemplate().find("from com.wisemapping.model.Collaboration mindmapUser where roleId=?", collaborationRole.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collaboration getMindmapUserBy(final int mindmapId, final User user) {
|
public Collaboration getMindmapUserBy(final int mindmapId, final User user) {
|
||||||
final Collaboration result;
|
final Collaboration result;
|
||||||
@ -138,17 +139,17 @@ public class MindmapManagerImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCollaborator(Collaborator collaborator) {
|
public void addCollaborator(Collaborator collaborator) {
|
||||||
assert collaborator != null : "ADD MINDMAP COLABORATOR: Collaborator is required!";
|
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
||||||
getHibernateTemplate().save(collaborator);
|
getHibernateTemplate().save(collaborator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeMindmapUser(Collaboration collaboration) {
|
public void removeCollaboration(Collaboration collaboration) {
|
||||||
getHibernateTemplate().delete(collaboration);
|
getHibernateTemplate().delete(collaboration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCollaborator(Collaborator collaborator) {
|
public void removeCollaborator(@NotNull Collaborator collaborator) {
|
||||||
getHibernateTemplate().delete(collaborator);
|
getHibernateTemplate().delete(collaborator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class Collaboration {
|
|||||||
this.collaborator = collaborator;
|
this.collaborator = collaborator;
|
||||||
|
|
||||||
// Guarantee referential integrity
|
// Guarantee referential integrity
|
||||||
mindmap.addMindmapUser(this);
|
mindmap.addCollaboration(this);
|
||||||
collaborator.addMindmapUser(this);
|
collaborator.addMindmapUser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +60,10 @@ public class Collaboration {
|
|||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRole(@NotNull CollaborationRole role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOwner() {
|
public boolean isOwner() {
|
||||||
return getRole() == CollaborationRole.OWNER;
|
return getRole() == CollaborationRole.OWNER;
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
public class ColaborationEmail
|
public class CollaborationEmail
|
||||||
{
|
{
|
||||||
private String subject;
|
private String subject;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public ColaborationEmail(){}
|
public CollaborationEmail(){}
|
||||||
|
|
||||||
public String getSubject() {
|
public String getSubject() {
|
||||||
return subject;
|
return subject;
|
@ -20,19 +20,19 @@ package com.wisemapping.model;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class MindmapCollaborationProperties {
|
public class CollaborationProperties {
|
||||||
private long id;
|
private long id;
|
||||||
private boolean starred;
|
private boolean starred;
|
||||||
private Collaborator collaborator;
|
private Collaborator collaborator;
|
||||||
private MindMap mindmap;
|
private MindMap mindmap;
|
||||||
|
|
||||||
|
|
||||||
public MindmapCollaborationProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
|
public CollaborationProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
|
||||||
this.collaborator = collaborator;
|
this.collaborator = collaborator;
|
||||||
this.mindmap = mindmap;
|
this.mindmap = mindmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindmapCollaborationProperties(){
|
public CollaborationProperties(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +20,7 @@ package com.wisemapping.model;
|
|||||||
|
|
||||||
import com.wisemapping.util.ZipUtils;
|
import com.wisemapping.util.ZipUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -42,7 +43,7 @@ public class MindMap {
|
|||||||
private String lastModifierUser;
|
private String lastModifierUser;
|
||||||
|
|
||||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||||
private Set<MindmapCollaborationProperties> collaboratorProperties = new HashSet<MindmapCollaborationProperties>();
|
private Set<CollaborationProperties> collaborationProperties = new HashSet<CollaborationProperties>();
|
||||||
|
|
||||||
private User owner;
|
private User owner;
|
||||||
private String properties;
|
private String properties;
|
||||||
@ -55,10 +56,6 @@ public class MindMap {
|
|||||||
public MindMap() {
|
public MindMap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindMap(Set<Collaboration> collaborations) {
|
|
||||||
this.collaborations = collaborations;
|
|
||||||
}
|
|
||||||
|
|
||||||
//~ Methods ..............................................................................................
|
//~ Methods ..............................................................................................
|
||||||
|
|
||||||
public void setXml(byte[] xml) {
|
public void setXml(byte[] xml) {
|
||||||
@ -119,10 +116,26 @@ public class MindMap {
|
|||||||
this.collaborations = collaborations;
|
this.collaborations = collaborations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMindmapUser(Collaboration collaboration) {
|
public void addCollaboration(@NotNull Collaboration collaboration) {
|
||||||
collaborations.add(collaboration);
|
collaborations.add(collaboration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removedCollaboration(@NotNull Collaboration collaboration) {
|
||||||
|
collaborations.add(collaboration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Collaboration findCollaborationByEmail(@NotNull String email) {
|
||||||
|
Collaboration result = null;
|
||||||
|
for (Collaboration collaboration : collaborations) {
|
||||||
|
if (collaboration.getCollaborator().getEmail().equals(email)) {
|
||||||
|
result = collaboration;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return isPublic;
|
return isPublic;
|
||||||
}
|
}
|
||||||
@ -222,18 +235,18 @@ public class MindMap {
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MindmapCollaborationProperties> getCollaboratorProperties() {
|
public Set<CollaborationProperties> getCollaborationProperties() {
|
||||||
return collaboratorProperties;
|
return collaborationProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollaboratorProperties(@NotNull Set<MindmapCollaborationProperties> collaboratorProperties) {
|
public void setCollaborationProperties(@NotNull Set<CollaborationProperties> collaborationProperties) {
|
||||||
this.collaboratorProperties = collaboratorProperties;
|
this.collaborationProperties = collaborationProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MindmapCollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
|
private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
|
||||||
final Set<MindmapCollaborationProperties> collaboratorProperties = this.getCollaboratorProperties();
|
final Set<CollaborationProperties> collaborationProp = this.getCollaborationProperties();
|
||||||
MindmapCollaborationProperties result = null;
|
CollaborationProperties result = null;
|
||||||
for (MindmapCollaborationProperties collaboratorProperty : collaboratorProperties) {
|
for (CollaborationProperties collaboratorProperty : collaborationProp) {
|
||||||
final Collaborator propCollab = collaboratorProperty.getCollaborator();
|
final Collaborator propCollab = collaboratorProperty.getCollaborator();
|
||||||
if (propCollab != null && propCollab.getEmail().equals(collaborator.getEmail())) {
|
if (propCollab != null && propCollab.getEmail().equals(collaborator.getEmail())) {
|
||||||
result = collaboratorProperty;
|
result = collaboratorProperty;
|
||||||
@ -244,20 +257,20 @@ public class MindMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
|
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
|
||||||
if(collaborator==null){
|
if (collaborator == null) {
|
||||||
throw new IllegalStateException("Collaborator can not be null");
|
throw new IllegalStateException("Collaborator can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
MindmapCollaborationProperties collaboratorProperties = this.findUserProperty(collaborator);
|
CollaborationProperties collaboratorProperties = this.findUserProperty(collaborator);
|
||||||
if (collaboratorProperties == null) {
|
if (collaboratorProperties == null) {
|
||||||
collaboratorProperties = new MindmapCollaborationProperties(collaborator, this);
|
collaboratorProperties = new CollaborationProperties(collaborator, this);
|
||||||
}
|
}
|
||||||
collaboratorProperties.setStarred(value);
|
collaboratorProperties.setStarred(value);
|
||||||
this.getCollaboratorProperties().add(collaboratorProperties);
|
this.getCollaborationProperties().add(collaboratorProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStarred(@NotNull Collaborator collaborator) {
|
public boolean isStarred(@NotNull Collaborator collaborator) {
|
||||||
final MindmapCollaborationProperties collaboratorProperty = this.findUserProperty(collaborator);
|
final CollaborationProperties collaboratorProperty = this.findUserProperty(collaborator);
|
||||||
return collaboratorProperty != null && collaboratorProperty.getStarred();
|
return collaboratorProperty != null && collaboratorProperty.getStarred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import com.wisemapping.service.MindmapService;
|
|||||||
import com.wisemapping.view.MindMapBean;
|
import com.wisemapping.view.MindMapBean;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
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;
|
||||||
@ -26,10 +27,7 @@ public class MindmapController {
|
|||||||
|
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
MindmapController() {
|
@Qualifier("mindmapService")
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MindmapService mindmapService;
|
private MindmapService mindmapService;
|
||||||
|
|
||||||
@ -186,7 +184,7 @@ public class MindmapController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<MindMapBean> findMindMapBeanList(@NotNull User user) {
|
private List<MindMapBean> findMindMapBeanList(@NotNull User user) {
|
||||||
final List<Collaboration> userMindmaps = mindmapService.getMindmapUserByUser(user);
|
final List<Collaboration> userMindmaps = mindmapService.getCollaborationsBy(user);
|
||||||
|
|
||||||
final List<MindMapBean> mindMapBeans = new ArrayList<MindMapBean>(userMindmaps.size());
|
final List<MindMapBean> mindMapBeans = new ArrayList<MindMapBean>(userMindmaps.size());
|
||||||
for (Collaboration mindmap : userMindmaps) {
|
for (Collaboration mindmap : userMindmaps) {
|
||||||
|
@ -24,17 +24,15 @@ import com.wisemapping.importer.ImportFormat;
|
|||||||
import com.wisemapping.importer.Importer;
|
import com.wisemapping.importer.Importer;
|
||||||
import com.wisemapping.importer.ImporterException;
|
import com.wisemapping.importer.ImporterException;
|
||||||
import com.wisemapping.importer.ImporterFactory;
|
import com.wisemapping.importer.ImporterFactory;
|
||||||
import com.wisemapping.model.Collaboration;
|
import com.wisemapping.model.*;
|
||||||
import com.wisemapping.model.MindMap;
|
import com.wisemapping.rest.model.*;
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.rest.model.RestMindmap;
|
|
||||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
|
||||||
import com.wisemapping.rest.model.RestMindmapList;
|
|
||||||
import com.wisemapping.security.Utils;
|
import com.wisemapping.security.Utils;
|
||||||
|
import com.wisemapping.service.InvalidCollaborationException;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
import com.wisemapping.validator.MapInfoValidator;
|
import com.wisemapping.validator.MapInfoValidator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.BeanPropertyBindingResult;
|
import org.springframework.validation.BeanPropertyBindingResult;
|
||||||
@ -50,14 +48,14 @@ import java.util.*;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class MindmapController extends BaseController {
|
public class MindmapController extends BaseController {
|
||||||
|
@Qualifier("mindmapService")
|
||||||
@Autowired
|
@Autowired
|
||||||
private MindmapService mindmapService;
|
private MindmapService mindmapService;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "application/xml", "text/html"})
|
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "application/xml", "text/html"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ModelAndView retrieve(@PathVariable int id) throws IOException {
|
public ModelAndView retrieve(@PathVariable int id) throws IOException {
|
||||||
final User user = com.wisemapping.security.Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
final RestMindmap map = new RestMindmap(mindMap, user);
|
final RestMindmap map = new RestMindmap(mindMap, user);
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ public class MindmapController extends BaseController {
|
|||||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
final Map<String, Object> values = new HashMap<String, Object>();
|
final Map<String, Object> values = new HashMap<String, Object>();
|
||||||
|
|
||||||
final User user = com.wisemapping.security.Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
values.put("mindmap", new RestMindmap(mindMap, user));
|
values.put("mindmap", new RestMindmap(mindMap, user));
|
||||||
values.put("filename", mindMap.getTitle());
|
values.put("filename", mindMap.getTitle());
|
||||||
return new ModelAndView("transformViewWise", values);
|
return new ModelAndView("transformViewWise", values);
|
||||||
@ -88,13 +86,13 @@ public class MindmapController extends BaseController {
|
|||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json", "text/html", "application/xml"})
|
||||||
public ModelAndView retrieveList(@RequestParam(required = false) String q) throws IOException {
|
public ModelAndView retrieveList(@RequestParam(required = false) String q) throws IOException {
|
||||||
final User user = com.wisemapping.security.Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||||
|
final List<Collaboration> collaborations = mindmapService.getCollaborationsBy(user);
|
||||||
|
|
||||||
final List<Collaboration> mapsByUser = mindmapService.getMindmapUserByUser(user);
|
|
||||||
final List<MindMap> mindmaps = new ArrayList<MindMap>();
|
final List<MindMap> mindmaps = new ArrayList<MindMap>();
|
||||||
for (Collaboration collaboration : mapsByUser) {
|
for (Collaboration collaboration : collaborations) {
|
||||||
final MindMap mindmap = collaboration.getMindMap();
|
final MindMap mindmap = collaboration.getMindMap();
|
||||||
if (filter.accept(mindmap, user)) {
|
if (filter.accept(mindmap, user)) {
|
||||||
mindmaps.add(mindmap);
|
mindmaps.add(mindmap);
|
||||||
@ -107,9 +105,13 @@ public class MindmapController extends BaseController {
|
|||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"})
|
||||||
public ModelAndView retrieveHistory(@PathVariable int id) throws IOException {
|
public ModelAndView retrieveHistory(@PathVariable int id) throws IOException {
|
||||||
final User user = com.wisemapping.security.Utils.getUser();
|
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
|
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||||
return null;
|
final RestCollaborationList result = new RestCollaborationList();
|
||||||
|
for (Collaboration collaboration : collaborations) {
|
||||||
|
result.addCollaboration(new RestCollaboration(collaboration));
|
||||||
|
}
|
||||||
|
return new ModelAndView("collabView", "list", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||||
@ -203,20 +205,56 @@ public class MindmapController extends BaseController {
|
|||||||
|
|
||||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "text/html", "application/xml"})
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
public void updateCollabs(@PathVariable int id) throws WiseMappingException {
|
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws InvalidCollaborationException {
|
||||||
|
|
||||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
|
if (!mindMap.getOwner().equals(user)) {
|
||||||
|
throw new IllegalArgumentException("No enough permissions");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare one by one if some of the elements has been changed ....
|
||||||
|
final Set<Collaboration> collabsToRemove = new HashSet<Collaboration>(mindMap.getCollaborations());
|
||||||
|
for (RestCollaboration restCollab : restCollabs.getCollaborations()) {
|
||||||
|
final Collaboration collaboration = mindMap.findCollaborationByEmail(restCollab.getEmail());
|
||||||
|
|
||||||
|
if (CollaborationRole.valueOf(restCollab.getRole()) != CollaborationRole.OWNER) {
|
||||||
|
|
||||||
|
// Validate role ...
|
||||||
|
String roleStr = restCollab.getRole();
|
||||||
|
if (roleStr == null) {
|
||||||
|
throw new IllegalArgumentException(roleStr + " is not a valid role");
|
||||||
|
}
|
||||||
|
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
||||||
|
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collaboration != null) {
|
||||||
|
collabsToRemove.remove(collaboration);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove all collaborations that no applies anymore ..
|
||||||
|
for (final Collaboration collaboration : collabsToRemove) {
|
||||||
|
mindmapService.removeCollaboration(collaboration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "text/html", "application/xml"})
|
||||||
public ModelAndView retrieveList(@PathVariable int id) throws IOException {
|
public ModelAndView retrieveList(@PathVariable int id) {
|
||||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
final User user = Utils.getUser();
|
|
||||||
|
|
||||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||||
|
final List<RestCollaboration> collabs = new ArrayList<RestCollaboration>();
|
||||||
|
for (Collaboration collaboration : collaborations) {
|
||||||
|
collabs.add(new RestCollaboration(collaboration));
|
||||||
|
}
|
||||||
|
|
||||||
return new ModelAndView("mapsView", "list", collaborations);
|
final RestCollaborationList restCollaborationList = new RestCollaborationList();
|
||||||
|
restCollaborationList.setCollaborations(collabs);
|
||||||
|
|
||||||
|
return new ModelAndView("collabsView", "list", restCollaborationList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.wisemapping.rest.model;
|
package com.wisemapping.rest.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.model.Collaboration;
|
||||||
import com.wisemapping.model.CollaborationRole;
|
import com.wisemapping.model.CollaborationRole;
|
||||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||||
@ -10,7 +11,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name = "collaborators")
|
@XmlRootElement(name = "collaboration")
|
||||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||||
@JsonAutoDetect(
|
@JsonAutoDetect(
|
||||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
@ -18,11 +19,13 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||||
public class RestCollaboration {
|
public class RestCollaboration {
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private String email;
|
private String email;
|
||||||
|
private String role;
|
||||||
|
|
||||||
@JsonIgnore
|
public RestCollaboration(@NotNull Collaboration collaboration) {
|
||||||
private CollaborationRole role;
|
this.email = collaboration.getCollaborator().getEmail();
|
||||||
|
this.role = collaboration.getRole().name();
|
||||||
|
}
|
||||||
|
|
||||||
public RestCollaboration() {
|
public RestCollaboration() {
|
||||||
|
|
||||||
@ -32,19 +35,21 @@ public class RestCollaboration {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new IllegalStateException("role can not be null");
|
throw new IllegalStateException("role can not be null");
|
||||||
}
|
}
|
||||||
|
// Only check ...
|
||||||
|
CollaborationRole.valueOf(value.toUpperCase());
|
||||||
|
role = value;
|
||||||
|
|
||||||
role = CollaborationRole.valueOf(value.toUpperCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRole() {
|
public String getRole() {
|
||||||
return role.toString().toLowerCase();
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmail(String email) {
|
public void setEmail(@NotNull String email) {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "collaboration")
|
@XmlRootElement(name = "collaboration")
|
||||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||||
@ -25,7 +23,7 @@ public class RestCollaborationList {
|
|||||||
private List<RestCollaboration> collaborations;
|
private List<RestCollaboration> collaborations;
|
||||||
|
|
||||||
public RestCollaborationList() {
|
public RestCollaborationList() {
|
||||||
|
collaborations = new ArrayList<RestCollaboration>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
@ -36,11 +34,15 @@ public class RestCollaborationList {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "collaborate")
|
@XmlElement(name = "collaborations")
|
||||||
public List<RestCollaboration> getCollaborations() {
|
public List<RestCollaboration> getCollaborations() {
|
||||||
return collaborations;
|
return collaborations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCollaboration(@NotNull RestCollaboration collaboration) {
|
||||||
|
collaborations.add(collaboration);
|
||||||
|
}
|
||||||
|
|
||||||
public void setCollaborations(@NotNull List<RestCollaboration> collaborations) {
|
public void setCollaborations(@NotNull List<RestCollaboration> collaborations) {
|
||||||
this.collaborations = collaborations;
|
this.collaborations = collaborations;
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,11 @@ public class RestMindmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RestMindmap() {
|
public RestMindmap() {
|
||||||
this(new MindMap(), Utils.getUser());
|
this(new MindMap(), null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestMindmap(@NotNull MindMap mindmap, @NotNull Collaborator collaborator) {
|
public RestMindmap(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) {
|
||||||
this.mindmap = mindmap;
|
this.mindmap = mindmap;
|
||||||
this.collaborator = collaborator;
|
this.collaborator = collaborator;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,8 @@ public class RestMindmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getOwner() {
|
public String getOwner() {
|
||||||
return mindmap.getOwner().getEmail();
|
final User owner = mindmap.getOwner();
|
||||||
|
return owner != null ? owner.getEmail() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreator(String creatorUser) {
|
public void setCreator(String creatorUser) {
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
package com.wisemapping.service;
|
package com.wisemapping.service;
|
||||||
|
|
||||||
public class InvalidColaboratorException
|
public class InvalidCollaborationException
|
||||||
extends Exception
|
extends Exception
|
||||||
{
|
{
|
||||||
public InvalidColaboratorException(String msg)
|
public InvalidCollaborationException(String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
@ -35,25 +35,23 @@ public interface MindmapService {
|
|||||||
|
|
||||||
public MindMap getMindmapByTitle(String title, User user);
|
public MindMap getMindmapByTitle(String title, User user);
|
||||||
|
|
||||||
public List<Collaboration> getMindmapUserByUser(User user);
|
public List<Collaboration> getCollaborationsBy(@NotNull User user);
|
||||||
|
|
||||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException;
|
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException;
|
||||||
|
|
||||||
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||||
|
|
||||||
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, CollaborationRole role, ColaborationEmail email)
|
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
||||||
throws InvalidColaboratorException;
|
throws InvalidCollaborationException;
|
||||||
|
|
||||||
|
public void removeCollaboration(@NotNull Collaboration collaboration);
|
||||||
|
|
||||||
public void addTags(MindMap mindmap, String tags);
|
public void addTags(MindMap mindmap, String tags);
|
||||||
|
|
||||||
public void removeCollaboratorFromMindmap(@NotNull final MindMap mindmap, long colaboratorId);
|
|
||||||
|
|
||||||
public void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException;
|
public void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException;
|
||||||
|
|
||||||
public List<MindMap> search(MindMapCriteria criteria);
|
public List<MindMap> search(MindMapCriteria criteria);
|
||||||
|
|
||||||
public List<MindMap> getPublicMaps(int cant);
|
|
||||||
|
|
||||||
public List<MindMapHistory> getMindMapHistory(int mindmapId);
|
public List<MindMapHistory> getMindMapHistory(int mindmapId);
|
||||||
|
|
||||||
public boolean isAllowedToView(User user, MindMap map, CollaborationRole allowedRole);
|
public boolean isAllowedToView(User user, MindMap map, CollaborationRole allowedRole);
|
||||||
|
@ -84,18 +84,22 @@ public class MindmapServiceImpl
|
|||||||
return mindmapManager.getMindmapUserBy(mindmapId, user);
|
return mindmapManager.getMindmapUserBy(mindmapId, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MindMap getMindmapByTitle(String title, User user) {
|
public MindMap getMindmapByTitle(String title, User user) {
|
||||||
return mindmapManager.getMindmapByTitle(title, user);
|
return mindmapManager.getMindmapByTitle(title, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MindMap getMindmapById(int mindmapId) {
|
public MindMap getMindmapById(int mindmapId) {
|
||||||
return mindmapManager.getMindmapById(mindmapId);
|
return mindmapManager.getMindmapById(mindmapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Collaboration> getMindmapUserByUser(@NotNull User user) {
|
@Override
|
||||||
|
public List<Collaboration> getCollaborationsBy(@NotNull User user) {
|
||||||
return mindmapManager.getMindmapUserByCollaborator(user.getId());
|
return mindmapManager.getMindmapUserByCollaborator(user.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException {
|
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException {
|
||||||
if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) {
|
if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) {
|
||||||
throw new WiseMappingException("The tile can not be empty");
|
throw new WiseMappingException("The tile can not be empty");
|
||||||
@ -104,39 +108,35 @@ public class MindmapServiceImpl
|
|||||||
mindmapManager.updateMindmap(mindMap, saveHistory);
|
mindmapManager.updateMindmap(mindMap, saveHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MindMap> getPublicMaps(int cant) {
|
@Override
|
||||||
return mindmapManager.search(null, cant);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MindMap> search(MindMapCriteria criteria) {
|
public List<MindMap> search(MindMapCriteria criteria) {
|
||||||
return mindmapManager.search(criteria);
|
return mindmapManager.search(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCollaboratorFromMindmap(@NotNull MindMap mindmap, long userId) {
|
@Override
|
||||||
|
public void removeCollaboration(@NotNull Collaboration collaboration) {
|
||||||
// remove collaborator association
|
// remove collaborator association
|
||||||
Set<Collaboration> mindmapusers = mindmap.getCollaborations();
|
final MindMap mindMap = collaboration.getMindMap();
|
||||||
Collaboration mindmapuserToDelete = null;
|
Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||||
for (Collaboration mindmapuser : mindmapusers) {
|
|
||||||
if (mindmapuser.getCollaborator().getId() == userId) {
|
// When you delete an object from hibernate you have to delete it from *all* collections it exists in...
|
||||||
mindmapuserToDelete = mindmapuser;
|
collaborations.remove(collaboration);
|
||||||
break;
|
mindmapManager.removeCollaboration(collaboration);
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mindmapuserToDelete != null) {
|
|
||||||
// When you delete an object from hibernate you have to delete it from *all* collections it exists in...
|
|
||||||
mindmapusers.remove(mindmapuserToDelete);
|
|
||||||
mindmapManager.removeMindmapUser(mindmapuserToDelete);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeMindmap(@NotNull MindMap mindmap, @NotNull User user) throws WiseMappingException {
|
public void removeMindmap(@NotNull MindMap mindmap, @NotNull User user) throws WiseMappingException {
|
||||||
if (mindmap.getOwner().equals(user)) {
|
if (mindmap.getOwner().equals(user)) {
|
||||||
mindmapManager.removeMindmap(mindmap);
|
mindmapManager.removeMindmap(mindmap);
|
||||||
} else {
|
} else {
|
||||||
this.removeCollaboratorFromMindmap(mindmap, user.getId());
|
final Collaboration collaboration = mindmap.findCollaborationByEmail(user.getEmail());
|
||||||
|
if (collaboration != null) {
|
||||||
|
this.removeCollaboration(collaboration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addMindmap(@NotNull MindMap map, @NotNull User user) throws WiseMappingException {
|
public void addMindmap(@NotNull MindMap map, @NotNull User user) throws WiseMappingException {
|
||||||
|
|
||||||
final String title = map.getTitle();
|
final String title = map.getTitle();
|
||||||
@ -165,29 +165,52 @@ public class MindmapServiceImpl
|
|||||||
mindmapManager.addMindmap(dbUser, map);
|
mindmapManager.addMindmap(dbUser, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, CollaborationRole role, ColaborationEmail email)
|
@Override
|
||||||
throws InvalidColaboratorException {
|
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
||||||
if (collaboratorEmails != null && collaboratorEmails.length > 0) {
|
throws InvalidCollaborationException {
|
||||||
final Collaborator owner = mindmap.getOwner();
|
|
||||||
final Set<Collaboration> collaborations = mindmap.getCollaborations();
|
|
||||||
|
|
||||||
for (String colaboratorEmail : collaboratorEmails) {
|
// Validate
|
||||||
if (owner.getEmail().equals(colaboratorEmail)) {
|
final Collaborator owner = mindmap.getOwner();
|
||||||
throw new InvalidColaboratorException("The user " + owner.getEmail() + " is the owner");
|
final Set<Collaboration> collaborations = mindmap.getCollaborations();
|
||||||
}
|
if (owner.getEmail().equals(email)) {
|
||||||
Collaboration collaboration = getMindmapUserBy(colaboratorEmail, collaborations);
|
throw new InvalidCollaborationException("The user " + owner.getEmail() + " is the owner");
|
||||||
if (collaboration == null) {
|
}
|
||||||
addCollaborator(colaboratorEmail, role, mindmap, email);
|
|
||||||
} else if (collaboration.getRole() != role) {
|
Collaboration collaboration = getCollaborationBy(email, collaborations);
|
||||||
// If the relationship already exists and the role changed then only update the role
|
if (collaboration == null) {
|
||||||
collaboration.setRoleId(role.ordinal());
|
final Collaborator collaborator = addCollaborator(email);
|
||||||
mindmapManager.updateMindmap(mindmap, false);
|
collaboration = new Collaboration(role, collaborator, mindmap);
|
||||||
}
|
mindmap.getCollaborations().add(collaboration);
|
||||||
}
|
mindmapManager.saveMindmap(mindmap);
|
||||||
|
|
||||||
|
// Sent collaboration email ...
|
||||||
|
final Map<String, Object> model = new HashMap<String, Object>();
|
||||||
|
model.put("role", role);
|
||||||
|
model.put("map", mindmap);
|
||||||
|
model.put("message", "message");
|
||||||
|
mailer.sendEmail(mailer.getSiteEmail(), email, "Collaboration", model, "newColaborator.vm");
|
||||||
|
|
||||||
|
} else if (collaboration.getRole() != role) {
|
||||||
|
// If the relationship already exists and the role changed then only update the role
|
||||||
|
collaboration.setRole(role);
|
||||||
|
mindmapManager.updateMindmap(mindmap, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTags(MindMap mindmap, String tags) {
|
private Collaborator addCollaborator(String email) {
|
||||||
|
// Add a new collaborator ...
|
||||||
|
Collaborator collaborator = mindmapManager.getCollaboratorBy(email);
|
||||||
|
if (collaborator == null) {
|
||||||
|
collaborator = new Collaborator();
|
||||||
|
collaborator.setEmail(email);
|
||||||
|
collaborator.setCreationDate(Calendar.getInstance());
|
||||||
|
mindmapManager.addCollaborator(collaborator);
|
||||||
|
}
|
||||||
|
return collaborator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTags(@NotNull MindMap mindmap, String tags) {
|
||||||
mindmap.setTags(tags);
|
mindmap.setTags(tags);
|
||||||
mindmapManager.updateMindmap(mindmap, false);
|
mindmapManager.updateMindmap(mindmap, false);
|
||||||
if (tags != null && tags.length() > 0) {
|
if (tags != null && tags.length() > 0) {
|
||||||
@ -233,7 +256,7 @@ public class MindmapServiceImpl
|
|||||||
updateMindmap(map, false);
|
updateMindmap(map, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collaboration getMindmapUserBy(String email, Set<Collaboration> collaborations) {
|
private Collaboration getCollaborationBy(String email, Set<Collaboration> collaborations) {
|
||||||
Collaboration collaboration = null;
|
Collaboration collaboration = null;
|
||||||
|
|
||||||
for (Collaboration user : collaborations) {
|
for (Collaboration user : collaborations) {
|
||||||
@ -245,27 +268,6 @@ public class MindmapServiceImpl
|
|||||||
return collaboration;
|
return collaboration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCollaborator(String colaboratorEmail, CollaborationRole role, MindMap mindmap, ColaborationEmail email) {
|
|
||||||
|
|
||||||
Collaborator collaborator = mindmapManager.getCollaboratorBy(colaboratorEmail);
|
|
||||||
if (collaborator == null) {
|
|
||||||
collaborator = new Collaborator();
|
|
||||||
collaborator.setEmail(colaboratorEmail);
|
|
||||||
collaborator.setCreationDate(Calendar.getInstance());
|
|
||||||
mindmapManager.addCollaborator(collaborator);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Collaboration newCollaboration = new Collaboration(role, collaborator, mindmap);
|
|
||||||
mindmap.getCollaborations().add(newCollaboration);
|
|
||||||
|
|
||||||
mindmapManager.saveMindmap(mindmap);
|
|
||||||
|
|
||||||
final Map<String, Object> model = new HashMap<String, Object>();
|
|
||||||
model.put("role", role);
|
|
||||||
model.put("map", mindmap);
|
|
||||||
model.put("message", email.getMessage());
|
|
||||||
mailer.sendEmail(mailer.getSiteEmail(), colaboratorEmail, email.getSubject(), model, "newColaborator.vm");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMindmapManager(MindmapManager mindmapManager) {
|
public void setMindmapManager(MindmapManager mindmapManager) {
|
||||||
this.mindmapManager = mindmapManager;
|
this.mindmapManager = mindmapManager;
|
||||||
|
@ -23,17 +23,17 @@
|
|||||||
<many-to-one name="owner" column="owner_id" unique="true" not-null="true"/>
|
<many-to-one name="owner" column="owner_id" unique="true" not-null="true"/>
|
||||||
|
|
||||||
<set name="collaborations"
|
<set name="collaborations"
|
||||||
cascade="all, delete-orphan"
|
cascade="all,delete-orphan"
|
||||||
inverse="true">
|
inverse="true">
|
||||||
<key column="MINDMAP_ID" not-null="true"/>
|
<key column="MINDMAP_ID" not-null="true"/>
|
||||||
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
||||||
</set>
|
</set>
|
||||||
|
|
||||||
<set name="collaboratorProperties"
|
<set name="collaborationProperties"
|
||||||
cascade="all, delete-orphan"
|
cascade="all, delete-orphan"
|
||||||
inverse="true">
|
inverse="true">
|
||||||
<key column="MINDMAP_ID" not-null="true"/>
|
<key column="MINDMAP_ID" not-null="true"/>
|
||||||
<one-to-many class="com.wisemapping.model.MindmapCollaborationProperties"/>
|
<one-to-many class="com.wisemapping.model.CollaborationProperties"/>
|
||||||
</set>
|
</set>
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<hibernate-mapping>
|
<hibernate-mapping>
|
||||||
|
|
||||||
<class name="com.wisemapping.model.MindmapCollaborationProperties" table="MINDMAP_COLLABORATION_PROPERTIES">
|
<class name="com.wisemapping.model.CollaborationProperties" table="MINDMAP_COLLABORATION_PROPERTIES">
|
||||||
<id name="id">
|
<id name="id">
|
||||||
<generator class="increment"/>
|
<generator class="increment"/>
|
||||||
</id>
|
</id>
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
<definition name="mindmapList" page="/jsp/mindmapList.jsp"/>
|
<definition name="mindmapList" page="/jsp/mindmapList.jsp"/>
|
||||||
<definition name="mindmapEmbedded" page="/jsp/mindmapEmbed.jsp"/>
|
<definition name="mindmapEmbedded" page="/jsp/mindmapEmbed.jsp"/>
|
||||||
<definition name="mindmapEditor" page="/jsp/mindmapEditor.jsp"/>
|
<definition name="mindmapEditor" page="/jsp/mindmapEditor.jsp"/>
|
||||||
<definition name="mindmapCooker" page="/jsp/mindmapCooker.jsp"/>
|
|
||||||
<definition name="mindmapPrint" page="/jsp/mindmapPrint.jsp"/>
|
<definition name="mindmapPrint" page="/jsp/mindmapPrint.jsp"/>
|
||||||
|
|
||||||
<!-- Template Declaration -->
|
<!-- Template Declaration -->
|
||||||
@ -85,12 +84,6 @@
|
|||||||
<put name="body" value="/jsp/login.jsp"/>
|
<put name="body" value="/jsp/login.jsp"/>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="mindmapPublicView" extends="pageTemplate">
|
|
||||||
<put name="title" value="PUBLIC_MAP_VIEW"/>
|
|
||||||
<put name="body" value="/jsp/mindmapPublicView.jsp"/>
|
|
||||||
</definition>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Dialog Forms -->
|
<!-- Dialog Forms -->
|
||||||
|
|
||||||
<definition name="mindmapDetail" extends="dialogTemplate">
|
<definition name="mindmapDetail" extends="dialogTemplate">
|
||||||
@ -152,12 +145,6 @@
|
|||||||
<put name="body" value="/jsp/mindmapShare.jsp"/>
|
<put name="body" value="/jsp/mindmapShare.jsp"/>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="mindmapCollaborator" extends="dialogTemplate">
|
|
||||||
<put name="title" value=""/>
|
|
||||||
<put name="details" value=""/>
|
|
||||||
<put name="body" value="/jsp/mindmapCollaborator.jsp"/>
|
|
||||||
</definition>
|
|
||||||
|
|
||||||
<definition name="keyboard" extends="dialogTemplate">
|
<definition name="keyboard" extends="dialogTemplate">
|
||||||
<put name="title" value="KEYBOARD"/>
|
<put name="title" value="KEYBOARD"/>
|
||||||
<put name="details" value="KEYBOARD_MSG"/>
|
<put name="details" value="KEYBOARD_MSG"/>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="mappedNames">
|
<property name="mappedNames">
|
||||||
<list>
|
<list>
|
||||||
|
<value>save*</value>
|
||||||
<value>update*</value>
|
<value>update*</value>
|
||||||
<value>add*</value>
|
<value>add*</value>
|
||||||
<value>remove*</value>
|
<value>remove*</value>
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</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"/>
|
||||||
@ -34,13 +33,6 @@
|
|||||||
<property name="driver" value="${database.driver}"/>
|
<property name="driver" value="${database.driver}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="sharingController" class="com.wisemapping.controller.MindmapSharingController">
|
|
||||||
<property name="methodNameResolver" ref="paramResolverByAction2"/>
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
<property name="userService" ref="userService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="userValidator" class="com.wisemapping.validator.UserValidator">
|
<bean id="userValidator" class="com.wisemapping.validator.UserValidator">
|
||||||
<property name="userService" ref="userService"/>
|
<property name="userService" ref="userService"/>
|
||||||
<property name="captchaService" ref="reCaptcha"/>
|
<property name="captchaService" ref="reCaptcha"/>
|
||||||
@ -136,7 +128,6 @@
|
|||||||
<props>
|
<props>
|
||||||
<!-- Forms based -->
|
<!-- Forms based -->
|
||||||
<prop key="userRegistration">userController</prop>
|
<prop key="userRegistration">userController</prop>
|
||||||
<prop key="sharing">sharingController</prop>
|
|
||||||
<prop key="login">loginController</prop>
|
<prop key="login">loginController</prop>
|
||||||
<prop key="forgotPassword">forgotPasswordController</prop>
|
<prop key="forgotPassword">forgotPasswordController</prop>
|
||||||
<prop key="activation">activationController</prop>
|
<prop key="activation">activationController</prop>
|
||||||
|
@ -1,141 +0,0 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
|
||||||
<c:url value="maps/" var="shareMap">
|
|
||||||
<c:param name="action" value="removeCollaborator"/>
|
|
||||||
<c:param name="userEmail" value="${pageContext.request.userPrincipal.name}"/>
|
|
||||||
</c:url>
|
|
||||||
<c:url value="sharing" var="removeCollaborator">
|
|
||||||
<c:param name="actionId" value="removeCollaborator"/>
|
|
||||||
<c:param name="mapId" value="${mindmap.id}"/>
|
|
||||||
</c:url>
|
|
||||||
<h1>
|
|
||||||
<spring:message code="COLLABORATION"/>:<spring:message code="SHARING"/>
|
|
||||||
'${mindmap.title}'</h1>
|
|
||||||
|
|
||||||
<div id="addCollaboratorPanel">
|
|
||||||
<form method="post" name="sharingForm"
|
|
||||||
action="${pageContext.request.contextPath}/c/sharing?mapId=${mindmap.id}">
|
|
||||||
|
|
||||||
<div id="userEmails">
|
|
||||||
<h2>
|
|
||||||
<spring:message code="INVITE_USERS"/>
|
|
||||||
</h2>
|
|
||||||
<input type="button" id="collaboratorButton" value="<spring:message code="AS_COLLABORATOR"/>"
|
|
||||||
onclick="toogleUserType(this.value)"
|
|
||||||
style="border: 1px solid #39C;padding: 5px;margin:5px;background-color: #838383;color: white;font-weight: bold;"/>
|
|
||||||
<input type="button" id="viewerButton" value="<spring:message code="AS_VIEWER"/>"
|
|
||||||
onclick="toogleUserType(this.value)"
|
|
||||||
style="border: 1px solid black;padding: 5px;margin:5px;background-color: #838383;color: white;font-weight: bold;"/>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
<textarea name="userEmails" id="emailList" rows="7"></textarea>
|
|
||||||
<h5>
|
|
||||||
<spring:message code="COMMA_SEPARATED_EMAILS"/>
|
|
||||||
</h5>
|
|
||||||
<a href="#" onclick="return toogleInvitation()">
|
|
||||||
<spring:message code="CUSTOMIZE_INVITATION"/>
|
|
||||||
</a><br/>
|
|
||||||
|
|
||||||
<div id="invitation" style="display:none;">
|
|
||||||
<h2>
|
|
||||||
<spring:message code="INVITATION"/>
|
|
||||||
</h2>
|
|
||||||
<span><spring:message code="SUBJECT"/>: </span><input name="subject" type="text"
|
|
||||||
value="${principal.firstname} <spring:message code="SUBJECT_MESSAGE"/>"
|
|
||||||
style="width:80%;">
|
|
||||||
<br>
|
|
||||||
<span><spring:message code="MESSAGE"/>:</span>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<textarea name="message" rows="5" style="width:100%;"><spring:message code="INVITATION_MSG"/>
|
|
||||||
</textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
<input id="invitationButton" type="submit" value="Invite Collaborators" class="btn-primary">
|
|
||||||
<input type="button" value="<spring:message code="CANCEL"/>" class="btn-secondary" id="cancelBtn"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="currentUsers">
|
|
||||||
<h2>
|
|
||||||
<spring:message code="CURRENT_COLLABORATORS"/> (${mindmap.countColaborators})
|
|
||||||
</h2>
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col width="95%"/>
|
|
||||||
</colgroup>
|
|
||||||
<c:forEach items="${mindmap.collaborators}" var="mindmapCollaborator">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
${mindmapCollaborator.username}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="${removeCollaborator}&colaboratorId=${mindmapCollaborator.id}"><img
|
|
||||||
src="../images/close12_1.gif" alt="<spring:message code="DELETE"/>" border="0"/></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</c:forEach>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h2>
|
|
||||||
<spring:message code="CURRENT_VIEWERS"/> (${mindmap.countViewers})
|
|
||||||
</h2>
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col width="95%"/>
|
|
||||||
</colgroup>
|
|
||||||
<c:forEach items="${mindmap.viewers}" var="mindmapViewer">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
${mindmapViewer.username}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="${removeCollaborator}&colaboratorId=${mindmapViewer.id}"><img
|
|
||||||
src="../images/close12_1.gif" alt="<spring:message code="DELETE"/>" border="0"/></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</c:forEach>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="actionId" value="addCollaborator"/>
|
|
||||||
<input type="hidden" name="colaboratorId" value=""/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$('cancelBtn').addEvent('click', function(event) {
|
|
||||||
MooDialog.Request.active.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
function toogleUserType(buttonValue) {
|
|
||||||
var collaboratorButton = $("collaboratorButton");
|
|
||||||
var viewerButton = $("viewerButton");
|
|
||||||
var newDisplay = "Invite Collaborators";
|
|
||||||
if (buttonValue == '<spring:message code="AS_VIEWER"/>') {
|
|
||||||
newDisplay = "Invite Viewers";
|
|
||||||
viewerButton.setStyle('border', '1px solid #39C');
|
|
||||||
collaboratorButton.setStyle('border', '1px solid black');
|
|
||||||
document.sharingForm.actionId.value = "addViewer";
|
|
||||||
} else {
|
|
||||||
viewerButton.setStyle('border', '1px solid black');
|
|
||||||
collaboratorButton.setStyle('border', '1px solid #39C');
|
|
||||||
document.sharingForm.actionId.value = "addCollaborator";
|
|
||||||
}
|
|
||||||
|
|
||||||
var invitationButton = document.getElementById("invitationButton");
|
|
||||||
invitationButton.value = newDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toogleInvitation() {
|
|
||||||
var invitationContainer = $("invitation");
|
|
||||||
var newDisplay = "none";
|
|
||||||
if (invitationContainer.style.display == 'none') {
|
|
||||||
newDisplay = "";
|
|
||||||
}
|
|
||||||
invitationContainer.style.display = newDisplay;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
@ -1,29 +0,0 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
|
||||||
|
|
||||||
<h1>Mindmap Cooker</h1>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<form action='<c:url value="/c/cooker"/>' method="post">
|
|
||||||
<input type="hidden" name="action" value="save"/>
|
|
||||||
<input type="hidden" name="mapId" value="${mindmap.id}"/>
|
|
||||||
<table>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td class="formLabel">
|
|
||||||
Native XML:
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<textarea name="xml" id="xml" rows="20" cols="70">${mindmap.xml}</textarea>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td> </td>
|
|
||||||
<td>
|
|
||||||
<input type="submit" value="<spring:message code="SUBMIT"/>" class="btn-primary"/>
|
|
||||||
<input type="button" value="<spring:message code="CANCEL"/>" class="btn-primary"/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
@ -1,16 +0,0 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
|
||||||
<h1>
|
|
||||||
<spring:message code="PUBLIC_VIEW_TITLE" arguments="'${mindmap.title}'"/>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
|
|
||||||
<c:url value="embeddedView?mapId=${mindmap.id}&fullView=true"
|
|
||||||
var="embeddedUrl"/>
|
|
||||||
|
|
||||||
|
|
||||||
<div id="publicViewContent">
|
|
||||||
<iframe style="border:0;width:800px;height:420px;border: 1px solid black;" src="${embeddedUrl}">
|
|
||||||
|
|
||||||
</iframe>
|
|
||||||
|
|
||||||
</div>
|
|
@ -61,7 +61,7 @@
|
|||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCollaborator(email, role) {
|
function addCollaboration(email, role) {
|
||||||
// Add row to the table ...
|
// Add row to the table ...
|
||||||
var tableElem = $("#collabsTable");
|
var tableElem = $("#collabsTable");
|
||||||
var rowTemplate = '\
|
var rowTemplate = '\
|
||||||
@ -106,17 +106,24 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var loadedCollabs = [
|
jQuery.ajax("service/maps/${mindmap.id}/collabs", {
|
||||||
{email:'paulo1@pveiga.com.ar',role:'viewer'},
|
async:false,
|
||||||
{email:'paulo2@pveiga.com.ar',role:'editor'},
|
dataType: 'json',
|
||||||
{email:'paulo3@pveiga.com.ar',role:'editor'}
|
type: 'GET',
|
||||||
];
|
contentType:"text/plain",
|
||||||
|
success : function(data, textStatus, jqXHR) {
|
||||||
|
// Init table will all values ...
|
||||||
|
var collabs = data.collaborations;
|
||||||
|
for (var i = 0; i < collabs.length; i++) {
|
||||||
|
var collab = collabs[i];
|
||||||
|
addCollaboration(collab.email, collab.role);
|
||||||
|
}
|
||||||
|
|
||||||
// Init table will all values ...
|
},
|
||||||
for (var i = 0; i < loadedCollabs.length; i++) {
|
error:function(jqXHR, textStatus, errorThrown) {
|
||||||
var collab = loadedCollabs[i];
|
alert(textStatus);
|
||||||
addCollaborator(collab.email, collab.role);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#addBtn").click(function(event) {
|
$("#addBtn").click(function(event) {
|
||||||
@ -164,7 +171,7 @@
|
|||||||
$("#collabEmails").val("");
|
$("#collabEmails").val("");
|
||||||
for (i = 0; i < emails.length; i++) {
|
for (i = 0; i < emails.length; i++) {
|
||||||
email = emails[i];
|
email = emails[i];
|
||||||
addCollaborator(email, role);
|
addCollaboration(email, role);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -190,20 +197,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildCollabModel() {
|
function buildCollabModel() {
|
||||||
return $('#collabsTable tr').map(function() {
|
var collabs = $('#collabsTable tr').map(function() {
|
||||||
return {
|
return {
|
||||||
email: $(this).attr('data-collab'),
|
email: $(this).attr('data-collab'),
|
||||||
role: $(this).attr('data-role')
|
role: $(this).attr('data-role')
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
collabs = jQuery.makeArray(collabs);
|
||||||
|
|
||||||
|
return {
|
||||||
|
count:collabs.length,
|
||||||
|
collaborations:collabs
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook for interaction with the main parent window ...
|
// Hook for interaction with the main parent window ...
|
||||||
var submitDialogForm = function() {
|
var submitDialogForm = function() {
|
||||||
|
|
||||||
console.log(buildCollabModel());
|
console.log(buildCollabModel());
|
||||||
|
jQuery.ajax("service/maps/${mindmap.id}/collabs", {
|
||||||
|
async:false,
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'PUT',
|
||||||
|
data: JSON.stringify(buildCollabModel()),
|
||||||
|
contentType:"application/json",
|
||||||
|
success : function(data, textStatus, jqXHR) {
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
alert(textStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>
|
|
||||||
<spring:message code="SITE.TITLE"/>
|
|
||||||
-</title>
|
|
||||||
!--[if lt IE 9]>
|
|
||||||
<![endif]-->
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function removeViewer(viewerEmail)
|
|
||||||
{
|
|
||||||
document.removeViewerForm.userEmail.value = viewerEmail;
|
|
||||||
document.removeViewerForm.submit();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<jsp:include page="header.jsp"/>
|
|
||||||
|
|
||||||
<h1>${mindmap.title}</h1>
|
|
||||||
|
|
||||||
<div>${mindmap.description}</div>
|
|
||||||
<div>${mindmap.userRole}</div>
|
|
||||||
|
|
||||||
<form method="post" action="<c:url value="sharing"/>">
|
|
||||||
<input type="hidden" name="action" value="addViewer"/>
|
|
||||||
<input type="hidden" name="mapId" value="${mindmap.id}"/>
|
|
||||||
|
|
||||||
<div id="sharing1">
|
|
||||||
<fieldset id="sharing">
|
|
||||||
|
|
||||||
<legend>
|
|
||||||
<spring:message code="VIEWERS"/>
|
|
||||||
</legend>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div id="addSharing">
|
|
||||||
<label for="viewers" accesskey="a">
|
|
||||||
<spring:message code="ADD_VIEWERS"/>
|
|
||||||
:</label>
|
|
||||||
<textarea name="userEmails" id="viewers" tabindex="1" cols="50" rows="5"></textarea><br/>
|
|
||||||
<input type="submit" value="<spring:message code="ADD"/>">
|
|
||||||
<input type="button" value="<spring:message code="CANCEL"/>"
|
|
||||||
onclick="window.location='<c:url value="maps/"/>'">
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="currentSharing">
|
|
||||||
<label for="viewers" accesskey="v">
|
|
||||||
<spring:message code="CURRENT_VIEWERS"/>
|
|
||||||
:</label><br/>
|
|
||||||
<table>
|
|
||||||
<c:forEach items="${mindmap.viewers}" var="mindmapViewer">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
${mindmapViewer}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="javascript:removeViewer('${mindmapViewer}')"><img
|
|
||||||
src="../images/removeUser.jpeg" border="0"
|
|
||||||
title="<spring:message code="REMOVE"/>"
|
|
||||||
alt="<spring:message code="REMOVE"/>"/></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</c:forEach>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form name="removeViewerForm" action="<c:url value="sharing"/>">
|
|
||||||
<input type="hidden" name="action" value="removeViewer"/>
|
|
||||||
<input type="hidden" name="mapId" value="${mindmap.id}"/>
|
|
||||||
<input type="hidden" name="userEmail" value=""/>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,13 +1,12 @@
|
|||||||
package com.wisemapping.test.model;
|
package com.wisemapping.test.model;
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.rest.model.RestMindmap;
|
import com.wisemapping.rest.model.*;
|
||||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
|
||||||
import com.wisemapping.rest.model.RestUser;
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public class JsonTest {
|
public class JsonTest {
|
||||||
@ -29,7 +28,6 @@ public class JsonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void serialize() throws IOException {
|
void serialize() throws IOException {
|
||||||
String mapJson = "{\"id\":\"1\",\"xml\":\"<map name=\\\"1\\\" version=\\\"tango\\\"><topic central=\\\"true\\\" text=\\\"ss\\\" id=\\\"1\\\"/></map>\",\"properties\":\"{\\\"zoom\\\":0.85}\"}";
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
final RestMindmap value = new RestMindmap();
|
final RestMindmap value = new RestMindmap();
|
||||||
@ -39,5 +37,18 @@ public class JsonTest {
|
|||||||
System.out.println(restMindmap);
|
System.out.println(restMindmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void deserializeCollbsList() throws IOException {
|
||||||
|
String collbsJson = "{\"count\":1,\"collaborations\":[{\"email\":\"paulo@pveiga.com.ar\",\"role\":\"editor\"}]}";
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
final RestCollaborationList list = mapper.readValue(collbsJson, RestCollaborationList.class);
|
||||||
|
final List<RestCollaboration> collaborations = list.getCollaborations();
|
||||||
|
for (RestCollaboration collaboration : collaborations) {
|
||||||
|
final String role = collaboration.getRole();
|
||||||
|
final String email = collaboration.getEmail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user