CCM NG: Ensure that fields of type LocalizedString are never null.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4875 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: 4e14799253
pull/2/head
jensp 2017-07-15 09:26:24 +00:00
parent 014a8d1c68
commit d3517423cf
25 changed files with 139 additions and 60 deletions

View File

@ -95,6 +95,7 @@ public class BinaryAsset extends Asset implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -23,7 +23,6 @@ import com.arsdigita.cms.ui.assets.forms.BookmarkForm;
import org.librecms.contentsection.Asset; import org.librecms.contentsection.Asset;
import java.io.Serializable; import java.io.Serializable;
import java.net.URL;
import java.util.Objects; import java.util.Objects;
import javax.persistence.AssociationOverride; import javax.persistence.AssociationOverride;
@ -85,6 +84,7 @@ public class Bookmark extends Asset implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -116,6 +116,7 @@ public class LegalMetadata extends Asset implements Serializable {
} }
public void setRights(final LocalizedString rights) { public void setRights(final LocalizedString rights) {
Objects.requireNonNull(rights);
this.rights = rights; this.rights = rights;
} }

View File

@ -75,6 +75,7 @@ public class SideNote extends Asset implements Serializable {
} }
public void setText(final LocalizedString text) { public void setText(final LocalizedString text) {
Objects.requireNonNull(text);
this.text = text; this.text = text;
} }

View File

@ -387,6 +387,7 @@ public class Asset extends CcmObject {
} }
public void setTitle(final LocalizedString title) { public void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }

View File

@ -192,6 +192,7 @@ public class AttachmentList implements Comparable<AttachmentList>,
} }
public void setTitle(final LocalizedString title) { public void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }

View File

@ -119,6 +119,12 @@ public class ContentType extends CcmObject implements Serializable {
@JoinColumn(name = "DEFAULT_WORKFLOW") @JoinColumn(name = "DEFAULT_WORKFLOW")
private WorkflowTemplate defaultWorkflow; private WorkflowTemplate defaultWorkflow;
public ContentType() {
super();
label = new LocalizedString();
description = new LocalizedString();
}
public String getContentItemClass() { public String getContentItemClass() {
return contentItemClass; return contentItemClass;
} }
@ -140,6 +146,7 @@ public class ContentType extends CcmObject implements Serializable {
} }
public void setLabel(final LocalizedString label) { public void setLabel(final LocalizedString label) {
Objects.requireNonNull(label);
this.label = label; this.label = label;
} }
@ -148,6 +155,7 @@ public class ContentType extends CcmObject implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -93,6 +93,7 @@ public class Article extends ContentItem implements Serializable {
} }
public void setText(final LocalizedString text) { public void setText(final LocalizedString text) {
Objects.requireNonNull(text);
this.text = text; this.text = text;
} }

View File

@ -169,11 +169,21 @@ public class Event extends ContentItem implements Serializable {
)) ))
private LocalizedString cost; private LocalizedString cost;
public Event() {
text = new LocalizedString();
eventDate = new LocalizedString();
location = new LocalizedString();
mainContributor = new LocalizedString();
eventType = new LocalizedString();
cost = new LocalizedString();
}
public LocalizedString getText() { public LocalizedString getText() {
return text; return text;
} }
public void setText(final LocalizedString text) { public void setText(final LocalizedString text) {
Objects.requireNonNull(text);
this.text = text; this.text = text;
} }
@ -214,6 +224,7 @@ public class Event extends ContentItem implements Serializable {
} }
public void setEventDate(final LocalizedString eventDate) { public void setEventDate(final LocalizedString eventDate) {
Objects.requireNonNull(eventDate);
this.eventDate = eventDate; this.eventDate = eventDate;
} }
@ -222,6 +233,7 @@ public class Event extends ContentItem implements Serializable {
} }
public void setLocation(final LocalizedString location) { public void setLocation(final LocalizedString location) {
Objects.requireNonNull(location);
this.location = location; this.location = location;
} }
@ -230,6 +242,7 @@ public class Event extends ContentItem implements Serializable {
} }
public void setMainContributor(final LocalizedString mainContributor) { public void setMainContributor(final LocalizedString mainContributor) {
Objects.requireNonNull(mainContributor);
this.mainContributor = mainContributor; this.mainContributor = mainContributor;
} }
@ -238,6 +251,7 @@ public class Event extends ContentItem implements Serializable {
} }
public void setEventType(final LocalizedString eventType) { public void setEventType(final LocalizedString eventType) {
Objects.requireNonNull(eventType);
this.eventType = eventType; this.eventType = eventType;
} }
@ -254,6 +268,7 @@ public class Event extends ContentItem implements Serializable {
} }
public void setCost(final LocalizedString cost) { public void setCost(final LocalizedString cost) {
Objects.requireNonNull(cost);
this.cost = cost; this.cost = cost;
} }

