mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-23 03:43:48 +01:00
Solve expcetion on editor exception on starred for a viewer.
This commit is contained in:
parent
29091dec88
commit
f25ea3a377
@ -25,7 +25,7 @@ import java.util.List;
|
||||
|
||||
public interface MindmapManager {
|
||||
|
||||
Collaborator getCollaboratorBy(@NotNull String email);
|
||||
Collaborator findCollaborator(@NotNull String email);
|
||||
|
||||
Collaborator findCollaborator(long id);
|
||||
|
||||
@ -62,4 +62,6 @@ public interface MindmapManager {
|
||||
public List<MindMapHistory> getHistoryFrom(int mindmapId);
|
||||
|
||||
public MindMapHistory getHistory(int historyId);
|
||||
|
||||
void updateCollaboration(@NotNull Collaboration collaboration);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class MindmapManagerImpl
|
||||
implements MindmapManager {
|
||||
|
||||
@Override
|
||||
public Collaborator getCollaboratorBy(final String email) {
|
||||
public Collaborator findCollaborator(@NotNull final String email) {
|
||||
final Collaborator collaborator;
|
||||
final List<Collaborator> collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email);
|
||||
if (collaborators != null && !collaborators.isEmpty()) {
|
||||
@ -69,6 +69,11 @@ public class MindmapManagerImpl
|
||||
return getHibernateTemplate().get(MindMapHistory.class, historyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCollaboration(@NotNull Collaboration collaboration) {
|
||||
getHibernateTemplate().save(collaboration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMap> search(MindMapCriteria criteria, int maxResult) {
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMap.class);
|
||||
@ -138,7 +143,7 @@ public class MindmapManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollaborator(Collaborator collaborator) {
|
||||
public void addCollaborator(@NotNull Collaborator collaborator) {
|
||||
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
||||
getHibernateTemplate().save(collaborator);
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ final public class NotificationService {
|
||||
model.put("baseUrl", formMail);
|
||||
model.put("senderMail", user.getEmail());
|
||||
model.put("message", message);
|
||||
model.put("supportEmail", mailer.getSupportEmail());
|
||||
|
||||
|
||||
mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm");
|
||||
|
@ -222,12 +222,12 @@ public class MindMap {
|
||||
}
|
||||
|
||||
public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException {
|
||||
final CollaborationProperties collaborationProperties = getCollaborationProperties(collaborator);
|
||||
final CollaborationProperties collaborationProperties = findCollaborationProperties(collaborator);
|
||||
collaborationProperties.setStarred(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CollaborationProperties getCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException {
|
||||
public CollaborationProperties findCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException {
|
||||
if (collaborator == null) {
|
||||
throw new IllegalStateException("Collaborator can not be null");
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "application/xml", "text/html"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieve(@PathVariable int id) throws IOException {
|
||||
public ModelAndView retrieve(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final MindMap mindMap = mindmapService.findMindmapById(id);
|
||||
final RestMindmap map = new RestMindmap(mindMap, user);
|
||||
@ -64,7 +64,7 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/wisemapping+xml"}, params = {"download=wxml"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveAsWise(@PathVariable int id) throws IOException {
|
||||
public ModelAndView retrieveAsWise(@PathVariable int id) throws WiseMappingException {
|
||||
final MindMap mindMap = mindmapService.findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
|
||||
@ -116,14 +116,14 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(value = "maps/{id}/history/{hid}", method = RequestMethod.POST)
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateRevertMindmap(@PathVariable int id, @PathVariable int hid) throws IOException, WiseMappingException {
|
||||
public void updateRevertMindmap(@PathVariable int id, @PathVariable int hid) throws WiseMappingException {
|
||||
final MindMap mindmap = mindmapService.findMindmapById(id);
|
||||
mindmapService.revertChange(mindmap, hid);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException {
|
||||
|
||||
final MindMap mindmap = mindmapService.findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
@ -135,7 +135,7 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
// Update collaboration properties ...
|
||||
final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(user);
|
||||
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user);
|
||||
collaborationProperties.setMindmapProperties(properties);
|
||||
|
||||
// Validate content ...
|
||||
@ -187,7 +187,7 @@ public class MindmapController extends BaseController {
|
||||
// Update document properties ...
|
||||
final String properties = restMindmap.getProperties();
|
||||
if (properties != null) {
|
||||
final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(user);
|
||||
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user);
|
||||
collaborationProperties.setMindmapProperties(properties);
|
||||
}
|
||||
|
||||
@ -307,12 +307,17 @@ public class MindmapController extends BaseController {
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.findMindmapById(id);
|
||||
final MindMap mindmap = mindmapService.findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Update map status ...
|
||||
mindMap.setStarred(user, Boolean.parseBoolean(value));
|
||||
saveMindmap(true, mindMap, user);
|
||||
final boolean starred = Boolean.parseBoolean(value);
|
||||
final Collaboration collaboration = mindmap.findCollaboration(user);
|
||||
if (collaboration == null) {
|
||||
throw new WiseMappingException("No enough permissions.");
|
||||
}
|
||||
collaboration.getCollaborationProperties().setStarred(starred);
|
||||
mindmapService.updateCollaboration(user, collaboration);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}")
|
||||
@ -425,7 +430,7 @@ public class MindmapController extends BaseController {
|
||||
mindmapService.updateMindmap(mindMap, !minor);
|
||||
}
|
||||
|
||||
private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException {
|
||||
private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws WiseMappingException {
|
||||
final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), "");
|
||||
result.rejectValue(fieldName, "error.not-specified", null, message);
|
||||
return new ValidationException(result);
|
||||
|
@ -3,7 +3,6 @@ package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.security.Utils;
|
||||
import org.codehaus.jackson.annotate.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -47,7 +46,7 @@ public class RestMindmap {
|
||||
this.mindmap = mindmap;
|
||||
this.collaborator = collaborator;
|
||||
if (collaborator != null) {
|
||||
final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(collaborator);
|
||||
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(collaborator);
|
||||
this.properties = collaborationProperties.getMindmapProperties();
|
||||
}
|
||||
}
|
||||
|
@ -28,38 +28,40 @@ import java.io.IOException;
|
||||
|
||||
public interface MindmapService {
|
||||
|
||||
public static final String TAG_SEPARATOR = " ";
|
||||
static final String TAG_SEPARATOR = " ";
|
||||
|
||||
public MindMap findMindmapById(int mindmapId);
|
||||
MindMap findMindmapById(int mindmapId);
|
||||
|
||||
public MindMap getMindmapByTitle(String title, User user);
|
||||
MindMap getMindmapByTitle(String title, User user);
|
||||
|
||||
public List<Collaboration> findCollaborations(@NotNull User user);
|
||||
List<Collaboration> findCollaborations(@NotNull User user);
|
||||
|
||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException;
|
||||
void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException;
|
||||
|
||||
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||
void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||
|
||||
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message)
|
||||
void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message)
|
||||
throws CollaborationException;
|
||||
|
||||
public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
|
||||
void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
|
||||
|
||||
public void addTags(@NotNull MindMap mindmap, String tags);
|
||||
void addTags(@NotNull MindMap mindmap, String tags);
|
||||
|
||||
public void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException;
|
||||
void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException;
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria);
|
||||
List<MindMap> search(MindMapCriteria criteria);
|
||||
|
||||
public List<MindMapHistory> findMindmapHistory(int mindmapId);
|
||||
List<MindMapHistory> findMindmapHistory(int mindmapId);
|
||||
|
||||
public boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole);
|
||||
boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole);
|
||||
|
||||
public boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
|
||||
boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
|
||||
|
||||
public void addWelcomeMindmap(User user) throws WiseMappingException;
|
||||
void addWelcomeMindmap(User user) throws WiseMappingException;
|
||||
|
||||
public void revertChange(@NotNull MindMap map, int historyId) throws WiseMappingException;
|
||||
void revertChange(@NotNull MindMap map, int historyId) throws WiseMappingException;
|
||||
|
||||
MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException;
|
||||
|
||||
void updateCollaboration(@NotNull Collaborator collaborator, @NotNull Collaboration collaboration) throws WiseMappingException;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class MindmapServiceImpl
|
||||
|
||||
private Collaborator addCollaborator(String email) {
|
||||
// Add a new collaborator ...
|
||||
Collaborator collaborator = mindmapManager.getCollaboratorBy(email);
|
||||
Collaborator collaborator = mindmapManager.findCollaborator(email);
|
||||
if (collaborator == null) {
|
||||
collaborator = new Collaborator();
|
||||
collaborator.setEmail(email);
|
||||
@ -219,6 +219,7 @@ public class MindmapServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWelcomeMindmap(User user) throws WiseMappingException {
|
||||
final MindMap savedWelcome = findMindmapById(Constants.WELCOME_MAP_ID);
|
||||
|
||||
@ -233,10 +234,12 @@ public class MindmapServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMapHistory> findMindmapHistory(int mindmapId) {
|
||||
return mindmapManager.getHistoryFrom(mindmapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revertChange(@NotNull MindMap mindmap, int historyId)
|
||||
throws WiseMappingException {
|
||||
final MindMapHistory history = mindmapManager.getHistory(historyId);
|
||||
@ -261,6 +264,14 @@ public class MindmapServiceImpl
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCollaboration(@NotNull Collaborator collaborator, @NotNull Collaboration collaboration) throws WiseMappingException {
|
||||
if (collaborator.equals(collaboration.getCollaborator())) {
|
||||
throw new WiseMappingException("No enough permissions for this operation.");
|
||||
}
|
||||
mindmapManager.updateCollaboration(collaboration);
|
||||
}
|
||||
|
||||
private Collaboration getCollaborationBy(String email, Set<Collaboration> collaborations) {
|
||||
Collaboration collaboration = null;
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class MindMapBean {
|
||||
}
|
||||
|
||||
public String getProperties() throws WiseMappingException {
|
||||
final CollaborationProperties collaboration = this.mindmap.getCollaborationProperties(collaborator);
|
||||
final CollaborationProperties collaboration = this.mindmap.findCollaborationProperties(collaborator);
|
||||
return collaboration.getMindmapProperties();
|
||||
}
|
||||
|
||||
|
@ -23,17 +23,19 @@
|
||||
</table>
|
||||
</div>
|
||||
<div style="font-size: 13px; background-color: #FFF; padding: 10px 7px 7px 7px; min-height: 100px">
|
||||
<p><strong>Message from ${senderMail}: </strong></p>
|
||||
#if($message )
|
||||
<pre style="font-family: Arial, sans-serif; color: #000; ">${message}</pre>
|
||||
#end
|
||||
<p>Click to open: <a href="${mapEditUrl}">${mindmap.title}</a></p>
|
||||
|
||||
<p style="color: #898989;">Do you have a WiseMapping account ?. Don't worry, you can create an account for
|
||||
free. </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p style="font-size: 13px;font-family: Arial, sans-serif">Important: Do not reply this email. If
|
||||
you need to contact mindmap sender, you can send an email clicking <a href="mailto:${senderMail}">here</a>.
|
||||
you need further help or have any concerns regarding your account, contact us to <a href="mailto:${supportEmail}">here</a>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user