Skip to content

Commit

Permalink
renaming of stuff, fixed dependency conflicts between ektorp and drop…
Browse files Browse the repository at this point in the history
…wizard, wired everything
  • Loading branch information
mguenther committed Oct 10, 2015
1 parent 9a8abe8 commit 5c83a75
Show file tree
Hide file tree
Showing 16 changed files with 208 additions and 70 deletions.
4 changes: 1 addition & 3 deletions photoalbum-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<artifactId>photoalbum-common</artifactId>
<packaging>jar</packaging>

<name>photoalbum-common</name>
<url>http:https://maven.apache.org</url>
<name>[photoalbum] Common</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -21,7 +20,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
3 changes: 1 addition & 2 deletions photoalbum-management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<artifactId>photoalbum-management</artifactId>
<packaging>jar</packaging>

<name>photoalbum-management</name>
<url>http:https://maven.apache.org</url>
<name>[photoalbum] Asset Management</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
3 changes: 1 addition & 2 deletions photoalbum-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<artifactId>photoalbum-security</artifactId>
<packaging>jar</packaging>

<name>photoalbum-security</name>
<url>http:https://maven.apache.org</url>
<name>[photoalbum] Security Component</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
5 changes: 0 additions & 5 deletions photoalbum-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@
<groupId>com.hubspot.dropwizard</groupId>
<artifactId>dropwizard-guice</artifactId>
</dependency>
<!-- Persistence -->
<dependency>
<groupId>org.ektorp</groupId>
<artifactId>org.ektorp</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
Expand Down
21 changes: 21 additions & 0 deletions photoalbum-webapp/src/main/config/development.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
connector.type=http
connector.port=8080

database.url=http:https://localhost:5984
database.name=test-photoalbum
database.user=
database.password=

photoalbum.archive.path=archive
photoalbum.caching.max_age=864000

log.file=logs/photoalbum-service.log
log.archive_logs=false
log.archived_file=logs/photoalbum-service-%d{yyyy-MM-dd}-%i.log.gz
log.max_archived_logs=7
log.level=DEBUG

log.request.file=logs/photoalbum-access.log
log.request.archive_logs=false
log.request.archived_file=logs/photoalbum-access-%d{yyyy-MM-dd}-%i.log.gz
log.request.max_archived_logs=7
21 changes: 21 additions & 0 deletions photoalbum-webapp/src/main/config/integration.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
connector.type=http
connector.port=8080

database.url=http:https://localhost:5984
database.name=test-photoalbum
database.user=
database.password=

photoalbum.archive.path=archive
photoalbum.caching.max_age=864000

log.file=logs/photoalbum-service.log
log.archive_logs=false
log.archived_file=logs/photoalbum-service-%d{yyyy-MM-dd}-%i.log.gz
log.max_archived_logs=7
log.level=DEBUG

log.request.file=logs/photoalbum-access.log
log.request.archive_logs=false
log.request.archived_file=logs/photoalbum-access-%d{yyyy-MM-dd}-%i.log.gz
log.request.max_archived_logs=7
21 changes: 21 additions & 0 deletions photoalbum-webapp/src/main/config/production.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
connector.type=http
connector.port=8080

database.url=http:https://localhost:5984
database.name=photoalbum
database.user=
database.password=

receipt.archive.path=/opt/app/photoalbum/archive
receipt.caching.max_age=864000

log.file=/var/log/photoalbum/photoalbum-service.log
log.archive_logs=true
log.archived_file=/var/log/photoalbum/archive/photoalbum-service-%d{yyyy-MM-dd}-%i.log.gz
log.max_archived_logs=7
log.level=INFO

log.request.file=/var/log/photoalbum/photoalbum-access.log
log.request.archive_logs=true
log.request.archived_file=/var/log/photoalbum/archive/photoalbum-access-%d{yyyy-MM-dd}-%i.log.gz
log.request.max_archived_logs=7
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mgu.photoalbum;

