-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some modules, some domain logic, much adapters
- Loading branch information
Showing
52 changed files
with
3,273 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
.idea | ||
photoalbum-webapp/photoalbum-webapp.iml | ||
photoalbum.iml | ||
photoalbum-couchdb-adapter/photoalbum-couchdb-adapter.iml | ||
photoalbum-management/photoalbum-management.iml | ||
photoalbum-common/photoalbum-common.iml | ||
photoalbum-fileio-adapter/photoalbum-fileio-adapter.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>photoalbum</artifactId> | ||
<groupId>com.mgu.photoalbum</groupId> | ||
<version>0.1.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>photoalbum-common</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>photoalbum-common</name> | ||
<url>https://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
photoalbum-common/src/main/java/com/mgu/photoalbum/exception/PhotoalbumException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mgu.photoalbum.exception; | ||
|
||
abstract public class PhotoalbumException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -8563374709814927511L; | ||
|
||
public PhotoalbumException(final String message) { | ||
super(message); | ||
} | ||
|
||
public PhotoalbumException(final Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public PhotoalbumException(final String message, final Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
abstract public String getErrorCode(); | ||
} |
66 changes: 66 additions & 0 deletions
66
photoalbum-common/src/main/java/com/mgu/photoalbum/identity/IdGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.mgu.photoalbum.identity; | ||
|
||
/** | ||
* IDs are generally generated at the server-side upon client request over the alphabet [A-Za-z0-9]. This | ||
* generator can be parameterized with an optional prefix and a length that the generated ID must adhere | ||
* to. | ||
* | ||
* Most of the properties of strong passwords should be applied to IDs as well. Some IDs - for instance user IDs - | ||
* should have a high level of entropy. With regard to strong passwords, NIST recommends an entropy of at least | ||
* 78 bits. If we apply this recommendation to an ID within the context of the given the alphabet [A-Za-z0-9], a minimum | ||
* length of 14 characters is advised. Thus, if the caller does not supply the length parameter, the default | ||
* length is exactly 14 characters. | ||
* | ||
* @author Markus Günther ([email protected]) | ||
*/ | ||
public class IdGenerator { | ||
|
||
private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVW" + "ABCDEFGHIJKLMNOPQRSTUVW".toLowerCase() + "0123456789"; | ||
|
||
private static final String WITHOUT_PREFIX = ""; | ||
|
||
private static final int DEFAULT_LENGTH = 14; | ||
|
||
public String generateId() { | ||
return generateId(WITHOUT_PREFIX, DEFAULT_LENGTH); | ||
} | ||
|
||
public String generateId(final int length) { | ||
return generateId(WITHOUT_PREFIX, length); | ||
} | ||
|
||
public String generateId(final String prefix) { | ||
return generateId(prefix, DEFAULT_LENGTH); | ||
} | ||
|
||
/** | ||
* Generates an ID that adheres to the given parameters {@code prefix} and {@code length}. The prefix | ||
* segment is separated using a '-' from the randomized segment. | ||
* | ||
* Example: Given the prefix 'CU' and a target length of 5, the ID 'CU-AbjEk' would be in the language | ||
* that both parameters span in conjunction with the alphabet. | ||
* | ||
* @param prefix | ||
* Optional prefix for the ID | ||
* @param length | ||
* Length of the randomized segment | ||
* @return | ||
* Generated ID with an optional prefix segment followed by a randomized segment, where both segments | ||
* are delimited by a dash ('-') | ||
*/ | ||
public String generateId(final String prefix, final int length) { | ||
|
||
final StringBuilder sb = new StringBuilder(); | ||
|
||
if (!prefix.equals(WITHOUT_PREFIX)) { | ||
sb.append(prefix).append("-"); | ||
} | ||
|
||
for (int i = 0; i < length; i++) { | ||
final int randomIndex = (int) (Math.random() * ALPHABET.length()); | ||
sb.append(ALPHABET.charAt(randomIndex)); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>photoalbum</artifactId> | ||
<groupId>com.mgu.photoalbum</groupId> | ||
<version>0.1.0</version> | ||
</parent> | ||
|
||
<artifactId>photoalbum-couchdb-adapter</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>[photoalbum] CouchDB Adapter</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.ektorp</groupId> | ||
<artifactId>org.ektorp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
</dependency> | ||
<!-- Test --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-core</artifactId> | ||
<version>${hamcrest.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<version>${mockito.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.