- Some cleanup
    - Entities for the new database based configuration system


git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3768 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2015-12-11 19:26:03 +00:00
parent 576d28a8ce
commit e743e052ff
23 changed files with 1155 additions and 171 deletions

View File

@ -211,8 +211,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version> <version>3.3</version>
<configuration> <configuration>
<source>1.7</source> <source>1.8</source>
<target>1.7</target> <target>1.8</target>
<optimize>true</optimize> <optimize>true</optimize>
<debug>true</debug> <debug>true</debug>
<encoding>${project.build.sourceEncoding}</encoding> <encoding>${project.build.sourceEncoding}</encoding>
@ -426,7 +426,9 @@
<exclude>**/AbstractConfig.java</exclude> <exclude>**/AbstractConfig.java</exclude>
<exclude>**/AbstractParameter.java</exclude> <exclude>**/AbstractParameter.java</exclude>
<exclude>**/AbstractParameterContext.java</exclude> <exclude>**/AbstractParameterContext.java</exclude>
<exclude>**/AbstractSingleSelectionModel.java</exclude>
<exclude>**/Assert.java</exclude> <exclude>**/Assert.java</exclude>
<exclude>**/bebop/**</exclude>
<exclude>**/CCMApplicationContextListener.java</exclude> <exclude>**/CCMApplicationContextListener.java</exclude>
<exclude>**/CCMResourceManager.java</exclude> <exclude>**/CCMResourceManager.java</exclude>
<exclude>**/Classes.java</exclude> <exclude>**/Classes.java</exclude>
@ -440,6 +442,7 @@
<exclude>**/DateFormatter.java</exclude> <exclude>**/DateFormatter.java</exclude>
<exclude>**/DateFormatterConfig.java</exclude> <exclude>**/DateFormatterConfig.java</exclude>
<exclude>**/DateTimeFormatter.java</exclude> <exclude>**/DateTimeFormatter.java</exclude>
<exclude>**/dispatcher/**</exclude>
<exclude>**/DispatcherConfig.java</exclude> <exclude>**/DispatcherConfig.java</exclude>
<exclude>**/Document.java</exclude> <exclude>**/Document.java</exclude>
<exclude>**/Element.java</exclude> <exclude>**/Element.java</exclude>
@ -451,12 +454,15 @@
<exclude>**/FileParameter.java</exclude> <exclude>**/FileParameter.java</exclude>
<exclude>**/FormBuilderConfig.java</exclude> <exclude>**/FormBuilderConfig.java</exclude>
<exclude>**/FullDateFormatter.java</exclude> <exclude>**/FullDateFormatter.java</exclude>
<exclude>**/globalization/**</exclude>
<exclude>**/GlobalizationConfig.java</exclude> <exclude>**/GlobalizationConfig.java</exclude>
<exclude>**/IntegerParameter.java</exclude> <exclude>**/IntegerParameter.java</exclude>
<exclude>**/JavaPropertyReader.java</exclude> <exclude>**/JavaPropertyReader.java</exclude>
<exclude>**/JavaPropertyWriter.java</exclude> <exclude>**/JavaPropertyWriter.java</exclude>
<exclude>**/kernel/**</exclude>
<exclude>**/KernelConfig.java</exclude> <exclude>**/KernelConfig.java</exclude>
<exclude>**/LockableImpl.java</exclude> <exclude>**/LockableImpl.java</exclude>
<exclude>**/mail/**</exclude>
<exclude>**/MailConfig.java</exclude> <exclude>**/MailConfig.java</exclude>
<exclude>**/MapParameter.java</exclude> <exclude>**/MapParameter.java</exclude>
<exclude>**/NotificationConfig.java</exclude> <exclude>**/NotificationConfig.java</exclude>
@ -470,20 +476,25 @@
<exclude>**/SingletonParameter.java</exclude> <exclude>**/SingletonParameter.java</exclude>
<exclude>**/SpecificClassParameter.java</exclude> <exclude>**/SpecificClassParameter.java</exclude>
<exclude>**/StringParameter.java</exclude> <exclude>**/StringParameter.java</exclude>
<exclude>**/templating/**</exclude>
<exclude>**/toolbox/**</exclude>
<exclude>**/TimeFormatter.java</exclude> <exclude>**/TimeFormatter.java</exclude>
<exclude>**/ui/**</exclude>
<exclude>**/UIConfig.java</exclude> <exclude>**/UIConfig.java</exclude>
<exclude>**/UncheckedWrapperException.java</exclude> <exclude>**/UncheckedWrapperException.java</exclude>
<exclude>**/util/**</exclude>
<exclude>**/web/**</exclude>
<exclude>**/WorkflowConfig.java</exclude> <exclude>**/WorkflowConfig.java</exclude>
<exclude>**/XML.java</exclude> <exclude>**/XML.java</exclude>
<exclude>**/XMLConfig.java</exclude> <exclude>**/XMLConfig.java</exclude>
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <!--<plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId> <artifactId>javancss-maven-plugin</artifactId>
<version>2.1</version> <version>2.1</version>
</plugin> </plugin>-->
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId> <artifactId>jdepend-maven-plugin</artifactId>

