This commit is contained in:
Paulo Gustavo Veiga
2024-02-17 11:18:43 -08:00
parent 0dcdc2c263
commit 52fdefb57e
68 changed files with 373 additions and 376 deletions

View File

@@ -21,9 +21,9 @@ package com.wisemapping.rest;
import com.wisemapping.exceptions.PasswordTooLongException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Label;
import com.wisemapping.model.MindmapLabel;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import com.wisemapping.rest.model.RestUser;
import com.wisemapping.security.Utils;
import com.wisemapping.service.LabelService;
@@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -61,18 +60,18 @@ public class AccountController extends BaseController {
throw new IllegalArgumentException("Password can not be null");
}
if (password.length() > User.MAX_PASSWORD_LENGTH_SIZE) {
if (password.length() > Account.MAX_PASSWORD_LENGTH_SIZE) {
throw new PasswordTooLongException();
}
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
user.setPassword(password);
userService.changePassword(user);
}
@RequestMapping(method = RequestMethod.GET, value = "", produces = {"application/json"})
public RestUser fetchAccount() {
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
return new RestUser(user);
}
@@ -83,7 +82,7 @@ public class AccountController extends BaseController {
throw new IllegalArgumentException("Firstname can not be null");
}
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
user.setFirstname(firstname);
userService.updateUser(user);
}
@@ -95,7 +94,7 @@ public class AccountController extends BaseController {
throw new IllegalArgumentException("lastname can not be null");
}
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
user.setLastname(lastname);
userService.updateUser(user);
}
@@ -108,7 +107,7 @@ public class AccountController extends BaseController {
}
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
user.setLocale(language);
userService.updateUser(user);
}
@@ -117,7 +116,7 @@ public class AccountController extends BaseController {
@RequestMapping(method = RequestMethod.DELETE, value = "")
public void deleteUser() throws WiseMappingException {
// Delete collaborations ...
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
for (Collaboration collaboration : collaborations) {
final Mindmap mindmap = collaboration.getMindMap();
@@ -125,7 +124,7 @@ public class AccountController extends BaseController {
}
// Delete labels ....
final List<Label> labels = labelService.getAll(user);
final List<MindmapLabel> labels = labelService.getAll(user);
labels.forEach(l -> {
try {
labelService.removeLabel(l, user);

View File

@@ -22,7 +22,7 @@ import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import com.wisemapping.rest.model.RestUser;
import com.wisemapping.service.MindmapService;
import com.wisemapping.service.UserService;
@@ -50,7 +50,7 @@ public class AdminController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/users/{id}", produces = {"application/json"})
@ResponseBody
public RestUser getUserById(@PathVariable int id) {
final User userBy = userService.getUserBy(id);
final Account userBy = userService.getUserBy(id);
if (userBy == null) {
throw new IllegalArgumentException("User could not be found");
}
@@ -60,7 +60,7 @@ public class AdminController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/users/email/{email:.+}", produces = {"application/json"})
@ResponseBody
public RestUser getUserByEmail(@PathVariable String email) {
final User user = userService.getUserBy(email);
final Account user = userService.getUserBy(email);
if (user == null) {
throw new IllegalArgumentException("User '" + email + "' could not be found");
}
@@ -81,7 +81,7 @@ public class AdminController extends BaseController {
}
// Run some other validations ...
final User delegated = user.getDelegated();
final Account delegated = user.getDelegated();
final String lastname = delegated.getLastname();
if (lastname == null || lastname.isEmpty()) {
throw new IllegalArgumentException("lastname can not be null");
@@ -111,7 +111,7 @@ public class AdminController extends BaseController {
throw new IllegalArgumentException("Password can not be null");
}
final User user = userService.getUserBy(id);
final Account user = userService.getUserBy(id);
if (user == null) {
throw new IllegalArgumentException("User '" + id + "' could not be found");
}
@@ -122,7 +122,7 @@ public class AdminController extends BaseController {
@RequestMapping(method = RequestMethod.DELETE, value = "/users/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteUserByEmail(@PathVariable int id) throws WiseMappingException {
final User user = userService.getUserBy(id);
final Account user = userService.getUserBy(id);
if (user == null) {
throw new IllegalArgumentException("User '" + id + "' could not be found");
}

View File

@@ -18,7 +18,7 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.*;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import com.wisemapping.rest.model.RestErrors;
import com.wisemapping.security.Utils;
import com.wisemapping.service.NotificationService;
@@ -124,7 +124,7 @@ public class BaseController {
@ResponseBody
public RestErrors handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) {
logger.error(ex.getMessage(), ex);
final User user = Utils.getUser(false);
final Account user = Utils.getUser(false);
notificationService.reportJavaException(ex, user, request);
return new RestErrors(ex.getMessage(), Severity.SEVERE);
}

View File

@@ -20,8 +20,8 @@ package com.wisemapping.rest;
import com.wisemapping.exceptions.LabelCouldNotFoundException;
import com.wisemapping.exceptions.ValidationException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.Label;
import com.wisemapping.model.User;
import com.wisemapping.model.MindmapLabel;
import com.wisemapping.model.Account;
import com.wisemapping.rest.model.RestLabel;
import com.wisemapping.rest.model.RestLabelList;
import com.wisemapping.security.Utils;
@@ -60,7 +60,7 @@ public class LabelController extends BaseController {
// Validate ...
validate(restLabel);
final Label label = createLabel(restLabel);
final MindmapLabel label = createLabel(restLabel);
// Return the new created label ...
response.setHeader("Location", "/api/restful/labels/" + label.getId());
@@ -69,17 +69,17 @@ public class LabelController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
public RestLabelList retrieveList() {
final User user = Utils.getUser();
final Account user = Utils.getUser();
assert user != null;
final List<Label> all = labelService.getAll(user);
final List<MindmapLabel> all = labelService.getAll(user);
return new RestLabelList(all);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteLabelById(@PathVariable int id) throws WiseMappingException {
final User user = Utils.getUser();
final Label label = labelService.findLabelById(id, user);
final Account user = Utils.getUser();
final MindmapLabel label = labelService.findLabelById(id, user);
if (label == null) {
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);
}
@@ -87,10 +87,10 @@ public class LabelController extends BaseController {
labelService.removeLabel(label, user);
}
@NotNull private Label createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
final Label label = restLabel.getDelegated();
@NotNull private MindmapLabel createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
final MindmapLabel label = restLabel.getDelegated();
// Add new label ...
final User user = Utils.getUser();
final Account user = Utils.getUser();
assert user != null;
labelService.addLabel(label, user);
return label;

View File

@@ -73,7 +73,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = {"application/json"})
@ResponseBody
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
final Mindmap mindMap = findMindmapById(id);
return new RestMindmap(mindMap, user);
}
@@ -82,7 +82,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/{id}/metadata", produces = {"application/json"})
@ResponseBody
public RestMindmapMetadata retrieveMetadata(@PathVariable int id) throws WiseMappingException {
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
final Mindmap mindmap = findMindmapById(id);
final MindMapBean mindMapBean = new MindMapBean(mindmap, user);
@@ -102,7 +102,7 @@ public class MindmapController extends BaseController {
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
final MindmapFilter filter = MindmapFilter.parse(q);
List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user);
@@ -131,7 +131,7 @@ public class MindmapController extends BaseController {
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
// Validate arguments ...
final String properties = restMindmap.getProperties();
@@ -160,7 +160,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException, IOException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
if (LATEST_HISTORY_REVISION.equals(hid)) {
// Revert to the latest stored version ...
@@ -190,7 +190,7 @@ public class MindmapController extends BaseController {
@ResponseBody
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
mindmap.setXmlStr(xmlDoc);
saveMindmapDocument(false, mindmap, user);
@@ -214,7 +214,7 @@ public class MindmapController extends BaseController {
public void updateProperties(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
final String xml = restMindmap.getXml();
if (xml != null && !xml.isEmpty()) {
@@ -250,7 +250,7 @@ public class MindmapController extends BaseController {
@NotNull
private Mindmap findMindmapById(int id) throws MapCouldNotFoundException, AccessDeniedSecurityException {
// Has enough permissions ?
final User user = Utils.getUser();
final Account user = Utils.getUser();
if (!mindmapService.hasPermissions(user, id, CollaborationRole.VIEWER)) {
throw new AccessDeniedSecurityException(id, user);
}
@@ -269,7 +269,7 @@ public class MindmapController extends BaseController {
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
final Mindmap mindMap = findMindmapById(id);
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
// Is there a map with the same name ?
if (mindmapService.getMindmapByTitle(title, user) != null) {
@@ -289,7 +289,7 @@ public class MindmapController extends BaseController {
final Mindmap mindMap = findMindmapById(id);
// Only owner can change collaborators...
final User user = Utils.getUser();
final Account user = Utils.getUser();
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
throw new IllegalArgumentException("No enough permissions");
}
@@ -339,7 +339,7 @@ public class MindmapController extends BaseController {
final Mindmap mindMap = findMindmapById(id);
// Only owner can change collaborators...
final User user = Utils.getUser();
final Account user = Utils.getUser();
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
throw new AccessDeniedSecurityException("User must be owner to share mindmap");
}
@@ -433,7 +433,7 @@ public class MindmapController extends BaseController {
final Mindmap mindMap = findMindmapById(id);
final User user = Utils.getUser();
final Account user = Utils.getUser();
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
throw new IllegalArgumentException("No enough to execute this operation");
}
@@ -448,7 +448,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteMapById(@PathVariable int id) throws WiseMappingException {
final User user = Utils.getUser();
final Account user = Utils.getUser();
final Mindmap mindmap = findMindmapById(id);
mindmapService.removeMindmap(mindmap, user);
}
@@ -466,7 +466,7 @@ public class MindmapController extends BaseController {
}
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
final Account user = Utils.getUser();
// Only owner can change collaborators...
if (!mindmap.hasPermissions(user, CollaborationRole.OWNER)) {
@@ -492,7 +492,7 @@ public class MindmapController extends BaseController {
logger.debug("Update starred:" + value);
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
final Account user = Utils.getUser();
// Update map status ...
final boolean starred = Boolean.parseBoolean(value);
@@ -509,7 +509,7 @@ public class MindmapController extends BaseController {
@ResponseBody
public String fetchStarred(@PathVariable int id) throws WiseMappingException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
final Account user = Utils.getUser();
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
if (collaboration.isEmpty()) {
@@ -523,7 +523,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.DELETE, value = "/batch")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void batchDelete(@RequestParam() String ids) throws WiseMappingException {
final User user = Utils.getUser();
final Account user = Utils.getUser();
final String[] mapsIds = ids.split(",");
try {
for (final String mapId : mapsIds) {
@@ -565,7 +565,7 @@ public class MindmapController extends BaseController {
mindmap.setXmlStr(mapXml);
// Add new mindmap ...
final User user = Utils.getUser(true);
final Account user = Utils.getUser(true);
mindmapService.addMindmap(mindmap, user);
// Return the new created map ...
@@ -585,7 +585,7 @@ public class MindmapController extends BaseController {
}
// Some basic validations ...
final User user = Utils.getUser();
final Account user = Utils.getUser();
// Create a shallowCopy of the map ...
final Mindmap mindMap = findMindmapById(id);
@@ -606,9 +606,9 @@ public class MindmapController extends BaseController {
@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();
final Account user = Utils.getUser();
final Mindmap mindmap = findMindmapById(id);
final Label label = labelService.findLabelById(lid, user);
final MindmapLabel label = labelService.findLabelById(lid, user);
if (label == null) {
throw new LabelCouldNotFoundException("Label could not be found. Id: " + lid);
@@ -622,8 +622,8 @@ public class MindmapController extends BaseController {
@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();
final Label label = labelService.findLabelById(lid, user);
final Account user = Utils.getUser();
final MindmapLabel label = labelService.findLabelById(lid, user);
if (label == null) {
throw new LabelCouldNotFoundException("Label could not be found. Id: " + lid);
}
@@ -636,7 +636,7 @@ public class MindmapController extends BaseController {
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
@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 Account user = Utils.getUser();
final LockManager lockManager = mindmapService.getLockManager();
final Mindmap mindmap = findMindmapById(id);
@@ -652,7 +652,7 @@ public class MindmapController extends BaseController {
}
private void saveMindmapDocument(boolean minor, @NotNull final Mindmap mindMap, @NotNull final User user) throws WiseMappingException {
private void saveMindmapDocument(boolean minor, @NotNull final Mindmap mindMap, @NotNull final Account user) throws WiseMappingException {
final Calendar now = Calendar.getInstance();
mindMap.setLastModificationTime(now);
mindMap.setLastEditor(user);
@@ -665,7 +665,7 @@ public class MindmapController extends BaseController {
return new ValidationException(result);
}
private void verifyActiveCollabs(@NotNull RestCollaborationList restCollabs, User user) throws TooManyInactiveAccountsExceptions {
private void verifyActiveCollabs(@NotNull RestCollaborationList restCollabs, Account user) throws TooManyInactiveAccountsExceptions {
// Do not allow more than 20 new accounts per mindmap...
final List<Mindmap> userMindmaps = mindmapService.findMindmapsByUser(user);
final Set<String> allEmails = userMindmaps

View File

@@ -21,7 +21,7 @@
package com.wisemapping.rest;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,35 +29,35 @@ public abstract class MindmapFilter {
public static final MindmapFilter ALL = new MindmapFilter("all") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
return true;
}
};
public static final MindmapFilter MY_MAPS = new MindmapFilter("my_maps") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
return mindmap.getCreator().identityEquality(user);
}
};
public static final MindmapFilter STARRED = new MindmapFilter("starred") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
return mindmap.isStarred(user);
}
};
public static final MindmapFilter SHARED_WITH_ME = new MindmapFilter("shared_with_me") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
return !MY_MAPS.accept(mindmap, user);
}
};
public static final MindmapFilter PUBLIC = new MindmapFilter("public") {
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
return mindmap.isPublic();
}
};
@@ -88,7 +88,7 @@ public abstract class MindmapFilter {
return result;
}
abstract boolean accept(@NotNull Mindmap mindmap, @NotNull User user);
abstract boolean accept(@NotNull Mindmap mindmap, @NotNull Account user);
private static final class LabelFilter extends MindmapFilter {
@@ -97,7 +97,7 @@ public abstract class MindmapFilter {
}
@Override
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
return mindmap.hasLabel(this.id);
}
}

View File

@@ -19,7 +19,7 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import com.wisemapping.rest.model.RestOath2CallbackResponse;
import com.wisemapping.security.JwtTokenUtil;
import com.wisemapping.service.UserService;
@@ -52,7 +52,7 @@ public class OAuth2Controller extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = "googlecallback", produces = {"application/json"})
@ResponseStatus(value = HttpStatus.OK)
public RestOath2CallbackResponse processGoogleCallback(@NotNull @RequestParam String code, @NotNull HttpServletResponse response, @NotNull HttpServletRequest request) throws WiseMappingException {
User user = userService.createAndAuthUserFromGoogle(code);
Account user = userService.createAndAuthUserFromGoogle(code);
if (user.getGoogleSync()) {
jwtTokenUtil.doLogin(response, user.getEmail());
}

View File

@@ -22,7 +22,7 @@ import com.wisemapping.exceptions.EmailNotExistsException;
import com.wisemapping.exceptions.PasswordTooLongException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import com.wisemapping.rest.model.RestResetPasswordResponse;
import com.wisemapping.rest.model.RestUserRegistration;
import com.wisemapping.service.*;
@@ -35,9 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.*;
@@ -77,7 +75,7 @@ public class UserController extends BaseController {
@NotNull HttpServletResponse response) throws WiseMappingException, BindException {
logger.debug("Register new user:" + registration.getEmail());
if (registration.getPassword().length() > User.MAX_PASSWORD_LENGTH_SIZE) {
if (registration.getPassword().length() > Account.MAX_PASSWORD_LENGTH_SIZE) {
throw new PasswordTooLongException();
}
@@ -90,7 +88,7 @@ public class UserController extends BaseController {
verify(registration, remoteIp);
final User user = new User();
final Account user = new Account();
user.setEmail(registration.getEmail().trim());
user.setFirstname(registration.getFirstname());
user.setLastname(registration.getLastname());

View File

@@ -21,7 +21,7 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.model.Label;
import com.wisemapping.model.MindmapLabel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -38,22 +38,22 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
public class RestLabel {
@JsonIgnore
private final Label label;
private final MindmapLabel label;
public RestLabel() {
this(new Label());
this(new MindmapLabel());
}
public RestLabel(@NotNull final Label label) {
public RestLabel(@NotNull final MindmapLabel label) {
this.label = label;
}
public void setParent(final Label parent) {
public void setParent(final MindmapLabel parent) {
this.label.setParent(parent);
}
@Nullable
public Label getParent() {
public MindmapLabel getParent() {
return this.label.getParent();
}
@@ -83,7 +83,7 @@ public class RestLabel {
}
@JsonIgnore
public Label getDelegated() {
public MindmapLabel getDelegated() {
return label;
}
}

View File

@@ -1,7 +1,7 @@
package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.wisemapping.model.Label;
import com.wisemapping.model.MindmapLabel;
import org.jetbrains.annotations.NotNull;
import jakarta.xml.bind.annotation.XmlElement;
@@ -20,9 +20,9 @@ public class RestLabelList {
this.restLabels = new ArrayList<>();
}
public RestLabelList(@NotNull final List<Label> labels) {
public RestLabelList(@NotNull final List<MindmapLabel> labels) {
this.restLabels = new ArrayList<>(labels.size());
for (Label label : labels) {
for (MindmapLabel label : labels) {
this.restLabels.add(new RestLabel(label));
}
}

View File

@@ -21,7 +21,7 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import com.wisemapping.service.LockInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -40,7 +40,7 @@ public class RestLockInfo {
}
public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull User user) {
public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull Account user) {
this.email = user.getEmail();
}

View File

@@ -29,9 +29,6 @@ import com.wisemapping.util.TimeUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.util.Calendar;
@@ -103,7 +100,7 @@ public class RestMindmap {
}
public String getCreator() {
final User creator = mindmap.getCreator();
final Account creator = mindmap.getCreator();
return creator != null ? creator.getEmail() : null;
}
@@ -112,7 +109,7 @@ public class RestMindmap {
public RestCollaborator getLastModifierUser() {
final User lastEditor = mindmap.getLastEditor();
final Account lastEditor = mindmap.getLastEditor();
RestCollaborator result = null;
if (lastEditor != null && mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR)) {
@@ -155,7 +152,7 @@ public class RestMindmap {
}
public String getOwner() {
final User owner = mindmap.getCreator();
final Account owner = mindmap.getCreator();
return owner != null ? owner.getEmail() : null;
}

View File

@@ -22,7 +22,7 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.model.MindMapHistory;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
@@ -55,7 +55,7 @@ public class RestMindmapHistory {
public RestMindmapHistory(@NotNull MindMapHistory history) {
this.id = history.getId();
this.creation = history.getCreationTime();
final User editor = history.getEditor();
final Account editor = history.getEditor();
this.creator = editor != null ? editor.getFullName() : "";
}

View File

@@ -92,7 +92,7 @@ public class RestMindmapInfo {
// Support test deserialization...
Set<RestLabel> result = this.restLabels;
if (result == null) {
final User me = Utils.getUser();
final Account me = Utils.getUser();
result = mindmap.getLabels().
stream()
.filter(l -> l.getCreator().equals(me))
@@ -119,7 +119,7 @@ public class RestMindmapInfo {
}
public String getCreator() {
final User creator = mindmap.getCreator();
final Account creator = mindmap.getCreator();
return creator != null ? creator.getFullName() : null;
}
@@ -132,7 +132,7 @@ public class RestMindmapInfo {
}
public String getRole() {
final User user = Utils.getUser();
final Account user = Utils.getUser();
String result;
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
return collaboration.map(value -> value.getRole().getLabel()).orElse(ROLE_NONE);
@@ -143,7 +143,7 @@ public class RestMindmapInfo {
}
public String getLastModifierUser() {
final User user = mindmap.getLastEditor();
final Account user = mindmap.getLastEditor();
return user != null ? user.getFullName() : "unknown";
}

View File

@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.User;
import com.wisemapping.model.Account;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
@@ -38,14 +38,14 @@ import java.util.Calendar;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestUser {
private final User user;
private final Account user;
private String password;
public RestUser() {
this(new User());
this(new Account());
}
public RestUser(@NotNull User user) {
public RestUser(@NotNull Account user) {
this.user = user;
}
@@ -99,7 +99,7 @@ public class RestUser {
}
@JsonIgnore
public User getDelegated() {
public Account getDelegated() {
return this.user;
}

View File

@@ -22,9 +22,7 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.model.User;
import java.awt.*;
import com.wisemapping.model.Account;
@JsonAutoDetect(
fieldVisibility = JsonAutoDetect.Visibility.NONE,
@@ -40,8 +38,8 @@ public class RestUserRegistration {
private String recaptcha;
@JsonIgnore
public User build() {
final User user = new User();
public Account build() {
final Account user = new Account();
user.setFirstname(firstname);
user.setLastname(lastname);
user.setEmail(email);