diff --git a/ccm-core/pom.xml b/ccm-core/pom.xml
index 8e6bc7926..0ead99f22 100644
--- a/ccm-core/pom.xml
+++ b/ccm-core/pom.xml
@@ -43,6 +43,11 @@
hibernate-entitymanager
+
+ org.hibernate
+ hibernate-validator
+
+
junit
junit
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Category.java b/ccm-core/src/main/java/org/libreccm/categorization/Category.java
index 2e554339f..0501316c4 100644
--- a/ccm-core/src/main/java/org/libreccm/categorization/Category.java
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Category.java
@@ -18,6 +18,7 @@
*/
package org.libreccm.categorization;
+import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.core.CcmObject;
import java.io.Serializable;
@@ -39,17 +40,17 @@ import java.util.Objects;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import javax.validation.constraints.Pattern;
/**
- * The category entity represents a single category. Each category is part
- * of a {@link Domain}. A category can be assigned to multiple
- * {@link CcmObject}s.
- *
+ * The category entity represents a single category. Each category is part of a
+ * {@link Domain}. A category can be assigned to multiple {@link CcmObject}s.
+ *
* In the old structure the properties of this class were split between the
- * {@code Category} entity from {@code ccm-core} and the {@code Term} entity
- * from {@code ccm-ldn-terms}. This class unifies the properties of these two
+ * {@code Category} entity from {@code ccm-core} and the {@code Term} entity
+ * from {@code ccm-ldn-terms}. This class unifies the properties of these two
* classes.
- *
+ *
* @author Jens Pelzetter
*/
@Entity
@@ -66,10 +67,12 @@ public class Category extends CcmObject implements Serializable {
private String uniqueId;
/**
- * The name of the category. This is used as URL stub, therefore only
- * the characters a to z, A to Z and 0 to 9 are allowed.
+ * The name of the category. This is used as URL stub, therefore only the
+ * characters a to z, A to Z and 0 to 9 are allowed.
*/
@Column(name = "name", nullable = false)
+ @NotBlank
+ @Pattern(regexp = "[\\w-.]*")
private String name;
/**
@@ -97,7 +100,7 @@ public class Category extends CcmObject implements Serializable {
private LocalizedString description;
/**
- * Defines if the category is enabled. If the category is not
+ * Defines if the category is enabled. If the category is not
* enabled, the category can't be used in any way.
*/
@Column(name = "enabled")
@@ -111,8 +114,8 @@ public class Category extends CcmObject implements Serializable {
private boolean visible;
/**
- * Defines if the category is abstract. It is not possible to add
- * objects to an abstract category.
+ * Defines if the category is abstract. It is not possible to add objects to
+ * an abstract category.
*/
@Column(name = "abstract_category")
private boolean abstractCategory;
@@ -203,7 +206,7 @@ public class Category extends CcmObject implements Serializable {
* Retrieves an unmodifiable list of the objects assigned
* to this category. To manage the assigned objects use the methods provided
* by the {@link CategoryManager}.
- *
+ *
* @return An unmodifiable list of objects assigned to this category.
*/
public List getObjects() {
@@ -224,9 +227,9 @@ public class Category extends CcmObject implements Serializable {
/**
* Retrieves an unmodifiable list of the sub categories of
- * this category. To manage the assigned objects use the methods provided
- * by the {@link CategoryManager}.
- *
+ * this category. To manage the assigned objects use the methods provided by
+ * the {@link CategoryManager}.
+ *
* @return An unmodifiable list of sub categories of this category.
*/
public List getSubCategories() {
@@ -235,7 +238,7 @@ public class Category extends CcmObject implements Serializable {
/**
* Internal setter for the list of sub categories.
- *
+ *
* @param subCategories The list of sub categories.
*/
protected void setSubCategories(final List subCategories) {
@@ -332,23 +335,23 @@ public class Category extends CcmObject implements Serializable {
@Override
public String toString(final String data) {
- return String.format(", uniqueId = %s, "
- + "name = \"%s\", "
- + "title = %s, "
- + "enabled = %b, "
- + "visible = %b, "
- + "abstractCategory = %b, "
- + "parentCategory = %s, "
- + "categoryOrder = %d%s",
- uniqueId,
- name,
- title.toString(),
- enabled,
- visible,
- abstractCategory,
- parentCategory,
- categoryOrder,
- data);
+ return super.toString(String.format(", uniqueId = %s, "
+ + "name = \"%s\", "
+ + "title = %s, "
+ + "enabled = %b, "
+ + "visible = %b, "
+ + "abstractCategory = %b, "
+ + "parentCategory = %s, "
+ + "categoryOrder = %d%s",
+ uniqueId,
+ name,
+ title.toString(),
+ enabled,
+ visible,
+ abstractCategory,
+ parentCategory,
+ categoryOrder,
+ data));
}
}
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
index 97c3c27c9..ca25ecee1 100644
--- a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
@@ -18,6 +18,8 @@
*/
package org.libreccm.categorization;
+import org.hibernate.validator.constraints.NotBlank;
+import org.hibernate.validator.constraints.URL;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
@@ -39,6 +41,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import javax.validation.constraints.Pattern;
/**
* A domain is collection of categories designed a specific purpose. This
@@ -65,6 +68,8 @@ public class Domain extends CcmObject implements Serializable {
* {@code MYNAV}.
*/
@Column(name = "domain_key", nullable = false, unique = true, length = 255)
+ @NotBlank
+ @Pattern(regexp = "[\\w-.]*")
private String domainKey;
/**
@@ -80,6 +85,8 @@ public class Domain extends CcmObject implements Serializable {
*
*/
@Column(name = "uri", nullable = false, unique = true, length = 2048)
+ @NotBlank
+ @URL
private URI uri;
/**
@@ -109,6 +116,7 @@ public class Domain extends CcmObject implements Serializable {
* A version string for the {@code Domain}.
*/
@Column(name = "version", nullable = false)
+ @NotBlank
private String version;
/**
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/PersonName.java b/ccm-core/src/main/java/org/libreccm/categorization/PersonName.java
new file mode 100644
index 000000000..69cb72843
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/categorization/PersonName.java
@@ -0,0 +1,148 @@
+/*
+ * 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.categorization;
+
+import org.hibernate.validator.constraints.NotBlank;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+/**
+ * An embeddable entity representing a person's name.
+ *
+ * @author Jens Pelzetter
+ */
+@Embeddable
+public class PersonName implements Serializable {
+
+ private static final long serialVersionUID = -5805626320605809172L;
+
+ @Column(name = "title_pre", length = 512)
+ private String titlePre;
+
+ @Column(name = "given_name", length = 512)
+ @NotBlank
+ private String givenName;
+
+ @Column(name = "middle_name", length = 512)
+ private String middleName;
+
+ @Column(name = "family_name", length = 512)
+ @NotBlank
+ private String familyName;
+
+ @Column(name = "title_post", length = 512)
+ private String titlePost;
+
+ public String getTitlePre() {
+ return titlePre;
+ }
+
+ public void setTitlePre(final String titlePre) {
+ this.titlePre = titlePre;
+ }
+
+ public String getGivenName() {
+ return givenName;
+ }
+
+ public void setGivenName(final String givenName) {
+ this.givenName = givenName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getFamilyName() {
+ return familyName;
+ }
+
+ public void setFamilyName(final String familyName) {
+ this.familyName = familyName;
+ }
+
+ public String getTitlePost() {
+ return titlePost;
+ }
+
+ public void setTitlePost(final String titlePost) {
+ this.titlePost = titlePost;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 37 * hash + Objects.hashCode(this.titlePre);
+ hash = 37 * hash + Objects.hashCode(this.givenName);
+ hash = 37 * hash + Objects.hashCode(this.middleName);
+ hash = 37 * hash + Objects.hashCode(this.familyName);
+ hash = 37 * hash + Objects.hashCode(this.titlePost);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final PersonName other = (PersonName) obj;
+ if (!Objects.equals(this.titlePre, other.getTitlePre())) {
+ return false;
+ }
+ if (!Objects.equals(this.givenName, other.getGivenName())) {
+ return false;
+ }
+ if (!Objects.equals(this.middleName, other.getMiddleName())) {
+ return false;
+ }
+ if (!Objects.equals(this.familyName, other.getFamilyName())) {
+ return false;
+ }
+ return Objects.equals(this.titlePost, other.getTitlePost());
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s{ "
+ + "titlePre = \"%s\", "
+ + "givenName = \"%s\", "
+ + "middleName = \"%s\", "
+ + "familyName = \"%s\", "
+ + "titlePost = \"%s\""
+ + " }",
+ super.toString(),
+ titlePre,
+ givenName,
+ middleName,
+ familyName,
+ titlePost);
+ }
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java b/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java
new file mode 100644
index 000000000..284a5508a
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java
@@ -0,0 +1,86 @@
+/*
+ * 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.core;
+
+import org.hibernate.validator.constraints.Email;
+import org.hibernate.validator.constraints.NotBlank;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+/**
+ * An embeddable entity for storing email addresses.
+ *
+ * @author Jens Pelzetter
+ */
+@Embeddable
+public class EmailAddress implements Serializable {
+
+ private static final long serialVersionUID = -4076089589412432766L;
+
+ @Column(name = "email_address", length = 512, nullable = false)
+ @NotBlank
+ @Email
+ private String eMailAddress;
+
+ @Column(name = "bouncing")
+ private boolean bouncing;
+
+ @Column(name = "verified")
+ private boolean verified;
+
+ public String getEmailAddress() {
+ return eMailAddress;
+ }
+
+ public void setEmailAddress(final String eMailAddress) {
+ this.eMailAddress = eMailAddress;
+ }
+
+ public boolean isBouncing() {
+ return bouncing;
+ }
+
+ public void setBouncing(final boolean bouncing) {
+ this.bouncing = bouncing;
+ }
+
+ public boolean isVerified() {
+ return verified;
+ }
+
+ public void setVerified(final boolean verified) {
+ this.verified = verified;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s{ "
+ + "eMailAddress = \"%s\", "
+ + "bouncing = %b, "
+ + "verified = %b }",
+ super.toString(),
+ eMailAddress,
+ bouncing,
+ verified);
+ }
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/core/Group.java b/ccm-core/src/main/java/org/libreccm/core/Group.java
new file mode 100644
index 000000000..31c1f4c70
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/core/Group.java
@@ -0,0 +1,36 @@
+/*
+ * 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.core;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@Entity
+@Table(name = "groups")
+public class Group extends Party implements Serializable {
+
+ private static final long serialVersionUID = -5555063356689597270L;
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/core/Party.java b/ccm-core/src/main/java/org/libreccm/core/Party.java
new file mode 100644
index 000000000..50ced74df
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/core/Party.java
@@ -0,0 +1,91 @@
+/*
+ * 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.core;
+
+import java.io.Serializable;
+import java.security.acl.Group;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.validation.constraints.Size;
+
+/**
+ * Internal basic class for {@link User} and {@link Group}.
+ *
+ * @author Jens Pelzetter
+ */
+@Entity
+@Table(name = "parties")
+public class Party extends CcmObject implements Serializable {
+
+ private static final long serialVersionUID = 6303836654273293979L;
+
+ @ElementCollection
+ @Size(min = 1)
+ private List eMailAddresses;
+
+ public List getEmailAddresses() {
+ return Collections.unmodifiableList(eMailAddresses);
+ }
+
+ protected void setEmailAddresses(final List eMailAddresses) {
+ this.eMailAddresses = eMailAddresses;
+ }
+
+ protected void addEmailAddress(final EmailAddress emailAddress) {
+ eMailAddresses.add(emailAddress);
+ }
+
+ protected void removeEmailAddress(final EmailAddress emailAddress) {
+ eMailAddresses.remove(emailAddress);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = super.hashCode();
+ hash = 41 * hash + Objects.hashCode(this.eMailAddresses);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Party other = (Party) obj;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+
+ return Objects.equals(this.eMailAddresses, other.getEmailAddresses());
+ }
+
+ @Override
+ public boolean canEqual(final Object obj) {
+ return obj instanceof Party;
+ }
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/core/Resource.java b/ccm-core/src/main/java/org/libreccm/core/Resource.java
index cb8cd4cf3..e0900f27d 100644
--- a/ccm-core/src/main/java/org/libreccm/core/Resource.java
+++ b/ccm-core/src/main/java/org/libreccm/core/Resource.java
@@ -39,8 +39,18 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
- *
- * @author Jens Pelzetter jens@jp-digital.de
+ * The {@code Resource} class is a base class for several other classes, for
+ * example the {@link Application} class.
+ *
+ * Resources can be nested, a resource can have multiple child resources.
+ *
+ * This class is an adopted variant of the class
+ * {@code com.arsdigita.kernel.Resource} from the old structure. This class is
+ * maybe removed in future releases. Therefore it is strictly recommend not to
+ * use this class directly.
+ *
+ * @author Jens Pelzetter
+ *
*/
@Entity
@Table(name = "resources")
@@ -48,6 +58,9 @@ public class Resource extends CcmObject implements Serializable {
private static final long serialVersionUID = 7345482620613842781L;
+ /**
+ * A localisable title for the {@code Resource}.
+ */
@Embedded
@AssociationOverride(
name = "values",
@@ -56,6 +69,9 @@ public class Resource extends CcmObject implements Serializable {
@JoinColumn(name = "object_id")}))
private LocalizedString title;
+ /**
+ * A localisable description for the {@code Resource}.
+ */
@Embedded
@AssociationOverride(
name = "values",
@@ -64,13 +80,23 @@ public class Resource extends CcmObject implements Serializable {
@JoinColumn(name = "object_id")}))
private LocalizedString description;
+ /**
+ * Date on which the resource was created.
+ */
@Column(name = "created")
@Temporal(TemporalType.TIMESTAMP)
private Date created;
+ /**
+ * The child resources of this resource.
+ */
@OneToMany(mappedBy = "parent")
private List childs;
+ /**
+ * The parent resources of this resource. If the resource is a root resource
+ * the property will be null.
+ */
@ManyToOne
private Resource parent;
diff --git a/ccm-core/src/main/java/org/libreccm/core/User.java b/ccm-core/src/main/java/org/libreccm/core/User.java
new file mode 100644
index 000000000..60b55eefe
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/core/User.java
@@ -0,0 +1,37 @@
+/*
+ * 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.core;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@Entity
+@Table(name = "users")
+public class User extends Party implements Serializable {
+ private static final long serialVersionUID = 892038270064849732L;
+
+
+
+}
diff --git a/pom.xml b/pom.xml
index 06642fa93..1392b9179 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,6 +240,15 @@
4.3.8.Final
+
+
+ org.hibernate
+ hibernate-validator
+ 5.1.3.Final
+
+