import com.hubspot.dropwizard.guice.GuiceBundle;
import com.mgu.photoalbum.config.DatabaseModule;
import com.mgu.photoalbum.config.ServiceConfig;
import com.mgu.photoalbum.config.ServiceModule;
import com.mgu.photoalbum.security.Principal;
Expand All @@ -21,7 +20,6 @@ public class PhotoalbumApplication extends Application<ServiceConfig> {
public void initialize(final Bootstrap<ServiceConfig> bootstrap) {

this.guiceBundle = GuiceBundle.<ServiceConfig>newBuilder()
.addModule(new DatabaseModule())
.addModule(new ServiceModule())
.setConfigClass(ServiceConfig.class)
.enableAutoConfig(getClass().getPackage().getName())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ public class PhotoalbumConfig {
@Range(min = 0)
private int maxCacheAge;

@JsonProperty("hostname")
@NotEmpty
private String hostname;

public String getHostname() {
return hostname;
}

public void setHostname(final String hostname) {
this.hostname = hostname;
}

public String getImageArchivePath() {
return imageArchivePath;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.mgu.photoalbum.config;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.mgu.photoalbum.adapter.fileio.PathAdapter;
import com.mgu.photoalbum.converter.AlbumReprConverter;
import com.mgu.photoalbum.converter.AlbumShortReprConverter;
import com.mgu.photoalbum.converter.GalleryReprConverter;
import com.mgu.photoalbum.converter.PhotoMetadataReprConverter;
import com.mgu.photoalbum.converter.PhotoShortReprConverter;
import com.mgu.photoalbum.identity.IdGenerator;
import com.mgu.photoalbum.resource.LinkScheme;
import com.mgu.photoalbum.security.Authentication;
import com.mgu.photoalbum.security.Authorization;
import com.mgu.photoalbum.security.IdentityBasedAuth;
Expand All @@ -15,9 +22,44 @@
import com.mgu.photoalbum.service.PhotoService;
import com.mgu.photoalbum.service.scaler.ImageScaler;
import com.mgu.photoalbum.service.scaler.ScalrImageScaler;
import com.mgu.photoalbum.storage.AlbumRepository;
import com.mgu.photoalbum.storage.PhotoRepository;
import com.mgu.photoalbum.user.UserQueryService;
import com.mgu.photoalbum.user.UserRepository;
import com.mgu.photoalbum.user.UserService;
import org.ektorp.CouchDbConnector;
import org.ektorp.CouchDbInstance;
import org.ektorp.http.HttpClient;
import org.ektorp.http.StdHttpClient;
import org.ektorp.impl.StdCouchDbConnector;
import org.ektorp.impl.StdCouchDbInstance;

import javax.inject.Named;

public class ServiceModule extends AbstractModule {

@Provides
@Named("pathToArchive")
public String provideImageArchive(final ServiceConfig configuration) {
return configuration.getPhotoalbumConfig().getImageArchivePath();
}

@Provides
public CouchDbConnector provideConnection(final ServiceConfig config) {
final DatabaseConfig database = config.getDatabaseConfig();
try {
final HttpClient httpClient = new StdHttpClient.Builder()
.url(database.getUrl())
.connectionTimeout(10000)
.socketTimeout(10000)
.build();
final CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
return new StdCouchDbConnector(database.getName(), dbInstance);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@Override
protected void configure() {

Expand All @@ -31,19 +73,46 @@ protected void configure() {

bind(PathAdapter.class).toInstance(new PathAdapter());

configureAssetManagement();
configureUserManagement();
configureSecurity();
configureFacade();
}

private void configureAssetManagement() {
bind(ImageScaler.class).to(ScalrImageScaler.class);
bind(PhotoCommandService.class).to(PhotoService.class);
bind(PhotoQueryService.class).to(PhotoService.class);
bind(AlbumCommandService.class).to(AlbumService.class);
bind(AlbumQueryService.class).to(AlbumService.class);
try {
bind(AlbumRepository.class).toConstructor(AlbumRepository.class.getConstructor(CouchDbConnector.class));
bind(PhotoRepository.class).toConstructor(PhotoRepository.class.getConstructor(CouchDbConnector.class));
} catch (NoSuchMethodException e) {
addError(e);
}
}

configureSecurity();


private void configureUserManagement() {
bind(UserQueryService.class).to(UserService.class);
try {
bind(UserRepository.class).toConstructor(UserRepository.class.getConstructor(CouchDbConnector.class));
} catch (NoSuchMethodException e) {
addError(e);
}
}

private void configureSecurity() {
bind(Authentication.class).to(IdentityBasedAuth.class);
bind(Authorization.class).to(IdentityBasedAuth.class);
}

private void configureFacade() {
bind(LinkScheme.class);
bind(AlbumReprConverter.class);
bind(AlbumShortReprConverter.class);
bind(GalleryReprConverter.class);
bind(PhotoMetadataReprConverter.class);
bind(PhotoShortReprConverter.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import java.util.List;
import java.util.stream.Collectors;

public class GalleryConverter implements Converter<List<Album>, GalleryRepr> {
public class GalleryReprConverter implements Converter<List<Album>, GalleryRepr> {

private final LinkScheme linkScheme;

private final AlbumShortReprConverter albumConverter;

@Inject
public GalleryConverter(final LinkScheme linkScheme, final AlbumShortReprConverter albumConverter) {
public GalleryReprConverter(final LinkScheme linkScheme, final AlbumShortReprConverter albumConverter) {
this.linkScheme = linkScheme;
this.albumConverter = albumConverter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.codahale.metrics.annotation.Timed;
import com.google.inject.Inject;
import com.mgu.photoalbum.converter.AlbumShortReprConverter;
import com.mgu.photoalbum.converter.GalleryConverter;
import com.mgu.photoalbum.converter.GalleryReprConverter;
import com.mgu.photoalbum.representation.CreateAlbumRepr;
import com.mgu.photoalbum.representation.GalleryRepr;
import com.mgu.photoalbum.security.Authorization;
Expand All @@ -28,7 +28,7 @@ public class AlbumsResource {

private final LinkScheme linkScheme;

private final GalleryConverter galleryConverter;
private final GalleryReprConverter galleryConverter;

@Inject
public AlbumsResource(
Expand All @@ -39,7 +39,7 @@ public AlbumsResource(
this.commandService = commandService;
this.authorization = authorization;
this.linkScheme = new LinkScheme();
this.galleryConverter = new GalleryConverter(linkScheme, new AlbumShortReprConverter(linkScheme));
this.galleryConverter = new GalleryReprConverter(linkScheme, new AlbumShortReprConverter(linkScheme));
}

@POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.mgu.photoalbum.resource;

import com.google.inject.Singleton;

import javax.ws.rs.core.UriBuilder;
import java.net.URI;

@Singleton
public class LinkScheme {

private static final String GALLERY_URI_TEMPLATE = "/albums";
Expand Down
12 changes: 12 additions & 0 deletions photoalbum-webapp/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


██████╗ ██╗ ██╗ ██████╗ ████████╗ ██████╗ █████╗ ██╗ ██████╗ ██╗ ██╗███╗ ███╗
██╔══██╗██║ ██║██╔═══██╗╚══██╔══╝██╔═══██╗██╔══██╗██║ ██╔══██╗██║ ██║████╗ ████║
██████╔╝███████║██║ ██║ ██║ ██║ ██║███████║██║ ██████╔╝██║ ██║██╔████╔██║
██╔═══╝ ██╔══██║██║ ██║ ██║ ██║ ██║██╔══██║██║ ██╔══██╗██║ ██║██║╚██╔╝██║
██║ ██║ ██║╚██████╔╝ ██║ ╚██████╔╝██║ ██║███████╗██████╔╝╚██████╔╝██║ ╚═╝ ██║
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝

_______________________________________________________________________________________
(c) 2015, mgu

0 comments on commit 5c83a75

Please sign in to comment.