View File

@ -94,6 +94,8 @@ public class MultiPartArticle extends ContentItem implements Serializable {
private List<MultiPartArticleSection> sections; private List<MultiPartArticleSection> sections;
public MultiPartArticle() { public MultiPartArticle() {
super();
summary = new LocalizedString();
this.sections = new ArrayList<>(); this.sections = new ArrayList<>();
} }
@ -102,6 +104,7 @@ public class MultiPartArticle extends ContentItem implements Serializable {
} }
public void setSummary(final LocalizedString summary) { public void setSummary(final LocalizedString summary) {
Objects.requireNonNull(summary);
this.summary = summary; this.summary = summary;
} }

View File

@ -93,6 +93,12 @@ public class MultiPartArticleSection implements Serializable {
)) ))
private LocalizedString text; private LocalizedString text;
public MultiPartArticleSection() {
super();
title = new LocalizedString();
text = new LocalizedString();
}
public long getSectionId() { public long getSectionId() {
return sectionId; return sectionId;
} }
@ -106,6 +112,7 @@ public class MultiPartArticleSection implements Serializable {
} }
public void setTitle(final LocalizedString title) { public void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }
@ -130,6 +137,7 @@ public class MultiPartArticleSection implements Serializable {
} }
public void setText(final LocalizedString text) { public void setText(final LocalizedString text) {
Objects.requireNonNull(text);
this.text = text; this.text = text;
} }

View File

@ -106,11 +106,17 @@ public class News extends ContentItem implements Serializable {
@Column(name = "HOMEPAGE") @Column(name = "HOMEPAGE")
private boolean homepage; private boolean homepage;
public News() {
super();
text = new LocalizedString();
}
public LocalizedString getText() { public LocalizedString getText() {
return text; return text;
} }
public void setText(final LocalizedString text) { public void setText(final LocalizedString text) {
Objects.requireNonNull(text);
this.text = text; this.text = text;
} }

View File

@ -101,6 +101,7 @@ public class LifecycleDefinition implements Serializable {
} }
public void setLabel(final LocalizedString label) { public void setLabel(final LocalizedString label) {
Objects.requireNonNull(label);
this.label = label; this.label = label;
} }
@ -109,6 +110,7 @@ public class LifecycleDefinition implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -98,6 +98,7 @@ public class PhaseDefinition implements Serializable {
} }
public void setLabel(final LocalizedString label) { public void setLabel(final LocalizedString label) {
Objects.requireNonNull(label);
this.label = label; this.label = label;
} }
@ -106,6 +107,7 @@ public class PhaseDefinition implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -288,6 +288,7 @@ public class Category extends CcmObject implements Serializable, Portable {
} }
public void setTitle(final LocalizedString title) { public void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }
@ -296,6 +297,7 @@ public class Category extends CcmObject implements Serializable, Portable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -229,6 +229,7 @@ public class Domain extends CcmObject implements Serializable {
} }
public void setTitle(final LocalizedString title) { public void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }
@ -237,6 +238,7 @@ public class Domain extends CcmObject implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -65,6 +65,7 @@ public class LocalizedStringSetting
@Override @Override
public void setValue(final LocalizedString value) { public void setValue(final LocalizedString value) {
Objects.requireNonNull(value);
this.value = value; this.value = value;
} }

View File

