diff --git a/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java b/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java
new file mode 100644
index 000000000..25f569aa4
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2018 LibreCCM Foundation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+package org.libreccm.imexport;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+
+/**
+ * Base class for importers/exporters. Implementations must be annotated with
+ * {@link Procsses} to register the implementation in the Import/Export service.
+ *
+ * Implementations must also be CDI beans. It is recommended that the beans are
+ * {@link RequestScoped}.
+ *
+ * @author Jens Pelzetter
+ * @param The type of the entity which is processed by the implementation.
+ */
+public abstract class AbstractEntityImExporter {
+
+ private final ObjectMapper objectMapper = new ObjectMapper();
+
+ protected abstract Class getEntityClass();
+
+ public T importEntity(final String data) throws ImportExpection {
+
+ try {
+ return objectMapper.readValue(data, getEntityClass());
+ } catch (IOException ex) {
+ throw new ImportExpection(ex);
+ }
+
+ }
+
+ public String exportEntity(final Exportable entity) throws ExportException {
+
+ try {
+ return objectMapper.writeValueAsString(entity);
+ } catch (JsonProcessingException ex) {
+ throw new ExportException(String.format(
+ "Failed to export entity \"%s\" of type \"%s\".",
+ entity.getUuid(),
+ getEntityClass().getName()),
+ ex);
+ }
+
+ }
+
+ protected abstract void saveImportedEntity(T entity);
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java
index 7d87a75b1..327163d5f 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
* method. With the returned list of nodes call the
* {@link #orderImExporters(java.util.List)} method. The list returned by
* {@link #orderImExporters(java.util.List)} contains all
- * {@link EntityImExporter} in the order.
+ * {@link AbstractEntityImExporter}s in the order.
*
* This class is not not part of the public API.
*
@@ -50,9 +50,9 @@ final class EntityImExporterTreeManager {
.getLogger(EntityImExporterTreeManager.class);
/**
- * Initialises the tree with the provided list of {@link EntityImExporter}s.
+ * Initialises the tree with the provided list of {@link AbstractEntityImExporter}s.
*
- * @param imExporters The available {@link EntityImExporter}s.
+ * @param imExporters The available {@link AbstractEntityImExporter}s.
*
* @return An ordered list of the tree nodes.
*
@@ -62,7 +62,7 @@ final class EntityImExporterTreeManager {
* cycle is detected in the dependency tree.
*/
public List generateTree(
- final List> imExporters)
+ final List> imExporters)
throws DependencyException {
LOGGER.info("Starting to generate dependency tree...");
@@ -81,7 +81,7 @@ final class EntityImExporterTreeManager {
node -> node));
//Add the dependency relations to the nodes
- for (final EntityImExporter> imExporter : imExporters) {
+ for (final AbstractEntityImExporter> imExporter : imExporters) {
addDependencyRelations(imExporter, nodes);
}
@@ -184,7 +184,7 @@ final class EntityImExporterTreeManager {
/**
* Helper method for adding the dependency relations for an
- * {@link EntityImExporter} to the nodes.
+ * {@link AbstractEntityImExporter} to the nodes.
*
* @param imExporter The current {@link EntityImExporter}.
* @param nodes The map of nodes.
@@ -192,7 +192,7 @@ final class EntityImExporterTreeManager {
* @throws DependencyException If something goes wrong.
*/
private void addDependencyRelations(
- final EntityImExporter> imExporter,
+ final AbstractEntityImExporter> imExporter,
final Map nodes)
throws DependencyException {
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeNode.java b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeNode.java
index cb921689b..6f1d4d040 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeNode.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeNode.java
@@ -29,7 +29,7 @@ import java.util.Objects;
*/
final class EntityImExporterTreeNode {
- private EntityImExporter> entityImExporter;
+ private AbstractEntityImExporter> entityImExporter;
private List dependentImExporters;
@@ -44,18 +44,19 @@ final class EntityImExporterTreeNode {
}
public EntityImExporterTreeNode(
- final EntityImExporter> entityImExporter) {
+ final AbstractEntityImExporter> entityImExporter) {
this();
this.entityImExporter = entityImExporter;
}
- public EntityImExporter> getEntityImExporter() {
+ public AbstractEntityImExporter> getEntityImExporter() {
return entityImExporter;
}
- void setEntityImExporter(final EntityImExporter> entityImExporter) {
+ void setEntityImExporter(
+ final AbstractEntityImExporter> entityImExporter) {
this.entityImExporter = entityImExporter;
}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/ExportException.java b/ccm-core/src/main/java/org/libreccm/imexport/ExportException.java
new file mode 100644
index 000000000..a3e71a224
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/imexport/ExportException.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 LibreCCM Foundation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+package org.libreccm.imexport;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class ExportException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a new instance of ExportException without detail message.
+ */
+ public ExportException() {
+ super();
+ }
+
+
+ /**
+ * Constructs an instance of ExportException with the specified detail message.
+ *
+ * @param msg The detail message.
+ */
+ public ExportException(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs an instance of ExportException which wraps the
+ * specified exception.
+ *
+ * @param exception The exception to wrap.
+ */
+ public ExportException(final Exception exception) {
+ super(exception);
+ }
+
+ /**
+ * Constructs an instance of ExportException with the specified message which also wraps the
+ * specified exception.
+ *
+ * @param msg The detail message.
+ * @param exception The exception to wrap.
+ */
+ public ExportException(final String msg, final Exception exception) {
+ super(msg, exception);
+ }
+}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/ImportExpection.java b/ccm-core/src/main/java/org/libreccm/imexport/ImportExpection.java
new file mode 100644
index 000000000..f1a1f977f
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/imexport/ImportExpection.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 LibreCCM Foundation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+package org.libreccm.imexport;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class ImportExpection extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a new instance of ImportExpection without detail message.
+ */
+ public ImportExpection() {
+ super();
+ }
+
+
+ /**
+ * Constructs an instance of ImportExpection with the specified detail message.
+ *
+ * @param msg The detail message.
+ */
+ public ImportExpection(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs an instance of ImportExpection which wraps the
+ * specified exception.
+ *
+ * @param exception The exception to wrap.
+ */
+ public ImportExpection(final Exception exception) {
+ super(exception);
+ }
+
+ /**
+ * Constructs an instance of ImportExpection with the specified message which also wraps the
+ * specified exception.
+ *
+ * @param msg The detail message.
+ * @param exception The exception to wrap.
+ */
+ public ImportExpection(final String msg, final Exception exception) {
+ super(msg, exception);
+ }
+}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java b/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java
index da8f289a4..37ea323f8 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java
@@ -26,11 +26,15 @@ import org.libreccm.files.FileAlreadyExistsException;
import org.libreccm.files.FileDoesNotExistException;
import org.libreccm.files.InsufficientPermissionsException;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
@@ -39,6 +43,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
@@ -68,7 +74,7 @@ public class ImportExport {
@Inject
@Any
- private Instance> imExporters;
+ private Instance> imExporters;
/**
* Exports the provided entities. The export will be written to a to the
@@ -128,7 +134,7 @@ public class ImportExport {
exportName));
try (JsonWriter manifestWriter = Json.
createWriter(manifestOutputStream)) {
-
+
manifestWriter.writeObject(manifestBuilder.build());
}
@@ -138,10 +144,10 @@ public class ImportExport {
throw new UnexpectedErrorException(ex);
}
- for(final Map.Entry> entry
- : typeEntityMap.entrySet()) {
-
- createExportedEntities(exportName,
+ for (final Map.Entry> entry
+ : typeEntityMap.entrySet()) {
+
+ createExportedEntities(exportName,
entry.getKey(),
entry.getValue());
}
@@ -162,10 +168,10 @@ public class ImportExport {
throw new UnexpectedErrorException(ex);
}
- final Instance> instance = imExporters
+ final Instance> instance = imExporters
.select(new ProcessesLiteral(clazz));
- final EntityImExporter> imExporter;
+ final AbstractEntityImExporter> imExporter;
if (instance.isUnsatisfied()) {
throw new UnexpectedErrorException(String.format(
"No EntityImExporter for entity type \"%s\" available.",
@@ -195,10 +201,23 @@ public class ImportExport {
throw new UnexpectedErrorException(ex);
}
- final JsonObject exportedEntity = imExporter.exportEntity(entity);
- try (JsonWriter writer = Json.createWriter(outputStream)) {
- writer.writeObject(exportedEntity);
+ final String exportedEntity;
+ try {
+ exportedEntity = imExporter.exportEntity(entity);
+ } catch (ExportException ex) {
+ throw new UnexpectedErrorException(ex);
}
+ try (final OutputStreamWriter writer = new OutputStreamWriter(
+ outputStream, StandardCharsets.UTF_8)) {
+
+ writer.write(exportedEntity);
+
+ } catch (IOException ex) {
+ throw new UnexpectedErrorException(ex);
+ }
+// try (JsonWriter writer = Json.createWriter(outputStream)) {
+// writer.writeObject(exportedEntity);
+// }
}
return filesArrayBuilder;
@@ -235,7 +254,8 @@ public class ImportExport {
throw new UnexpectedErrorException(ex);
}
- final List> imExportersList = new ArrayList<>();
+ final List> imExportersList
+ = new ArrayList<>();
imExporters.forEach(imExporter -> imExportersList.add(imExporter));
try {
@@ -270,7 +290,8 @@ public class ImportExport {
private boolean filterImporters(final ImportManifest manifest,
final EntityImExporterTreeNode node) {
- final EntityImExporter> imExporter = node.getEntityImExporter();
+ final AbstractEntityImExporter> imExporter = node
+ .getEntityImExporter();
final String type = imExporter
.getClass()
.getAnnotation(Processes.class).value().getName();
@@ -280,7 +301,7 @@ public class ImportExport {
private void importEntitiesOfType(
final String importName,
- final EntityImExporter> entityImExporter) {
+ final AbstractEntityImExporter> entityImExporter) {
final String type = entityImExporter
.getClass()
@@ -313,7 +334,7 @@ public class ImportExport {
private void importEntity(final String importName,
final String type,
final String fileName,
- final EntityImExporter> imExporter) {
+ final AbstractEntityImExporter> imExporter) {
final String filePath = String.format("imports/%s/%s/%s",
importName,
@@ -322,15 +343,20 @@ public class ImportExport {
try (final InputStream inputStream
= ccmFiles.createInputStream(filePath)) {
- final JsonReader reader = Json.createReader(inputStream);
- final JsonObject data = reader.readObject();
+ final String data = new BufferedReader(
+ new InputStreamReader(inputStream, StandardCharsets.UTF_8))
+ .lines()
+ .collect(Collectors.joining("\n"));
+// final JsonReader reader = Json.createReader(inputStream);
+// final JsonObject data = reader.readObject();
imExporter.importEntity(data);
} catch (IOException
| FileDoesNotExistException
| FileAccessException
- | InsufficientPermissionsException ex) {
+ | InsufficientPermissionsException
+ | ImportExpection ex) {
throw new UnexpectedErrorException(ex);
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/Group.java b/ccm-core/src/main/java/org/libreccm/security/Group.java
index aa084eb54..242da61c7 100644
--- a/ccm-core/src/main/java/org/libreccm/security/Group.java
+++ b/ccm-core/src/main/java/org/libreccm/security/Group.java
@@ -21,7 +21,6 @@ package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
-import org.libreccm.portation.Portable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
@@ -35,6 +34,8 @@ import java.util.Set;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
+import org.libreccm.imexport.Exportable;
+
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedAttributeNode;
@@ -58,6 +59,10 @@ import javax.persistence.Table;
@Entity
@Table(name = "GROUPS", schema = DB_SCHEMA)
@NamedQueries({
+ @NamedQuery(
+ name = "Group.findByUuid",
+ query = "SELECT g FROM Group g WHERE g.uuid = :uuid"
+ ),
@NamedQuery(
name = "Group.findByName",
query = "SELECT g FROM Group g WHERE g.name = :name "
@@ -105,8 +110,8 @@ import javax.persistence.Table;
@XmlRootElement(name = "user-group", namespace = CORE_XML_NS)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = GroupIdResolver.class,
- property = "name")
-public class Group extends Party implements Serializable, Portable {
+ property = "uuid")
+public class Group extends Party implements Serializable, Exportable {
private static final long serialVersionUID = -4800759206452780739L;
diff --git a/ccm-core/src/main/java/org/libreccm/security/GroupIdResolver.java b/ccm-core/src/main/java/org/libreccm/security/GroupIdResolver.java
index 8df906aa7..955d72785 100644
--- a/ccm-core/src/main/java/org/libreccm/security/GroupIdResolver.java
+++ b/ccm-core/src/main/java/org/libreccm/security/GroupIdResolver.java
@@ -26,7 +26,7 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
- * @author Tobias Osmers
* @version created on 3/23/17
*/
@RequestScoped
@@ -43,14 +43,15 @@ public class GroupIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
+
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final GroupRepository groupRepo = cdiUtil
.findBean(GroupRepository.class);
return groupRepo
- .findByName(id.key.toString())
+ .findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
- .format("No Group with name %s in the database.",
+ .format("No Group with uuid %s in the database.",
id.key.toString())));
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/GroupMarshaller.java b/ccm-core/src/main/java/org/libreccm/security/GroupImExporter.java
similarity index 64%
rename from ccm-core/src/main/java/org/libreccm/security/GroupMarshaller.java
rename to ccm-core/src/main/java/org/libreccm/security/GroupImExporter.java
index 09e76aad7..090e0d875 100644
--- a/ccm-core/src/main/java/org/libreccm/security/GroupMarshaller.java
+++ b/ccm-core/src/main/java/org/libreccm/security/GroupImExporter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 LibreCCM Foundation.
+ * Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,35 +18,34 @@
*/
package org.libreccm.security;
-import org.libreccm.portation.AbstractMarshaller;
-import org.libreccm.portation.Marshals;
+import org.libreccm.imexport.AbstractEntityImExporter;
+import org.libreccm.imexport.Processes;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
- * @author Jens Pelzetter
*/
@RequestScoped
-@Marshals(Group.class)
-public class GroupMarshaller extends AbstractMarshaller {
-
- private static final long serialVersionUID = 5004457104585052013L;
+@Processes(Group.class)
+public class GroupImExporter extends AbstractEntityImExporter{
@Inject
private GroupRepository groupRepository;
-
+
@Override
- protected Class getObjectClass() {
+ protected Class getEntityClass() {
return Group.class;
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
- protected void insertIntoDb(Group portableObject) {
- portableObject.setPartyId(portableObject.getPartyId() * -1);
- groupRepository.save(portableObject);
+ protected void saveImportedEntity(final Group entity) {
+
+ groupRepository.save(entity);
}
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/GroupManager.java b/ccm-core/src/main/java/org/libreccm/security/GroupManager.java
index 5967c5cc8..326643beb 100644
--- a/ccm-core/src/main/java/org/libreccm/security/GroupManager.java
+++ b/ccm-core/src/main/java/org/libreccm/security/GroupManager.java
@@ -26,8 +26,10 @@ import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
+
import java.io.Serializable;
import java.util.List;
+import java.util.UUID;
/**
* Manager class providing methods for adding and removing members to and from
@@ -74,6 +76,7 @@ public class GroupManager implements Serializable {
}
final GroupMembership membership = new GroupMembership();
+ membership.setUuid(UUID.randomUUID().toString());
membership.setGroup(group);
membership.setMember(user);
diff --git a/ccm-core/src/main/java/org/libreccm/security/GroupMembership.java b/ccm-core/src/main/java/org/libreccm/security/GroupMembership.java
index 1a735ce56..fcb19541f 100644
--- a/ccm-core/src/main/java/org/libreccm/security/GroupMembership.java
+++ b/ccm-core/src/main/java/org/libreccm/security/GroupMembership.java
@@ -20,34 +20,50 @@ package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
-import org.libreccm.portation.Portable;
-import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
+import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import org.libreccm.imexport.Exportable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
/**
- * A association class representing the assoication between a {@link User} and
- * a {@code Group}.
- *
+ * A association class representing the association between a {@link User} and a
+ * {@code Group}.
+ *
* @author Jens Pelzetter
*/
@Entity
@Table(name = "GROUP_MEMBERSHIPS", schema = DB_SCHEMA)
@NamedQueries({
+ @NamedQuery(name = "GroupMembership.findByUuid",
+ query = "SELECT m FROM GroupMembership m WHERE m.uuid = :uuid")
+ ,
@NamedQuery(name = "GroupMembership.findByGroupAndUser",
query = "SELECT m FROM GroupMembership m "
+ "WHERE m.member = :member AND m.group = :group")})
@XmlRootElement(name = "group-membership", namespace = CORE_XML_NS)
-@JsonIdentityInfo(generator = GroupMembershipIdGenerator.class,
- property = "customMemId")
-public class GroupMembership implements Serializable, Portable {
+@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
+ property = "uuid")
+public class GroupMembership implements Serializable, Exportable {
private static final long serialVersionUID = 83192968306850665L;
@@ -57,6 +73,10 @@ public class GroupMembership implements Serializable, Portable {
@XmlElement(name = "membership-id", namespace = CORE_XML_NS)
private long membershipId;
+ @Column(name = "UUID", unique = true, nullable = false)
+ @XmlElement(name = "uuid", namespace = CORE_XML_NS)
+ private String uuid;
+
@ManyToOne
@JoinColumn(name = "GROUP_ID")
@XmlTransient
@@ -77,6 +97,15 @@ public class GroupMembership implements Serializable, Portable {
this.membershipId = membershipId;
}
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ protected void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
+
public Group getGroup() {
return group;
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/GroupMembershipIdGenerator.java b/ccm-core/src/main/java/org/libreccm/security/GroupMembershipIdGenerator.java
deleted file mode 100644
index 406681631..000000000
--- a/ccm-core/src/main/java/org/libreccm/security/GroupMembershipIdGenerator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2015 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.libreccm.security;
-
-import com.fasterxml.jackson.annotation.ObjectIdGenerator;
-
-/**
- * @author Jens Pelzetter
*/
-@RequestScoped
-@Marshals(GroupMembership.class)
-public class GroupMembershipMarshaller extends AbstractMarshaller {
-
- private static final long serialVersionUID = -1920271635191667015L;
+@Processes(GroupMembership.class)
+@DependsOn({User.class, Group.class})
+public class GroupMembershipImExporter extends AbstractEntityImExporter {
@Inject
private EntityManager entityManager;
@Override
- protected Class getObjectClass() {
+ protected Class getEntityClass() {
+
return GroupMembership.class;
+
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
- protected void insertIntoDb(final GroupMembership portableObject) {
- portableObject.setMembershipId(portableObject.getMembershipId() * -1);
- entityManager.merge(portableObject);
- entityManager.flush();
+ protected void saveImportedEntity(final GroupMembership entity) {
+
+ entityManager.persist(entity);
}
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/GroupRepository.java b/ccm-core/src/main/java/org/libreccm/security/GroupRepository.java
index c9fde6d6a..1e49d9032 100644
--- a/ccm-core/src/main/java/org/libreccm/security/GroupRepository.java
+++ b/ccm-core/src/main/java/org/libreccm/security/GroupRepository.java
@@ -60,6 +60,19 @@ public class GroupRepository extends AbstractEntityRepository {
return entity.getPartyId() == 0;
}
+
+ public Optional findByUuid(final String uuid) {
+
+ final TypedQuery query = getEntityManager()
+ .createNamedQuery("Group.findByUuid", Group.class);
+ query.setParameter("uuid", uuid);
+ final List result = query.getResultList();
+ if (result.isEmpty()) {
+ return Optional.empty();
+ } else {
+ return Optional.of(result.get(0));
+ }
+ }
/**
* Finds a group by its name.
diff --git a/ccm-core/src/main/java/org/libreccm/security/Party.java b/ccm-core/src/main/java/org/libreccm/security/Party.java
index c44444b40..e0be03b9c 100644
--- a/ccm-core/src/main/java/org/libreccm/security/Party.java
+++ b/ccm-core/src/main/java/org/libreccm/security/Party.java
@@ -18,6 +18,8 @@
*/
package org.libreccm.security;
+import static org.libreccm.core.CoreConstants.*;
+
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@@ -33,9 +35,6 @@ import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
-import static org.libreccm.core.CoreConstants.CORE_XML_NS;
-import static org.libreccm.core.CoreConstants.DB_SCHEMA;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -62,6 +61,10 @@ import javax.persistence.Table;
@Table(name = "PARTIES", schema = DB_SCHEMA)
@Inheritance(strategy = InheritanceType.JOINED)
@NamedQueries({
+ @NamedQuery(
+ name = "Party.findByUuid",
+ query = "SELECT p FROM Party p WHERE p.uuid = :uuid"
+ ),
@NamedQuery(
name = "Party.findByName",
query = "SELECT p FROM Party p WHERE p.name = :name")
@@ -86,7 +89,7 @@ import javax.persistence.Table;
})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = PartyIdResolver.class,
- property = "name")
+ property = "uuid")
public class Party implements Serializable {
private static final long serialVersionUID = 3319997992281332204L;
@@ -94,9 +97,11 @@ public class Party implements Serializable {
@Id
@Column(name = "PARTY_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
+ @XmlElement(name = "party-id", namespace = CORE_XML_NS)
private long partyId;
@Column(name = "UUID", unique = true, nullable = false)
+ @XmlElement(name = "uuid", namespace = CORE_XML_NS)
private String uuid;
/**
@@ -105,6 +110,7 @@ public class Party implements Serializable {
*/
@Column(name = "NAME", length = 256, nullable = false)
@NotNull
+ @XmlElement(name = "name", namespace = CORE_XML_NS)
// @Pattern(regexp = "[a-zA-Z0-9\\-_\\.]*")
private String name;
diff --git a/ccm-core/src/main/java/org/libreccm/security/PartyIdResolver.java b/ccm-core/src/main/java/org/libreccm/security/PartyIdResolver.java
index 96d629855..ec5679fc8 100644
--- a/ccm-core/src/main/java/org/libreccm/security/PartyIdResolver.java
+++ b/ccm-core/src/main/java/org/libreccm/security/PartyIdResolver.java
@@ -26,7 +26,7 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
- * @author Tobias Osmers
* @version created on 3/23/17
*/
@RequestScoped
@@ -43,14 +43,15 @@ public class PartyIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
+
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PartyRepository partyRepository = cdiUtil
.findBean(PartyRepository.class);
return partyRepository
- .findByName(id.key.toString())
+ .findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
- .format("No Party with name %s in the database.",
+ .format("No Party with uuid %s in the database.",
id.key.toString())));
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java b/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java
index b0ae59d50..a6c2d2a84 100644
--- a/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java
+++ b/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java
@@ -67,6 +67,20 @@ public class PartyRepository extends AbstractEntityRepository {
party.setUuid(UUID.randomUUID().toString());
}
+
+ public Optional findByUuid(final String uuid) {
+ final TypedQuery query = getEntityManager().createNamedQuery(
+ "Party.findByUuid", Party.class);
+ query.setParameter("uuid", uuid);
+
+ final List result = query.getResultList();
+ if (result.isEmpty()) {
+ return Optional.empty();
+ } else {
+ return Optional.of(result.get(0));
+ }
+ }
+
/**
* Finds a {@link Party} (which can be a user or group) by its name.
*
diff --git a/ccm-core/src/main/java/org/libreccm/security/Permission.java b/ccm-core/src/main/java/org/libreccm/security/Permission.java
index 7ab5d5ced..63c9bd042 100644
--- a/ccm-core/src/main/java/org/libreccm/security/Permission.java
+++ b/ccm-core/src/main/java/org/libreccm/security/Permission.java
@@ -24,13 +24,13 @@ import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.libreccm.core.CcmObject;
-import org.libreccm.portation.Portable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
@@ -38,6 +38,9 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
+import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import org.libreccm.imexport.Exportable;
+
/**
* A permission grants a privilege on an object or system wide to {@link Role}.
*
@@ -46,6 +49,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@Entity
@Table(name = "PERMISSIONS", schema = DB_SCHEMA)
@NamedQueries({
+ @NamedQuery(name = "Permission.findByUuid",
+ query = "SELECT p FROM Permission p WHERE p.uuid = :uuid")
+ ,
@NamedQuery(name = "Permission.findByCustomPermId",
query = "SELECT p FROM Permission p "
+ "WHERE p.grantedPrivilege = :privilege "
@@ -93,10 +99,10 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
})
@XmlRootElement(name = "permission", namespace = CORE_XML_NS)
@XmlAccessorType(XmlAccessType.FIELD)
-@JsonIdentityInfo(generator = PermissionIdGenerator.class,
+@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = PermissionIdResolver.class,
- property = "customPermId")
-public class Permission implements Serializable, Portable {
+ property = "uuid")
+public class Permission implements Serializable, Exportable {
private static final long serialVersionUID = -5178045844045517958L;
@@ -109,6 +115,10 @@ public class Permission implements Serializable, Portable {
@XmlElement(name = "permission-id", namespace = CORE_XML_NS)
private long permissionId;
+ @Column(name = "UUID", unique = true, nullable = false)
+ @XmlElement(name = "uuid", namespace = CORE_XML_NS)
+ private String uuid;
+
/**
* The granted privilege.
*/
@@ -192,6 +202,15 @@ public class Permission implements Serializable, Portable {
this.permissionId = permissionId;
}
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ protected void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
+
public String getGrantedPrivilege() {
return grantedPrivilege;
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/PermissionIdGenerator.java b/ccm-core/src/main/java/org/libreccm/security/PermissionIdGenerator.java
deleted file mode 100644
index 13e626550..000000000
--- a/ccm-core/src/main/java/org/libreccm/security/PermissionIdGenerator.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2015 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.libreccm.security;
-
-import com.fasterxml.jackson.annotation.ObjectIdGenerator;
-
-/**
- * @author object = ccmObjectRepository
- .findObjectByUuid(objectUuid);
- final Optional grantee = roleRepository
- .findByName(granteeName);
- if (!grantee.isPresent()) {
- throw new UnexpectedErrorException(String.format(
- "Role with id \"%s\" was not found in the database," +
- " but has been associated with a permission.",
- granteeName));
- }
- Optional permission = permissionRepository
- .findByCustomPermId(privilege,
- grantee.get(),
- object.orElse(null));
-
- if (!permission.isPresent()) {
- throw new UnexpectedErrorException(String.format(
- "Permission with privilege \"%s\", grantee \"%s and " +
- "object \"%s\" was not found in the database.",
- privilege, grantee.toString(), object.toString()));
- }
-
- return permission.get();
+ return permissionRepository
+ .findByUuid(id.key.toString())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No Permission with UUID %s in the database.",
+ id.key.toString())));
}
@Override
diff --git a/ccm-core/src/main/java/org/libreccm/security/UserMarshaller.java b/ccm-core/src/main/java/org/libreccm/security/PermissionImExporter.java
similarity index 57%
rename from ccm-core/src/main/java/org/libreccm/security/UserMarshaller.java
rename to ccm-core/src/main/java/org/libreccm/security/PermissionImExporter.java
index 308a98890..fde80db45 100644
--- a/ccm-core/src/main/java/org/libreccm/security/UserMarshaller.java
+++ b/ccm-core/src/main/java/org/libreccm/security/PermissionImExporter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 LibreCCM Foundation.
+ * Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,33 +18,36 @@
*/
package org.libreccm.security;
-import org.libreccm.portation.AbstractMarshaller;
-import org.libreccm.portation.Marshals;
+import org.libreccm.imexport.AbstractEntityImExporter;
+import org.libreccm.imexport.DependsOn;
+import org.libreccm.imexport.Processes;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
-import javax.transaction.Transactional;
/**
- * @author Jens Pelzetter
*/
@RequestScoped
-@Marshals(User.class)
-public class UserMarshaller extends AbstractMarshaller {
- private static final long serialVersionUID = -7857346915894246160L;
+@Processes(Permission.class)
+@DependsOn({Role.class})
+public class PermissionImExporter extends AbstractEntityImExporter{
@Inject
- private UserRepository userRepository;
-
+ private PermissionRepository permissionRepository;
+
@Override
- protected Class getObjectClass() {
- return User.class;
+ protected Class getEntityClass() {
+ return Permission.class;
}
@Override
- @Transactional(Transactional.TxType.REQUIRED)
- protected void insertIntoDb(User portableObject) {
- userRepository.save(portableObject);
+ protected void saveImportedEntity(final Permission entity) {
+
+ permissionRepository.save(entity);
}
+
+
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/PermissionRepository.java b/ccm-core/src/main/java/org/libreccm/security/PermissionRepository.java
index e730eb59c..0720a84f4 100644
--- a/ccm-core/src/main/java/org/libreccm/security/PermissionRepository.java
+++ b/ccm-core/src/main/java/org/libreccm/security/PermissionRepository.java
@@ -23,7 +23,9 @@ import org.libreccm.core.AbstractEntityRepository;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
+
import java.util.Optional;
+import java.util.UUID;
/**
* A repository class for {@link Permission}.
@@ -53,13 +55,27 @@ public class PermissionRepository
}
@Override
- public boolean isNew(Permission entity) {
+ public boolean isNew(final Permission entity) {
if (entity == null) {
throw new IllegalArgumentException("Can't save null");
}
return entity.getPermissionId() == 0;
}
+ @Override
+ public void initNewEntity(final Permission permission) {
+
+ permission.setUuid(UUID.randomUUID().toString());
+ }
+
+ public Optional findByUuid(final String uuid) {
+ final TypedQuery query = getEntityManager()
+ .createNamedQuery("Permission.findByUuid", Permission.class);
+ query.setParameter("uuid", uuid);
+
+ return getSingleResult(query);
+ }
+
/**
* Finds a {@link Permission} by the privilege, the grantee and the object.
* Where the grantee has been granted the given privilege on the given
diff --git a/ccm-core/src/main/java/org/libreccm/security/Role.java b/ccm-core/src/main/java/org/libreccm/security/Role.java
index adb283ca2..c1b56f900 100644
--- a/ccm-core/src/main/java/org/libreccm/security/Role.java
+++ b/ccm-core/src/main/java/org/libreccm/security/Role.java
@@ -24,17 +24,45 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.search.annotations.Field;
import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.l10n.LocalizedString;
-import org.libreccm.portation.Portable;
import org.libreccm.workflow.TaskAssignment;
-import javax.persistence.*;
-import javax.xml.bind.annotation.*;
-import java.io.Serializable;
-import java.util.*;
-
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
+import org.libreccm.imexport.Exportable;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+import javax.persistence.AssociationOverride;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.NamedAttributeNode;
+import javax.persistence.NamedEntityGraph;
+import javax.persistence.NamedEntityGraphs;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
/**
* A role is basically a collection a {@link Permission}s and {@code Task}s.
*
@@ -43,6 +71,8 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@Entity
@Table(name = "CCM_ROLES", schema = DB_SCHEMA)
@NamedQueries({
+ @NamedQuery(name = "Role.findByUuid",
+ query = "SELECT r FROM Role r WHERE r.uuid = :uuid"),
@NamedQuery(name = "Role.findByName",
query = "SELECT r FROM Role r "
+ "WHERE r.name = :name")
@@ -118,8 +148,8 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@SuppressWarnings({"PMD.ShortClassName", "PMD.TooManyMethods"})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = RoleIdResolver.class,
- property = "name")
-public class Role implements Serializable, Portable {
+ property = "uuid")
+public class Role implements Serializable, Exportable {
private static final long serialVersionUID = -7121296514181469687L;
@@ -134,6 +164,10 @@ public class Role implements Serializable, Portable {
@XmlElement(name = "role-id", namespace = CORE_XML_NS)
private long roleId;
+ @Column(name = "UUID", unique = true, nullable = false)
+ @XmlElement(name = "uuid", namespace = CORE_XML_NS)
+ private String uuid;
+
/**
* The name of the role. May only contain the letters a to z, A to Z, the
* numbers 0 to 9, the {@code -} (dash) and the {@code _} (underscore).
@@ -193,6 +227,15 @@ public class Role implements Serializable, Portable {
protected void setRoleId(final long roleId) {
this.roleId = roleId;
}
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ protected void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
public String getName() {
return name;
diff --git a/ccm-core/src/main/java/org/libreccm/security/RoleIdResolver.java b/ccm-core/src/main/java/org/libreccm/security/RoleIdResolver.java
index 79cd911fd..afedb0e77 100644
--- a/ccm-core/src/main/java/org/libreccm/security/RoleIdResolver.java
+++ b/ccm-core/src/main/java/org/libreccm/security/RoleIdResolver.java
@@ -48,9 +48,9 @@ public class RoleIdResolver implements Serializable, ObjectIdResolver {
.findBean(RoleRepository.class);
return roleRepository
- .findByName(id.key.toString())
+ .findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
- .format("No Role with name %s in the database.",
+ .format("No Role with uuid %s in the database.",
id.key.toString())));
}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java b/ccm-core/src/main/java/org/libreccm/security/RoleImExporter.java
similarity index 59%
rename from ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java
rename to ccm-core/src/main/java/org/libreccm/security/RoleImExporter.java
index eba225a4a..168b29485 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java
+++ b/ccm-core/src/main/java/org/libreccm/security/RoleImExporter.java
@@ -16,25 +16,33 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
-package org.libreccm.imexport;
+package org.libreccm.security;
-import javax.enterprise.context.RequestScoped;
-import javax.json.JsonObject;
+import org.libreccm.imexport.AbstractEntityImExporter;
+import org.libreccm.imexport.Processes;
+
+import javax.inject.Inject;
/**
- * Interface for importers/exporters. Implementations must be annotated with
- * {@link Procsses} to register the implementation in the Import/Export service.
- *
- * Implementations must also be CDI beans. It is recommended that the beans
- * are {@link RequestScoped}.
- *
+ *
* @author Jens Pelzetter
- * @param The type of the entity which is processed by the implementation.
*/
-public interface EntityImExporter {
+@Processes(Role.class)
+public class RoleImExporter extends AbstractEntityImExporter {
+
+ @Inject
+ private RoleRepository roleRepository;
- T importEntity(JsonObject data);
-
- JsonObject exportEntity(Exportable entity);
+ @Override
+ protected Class getEntityClass() {
+
+ return Role.class;
+ }
+
+ @Override
+ protected void saveImportedEntity(final Role entity) {
+
+ roleRepository.save(entity);
+ }
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/RoleManager.java b/ccm-core/src/main/java/org/libreccm/security/RoleManager.java
index 4fdb7997c..903aae702 100644
--- a/ccm-core/src/main/java/org/libreccm/security/RoleManager.java
+++ b/ccm-core/src/main/java/org/libreccm/security/RoleManager.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.UUID;
import java.util.stream.Collectors;
/**
@@ -83,6 +84,7 @@ public class RoleManager implements Serializable {
}
final RoleMembership membership = new RoleMembership();
+ membership.setUuid(UUID.randomUUID().toString());
membership.setRole(role);
membership.setMember(party);
diff --git a/ccm-core/src/main/java/org/libreccm/security/RoleMarshaller.java b/ccm-core/src/main/java/org/libreccm/security/RoleMarshaller.java
deleted file mode 100644
index 89c0fa14b..000000000
--- a/ccm-core/src/main/java/org/libreccm/security/RoleMarshaller.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2015 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.libreccm.security;
-
-import org.libreccm.portation.AbstractMarshaller;
-import org.libreccm.portation.Marshals;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- * @author Tobias Osmers
- * @version created on 11/7/16
+ *
+ * @author Jens Pelzetter
*/
-@RequestScoped
-@Marshals(Permission.class)
-public class PermissionMarshaller extends AbstractMarshaller {
- private static final long serialVersionUID = -5145925775270121916L;
+@Processes(RoleMembership.class)
+@DependsOn({User.class, Group.class, Role.class})
+public class RoleMembershipImExporter
+ extends AbstractEntityImExporter{
@Inject
private EntityManager entityManager;
-
+
@Override
- protected Class getObjectClass() {
- return Permission.class;
+ protected Class getEntityClass() {
+
+ return RoleMembership.class;
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
- protected void insertIntoDb(Permission portableObject) {
- if (portableObject.getPermissionId() == 0) {
- entityManager.persist(portableObject);
- } else {
- entityManager.merge(portableObject);
- }
+ protected void saveImportedEntity(final RoleMembership entity) {
+
+ entityManager.persist(entity);
}
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/RoleMembershipMarshaller.java b/ccm-core/src/main/java/org/libreccm/security/RoleMembershipMarshaller.java
deleted file mode 100644
index 91125321f..000000000
--- a/ccm-core/src/main/java/org/libreccm/security/RoleMembershipMarshaller.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2015 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.libreccm.security;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.portation.AbstractMarshaller;
-import org.libreccm.portation.Marshals;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.transaction.Transactional;
-
-/**
- * @author Tobias Osmers
- * @version created on 11/7/16
- */
-@RequestScoped
-@Marshals(RoleMembership.class)
-public class RoleMembershipMarshaller extends AbstractMarshaller {
- private static final long serialVersionUID = 1304404004268502935L;
-
- private static final Logger LOGGER = LogManager.getLogger(RoleMembershipMarshaller.class);
-
- @Inject
- private EntityManager entityManager;
-
- @Override
- protected Class getObjectClass() {
- return RoleMembership.class;
- }
-
- @Override
- @Transactional(Transactional.TxType.REQUIRED)
- protected void insertIntoDb(final RoleMembership portableObject) {
- portableObject.setMembershipId(portableObject.getMembershipId() * -1);
- entityManager.merge(portableObject);
- entityManager.flush();
- }
-
-}
diff --git a/ccm-core/src/main/java/org/libreccm/security/RoleRepository.java b/ccm-core/src/main/java/org/libreccm/security/RoleRepository.java
index 9fd5a2e5e..b694dabb0 100644
--- a/ccm-core/src/main/java/org/libreccm/security/RoleRepository.java
+++ b/ccm-core/src/main/java/org/libreccm/security/RoleRepository.java
@@ -26,8 +26,10 @@ import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
+
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
/**
* Repository class for {@link Role} entities.
@@ -61,12 +63,28 @@ public class RoleRepository extends AbstractEntityRepository {
}
return entity.getRoleId() == 0;
}
+
+ @Override
+ public void initNewEntity(final Role role) {
+
+ role.setUuid(UUID.randomUUID().toString());
+
+ }
public long count() {
final TypedQuery query = getEntityManager().createNamedQuery(
"Role.count", Long.class);
return query.getSingleResult();
}
+
+ public Optional findByUuid(final String uuid) {
+
+ final TypedQuery query = getEntityManager()
+ .createNamedQuery("Role.findByUuid", Role.class);
+ query.setParameter("uuid", uuid);
+
+ return getSingleResult(query);
+ }
/**
* Finds a role a its name.
diff --git a/ccm-core/src/main/java/org/libreccm/security/User.java b/ccm-core/src/main/java/org/libreccm/security/User.java
index 799903bd3..3b2fc667d 100644
--- a/ccm-core/src/main/java/org/libreccm/security/User.java
+++ b/ccm-core/src/main/java/org/libreccm/security/User.java
@@ -22,7 +22,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.EmailAddress;
-import org.libreccm.portation.Portable;
import javax.validation.constraints.NotNull;
@@ -73,6 +72,9 @@ import javax.xml.bind.annotation.XmlTransient;
@Entity
@Table(name = "USERS", schema = DB_SCHEMA)
@NamedQueries({
+ @NamedQuery(name = "User.findByUuid",
+ query = "SELECT u FROM User u WHERE u.uuid = :uuid")
+ ,
@NamedQuery(name = "User.findByName",
query = "SELECT u FROM User u WHERE u.name = :name "
+ "ORDER BY u.name, "
@@ -151,8 +153,8 @@ import javax.xml.bind.annotation.XmlTransient;
@SuppressWarnings({"PMD.ShortClassName", "PMD.LongVariable"})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = UserIdResolver.class,
- property = "name")
-public class User extends Party implements Serializable, Exportable, Portable {
+ property = "uuid")
+public class User extends Party implements Serializable, Exportable {
private static final long serialVersionUID = 4035223413596611393L;
diff --git a/ccm-core/src/main/java/org/libreccm/security/UserIdResolver.java b/ccm-core/src/main/java/org/libreccm/security/UserIdResolver.java
index f4b9b3b90..bfeb9c231 100644
--- a/ccm-core/src/main/java/org/libreccm/security/UserIdResolver.java
+++ b/ccm-core/src/main/java/org/libreccm/security/UserIdResolver.java
@@ -26,11 +26,12 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
- * @author Tobias Osmers
+ * @author Jens Pelzetter
*/
@RequestScoped
public class UserIdResolver implements Serializable, ObjectIdResolver {
+
private static final long serialVersionUID = -2541656707906049331L;
@Override
@@ -43,12 +44,13 @@ public class UserIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
+
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final UserRepository userRepository = cdiUtil
.findBean(UserRepository.class);
return userRepository
- .findByName(id.key.toString())
+ .findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No User with name %s in the database.",
id.key.toString())));
diff --git a/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java b/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java
index 089b78de8..148916d0f 100644
--- a/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java
+++ b/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java
@@ -18,12 +18,12 @@
*/
package org.libreccm.security;
-import org.libreccm.imexport.EntityImExporter;
-import org.libreccm.imexport.Exportable;
+import org.libreccm.imexport.AbstractEntityImExporter;
import org.libreccm.imexport.Processes;
import javax.enterprise.context.RequestScoped;
-import javax.json.JsonObject;
+import javax.inject.Inject;
+import javax.transaction.Transactional;
/**
*
@@ -31,16 +31,21 @@ import javax.json.JsonObject;
*/
@RequestScoped
@Processes(User.class)
-public class UserImExporter implements EntityImExporter {
+public class UserImExporter extends AbstractEntityImExporter {
+
+ @Inject
+ private UserRepository userRepository;
@Override
- public User importEntity(final JsonObject data) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ protected Class getEntityClass() {
+ return User.class;
}
@Override
- public JsonObject exportEntity(final Exportable entity) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ @Transactional(Transactional.TxType.REQUIRED)
+ protected void saveImportedEntity(final User entity) {
+
+ userRepository.save(entity);
}
-
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/UserRepository.java b/ccm-core/src/main/java/org/libreccm/security/UserRepository.java
index 1fe96e205..7484ec81f 100644
--- a/ccm-core/src/main/java/org/libreccm/security/UserRepository.java
+++ b/ccm-core/src/main/java/org/libreccm/security/UserRepository.java
@@ -61,6 +61,14 @@ public class UserRepository extends AbstractEntityRepository {
return user.getPartyId() == 0;
}
+ public Optional findByUuid(final String uuid) {
+ final TypedQuery query = getEntityManager().createNamedQuery(
+ "User.findByUuid", User.class);
+ query.setParameter("uuid", uuid);
+
+ return getSingleResult(query);
+ }
+
/**
* Finds a user by its user name.
*
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_28__add_role_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_28__add_role_uuid.sql
new file mode 100644
index 000000000..69dbfa84b
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_28__add_role_uuid.sql
@@ -0,0 +1,5 @@
+alter table CCM_CORE.ROLES
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.ROLES
+ add constraint UK_rfmsjqsq6kagolsod3ufkugll unique (UUID);
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_29__add_permission_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_29__add_permission_uuid.sql
new file mode 100644
index 000000000..38f3e2fc4
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_29__add_permission_uuid.sql
@@ -0,0 +1,6 @@
+alter table CCM_CORE.PERMISSIONS
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.PERMISSIONS
+ add constraint UK_p50se7rdexv7xnkiqsl6ijyti unique (UUID);
+
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_30__add_groupmembership_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_30__add_groupmembership_uuid.sql
new file mode 100644
index 000000000..3c2ef30e9
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_30__add_groupmembership_uuid.sql
@@ -0,0 +1,7 @@
+alter table CCM_CORE.GROUP_MEMBERSHIPS
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.GROUP_MEMBERSHIPS
+ add constraint UK_kkdoia60bmiwhhdru169p3n9g unique (UUID);
+
+
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_31__add_rolemembership_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_31__add_rolemembership_uuid.sql
new file mode 100644
index 000000000..c4a5856f8
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_31__add_rolemembership_uuid.sql
@@ -0,0 +1,7 @@
+alter table CCM_CORE.ROLE_MEMBERSHIPS
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.ROLE_MEMBERSHIPS
+ add constraint UK_82wdq214bfs99eii71fp50s97 unique (UUID);
+
+
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_28__add_role_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_28__add_role_uuid.sql
new file mode 100644
index 000000000..69dbfa84b
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_28__add_role_uuid.sql
@@ -0,0 +1,5 @@
+alter table CCM_CORE.ROLES
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.ROLES
+ add constraint UK_rfmsjqsq6kagolsod3ufkugll unique (UUID);
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_29__add_permission_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_29__add_permission_uuid.sql
new file mode 100644
index 000000000..38f3e2fc4
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_29__add_permission_uuid.sql
@@ -0,0 +1,6 @@
+alter table CCM_CORE.PERMISSIONS
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.PERMISSIONS
+ add constraint UK_p50se7rdexv7xnkiqsl6ijyti unique (UUID);
+
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_30__add_groupmembership_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_30__add_groupmembership_uuid.sql
new file mode 100644
index 000000000..3c2ef30e9
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_30__add_groupmembership_uuid.sql
@@ -0,0 +1,7 @@
+alter table CCM_CORE.GROUP_MEMBERSHIPS
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.GROUP_MEMBERSHIPS
+ add constraint UK_kkdoia60bmiwhhdru169p3n9g unique (UUID);
+
+
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_31__add_rolemembership_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_31__add_rolemembership_uuid.sql
new file mode 100644
index 000000000..c4a5856f8
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_31__add_rolemembership_uuid.sql
@@ -0,0 +1,7 @@
+alter table CCM_CORE.ROLE_MEMBERSHIPS
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.ROLE_MEMBERSHIPS
+ add constraint UK_82wdq214bfs99eii71fp50s97 unique (UUID);
+
+
diff --git a/ccm-core/src/test/java/org/libreccm/portation/CoreDataImportTest.java b/ccm-core/src/test/java/org/libreccm/portation/CoreDataImportTest.java.off
similarity index 100%
rename from ccm-core/src/test/java/org/libreccm/portation/CoreDataImportTest.java
rename to ccm-core/src/test/java/org/libreccm/portation/CoreDataImportTest.java.off
diff --git a/ccm-core/src/test/java/org/libreccm/portation/ImportHelper.java b/ccm-core/src/test/java/org/libreccm/portation/ImportHelper.java.off
similarity index 100%
rename from ccm-core/src/test/java/org/libreccm/portation/ImportHelper.java
rename to ccm-core/src/test/java/org/libreccm/portation/ImportHelper.java.off
diff --git a/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql b/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql
index 2485b44cc..236fa516a 100644
--- a/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql
+++ b/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql
@@ -4,6 +4,7 @@ drop sequence if exists HIBERNATE_SEQUENCE;
create schema CCM_CORE;
+
create table CCM_CORE.APPLICATIONS (
APPLICATION_TYPE varchar(1024) not null,
PRIMARY_URL varchar(1024) not null,
@@ -94,6 +95,7 @@ drop sequence if exists HIBERNATE_SEQUENCE;
create table CCM_CORE.CCM_ROLES (
ROLE_ID bigint not null,
NAME varchar(512) not null,
+ UUID varchar(255) not null,
primary key (ROLE_ID)
);
@@ -541,11 +543,11 @@ drop sequence if exists HIBERNATE_SEQUENCE;
SETTING_ID bigint not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
+ SETTING_VALUE_LONG bigint,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_BOOLEAN boolean,
- SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE double,
- SETTING_VALUE_LONG bigint,
+ SETTING_VALUE_STRING varchar(1024),
primary key (SETTING_ID)
);
@@ -771,6 +773,9 @@ drop sequence if exists HIBERNATE_SEQUENCE;
alter table CCM_CORE.CCM_OBJECTS
add constraint UK_1cm71jlagvyvcnkqvxqyit3wx unique (UUID);
+ alter table CCM_CORE.CCM_ROLES
+ add constraint UK_rfmsjqsq6kagolsod3ufkugll unique (UUID);
+
alter table CCM_CORE.HOSTS
add constraint UK9ramlv6uxwt13v0wj7q0tucsx unique (SERVER_NAME, SERVER_PORT);
diff --git a/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql b/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql
index 2988482e5..c153b00e0 100644
--- a/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql
+++ b/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql
@@ -2,8 +2,6 @@ drop schema if exists CCM_CORE cascade;
drop sequence if exists HIBERNATE_SEQUENCE;
- create schema CCM_CORE;
-
create table CCM_CORE.APPLICATIONS (
APPLICATION_TYPE varchar(1024) not null,
PRIMARY_URL varchar(1024) not null,
@@ -94,6 +92,7 @@ drop sequence if exists HIBERNATE_SEQUENCE;
create table CCM_CORE.CCM_ROLES (
ROLE_ID int8 not null,
NAME varchar(512) not null,
+ UUID varchar(255) not null,
primary key (ROLE_ID)
);
@@ -541,11 +540,11 @@ drop sequence if exists HIBERNATE_SEQUENCE;
SETTING_ID int8 not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
+ SETTING_VALUE_LONG int8,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_BOOLEAN boolean,
- SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE float8,
- SETTING_VALUE_LONG int8,
+ SETTING_VALUE_STRING varchar(1024),
primary key (SETTING_ID)
);
@@ -771,6 +770,9 @@ drop sequence if exists HIBERNATE_SEQUENCE;
alter table CCM_CORE.CCM_OBJECTS
add constraint UK_1cm71jlagvyvcnkqvxqyit3wx unique (UUID);
+ alter table CCM_CORE.CCM_ROLES
+ add constraint UK_rfmsjqsq6kagolsod3ufkugll unique (UUID);
+
alter table CCM_CORE.HOSTS
add constraint UK9ramlv6uxwt13v0wj7q0tucsx unique (SERVER_NAME, SERVER_PORT);
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-copy.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-copy.yml
index 9927debf3..21ae28f3d 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-copy.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-copy.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml
index ca6623d18..bdb7d9dc7 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml
index 2305fe1c3..5053b5c5e 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant.yml
index d07791b22..809e592ed 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml
index 6b35673e5..6806bc685 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke.yml
index 0ce39604f..8375d30ab 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml
index 2452d2699..f8525f54b 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data.yml
index 00a4de929..58eba61f9 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data.yml
@@ -1,7 +1,9 @@
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
ccm_core.ccm_objects:
- object_id: -20001
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-add.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-add.yml
index d758b6f8f..40e616304 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-add.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-add.yml
@@ -82,10 +82,13 @@ ccm_core.group_memberships:
member_id: -30
ccm_core.ccm_roles:
- role_id: -2000
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -2100
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
- role_id: -2200
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: role3
ccm_core.role_memberships:
# role1 <-> jdoe
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-remove.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-remove.yml
index 8f0a41d6b..833e27692 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-remove.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/after-remove.yml
@@ -82,10 +82,13 @@ ccm_core.group_memberships:
member_id: -30
ccm_core.ccm_roles:
- role_id: -2000
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -2100
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
- role_id: -2200
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: role3
ccm_core.role_memberships:
# role1 <-> group3
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/data.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/data.yml
index 8ad457329..9de7856d2 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/data.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleManagerTest/data.yml
@@ -82,10 +82,13 @@ ccm_core.group_memberships:
member_id: -30
ccm_core.ccm_roles:
- role_id: -2000
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -2100
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
- role_id: -2200
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: role3
ccm_core.role_memberships:
# role1 <-> jdoe
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-delete.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-delete.yml
index b93a68a20..7dbd5bf3e 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-delete.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-delete.yml
@@ -1,5 +1,7 @@
ccm_core.ccm_roles:
- role_id: -10
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: administrator
- role_id: -30
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: reader
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-changed.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-changed.yml
index 5201f806a..165226779 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-changed.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-changed.yml
@@ -1,7 +1,10 @@
ccm_core.ccm_roles:
- role_id: -10
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: administrator
- role_id: -20
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: writer
- role_id: -30
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: reader
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-new.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-new.yml
index 19a433b63..09cc640bf 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-new.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/after-save-new.yml
@@ -1,9 +1,13 @@
ccm_core.ccm_roles:
- role_id: -10
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: administrator
- role_id: -20
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: user
- role_id: -30
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: reader
- role_id: -40
+ uuid: 9feb2623-671a-4fd4-bd3f-1adc7f51f62e
name: editor
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/data.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/data.yml
index e2a3bde33..0edd7175c 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/data.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/RoleRepositoryTest/data.yml
@@ -1,7 +1,10 @@
ccm_core.ccm_roles:
- role_id: -10
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: administrator
- role_id: -20
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: user
- role_id: -30
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: reader
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/ShiroTest/data.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/ShiroTest/data.yml
index 238c71e0d..8e24d3709 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/ShiroTest/data.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/ShiroTest/data.yml
@@ -98,10 +98,13 @@ ccm_core.group_memberships:
member_id: -41003
ccm_core.ccm_roles:
- role_id: -10001
+ uuid: 42038ba3-35b9-4894-843f-cb39ae1be763
name: role1
- role_id: -10002
+ uuid: c821a93d-78aa-4b87-ac1b-3e3229e0fdd9
name: role2
- role_id: -10003
+ uuid: 0e73623c-8d6a-4544-88a4-e4b104e7c0b6
name: public-role
ccm_core.role_memberships:
# role1 <-> group1