Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Apr 28, 2022
0 parents commit 1c651c0
Show file tree
Hide file tree
Showing 47 changed files with 2,673 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<local-check-config name="IES Content Repository Checkstyle" location="checkstyle.xml" type="project" description="">
<additional-data name="protect-config-file" value="false"/>
</local-check-config>
<fileset name="all" enabled="true" check-config-name="IES Content Repository Checkstyle" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# eclipse
.classpath
.project
.settings/

# ? validate
reports/

target/
8 changes: 8 additions & 0 deletions .pmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<pmd>
<useProjectRuleSet>true</useProjectRuleSet>
<ruleSetFile>pmd-ruleset.xml</ruleSetFile>
<includeDerivedFiles>false</includeDerivedFiles>
<violationsAsErrors>true</violationsAsErrors>
<fullBuildEnabled>true</fullBuildEnabled>
</pmd>
338 changes: 338 additions & 0 deletions .ruleset

Large diffs are not rendered by default.

166 changes: 166 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Content-Repository

The content repository contains the content-bearing objects and groups. These have master data and schema-less content. There are three types.

1. **Media objects** - media objects are linked to a media such as a PDF or an image file and contains master data. The media object represents this linked media file. Each media object must be assigned to exactly one group. Additionally, any content information can be stored at the media object.
2. **Entity object** - A content object can contain any content information in addition to its master data. Each object must be assigned to exactly one group. An optional property of a content object is to provide a file name.
3. **Group object** - objects are structured in groups. These groups can be structured hierarchically. A group object can include any content information to its master data. An optional property of a group object is to provide a directory name. This is used for the objects within the group. Another optional property of a group object is to provide a file name.

## Features

Features of the content repository are:

* To store objects and groups
* To make objects and groups findable and return them.
* To version changes of objects and groups.
* To provide the history of an object.
* To lock objects for exclusive write access for others.
* Deliver different versions of an object.
* To be able to compare contents before saving, in order to be able to announce changes of individual fields
* To be able to revert an object to an older version.
* To be able to restore deleted objects (recycle bin).

### Saving

When saving an object or a group, the changes are always determined so that other components can react to them.

Rule when saving objects:
Only the data specified for saving will be changed. All other data remain unchanged.
When saving, all changes are compared with the actual state, so that all changed fields are known.

Contents can be structured in lists and sub-objects. If a list is saved, it is not merged but replaced. This means that if a list with three elements is updated with two elements, only the two elements are kept. If not all fields of the list element are specified, only the specified fields are updated, the others remain unchanged.

List elements can be reordered and then saved. In this case, the fields of the list elements that were not specified will also be reordered when saving.

### Handling media

The content module does not handle media but only uses references to media.

The media itself is managed in a media repository.

## Architecture

The architecture follows the principles of [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)

### Ports

Ports are interfaces that the core requires for the execution of the individual usecases. The implementation is provided externally.

#### AccessControl

Is needed to be able to valid the permissions for individual actions.

#### ContentRepository

Basic CRUD operations for repository entries

#### Publisher

Publisher to handle publishing

#### EntityLockManager

Manage it exclusive write access.

#### HistoryManager

Provides methods to manage the history of an entry

#### IdGenerator

Creates unique ID's for new entries

#### RecycleBin

Recycle Bin Management

#### VersioningManager

Versioning management to be able to get or restore older versions.


## Coding-Standard

### Use @NotNull Annotation for Method-Arguments

```java
public Optional<Entity> remove(@NonNull Identifier identifier) {

if (identifier == null) {
throw new IllegalArgumentException("identifier is null");
}

// ...
}
```

### Use Unchecked Exceptions

```java
public abstract class ContentRepositoryException extends RuntimeException {
// ...
}
```

See [How to handle Java exceptions in clean code](https://ahmadatwi.me/2017/01/20/how-to-handle-java-exceptions-in-clean-code-part-1/)

### Use Builder-Pattern for immutable objects

```java
public class Settings {

private final String a;
private final String b;

private Settings(Builder builder) {
this.a = builder.a;
this.b = builder.b;
}

public String getA() {
return this.a;
}

public String getB() {
return this.b;
}

public static Builder builder() {
return new Builder();
}

public Builder toBuilder() {
return new Builder(this);
}

public static class Builder {

private String a;

private String b;

private Builder() {}

private Builder(Settings settings) {
this.a = settings.a;
this.b = settings.b;
}

public Builder a(String a) {
this.a = a;
return this;
}

public Builder b(String b) {
this.b = b;
return this;
}

public Settings build() {
return new Settings(this);
}
}
}
```

Inheritance is a bit of a challenge in the Builder pattern. See [here](https://github.com/rtenhove/eg-builder-inheritance) for a good explanation and apply the proposed solution. `com.sitepark.ies.contentrepository.core.domain.entity.Entity` shows this solution.
117 changes: 117 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
Checkstyle-Configuration: IES Content Repository Checkstyle
Description: none
-->
<module name="Checker">
<property name="severity" value="error"/>
<property name="charset" value="UTF-8"/>
<property name="tabWidth" value="4"/>
<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* "/>
<property name="message" value="Indent must use tab characters"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
<module name="EmptyBlock"/>
<module name="NeedBraces">
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_IF,LITERAL_FOR,LITERAL_WHILE"/>
</module>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="NoWhitespaceAfter"/>
<module name="GenericWhitespace"/>
<module name="NoWhitespaceBefore"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA,SEMI,LITERAL_IF,LITERAL_ELSE,LITERAL_WHILE,LITERAL_DO,LITERAL_FOR,DO_WHILE"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
<property name="allowEmptyCatches" value="true"/>
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,TYPE_EXTENSION_AND"/>
</module>
<module name="SingleSpaceSeparator"/>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyCatches" value="true"/>
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,TYPE_EXTENSION_AND"/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/>
<module name="MissingSwitchDefault"/>
<module name="FallThrough"/>
<module name="UpperEll"/>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapDot"/>
<property name="option" value="nl"/>
<property name="tokens" value="DOT"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapComma"/>
<property name="option" value="EOL"/>
<property name="tokens" value="COMMA"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapEllipsis"/>
<property name="option" value="EOL"/>
<property name="tokens" value="ELLIPSIS"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapArrayDeclarator"/>
<property name="option" value="EOL"/>
<property name="tokens" value="ARRAY_DECLARATOR"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapMethodRef"/>
<property name="option" value="nl"/>
<property name="tokens" value="METHOD_REF"/>
</module>
<module name="ClassTypeParameterName"/>
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="MethodTypeParameterName"/>
<module name="InterfaceTypeParameterName"/>
<module name="PackageName"/>
<module name="ParameterName">
<property name="accessModifiers" value="public"/>
</module>
<module name="StaticVariableName">
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>
<module name="TypeName"/>
<module name="AbbreviationAsWordInName"/>
<module name="CatchParameterName"/>
<module name="LambdaParameterName"/>
<module name="NoFinalizer"/>
<module name="NoClone"/>
</module>
<module name="SuppressionSingleFilter">
<property name="files" value="[/\\]target[/\\]"/>
<property name="checks" value=".*"/>
</module>
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="LineLength">
<property name="fileExtensions" value=".java"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
<property name="max" value="120"/>
</module>
</module>
13 changes: 13 additions & 0 deletions ies-4-contentrepository-core-cs-cleanup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<profiles version="2">
<profile kind="CleanUpProfile"
name="CheckStyle-Generated ies-4-contentrepository-core"
version="2">
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.always_use_blocks" value="true"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.remove_unused_imports" value="true"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
</profile>
</profiles>
Loading

0 comments on commit 1c651c0

Please sign in to comment.