|
|
|
@ -35,8 +35,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.BeanPropertyBindingResult;
|
|
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@ -48,7 +46,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
//@RequestMapping("/api/restfull/labels")
|
|
|
|
|
@RequestMapping("/api/restfull/maps")
|
|
|
|
|
public class MindmapController extends BaseController {
|
|
|
|
|
private final Logger logger = LogManager.getLogger();
|
|
|
|
|
|
|
|
|
@ -71,7 +69,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/api/restfull/maps/{id}", produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = {"application/json"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
@ -80,7 +78,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/api/restfull/maps/", produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
|
|
|
|
|
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
|
|
|
|
|
@ -94,7 +92,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/api/restfull/maps/{id}/history/", produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}/history/", produces = {"application/json"})
|
|
|
|
|
public RestMindmapHistoryList fetchHistory(@PathVariable int id) {
|
|
|
|
|
final List<MindMapHistory> histories = mindmapService.findMindmapHistory(id);
|
|
|
|
|
final RestMindmapHistoryList result = new RestMindmapHistoryList();
|
|
|
|
@ -104,7 +102,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/document", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/document", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
|
|
|
|
@ -136,7 +134,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(value = "/api/restfull/maps/{id}/history/{hid}", method = RequestMethod.POST)
|
|
|
|
|
@RequestMapping(value = "/{id}/history/{hid}", method = RequestMethod.POST)
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException, IOException {
|
|
|
|
|
final Mindmap mindmap = findMindmapById(id);
|
|
|
|
@ -156,7 +154,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("permitAll()")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/api/restfull/maps/{id}/document/xml", "/api/restfull/maps/{id}/document/xml-pub"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/document/xml", "/{id}/document/xml-pub"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public byte[] retrieveDocument(@PathVariable int id, @NotNull HttpServletResponse response) throws WiseMappingException, IOException {
|
|
|
|
|
final Mindmap mindmap = findMindmapById(id);
|
|
|
|
@ -166,9 +164,9 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = {"/api/restfull/maps/{id}/document/xml"}, consumes = {"text/plain"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = {"/{id}/document/xml"}, consumes = {"text/plain"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException, IOException {
|
|
|
|
|
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException {
|
|
|
|
|
final Mindmap mindmap = findMindmapById(id);
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
|
mindmap.setXmlStr(xmlDoc);
|
|
|
|
@ -178,7 +176,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/api/restfull/maps/{id}/{hid}/document/xml"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/{hid}/document/xml"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public byte[] retrieveDocument(@PathVariable int id, @PathVariable int hid, @NotNull HttpServletResponse response) throws WiseMappingException, IOException {
|
|
|
|
|
final MindMapHistory mindmapHistory = mindmapService.findMindmapHistory(id, hid);
|
|
|
|
@ -190,7 +188,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
* The intention of this method is the update of several properties at once ...
|
|
|
|
|
*/
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updateProperties(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
|
|
|
|
|
|
|
|
@ -245,7 +243,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/title", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
|
|
|
|
|
|
|
|
|
@ -264,7 +262,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/api/restfull/maps/{id}/collabs/", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/{id}/collabs/", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException, TooManyInactiveAccountsExceptions {
|
|
|
|
|
final Mindmap mindMap = findMindmapById(id);
|
|
|
|
@ -314,7 +312,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/collabs/", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/collabs/", consumes = {"application/json"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException, TooManyInactiveAccountsExceptions, OwnerCannotChangeException {
|
|
|
|
|
final Mindmap mindMap = findMindmapById(id);
|
|
|
|
@ -382,7 +380,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/api/restfull/maps/{id}/collabs", produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}/collabs", produces = {"application/json"})
|
|
|
|
|
public RestCollaborationList retrieveList(@PathVariable int id) throws MapCouldNotFoundException, AccessDeniedSecurityException {
|
|
|
|
|
final Mindmap mindMap = findMindmapById(id);
|
|
|
|
|
|
|
|
|
@ -399,7 +397,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/description", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updateDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException {
|
|
|
|
|
final Mindmap mindmap = findMindmapById(id);
|
|
|
|
@ -408,7 +406,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/publish", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/publish", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updatePublishState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
|
|
|
|
|
|
|
|
@ -426,18 +424,18 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/api/restfull/maps/{id}")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void deleteMapById(@PathVariable int id) throws IOException, WiseMappingException {
|
|
|
|
|
public void deleteMapById(@PathVariable int id) throws WiseMappingException {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
|
final Mindmap mindmap = findMindmapById(id);
|
|
|
|
|
mindmapService.removeMindmap(mindmap, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/api/restfull/maps/{id}/collabs")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}/collabs")
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void deleteCollabByEmail(@PathVariable int id, @RequestParam(required = false) String email) throws IOException, WiseMappingException {
|
|
|
|
|
public void deleteCollabByEmail(@PathVariable int id, @RequestParam(required = false) String email) throws WiseMappingException {
|
|
|
|
|
logger.debug("Deleting permission for email:" + email);
|
|
|
|
|
|
|
|
|
|
// Is a valid email address ?
|
|
|
|
@ -467,7 +465,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/starred", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/starred", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
|
|
|
|
|
|
|
|
@ -486,7 +484,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/api/restfull/maps/{id}/starred", produces = {"text/plain"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}/starred", produces = {"text/plain"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String fetchStarred(@PathVariable int id) throws WiseMappingException {
|
|
|
|
|
final Mindmap mindmap = findMindmapById(id);
|
|
|
|
@ -501,9 +499,9 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/api/restfull/maps/batch")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/batch")
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException {
|
|
|
|
|
public void batchDelete(@RequestParam() String ids) throws WiseMappingException {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
|
final String[] mapsIds = ids.split(",");
|
|
|
|
|
try {
|
|
|
|
@ -519,9 +517,9 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/api/restfull/maps", consumes = {"application/xml", "application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "", consumes = {"application/xml", "application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.CREATED)
|
|
|
|
|
public void createMap(@RequestBody(required = false) String mapXml, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
|
|
|
|
|
public void createMap(@RequestBody(required = false) String mapXml, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws WiseMappingException {
|
|
|
|
|
|
|
|
|
|
final Mindmap mindmap = new Mindmap();
|
|
|
|
|
if (title != null && !title.isEmpty()) {
|
|
|
|
@ -555,9 +553,9 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/api/restfull/maps/{id}", consumes = {"application/json"}, produces = {"application/json", "text/plain"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/{id}", consumes = {"application/json"}, produces = {"application/json", "text/plain"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.CREATED)
|
|
|
|
|
public void createDuplicate(@RequestBody RestMindmapInfo restMindmap, @PathVariable int id, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
|
|
|
|
public void createDuplicate(@RequestBody RestMindmapInfo restMindmap, @PathVariable int id, @NotNull HttpServletResponse response) throws WiseMappingException {
|
|
|
|
|
// Validate ...
|
|
|
|
|
final BindingResult result = new BeanPropertyBindingResult(restMindmap, "");
|
|
|
|
|
new MapInfoValidator(mindmapService).validate(restMindmap.getDelegated(), result);
|
|
|
|
@ -584,7 +582,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/api/restfull/maps/{id}/labels/{lid}")
|
|
|
|
|
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}/labels/{lid}")
|
|
|
|
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
|
|
|
public void removeLabelFromMap(@PathVariable int id, @PathVariable int lid) throws WiseMappingException {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
@ -600,7 +598,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/api/restfull/maps/{id}/labels", consumes = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = "/{id}/labels", consumes = {"application/json"})
|
|
|
|
|
@ResponseStatus(value = HttpStatus.OK)
|
|
|
|
|
public void updateLabel(@PathVariable int id, @RequestBody int lid) throws WiseMappingException {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
@ -615,7 +613,7 @@ public class MindmapController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/api/restfull/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/lock", consumes = {"text/plain"}, produces = {"application/json"})
|
|
|
|
|
public ResponseEntity<RestLockInfo> lockMindmap(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
|
|
|
|
final User user = Utils.getUser();
|
|
|
|
|
final LockManager lockManager = mindmapService.getLockManager();
|
|
|
|
|