View File

@ -75,7 +75,7 @@ public abstract class AbstractAuditedEntityRepository<K, T>
* @throws IllegalStateException If the associated entity manager is closed. * @throws IllegalStateException If the associated entity manager is closed.
*/ */
public List<Number> retrieveRevisionNumbersOfEntity(final T entity, public List<Number> retrieveRevisionNumbersOfEntity(final T entity,
Long objectId) final Long objectId)
throws IllegalArgumentException, NotAuditedException, throws IllegalArgumentException, NotAuditedException,
IllegalStateException { IllegalStateException {
return auditReader.getRevisions(entity.getClass(), objectId); return auditReader.getRevisions(entity.getClass(), objectId);

View File

@ -20,7 +20,6 @@ package org.libreccm.auditing;
import org.hibernate.envers.RevisionListener; import org.hibernate.envers.RevisionListener;
import javax.inject.Inject;
/** /**
* {@link RevisionListener} setting the user for the {@link CcmRevision} entity. * {@link RevisionListener} setting the user for the {@link CcmRevision} entity.

View File

@ -0,0 +1,101 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import org.libreccm.core.CcmObject;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
*/
@Entity
@Table(name = "CONFIGURATION_ENTRIES", schema = DB_SCHEMA)
public abstract class AbstractConfigurationEntry<T>
extends CcmObject implements Serializable {
private static final long serialVersionUID = -839223659103128135L;
@Column(name = "comment", length = 2048)
private String comment;
public String getComment() {
return comment;
}
public void setComment(final String comment) {
this.comment = comment;
}
public abstract T getValue();
public abstract void setValue(T value);
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 47 * hash + Objects.hashCode(comment);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AbstractConfigurationEntry)) {
return false;
}
final AbstractConfigurationEntry<?> other
= (AbstractConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(comment, other.getComment());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof AbstractConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", comment = \"%s\"%s",
comment,
data));
}
}

View File