@ -115,13 +115,12 @@ public class Resource extends CcmObject implements Serializable {
childs = new ArrayList<>(); childs = new ArrayList<>();
} }
// @Column(name = "resource_type")
// private String resourceType;
public LocalizedString getTitle() { public LocalizedString getTitle() {
return title; return title;
} }
public void setTitle(final LocalizedString title) { public void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }
@ -130,6 +129,7 @@ public class Resource extends CcmObject implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -114,6 +114,7 @@ public class ResourceType implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -65,6 +65,12 @@ public class PersistentDataQuery extends CcmObject implements Serializable {
@JoinColumn(name = "DATA_QUERY_ID")})) @JoinColumn(name = "DATA_QUERY_ID")}))
private LocalizedString description; private LocalizedString description;
public PersistentDataQuery() {
super();
name = new LocalizedString();
description = new LocalizedString();
}
public String getQueryId() { public String getQueryId() {
return queryId; return queryId;
} }
@ -78,6 +84,7 @@ public class PersistentDataQuery extends CcmObject implements Serializable {
} }
public void setName(final LocalizedString name) { public void setName(final LocalizedString name) {
Objects.requireNonNull(name);
this.name = name; this.name = name;
} }
@ -86,6 +93,7 @@ public class PersistentDataQuery extends CcmObject implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -73,11 +73,18 @@ public class ProcessListener extends CcmObject implements Serializable {
@Column(name = "PROCESS_LISTENER_ORDER") @Column(name = "PROCESS_LISTENER_ORDER")
private long order; private long order;
public ProcessListener() {
super();
name = new LocalizedString();
description = new LocalizedString();
}
public LocalizedString getName() { public LocalizedString getName() {
return name; return name;
} }
public void setName(final LocalizedString name) { public void setName(final LocalizedString name) {
Objects.requireNonNull(name);
this.name = name; this.name = name;
} }
@ -86,6 +93,7 @@ public class ProcessListener extends CcmObject implements Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -62,51 +62,51 @@ import javax.validation.constraints.NotNull;
@Table(name = "PAGE_MODELS", schema = CoreConstants.DB_SCHEMA) @Table(name = "PAGE_MODELS", schema = CoreConstants.DB_SCHEMA)
@NamedQueries({ @NamedQueries({
@NamedQuery( @NamedQuery(
name = "PageModel.findDraftVersion", name = "PageModel.findDraftVersion",
query = "SELECT p FROM PageModel p " query = "SELECT p FROM PageModel p "
+ "WHERE p.modelUuid = :uuid " + "WHERE p.modelUuid = :uuid "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.DRAFT") + "AND p.version = org.libreccm.pagemodel.PageModelVersion.DRAFT")
, ,
@NamedQuery( @NamedQuery(
name = "PageModel.hasLiveVersion", name = "PageModel.hasLiveVersion",
query = "SELECT (CASE WHEN COUNT(p) > 0 THEN true ELSE False END) " query = "SELECT (CASE WHEN COUNT(p) > 0 THEN true ELSE False END) "
+ "FROM PageModel p " + "FROM PageModel p "
+ "WHERE p.modelUuid = :uuid " + "WHERE p.modelUuid = :uuid "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE" + "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE"
) )
, ,
@NamedQuery( @NamedQuery(
name = "PageModel.findLiveVersion", name = "PageModel.findLiveVersion",
query = "SELECT p FROM PageModel p " query = "SELECT p FROM PageModel p "
+ "WHERE p.modelUuid = :uuid " + "WHERE p.modelUuid = :uuid "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE") + "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE")
, ,
@NamedQuery( @NamedQuery(
name = "PageModel.findByApplication", name = "PageModel.findByApplication",
query = "SELECT p FROM PageModel p " query = "SELECT p FROM PageModel p "
+ "WHERE p.application = :application " + "WHERE p.application = :application "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE") + "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE")
, ,
@NamedQuery( @NamedQuery(
name = "PageModel.countByApplication", name = "PageModel.countByApplication",
query = "SELECT COUNT(p) FROM PageModel p " query = "SELECT COUNT(p) FROM PageModel p "
+ "WHERE p.application = :application " + "WHERE p.application = :application "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE") + "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE")
, ,
@NamedQuery( @NamedQuery(
name = "PageModel.findByApplicationAndName", name = "PageModel.findByApplicationAndName",
query = "SELECT p FROM PageModel p " query = "SELECT p FROM PageModel p "
+ "WHERE p.name = :name " + "WHERE p.name = :name "
+ "AND p.application = :application " + "AND p.application = :application "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE" + "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE"
) )
, ,
@NamedQuery( @NamedQuery(
name = "PageModel.countByApplicationAndName", name = "PageModel.countByApplicationAndName",
query = "SELECT COUNT(p) FROM PageModel p " query = "SELECT COUNT(p) FROM PageModel p "
+ "WHERE p.name = :name " + "WHERE p.name = :name "
+ "AND p.application = :application " + "AND p.application = :application "
+ "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE" + "AND p.version = org.libreccm.pagemodel.PageModelVersion.LIVE"
) )
}) })
public class PageModel implements Serializable { public class PageModel implements Serializable {
@ -156,12 +156,12 @@ public class PageModel implements Serializable {
*/ */
@Embedded @Embedded
@AssociationOverride( @AssociationOverride(
name = "values", name = "values",
joinTable = @JoinTable(name = "PAGE_MODEL_TITLES", joinTable = @JoinTable(name = "PAGE_MODEL_TITLES",
schema = CoreConstants.DB_SCHEMA, schema = CoreConstants.DB_SCHEMA,
joinColumns = { joinColumns = {
@JoinColumn(name = "PAGE_MODEL_ID") @JoinColumn(name = "PAGE_MODEL_ID")
})) }))
private LocalizedString title; private LocalizedString title;
/** /**
@ -169,12 +169,12 @@ public class PageModel implements Serializable {
*/ */
@Embedded @Embedded
@AssociationOverride( @AssociationOverride(
name = "values", name = "values",
joinTable = @JoinTable(name = "PAGE_MODEL_DESCRIPTIONS", joinTable = @JoinTable(name = "PAGE_MODEL_DESCRIPTIONS",
schema = CoreConstants.DB_SCHEMA, schema = CoreConstants.DB_SCHEMA,
joinColumns = { joinColumns = {
@JoinColumn(name = "PAGE_MODEL_ID") @JoinColumn(name = "PAGE_MODEL_ID")
})) }))
private LocalizedString description; private LocalizedString description;
/** /**
@ -247,6 +247,7 @@ public class PageModel implements Serializable {
} }
protected void setTitle(final LocalizedString title) { protected void setTitle(final LocalizedString title) {
Objects.requireNonNull(title);
this.title = title; this.title = title;
} }
@ -255,6 +256,7 @@ public class PageModel implements Serializable {
} }
protected void setDescription(final LocalizedString description) { protected void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }
@ -350,13 +352,13 @@ public class PageModel implements Serializable {
public String toString(final String data) { public String toString(final String data) {
return String.format("%s{ " return String.format("%s{ "
+ "pageModelId = %d, " + "pageModelId = %d, "
+ "uuid = %s, " + "uuid = %s, "
+ "name = \"%s\", " + "name = \"%s\", "
+ "title = %s, " + "title = %s, "
+ "description = %s, " + "description = %s, "
+ "type = \"%s\"" + "type = \"%s\""
+ " }", + " }",
super.toString(), super.toString(),
pageModelId, pageModelId,
uuid, uuid,

View File

@ -286,14 +286,15 @@ public class Role implements Serializable, Portable {
assignedTasks.remove(taskAssignment); assignedTasks.remove(taskAssignment);
} }
public void setDescription(final LocalizedString description) {
this.description = description;
}
public LocalizedString getDescription() { public LocalizedString getDescription() {
return this.description; return this.description;
} }
public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description;
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 7; int hash = 7;
@ -319,7 +320,7 @@ public class Role implements Serializable, Portable {
if (roleId != other.getRoleId()) { if (roleId != other.getRoleId()) {
return false; return false;
} }
return Objects.equals(name, other.getName()); return Objects.equals(name, other.getName());
// if (!Objects.equals(name, other.getName())) { // if (!Objects.equals(name, other.getName())) {
// return false; // return false;

View File

@ -230,6 +230,7 @@ public class Task implements Identifiable, Serializable {
} }
public void setLabel(final LocalizedString label) { public void setLabel(final LocalizedString label) {
Objects.requireNonNull(label);
this.label = label; this.label = label;
} }
@ -238,6 +239,7 @@ public class Task implements Identifiable, Serializable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }

View File

@ -112,7 +112,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
schema = DB_SCHEMA, schema = DB_SCHEMA,
joinColumns = { joinColumns = {
@JoinColumn(name = "WORKFLOW_ID")})) @JoinColumn(name = "WORKFLOW_ID")}))
private LocalizedString name; private LocalizedString name = new LocalizedString();
/** /**
* Description of the workflow. * Description of the workflow.
@ -125,7 +125,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
joinColumns = { joinColumns = {
@JoinColumn(name = "WORKFLOW_ID") @JoinColumn(name = "WORKFLOW_ID")
})) }))
private LocalizedString description; private LocalizedString description = new LocalizedString();
/** /**
* The current state of the workflow. * The current state of the workflow.
@ -201,6 +201,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
} }
public void setName(final LocalizedString name) { public void setName(final LocalizedString name) {
Objects.requireNonNull(name);
this.name = name; this.name = name;
} }
@ -209,6 +210,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
} }
public void setDescription(final LocalizedString description) { public void setDescription(final LocalizedString description) {
Objects.requireNonNull(description);
this.description = description; this.description = description;
} }