Migrate hibernate xml annotation to annotations
This commit is contained in:
@@ -29,9 +29,9 @@ public interface MindmapManager {
|
||||
|
||||
Collaborator findCollaborator(@NotNull String email);
|
||||
|
||||
Collaborator findCollaborator(long id);
|
||||
Collaborator findCollaborator(int id);
|
||||
|
||||
List<Collaboration> findCollaboration(final long collaboratorId);
|
||||
List<Collaboration> findCollaboration(final int collaboratorId);
|
||||
|
||||
List<Collaboration> findCollaboration(final CollaborationRole userRole);
|
||||
|
||||
@@ -46,15 +46,15 @@ public interface MindmapManager {
|
||||
|
||||
void addCollaborator(Collaborator collaborator);
|
||||
|
||||
void addMindmap(User user, Mindmap mindMap);
|
||||
void addMindmap(User user, Mindmap mindmap);
|
||||
|
||||
void saveMindmap(Mindmap mindMap);
|
||||
void saveMindmap(Mindmap mindmap);
|
||||
|
||||
void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory);
|
||||
void updateMindmap(@NotNull Mindmap mindmap, boolean saveHistory);
|
||||
|
||||
void removeCollaborator(@NotNull Collaborator collaborator);
|
||||
|
||||
void removeMindmap(Mindmap mindap);
|
||||
void removeMindmap(Mindmap mindmap);
|
||||
|
||||
void removeCollaboration(Collaboration collaboration);
|
||||
|
||||
|
@@ -150,12 +150,12 @@ public class MindmapManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaborator findCollaborator(long id) {
|
||||
public Collaborator findCollaborator(int id) {
|
||||
return getHibernateTemplate().get(Collaborator.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaboration(final long collaboratorId) {
|
||||
public List<Collaboration> findCollaboration(final int collaboratorId) {
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration collaboration where colaborator_id=:colaboratorId");
|
||||
query.setParameter("colaboratorId", collaboratorId);
|
||||
return query.list();
|
||||
|
@@ -31,7 +31,7 @@ public interface UserManager {
|
||||
|
||||
User getUserBy(String email);
|
||||
|
||||
User getUserBy(long id);
|
||||
User getUserBy(int id);
|
||||
|
||||
void createUser(User user);
|
||||
|
||||
|
@@ -83,7 +83,8 @@ public class UserManagerImpl
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public User getUserBy(long id) {
|
||||
@Override
|
||||
public User getUserBy(int id) {
|
||||
User user = null;
|
||||
try {
|
||||
user = getHibernateTemplate().get(User.class, id);
|
||||
|
@@ -1,33 +1,43 @@
|
||||
/*
|
||||
* Copyright [2015] [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.
|
||||
*/
|
||||
* Copyright [2015] [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.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ACCESS_AUDITORY")
|
||||
public class AccessAuditory
|
||||
implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
@Column(name = "login_Date")
|
||||
private Calendar loginDate = null;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "user_id", nullable = true)
|
||||
private User user = null;
|
||||
|
||||
public AccessAuditory() {
|
||||
|
@@ -18,15 +18,33 @@
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Collaboration {
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
private long id;
|
||||
@Entity
|
||||
@Table(name = "COLLABORATION")
|
||||
public class Collaboration implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;;
|
||||
|
||||
@Column(name = "role_id",unique = true,nullable = true)
|
||||
private CollaborationRole role;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="mindmap_id",nullable = false)
|
||||
private Mindmap mindMap;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="colaborator_id",nullable = false)
|
||||
private Collaborator collaborator;
|
||||
private CollaborationProperties collaborationProperties;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
|
||||
@JoinColumn(name="properties_id",nullable = false, unique = true)
|
||||
private CollaborationProperties collaborationProperties = new CollaborationProperties();;
|
||||
|
||||
public Collaboration() {
|
||||
}
|
||||
@@ -41,11 +59,11 @@ public class Collaboration {
|
||||
collaborator.addCollaboration(this);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -84,12 +102,7 @@ public class Collaboration {
|
||||
|
||||
@NotNull
|
||||
public CollaborationProperties getCollaborationProperties() {
|
||||
CollaborationProperties result = collaborationProperties;
|
||||
if (result == null) {
|
||||
collaborationProperties = new CollaborationProperties();
|
||||
result = collaborationProperties;
|
||||
}
|
||||
return result;
|
||||
return this.collaborationProperties;
|
||||
}
|
||||
|
||||
public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) {
|
||||
|
@@ -20,10 +20,19 @@ package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CollaborationProperties {
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "COLLABORATION_PROPERTIES")
|
||||
public class CollaborationProperties implements Serializable {
|
||||
public static final String DEFAULT_JSON_PROPERTIES = "{zoom:0.8}";
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
private boolean starred;
|
||||
@Column(name = "mindmap_properties")
|
||||
private String mindmapProperties;
|
||||
|
||||
public CollaborationProperties() {
|
||||
|
@@ -18,20 +18,33 @@
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "COLLABORATOR")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Collaborator implements Serializable {
|
||||
private long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private String email;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private Calendar creationDate;
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
|
||||
@OneToMany(mappedBy="collaborator")
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
public Collaborator() {
|
||||
}
|
||||
@@ -52,11 +65,11 @@ public class Collaborator implements Serializable {
|
||||
return collaborations;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -89,7 +102,7 @@ public class Collaborator implements Serializable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
long id = this.getId();
|
||||
int id = this.getId();
|
||||
String email = this.getEmail();
|
||||
|
||||
int result = (int) (id ^ (id >>> 32));
|
||||
|
@@ -4,16 +4,28 @@ package com.wisemapping.model;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Label {
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
//~ Instance fields ......................................................................................
|
||||
@Entity
|
||||
@Table(name = "LABEL")
|
||||
public class Label implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
@NotNull private String title;
|
||||
@NotNull private User creator;
|
||||
@Nullable private Label parent;
|
||||
@NotNull private String color;
|
||||
@NotNull private String iconName;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="creator_id",nullable = true,unique = true)
|
||||
@NotNull private User creator;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="parent_label_id",nullable = true)
|
||||
@Nullable private Label parent;
|
||||
|
||||
public void setParent(@Nullable Label parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
@@ -80,11 +92,11 @@ public class Label {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
long result = id;
|
||||
result = 31 * result + title.hashCode();
|
||||
result = 31 * result + creator.hashCode();
|
||||
result = 31 * result + (parent != null ? parent.hashCode() : 0);
|
||||
return result;
|
||||
return (int) result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,15 +22,28 @@ import com.wisemapping.util.ZipUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
|
||||
@Entity
|
||||
@Table(name = "MINDMAP_HISTORY")
|
||||
public class MindMapHistory {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private Calendar creationTime;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "editor_id", nullable = true,unique = false)
|
||||
private User editor;
|
||||
|
||||
@Column(name = "xml")
|
||||
private byte[] zippedXml;
|
||||
|
||||
@Column(name = "mindmap_id")
|
||||
private int mindmapId;
|
||||
|
||||
public MindMapHistory() {
|
||||
|
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
* Copyright [2015] [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.
|
||||
*/
|
||||
* Copyright [2015] [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.model;
|
||||
|
||||
@@ -25,29 +25,55 @@ import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class Mindmap {
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
@Entity
|
||||
@Table(name = "MINDMAP")
|
||||
public class Mindmap implements Serializable {
|
||||
|
||||
//~ Instance fields ......................................................................................
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private Calendar creationTime;
|
||||
private String description;
|
||||
|
||||
private boolean isPublic;
|
||||
@Column(name = "edition_date")
|
||||
private Calendar lastModificationTime;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "creator_id", unique = true, nullable = true)
|
||||
private User creator;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "last_editor_id", unique = false, nullable = false)
|
||||
private User lastEditor;
|
||||
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private String description;
|
||||
|
||||
@Column(name = "public")
|
||||
private boolean isPublic;
|
||||
|
||||
@OneToMany(mappedBy="mindMap",orphanRemoval = true, cascade = {CascadeType.ALL},fetch = FetchType.LAZY)
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "R_LABEL_MINDMAP",
|
||||
joinColumns = @JoinColumn(name = "mindmap_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "label_id"))
|
||||
private Set<Label> labels = new LinkedHashSet<>();
|
||||
|
||||
private User creator;
|
||||
private String tags;
|
||||
private String title;
|
||||
|
||||
@Column(name = "xml")
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
private byte[] zippedXml;
|
||||
|
||||
//~ Constructors .........................................................................................
|
||||
@@ -114,7 +140,8 @@ public class Mindmap {
|
||||
collaborations.add(collaboration);
|
||||
}
|
||||
|
||||
@NotNull public Set<Label> getLabels() {
|
||||
@NotNull
|
||||
public Set<Label> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
@@ -317,7 +344,7 @@ public class Mindmap {
|
||||
return result;
|
||||
|
||||
}
|
||||
//creo que no se usa mas
|
||||
|
||||
public boolean hasLabel(@NotNull final String name) {
|
||||
for (Label label : this.labels) {
|
||||
if (label.getTitle().equals(name)) {
|
||||
@@ -327,7 +354,8 @@ public class Mindmap {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable public Label findLabel(int labelId) {
|
||||
@Nullable
|
||||
public Label findLabel(int labelId) {
|
||||
Label result = null;
|
||||
for (Label label : this.labels) {
|
||||
if (label.getId() == labelId) {
|
||||
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright [2015] [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.model;
|
||||
|
||||
public enum ShapeStyle
|
||||
{
|
||||
LINE("line"),
|
||||
ROUNDED_RECTANGLE("rounded rectagle"),
|
||||
RECTANGLE("rectagle"),
|
||||
ELLIPSE("elipse"),
|
||||
IMAGE("image");
|
||||
|
||||
private final String style;
|
||||
|
||||
ShapeStyle(String style)
|
||||
{
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public String getStyle()
|
||||
{
|
||||
return style;
|
||||
}
|
||||
|
||||
public static ShapeStyle fromValue(String value) {
|
||||
for (ShapeStyle shapeStyle : ShapeStyle.values()) {
|
||||
if (shapeStyle.getStyle().equals(value)) {
|
||||
return shapeStyle;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Shape value \"" + value + "\" doesn't match with a value shape style.");
|
||||
}
|
||||
}
|
@@ -21,11 +21,15 @@ package com.wisemapping.model;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USER")
|
||||
@PrimaryKeyJoinColumn(name="colaborator_id")
|
||||
public class User
|
||||
extends Collaborator
|
||||
implements Serializable {
|
||||
@@ -33,16 +37,28 @@ public class User
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String password;
|
||||
private long activationCode;
|
||||
private Calendar activationDate;
|
||||
private Set<String> tags = new HashSet<String>();
|
||||
private boolean allowSendEmail = false;
|
||||
private String locale;
|
||||
private AuthenticationType authenticationType;
|
||||
|
||||
@Column(name = "activation_code")
|
||||
private long activationCode;
|
||||
|
||||
@Column(name = "activation_date")
|
||||
private Calendar activationDate;
|
||||
|
||||
@Column(name = "allow_send_email")
|
||||
private boolean allowSendEmail = false;
|
||||
|
||||
@Column(name="authentication_type")
|
||||
private Character authenticationTypeCode = AuthenticationType.DATABASE.getCode();
|
||||
|
||||
@Column(name="authenticator_uri")
|
||||
private String authenticatorUri;
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "TAG", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Column(name = "name")
|
||||
private Set<String> tags = new HashSet<>();
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
@@ -118,25 +134,24 @@ public class User
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public char getAutheticationTypeCode() {
|
||||
// Default authentication is database ....
|
||||
return this.authenticationType != null ? this.authenticationType.getCode() : AuthenticationType.DATABASE.getCode();
|
||||
public char getAuthenticationTypeCode() {
|
||||
return this.authenticationTypeCode;
|
||||
}
|
||||
|
||||
public void setAutheticationTypeCode(char code) {
|
||||
this.authenticationType = AuthenticationType.valueOf(code);
|
||||
public void setAuthenticationTypeCode(char code) {
|
||||
this.authenticationTypeCode = code;
|
||||
}
|
||||
|
||||
public AuthenticationType getAuthenticationType() {
|
||||
return authenticationType;
|
||||
return authenticationTypeCode!=null ? AuthenticationType.valueOf(authenticationTypeCode):AuthenticationType.DATABASE;
|
||||
}
|
||||
|
||||
public void setAuthenticationType(@NotNull AuthenticationType authenticationType) {
|
||||
this.authenticationType = authenticationType;
|
||||
this.authenticationTypeCode = authenticationType.getCode();
|
||||
}
|
||||
|
||||
public boolean isDatabaseSchema(){
|
||||
return this.authenticationType == AuthenticationType.DATABASE;
|
||||
return this.getAuthenticationType() == AuthenticationType.DATABASE;
|
||||
}
|
||||
|
||||
public String getAuthenticatorUri() {
|
||||
|
@@ -52,7 +52,7 @@ public class AdminController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "application/xml"})
|
||||
@ResponseBody
|
||||
public RestUser getUserById(@PathVariable long id) throws IOException {
|
||||
public RestUser getUserById(@PathVariable int id) throws IOException {
|
||||
final User userBy = userService.getUserBy(id);
|
||||
if (userBy == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
@@ -109,7 +109,7 @@ public class AdminController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changePassword(@RequestBody String password, @PathVariable long id) throws WiseMappingException {
|
||||
public void changePassword(@RequestBody String password, @PathVariable int id) throws WiseMappingException {
|
||||
if (password == null) {
|
||||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class AdminController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteUserByEmail(@PathVariable long id) throws WiseMappingException {
|
||||
public void deleteUserByEmail(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = userService.getUserBy(id);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||
|
@@ -44,7 +44,7 @@ public class LabelController extends BaseController {
|
||||
|
||||
// Return the new created label ...
|
||||
response.setHeader("Location", "/service/labels/" + label.getId());
|
||||
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
||||
response.setHeader("ResourceId", Long.toString(label.getId()));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/labels", produces = {"application/json", "application/xml"})
|
||||
|
@@ -18,7 +18,10 @@
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.*;
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.SessionExpiredException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.rest.model.*;
|
||||
import com.wisemapping.security.Utils;
|
||||
@@ -33,10 +36,8 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
@@ -71,8 +72,9 @@ public class MindmapController extends BaseController {
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
logger.debug("Collaborators list: " + collaborations.size());
|
||||
|
||||
final List<Mindmap> mindmaps = new ArrayList<Mindmap>();
|
||||
final List<Mindmap> mindmaps = new ArrayList<>();
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
if (filter.accept(mindmap, user)) {
|
||||
@@ -83,7 +85,7 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "application/xml"})
|
||||
public RestMindmapHistoryList retrieveHistory(@PathVariable int id) throws IOException {
|
||||
public RestMindmapHistoryList retrieveHistory(@PathVariable int id) {
|
||||
final List<MindMapHistory> histories = mindmapService.findMindmapHistory(id);
|
||||
final RestMindmapHistoryList result = new RestMindmapHistoryList();
|
||||
for (MindMapHistory history : histories) {
|
||||
@@ -301,7 +303,7 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
// Compare one by one if some of the elements has been changed ....
|
||||
final Set<Collaboration> collabsToRemove = new HashSet<Collaboration>(mindMap.getCollaborations());
|
||||
final Set<Collaboration> collabsToRemove = new HashSet<>(mindMap.getCollaborations());
|
||||
for (RestCollaboration restCollab : restCollabs.getCollaborations()) {
|
||||
final Collaboration collaboration = mindMap.findCollaboration(restCollab.getEmail());
|
||||
// Validate role format ...
|
||||
@@ -385,7 +387,7 @@ public class MindmapController extends BaseController {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||
final List<RestCollaboration> collabs = new ArrayList<RestCollaboration>();
|
||||
final List<RestCollaboration> collabs = new ArrayList<>();
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
collabs.add(new RestCollaboration(collaboration));
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestCollaboration {
|
||||
|
||||
private long id;
|
||||
private int id;
|
||||
private String email;
|
||||
private String role;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class RestCollaboration {
|
||||
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@@ -77,11 +77,11 @@ public class RestUser {
|
||||
user.setLastname(lastname);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public int getId() {
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
public void setId(int id) {
|
||||
user.setId(id);
|
||||
}
|
||||
|
||||
|
@@ -30,11 +30,13 @@ public class UpdateSecurityAdvise
|
||||
extends BaseSecurityAdvice
|
||||
implements MethodInterceptor {
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
||||
checkRole(methodInvocation);
|
||||
return methodInvocation.proceed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable User user, @NotNull Mindmap map) {
|
||||
boolean result;
|
||||
if (map.getCreator() == null) {
|
||||
@@ -46,6 +48,7 @@ public class UpdateSecurityAdvise
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable User user, int mapId) {
|
||||
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR);
|
||||
}
|
||||
|
@@ -30,15 +30,18 @@ public class ViewBaseSecurityAdvise
|
||||
extends BaseSecurityAdvice
|
||||
implements MethodInterceptor {
|
||||
|
||||
@Override
|
||||
public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable {
|
||||
checkRole(methodInvocation);
|
||||
return methodInvocation.proceed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable User user, Mindmap map) {
|
||||
return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable User user, int mapId) {
|
||||
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER);
|
||||
}
|
||||
|
@@ -28,12 +28,10 @@ import java.util.List;
|
||||
|
||||
public interface MindmapService {
|
||||
|
||||
String TAG_SEPARATOR = " ";
|
||||
|
||||
@Nullable
|
||||
Mindmap findMindmapById(int id);
|
||||
|
||||
Mindmap getMindmapByTitle(String title, User user);
|
||||
Mindmap getMindmapByTitle(@NotNull String title, User user);
|
||||
|
||||
List<Collaboration> findCollaborations(@NotNull User user);
|
||||
|
||||
|
@@ -168,7 +168,7 @@ public class MindmapServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMindmap(@NotNull Mindmap map, @NotNull User user) throws WiseMappingException {
|
||||
public void addMindmap(@NotNull Mindmap map, @NotNull User user) {
|
||||
|
||||
final String title = map.getTitle();
|
||||
|
||||
|
@@ -32,7 +32,7 @@ public interface UserService {
|
||||
|
||||
User getUserBy(String email);
|
||||
|
||||
User getUserBy(long id);
|
||||
User getUserBy(int id);
|
||||
|
||||
void updateUser(User user);
|
||||
|
||||
|
@@ -181,7 +181,7 @@ public class UserServiceImpl
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public User getUserBy(long id) {
|
||||
public User getUserBy(int id) {
|
||||
return userManager.getUserBy(id);
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,7 @@ public class CollaboratorBean {
|
||||
return collaborator.getEmail();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public int getId() {
|
||||
return collaborator.getId();
|
||||
}
|
||||
}
|
||||
|
@@ -154,7 +154,7 @@ public class MindmapController {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Mindmap findMindmap(long mapId) throws MapCouldNotFoundException {
|
||||
private Mindmap findMindmap(int mapId) throws MapCouldNotFoundException {
|
||||
final Mindmap result = mindmapService.findMindmapById((int) mapId);
|
||||
if (result == null) {
|
||||
throw new MapCouldNotFoundException("Map could not be found " + mapId);
|
||||
@@ -164,7 +164,7 @@ public class MindmapController {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private MindMapBean findMindmapBean(long mapId) throws MapCouldNotFoundException {
|
||||
private MindMapBean findMindmapBean(int mapId) throws MapCouldNotFoundException {
|
||||
final Mindmap mindmap = findMindmap(mapId);
|
||||
return new MindMapBean(mindmap, Utils.getUser());
|
||||
}
|
||||
|
Reference in New Issue
Block a user