@ -0,0 +1,95 @@
/*
* 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.configuration;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_BIG_DECIMAL")
public class BigDecimalConfigurationEntry
extends AbstractConfigurationEntry<BigDecimal> implements Serializable {
private static final long serialVersionUID = 1869044294174385532L;
@Column(name = "entry_value")
private BigDecimal value;
@Override
public BigDecimal getValue() {
return value;
}
@Override
public void setValue(final BigDecimal value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 79 * hash + Objects.hashCode(value);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof BigDecimalConfigurationEntry)) {
return false;
}
final BigDecimalConfigurationEntry other
= (BigDecimalConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(value, other.getValue());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof BigDecimalConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", value = %s%s",
value,
data));
}
}

View File

@ -0,0 +1,100 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_BOOLEAN", schema = DB_SCHEMA)
public class BooleanConfigurationEntry
extends AbstractConfigurationEntry<Boolean> implements Serializable {
private static final long serialVersionUID = -1724350134756734938L;
@Column(name = "entry_value")
private boolean value;
@Override
public Boolean getValue() {
return value;
}
@Override
public void setValue(final Boolean value) {
this.value = value;
}
public boolean isValue() {
return value;
}
public void setValue(final boolean value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 89 * hash + (this.value ? 1 : 0);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!(super.equals(obj))) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof BooleanConfigurationEntry)) {
return false;
}
final BooleanConfigurationEntry other = (BooleanConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return value == other.getValue();
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof BooleanConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", value = %b%s",
value,
data));
}
}

View File

@ -0,0 +1,93 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_DOUBLE", schema = DB_SCHEMA)
public class DoubleConfigurationEntry
extends AbstractConfigurationEntry<Double> implements Serializable {
private static final long serialVersionUID = -6944518527865528160L;
@Column(name = "entry_value")
private double value;
@Override
public Double getValue() {
return value;
}
@Override
public void setValue(final Double value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 71 * hash + Double.hashCode(value);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DoubleConfigurationEntry)) {
return false;
}
final DoubleConfigurationEntry other = (DoubleConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return Double.doubleToLongBits(value) == Double.doubleToLongBits(other
.getValue());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof DoubleConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", value = %f%s",
value,
data));
}
}

View File

@ -0,0 +1,119 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_ENUM", schema = DB_SCHEMA)
public class EnumConfigurationEntry
extends AbstractConfigurationEntry<List<String>> implements Serializable {
private static final long serialVersionUID = 8506016944203102813L;
@ElementCollection
private List<String> value;
@Override
public List<String> getValue() {
if (value == null) {
return null;
} else {
return Collections.unmodifiableList(value);
}
}
@Override
public void setValue(final List<String> value) {
this.value = value;
}
public void addEnumValue(final String value) {
this.value.add(value);
}
public void removeEnumValue(final String value) {
this.value.remove(value);
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 89 * hash + Objects.hashCode(value);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof EnumConfigurationEntry)) {
return false;
}
final EnumConfigurationEntry other = (EnumConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(value, other.getValue());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof EnumConfigurationEntry;
}
@Override
public String toString(final String data) {
final StringBuffer enumValues = new StringBuffer();
enumValues.append("{ ");
if (value != null) {
value.forEach((String v) -> {
enumValues.append('\"').append(v).append('\"');
if (enumValues.indexOf(v) != enumValues.length() - 1) {
enumValues.append(", ");
}
});
enumValues.append(" }");
}
return super.toString(String.format(", value = %s%s",
enumValues.toString(),
data));
}
}

View File

@ -0,0 +1,106 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import org.libreccm.l10n.LocalizedString;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.AssociationOverride;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_L10N_STRING", schema = DB_SCHEMA)
public class LocalizedStringConfigurationEntry
extends AbstractConfigurationEntry<LocalizedString> implements Serializable {
private static final long serialVersionUID = -5854552013878000164L;
@Embedded
@AssociationOverride(
name = "values",
joinTable = @JoinTable(name = "CONF_ENTRIES_L10N_STR_VALUES",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "ENTRY_ID")}))
private LocalizedString value;
@Override
public LocalizedString getValue() {
return value;
}
@Override
public void setValue(final LocalizedString value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 53 * hash + Objects.hashCode(value);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LocalizedStringConfigurationEntry)) {
return false;
}
final LocalizedStringConfigurationEntry other
= (LocalizedStringConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(value, other.getValue());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof LocalizedStringConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", value = %s%s",
Objects.toString(value),
data));
}
}

View File

@ -0,0 +1,93 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_INTEGER", schema = DB_SCHEMA)
public class LongConfigurationEntry
extends AbstractConfigurationEntry<Long> implements Serializable{
private static final long serialVersionUID = 818622372461020368L;
@Column(name = "entry_value")
private long value;
@Override
public Long getValue() {
return value;
}
@Override
public void setValue(final Long value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 89 * hash + Long.hashCode(value);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LongConfigurationEntry)) {
return false;
}
final LongConfigurationEntry other
= (LongConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return this.value == other.getValue();
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof LongConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", value = %d%s",
value,
data));
}
}

View File

@ -0,0 +1,94 @@
/*
* 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.configuration;
import static org.libreccm.core.CoreConstants.*;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "CONF_ENTRIES_STRING", schema = DB_SCHEMA)
public class StringConfigurationEntry
extends AbstractConfigurationEntry<String> implements Serializable {
private static final long serialVersionUID = -8564570962027541731L;
@Column(name = "entry_value", length = 1024)
private String value;
@Override
public String getValue() {
return value;
}
@Override
public void setValue(final String value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 67 * hash + Objects.hashCode(value);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj == null) {
return false;
}
if (!(obj instanceof StringConfigurationEntry)) {
return false;
}
final StringConfigurationEntry other = (StringConfigurationEntry) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(value, other.getValue());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof StringConfigurationEntry;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", value = %s%s",
value,
data));
}
}

View File

@ -40,7 +40,6 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType; import javax.persistence.InheritanceType;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -80,8 +80,7 @@ public class CcmIntegrator implements Integrator {
modules = ServiceLoader.load(CcmModule.class); modules = ServiceLoader.load(CcmModule.class);
for (final CcmModule module : modules) { for (final CcmModule module : modules) {
LOGGER.info("Found module class {}...", module.getClass().getName()); LOGGER.info("Found module class {}...", module.getClass().getName());
final ModuleInfo moduleInfo = new ModuleInfo(); final ModuleInfo moduleInfo = loadModuleInfo(module);
moduleInfo.load(module);
LOGGER.info("Found module {}.", moduleInfo.getModuleName()); LOGGER.info("Found module {}.", moduleInfo.getModuleName());
} }
@ -130,12 +129,27 @@ public class CcmIntegrator implements Integrator {
LOGGER.info("All modules integrated successfully."); LOGGER.info("All modules integrated successfully.");
} }
/**
* Helper method for loading the module info for a module.
*
* @param module The module for which the module is loaded.
*
* @return The {@link ModuleInfo} object for the module
*/
private ModuleInfo loadModuleInfo(final CcmModule module) {
final ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.load(module);
return moduleInfo;
}
/** /**
* Private helper method to get the database schema name of a module. The * Private helper method to get the database schema name of a module. The
* name is then name of the module in lower case with all hyphens replaced * name is then name of the module in lower case with all hyphens replaced
* with underscores. * with underscores.
* *
* @param moduleInfo The module info object for the module * @param moduleInfo The module info object for the module
*
* @return The database schema name of the module. * @return The database schema name of the module.
*/ */
private String getSchemaName(final ModuleInfo moduleInfo) { private String getSchemaName(final ModuleInfo moduleInfo) {
@ -169,7 +183,9 @@ public class CcmIntegrator implements Integrator {
* *
* @param buffer Buffer for the location string. * @param buffer Buffer for the location string.
* @param connection The JDBC connection object. * @param connection The JDBC connection object.
* @throws SQLException If an error occurs while accessing the database. *
* @throws SQLException If an error occurs while accessing the
* database.
* @throws IntegrationException If the database is not supported yet. * @throws IntegrationException If the database is not supported yet.
*/ */
private void appendDbLocation(final StringBuffer buffer, private void appendDbLocation(final StringBuffer buffer,
@ -196,7 +212,9 @@ public class CcmIntegrator implements Integrator {
* *
* @param moduleInfo The module info object of the module. * @param moduleInfo The module info object of the module.
* @param connection The database connection. * @param connection The database connection.
*
* @return The location of the database migrations for a specific module. * @return The location of the database migrations for a specific module.
*
* @throws SQLException If an error on the JDBC site occurs. * @throws SQLException If an error on the JDBC site occurs.
*/ */
private String getLocation(final ModuleInfo moduleInfo, private String getLocation(final ModuleInfo moduleInfo,
@ -216,12 +234,13 @@ public class CcmIntegrator implements Integrator {
* *
* @param module The module for which the migrations are executed. * @param module The module for which the migrations are executed.
* @param dataSource The JDBC data source for connecting to the database. * @param dataSource The JDBC data source for connecting to the database.
*
* @throws SQLException If an error occurs while applying the migrations. * @throws SQLException If an error occurs while applying the migrations.
*/ */
private void migrateModule(final Class<? extends CcmModule> module, private void migrateModule(final Class<? extends CcmModule> module,
final DataSource dataSource) throws SQLException { final DataSource dataSource) throws SQLException {
//Get the JDBC connection from the DataSource //Get the JDBC connection from the DataSource
final Connection connection = dataSource.getConnection(); try (final Connection connection = dataSource.getConnection()) {
//Load the module info for the module //Load the module info for the module
final ModuleInfo moduleInfo = new ModuleInfo(); final ModuleInfo moduleInfo = new ModuleInfo();
@ -277,6 +296,7 @@ public class CcmIntegrator implements Integrator {
} }
} }
} }
}
@Override @Override
public void integrate(final MetadataImplementor metadata, public void integrate(final MetadataImplementor metadata,
@ -309,8 +329,7 @@ public class CcmIntegrator implements Integrator {
LOGGER.info("Checking modules..."); LOGGER.info("Checking modules...");
for (final CcmModule module : modules) { for (final CcmModule module : modules) {
final ModuleInfo moduleInfo = new ModuleInfo(); final ModuleInfo moduleInfo = loadModuleInfo(module);
moduleInfo.load(module);
try (Statement query = connection.createStatement(); try (Statement query = connection.createStatement();
//Check status of each module //Check status of each module
@ -327,7 +346,40 @@ public class CcmIntegrator implements Integrator {
//of the module from the database. //of the module from the database.
if (result.next() && ModuleStatus.UNINSTALL.toString() if (result.next() && ModuleStatus.UNINSTALL.toString()
.equals(result.getString("status"))) { .equals(result.getString("status"))) {
uninstallModule(connection,
dataSource,
module,
moduleInfo);
}
} catch (SQLException ex) {
throw new IntegrationException("Failed to desintegrate.",
ex);
}
}
} catch (SQLException ex) {
LOGGER.error("Desintegration failed: ", ex);
System.err.println("Desintegration failed");
ex.printStackTrace(System.err);
System.err.println();
SQLException next = ex.getNextException();
while (next != null) {
next.printStackTrace(System.err);
System.err.println();
next = next.getNextException();
}
throw new IntegrationException("Failed to desintegrate.", ex);
} finally {
JdbcUtils.closeConnection(connection);
}
}
private void uninstallModule(final Connection connection,
final DataSource dataSource,
final CcmModule module,
final ModuleInfo moduleInfo)
throws SQLException {
LOGGER.info("Removing schema for module %s...", LOGGER.info("Removing schema for module %s...",
module.getClass().getName()); module.getClass().getName());
final Flyway flyway = new Flyway(); final Flyway flyway = new Flyway();
@ -353,28 +405,4 @@ public class CcmIntegrator implements Integrator {
} }
} }
} catch (SQLException ex) {
throw new IntegrationException("Failed to desintegrate.");
}
}
} catch (SQLException ex) {
LOGGER.error("Desintegration failed: ", ex);
System.err.println("Desintegration failed");
ex.printStackTrace(System.err);
System.err.println();
SQLException next = ex.getNextException();
while (next != null) {
next.printStackTrace(System.err);
System.err.println();
next = next.getNextException();
}
throw new IntegrationException("Failed to desintegrate.");
} finally {
JdbcUtils.closeConnection(connection);
}
}
} }

View File

@ -20,12 +20,9 @@ package org.libreccm.modules;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;

View File

@ -73,8 +73,7 @@ public class ModuleManager {
LOGGER.info("Creating dependency tree these modules:"); LOGGER.info("Creating dependency tree these modules:");
for (final CcmModule module : modules) { for (final CcmModule module : modules) {
final ModuleInfo moduleInfo = new ModuleInfo(); final ModuleInfo moduleInfo = loadModuleInfo(module);
moduleInfo.load(module);
LOGGER.info("\t{} {}", LOGGER.info("\t{} {}",
moduleInfo.getModuleName(), moduleInfo.getModuleName(),
moduleInfo.getModuleVersion()); moduleInfo.getModuleVersion());
@ -101,8 +100,7 @@ public class ModuleManager {
for (final TreeNode node : moduleNodes) { for (final TreeNode node : moduleNodes) {
//Create an install event instance. //Create an install event instance.
final InstallEvent installEvent = new InstallEvent(); final InstallEvent installEvent = createInstallEvent(entityManager);
installEvent.setEntityManager(entityManager);
//Check if the module is a new module. If it is a new module //Check if the module is a new module. If it is a new module
//call the install method of the module and set the module status //call the install method of the module and set the module status
@ -118,8 +116,7 @@ public class ModuleManager {
} }
//Create an init event instance and call the init method. //Create an init event instance and call the init method.
final InitEvent initEvent = new InitEvent(); final InitEvent initEvent = createInitEvent(entityManager);
initEvent.setEntityManager(entityManager);
node.getModule().init(initEvent); node.getModule().init(initEvent);
LOGGER.info("Data from module-info.properties for {}:", LOGGER.info("Data from module-info.properties for {}:",
@ -141,6 +138,7 @@ public class ModuleManager {
* Helper method for retrieving the module info for a module. * Helper method for retrieving the module info for a module.
* *
* @param module * @param module
*
* @return * @return
*/ */
private Properties getModuleInfo(final CcmModule module) { private Properties getModuleInfo(final CcmModule module) {
@ -176,8 +174,8 @@ public class ModuleManager {
for (final TreeNode node : moduleNodes) { for (final TreeNode node : moduleNodes) {
//Create a shutdown event instance and call the shutdown method of //Create a shutdown event instance and call the shutdown method of
//the module. //the module.
final ShutdownEvent shutdownEvent = new ShutdownEvent(); final ShutdownEvent shutdownEvent = createShutdownEvent(
shutdownEvent.setEntityManager(entityManager); entityManager);
node.getModule().shutdown(shutdownEvent); node.getModule().shutdown(shutdownEvent);
} }
@ -213,8 +211,8 @@ public class ModuleManager {
System.out. System.out.
printf("Calling uninstall method of module %s...%n", printf("Calling uninstall method of module %s...%n",
node.getModuleInfo().getModuleName()); node.getModuleInfo().getModuleName());
final UnInstallEvent unInstallEvent = new UnInstallEvent(); final UnInstallEvent unInstallEvent = createUnInstallEvent(
unInstallEvent.setEntityManager(entityManager); entityManager);
node.getModule().uninstall(null); node.getModule().uninstall(null);
} else { } else {
@ -241,4 +239,43 @@ public class ModuleManager {
} }
} }
private ModuleInfo loadModuleInfo(final CcmModule module) {
final ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.load(module);
return moduleInfo;
}
private InstallEvent createInstallEvent(final EntityManager entityManager) {
final InstallEvent installEvent = new InstallEvent();
installEvent.setEntityManager(entityManager);
return installEvent;
}
private InitEvent createInitEvent(final EntityManager entityManager) {
final InitEvent initEvent = new InitEvent();
initEvent.setEntityManager(entityManager);
return initEvent;
}
private ShutdownEvent createShutdownEvent(
final EntityManager entityManager) {
final ShutdownEvent shutdownEvent = new ShutdownEvent();
shutdownEvent.setEntityManager(entityManager);
return shutdownEvent;
}
private UnInstallEvent createUnInstallEvent(
final EntityManager entityManager) {
final UnInstallEvent unInstallEvent = new UnInstallEvent();
unInstallEvent.setEntityManager(entityManager);
return unInstallEvent;
}
} }

View File

@ -56,7 +56,7 @@ import javax.xml.bind.annotation.XmlRootElement;
+ "WHERE r.name = :name") + "WHERE r.name = :name")
}) })
@XmlRootElement(name = "role", namespace = CORE_XML_NS) @XmlRootElement(name = "role", namespace = CORE_XML_NS)
@SuppressWarnings({"PMD.ShortClassName"}) @SuppressWarnings({"PMD.ShortClassName", "PMD.TooManyMethods"})
public class Role implements Serializable { public class Role implements Serializable {
private static final long serialVersionUID = -7121296514181469687L; private static final long serialVersionUID = -7121296514181469687L;
@ -156,7 +156,7 @@ public class Role implements Serializable {
permissions.remove(permission); permissions.remove(permission);
} }
public List<TaskAssignment> assignedTasks() { public List<TaskAssignment> getAssignedTasks() {
if (assignedTasks == null) { if (assignedTasks == null) {
return null; return null;
} else { } else {

View File

@ -40,7 +40,8 @@ public class SystemUsersSetup {
private static final Logger LOGGER = LogManager.getLogger( private static final Logger LOGGER = LogManager.getLogger(
SystemUsersSetup.class); SystemUsersSetup.class);
private static final String DEFAULT_ADMIN_PW = "$shiro1$SHA-512$500000$MFPkVikNoRrBZ8R8CxQIHA==$UvgO2K+poSRGw5co63P3ygpWsX7H9N0TgqdrZPBqdXv6Q+/OCL/qOocVbg65/Yjv5hyri6A3zhw7K8mEgpISoA=="; private static final String DEFAULT_ADMIN_PW
= "$shiro1$SHA-512$500000$MFPkVikNoRrBZ8R8CxQIHA==$UvgO2K+poSRGw5co63P3ygpWsX7H9N0TgqdrZPBqdXv6Q+/OCL/qOocVbg65/Yjv5hyri6A3zhw7K8mEgpISoA==";
private final EntityManager entityManager; private final EntityManager entityManager;
@ -65,17 +66,19 @@ public class SystemUsersSetup {
admin.setPrimaryEmailAddress(adminEmail); admin.setPrimaryEmailAddress(adminEmail);
String adminPassword = DEFAULT_ADMIN_PW; String adminPassword = DEFAULT_ADMIN_PW;
final InputStream inputStream = getClass().getResourceAsStream( try (final InputStream inputStream = getClass().getResourceAsStream(
"/integration.properties"); "/integration.properties")) {
if (inputStream == null) { if (inputStream == null) {
LOGGER.warn("No integration.properties file found. Using default " LOGGER.warn(
"No integration.properties file found. Using default "
+ "password (see documentation)"); + "password (see documentation)");
} else { } else {
final Properties properties = new Properties(); final Properties properties = new Properties();
try { try {
properties.load(inputStream); properties.load(inputStream);
final String password = properties.getProperty("admin.password"); final String password = properties.getProperty(
if((password != null) && !password.isEmpty()) { "admin.password");
if (password != null && !password.isEmpty()) {
adminPassword = password; adminPassword = password;
} }
} catch (IOException ex) { } catch (IOException ex) {
@ -84,6 +87,11 @@ public class SystemUsersSetup {
ex); ex);
} }
} }
} catch (IOException ex) {
LOGGER.warn("Exception while reading integration.properties file."
+ "Using default password for admin account. ",
ex);
}
admin.setPassword(adminPassword); admin.setPassword(adminPassword);
final Role adminRole = new Role(); final Role adminRole = new Role();

View File

@ -20,8 +20,6 @@ package org.libreccm.workflow;
import static org.libreccm.core.CoreConstants.*; import static org.libreccm.core.CoreConstants.*;
import org.libreccm.security.Group;
import org.libreccm.security.Role;
import org.libreccm.security.User; import org.libreccm.security.User;
import java.io.Serializable; import java.io.Serializable;
@ -34,8 +32,6 @@ import java.util.Objects;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;

View File

@ -26,7 +26,6 @@ import org.junit.runners.Parameterized;
import org.libreccm.tests.categories.UnitTest; import org.libreccm.tests.categories.UnitTest;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;

View File

@ -43,8 +43,8 @@ public class ToStringTest extends ToStringVerifier {
DomainOwnership.class}); DomainOwnership.class});
} }
public ToStringTest(final Class<?> entitiesClass) { public ToStringTest(final Class<?> entityClass) {
super(entitiesClass); super(entityClass);
} }
} }

View File

@ -0,0 +1,55 @@
/*
* 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.configuration;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import java.util.Arrays;
import java.util.Collection;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@Category(UnitTest.class)
public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
BigDecimalConfigurationEntry.class,
BooleanConfigurationEntry.class,
DoubleConfigurationEntry.class,
EnumConfigurationEntry.class,
LocalizedStringConfigurationEntry.class,
LongConfigurationEntry.class,
StringConfigurationEntry.class
});
}
public EqualsAndHashCodeTest(final Class<?> entityClass) {
super(entityClass);
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.configuration;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.ToStringVerifier;
import java.util.Arrays;
import java.util.Collection;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@Category(UnitTest.class)
public class ToStringTest extends ToStringVerifier {
@Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
BigDecimalConfigurationEntry.class,
BooleanConfigurationEntry.class,
DoubleConfigurationEntry.class,
EnumConfigurationEntry.class,
LocalizedStringConfigurationEntry.class,
LongConfigurationEntry.class,
StringConfigurationEntry.class
});
}
public ToStringTest(final Class<?> entityClass) {
super(entityClass);
}
}

View File

@ -79,10 +79,9 @@ public class ToStringVerifier {
InvocationTargetException { InvocationTargetException {
final Object obj; final Object obj;
try { try {
final Constructor<?> constructor = entityClass final Constructor<?> constructor = entityClass.asSubclass(
.getDeclaredConstructor(); entityClass).getDeclaredConstructor();
constructor.setAccessible(true); constructor.setAccessible(true);
obj = constructor.newInstance(); obj = constructor.newInstance();
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException ex) {
final StringWriter stringWriter = new StringWriter(); final StringWriter stringWriter = new StringWriter();