Skip to content

Commit

Permalink
Refactor ZebedeeConfiguration for readbility
Browse files Browse the repository at this point in the history
Structure ZebedeeConfiguration in such a way as to keep the
initialisation of each service together and to ensure that dependencies
between services are clear.
  • Loading branch information
janderson2 committed Feb 9, 2022
1 parent 2c0c1c4 commit 01d4fec
Show file tree
Hide file tree
Showing 35 changed files with 725 additions and 539 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.github.onsdigital.zebedee.model.Collection;
import com.github.onsdigital.zebedee.model.Collections;
import com.github.onsdigital.zebedee.model.Content;
import com.github.onsdigital.zebedee.model.PublishedContent;
import com.github.onsdigital.zebedee.model.ZebedeeCollectionReader;
import com.github.onsdigital.zebedee.model.encryption.EncryptionKeyFactory;
import com.github.onsdigital.zebedee.model.publishing.PublishedCollections;
Expand All @@ -19,8 +20,7 @@
import com.github.onsdigital.zebedee.service.DatasetService;
import com.github.onsdigital.zebedee.service.ImageService;
import com.github.onsdigital.zebedee.service.KafkaService;
import com.github.onsdigital.zebedee.service.ServiceStore;
import com.github.onsdigital.zebedee.service.ServiceStoreImpl;
import com.github.onsdigital.zebedee.servicetokens.store.ServiceStore;
import com.github.onsdigital.zebedee.session.model.Session;
import com.github.onsdigital.zebedee.session.service.Sessions;
import com.github.onsdigital.zebedee.teams.service.TeamsService;
Expand All @@ -36,6 +36,7 @@
import java.nio.file.Paths;
import java.util.Optional;

import static com.github.onsdigital.zebedee.ZebedeeConfiguration.COLLECTIONS;
import static com.github.onsdigital.zebedee.configuration.Configuration.isVerificationEnabled;
import static com.github.onsdigital.zebedee.exceptions.DeleteContentRequestDeniedException.beingEditedByAnotherCollectionError;
import static com.github.onsdigital.zebedee.exceptions.DeleteContentRequestDeniedException.beingEditedByThisCollectionError;
Expand All @@ -44,36 +45,11 @@
import static com.github.onsdigital.zebedee.logging.CMSLogEvent.info;

public class Zebedee {
public static final String PUBLISHED = "master";
public static final String COLLECTIONS = "collections";
public static final String PUBLISHED_COLLECTIONS = "publish-log";
public static final String ZEBEDEE = "zebedee";
public static final String USERS = "users";
public static final String SESSIONS = "sessions";
public static final String PERMISSIONS = "permissions";
public static final String TEAMS = "teams";
public static final String LAUNCHPAD = "launchpad";
public static final String APPLICATION_KEYS = "application-keys";
public static final String SERVICES = "services";
public static final String KEYRING = "keyring";

private final Path publishedCollectionsPath;
private final Path collectionsPath;
private final Path usersPath;
private final Path sessionsPath;
private final Path permissionsPath;
private final Path teamsPath;
private final Path redirectPath;
private final Path servicePath;
private final Path keyRingPath;

private final VerificationAgent verificationAgent;
private final PublishedCollections publishedCollections;
private final Collections collections;
private final Content published;
private final PublishedContent published;
private final CollectionKeyCache schedulerKeyCache;
private final Path publishedContentPath;
private final Path path;
private final PermissionsService permissionsService;
private final CollectionKeyring collectionKeyring;
private final EncryptionKeyFactory encryptionKeyFactory;
Expand All @@ -85,18 +61,19 @@ public class Zebedee {
private final DatasetService datasetService;
private final ImageService imageService;
private final KafkaService kafkaService;
private final ServiceStoreImpl serviceStoreImpl;
private final ServiceStore serviceStore;
private final StartUpNotifier startUpNotifier;
private final Notifier slackNotifier;

private final Path path;

/**
* Create a new instance of Zebedee setting.
*
* @param cfg {@link ZebedeeConfiguration} contains the set up to use for this instance.
*/
public Zebedee(ZebedeeConfiguration cfg) {
this.path = cfg.getZebedeePath();
this.publishedContentPath = cfg.getPublishedContentPath();
this.sessions = cfg.getSessions();
this.schedulerKeyCache = cfg.getSchedulerKeyringCache();
this.permissionsService = cfg.getPermissionsService();
Expand All @@ -106,23 +83,14 @@ public Zebedee(ZebedeeConfiguration cfg) {
this.publishedCollections = cfg.getPublishCollections();
this.teamsService = cfg.getTeamsService();
this.usersService = cfg.getUsersService();
this.verificationAgent = cfg.getVerificationAgent(isVerificationEnabled(), this);
this.verificationAgent = cfg.getVerificationAgent();
this.datasetService = cfg.getDatasetService();
this.imageService = cfg.getImageService();
this.kafkaService = cfg.getKafkaService();
this.serviceStoreImpl = cfg.getServiceStore();
this.serviceStore = cfg.getServiceStore();
this.collectionKeyring = cfg.getCollectionKeyring();
this.encryptionKeyFactory = cfg.getEncryptionKeyFactory();

this.collectionsPath = cfg.getCollectionsPath();
this.publishedCollectionsPath = cfg.getPublishedCollectionsPath();
this.usersPath = cfg.getUsersPath();
this.sessionsPath = cfg.getSessionsPath();
this.permissionsPath = cfg.getPermissionsPath();
this.teamsPath = cfg.getTeamsPath();
this.redirectPath = cfg.getRedirectPath();
this.servicePath = cfg.getServicePath();
this.keyRingPath = cfg.getKeyRingPath();
this.startUpNotifier = cfg.getStartUpNotifier();
this.slackNotifier = cfg.getSlackNotifier();
}
Expand Down Expand Up @@ -325,11 +293,7 @@ public PermissionsService getPermissionsService() {
return this.permissionsService;
}

public Path getPublishedContentPath() {
return this.publishedContentPath;
}

public Content getPublished() {
public PublishedContent getPublished() {
return this.published;
}

Expand Down Expand Up @@ -374,15 +338,7 @@ public KafkaService getKafkaService() {
}

public ServiceStore getServiceStore() {
return serviceStoreImpl;
}

public Path getServicePath() {
return servicePath;
}

public Path getKeyRingPath() {
return keyRingPath;
return serviceStore;
}

public CollectionKeyring getCollectionKeyring() {
Expand Down
Loading

0 comments on commit 01d4fec

Please sign in to comment.