Skip to content

Commit 01d4fec

Browse files
committed
Refactor ZebedeeConfiguration for readbility
Structure ZebedeeConfiguration in such a way as to keep the initialisation of each service together and to ensure that dependencies between services are clear.
1 parent 2c0c1c4 commit 01d4fec

35 files changed

+725
-539
lines changed

zebedee-cms/src/main/java/com/github/onsdigital/zebedee/Zebedee.java

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.github.onsdigital.zebedee.model.Collection;
1212
import com.github.onsdigital.zebedee.model.Collections;
1313
import com.github.onsdigital.zebedee.model.Content;
14+
import com.github.onsdigital.zebedee.model.PublishedContent;
1415
import com.github.onsdigital.zebedee.model.ZebedeeCollectionReader;
1516
import com.github.onsdigital.zebedee.model.encryption.EncryptionKeyFactory;
1617
import com.github.onsdigital.zebedee.model.publishing.PublishedCollections;
@@ -19,8 +20,7 @@
1920
import com.github.onsdigital.zebedee.service.DatasetService;
2021
import com.github.onsdigital.zebedee.service.ImageService;
2122
import com.github.onsdigital.zebedee.service.KafkaService;
22-
import com.github.onsdigital.zebedee.service.ServiceStore;
23-
import com.github.onsdigital.zebedee.service.ServiceStoreImpl;
23+
import com.github.onsdigital.zebedee.servicetokens.store.ServiceStore;
2424
import com.github.onsdigital.zebedee.session.model.Session;
2525
import com.github.onsdigital.zebedee.session.service.Sessions;
2626
import com.github.onsdigital.zebedee.teams.service.TeamsService;
@@ -36,6 +36,7 @@
3636
import java.nio.file.Paths;
3737
import java.util.Optional;
3838

39+
import static com.github.onsdigital.zebedee.ZebedeeConfiguration.COLLECTIONS;
3940
import static com.github.onsdigital.zebedee.configuration.Configuration.isVerificationEnabled;
4041
import static com.github.onsdigital.zebedee.exceptions.DeleteContentRequestDeniedException.beingEditedByAnotherCollectionError;
4142
import static com.github.onsdigital.zebedee.exceptions.DeleteContentRequestDeniedException.beingEditedByThisCollectionError;
@@ -44,36 +45,11 @@
4445
import static com.github.onsdigital.zebedee.logging.CMSLogEvent.info;
4546

4647
public class Zebedee {
47-
public static final String PUBLISHED = "master";
48-
public static final String COLLECTIONS = "collections";
49-
public static final String PUBLISHED_COLLECTIONS = "publish-log";
50-
public static final String ZEBEDEE = "zebedee";
51-
public static final String USERS = "users";
52-
public static final String SESSIONS = "sessions";
53-
public static final String PERMISSIONS = "permissions";
54-
public static final String TEAMS = "teams";
55-
public static final String LAUNCHPAD = "launchpad";
56-
public static final String APPLICATION_KEYS = "application-keys";
57-
public static final String SERVICES = "services";
58-
public static final String KEYRING = "keyring";
59-
60-
private final Path publishedCollectionsPath;
61-
private final Path collectionsPath;
62-
private final Path usersPath;
63-
private final Path sessionsPath;
64-
private final Path permissionsPath;
65-
private final Path teamsPath;
66-
private final Path redirectPath;
67-
private final Path servicePath;
68-
private final Path keyRingPath;
69-
7048
private final VerificationAgent verificationAgent;
7149
private final PublishedCollections publishedCollections;
7250
private final Collections collections;
73-
private final Content published;
51+
private final PublishedContent published;
7452
private final CollectionKeyCache schedulerKeyCache;
75-
private final Path publishedContentPath;
76-
private final Path path;
7753
private final PermissionsService permissionsService;
7854
private final CollectionKeyring collectionKeyring;
7955
private final EncryptionKeyFactory encryptionKeyFactory;
@@ -85,18 +61,19 @@ public class Zebedee {
8561
private final DatasetService datasetService;
8662
private final ImageService imageService;
8763
private final KafkaService kafkaService;
88-
private final ServiceStoreImpl serviceStoreImpl;
64+
private final ServiceStore serviceStore;
8965
private final StartUpNotifier startUpNotifier;
9066
private final Notifier slackNotifier;
9167

68+
private final Path path;
69+
9270
/**
9371
* Create a new instance of Zebedee setting.
9472
*
9573
* @param cfg {@link ZebedeeConfiguration} contains the set up to use for this instance.
9674
*/
9775
public Zebedee(ZebedeeConfiguration cfg) {
9876
this.path = cfg.getZebedeePath();
99-
this.publishedContentPath = cfg.getPublishedContentPath();
10077
this.sessions = cfg.getSessions();
10178
this.schedulerKeyCache = cfg.getSchedulerKeyringCache();
10279
this.permissionsService = cfg.getPermissionsService();
@@ -106,23 +83,14 @@ public Zebedee(ZebedeeConfiguration cfg) {
10683
this.publishedCollections = cfg.getPublishCollections();
10784
this.teamsService = cfg.getTeamsService();
10885
this.usersService = cfg.getUsersService();
109-
this.verificationAgent = cfg.getVerificationAgent(isVerificationEnabled(), this);
86+
this.verificationAgent = cfg.getVerificationAgent();
11087
this.datasetService = cfg.getDatasetService();
11188
this.imageService = cfg.getImageService();
11289
this.kafkaService = cfg.getKafkaService();
113-
this.serviceStoreImpl = cfg.getServiceStore();
90+
this.serviceStore = cfg.getServiceStore();
11491
this.collectionKeyring = cfg.getCollectionKeyring();
11592
this.encryptionKeyFactory = cfg.getEncryptionKeyFactory();
11693

117-
this.collectionsPath = cfg.getCollectionsPath();
118-
this.publishedCollectionsPath = cfg.getPublishedCollectionsPath();
119-
this.usersPath = cfg.getUsersPath();
120-
this.sessionsPath = cfg.getSessionsPath();
121-
this.permissionsPath = cfg.getPermissionsPath();
122-
this.teamsPath = cfg.getTeamsPath();
123-
this.redirectPath = cfg.getRedirectPath();
124-
this.servicePath = cfg.getServicePath();
125-
this.keyRingPath = cfg.getKeyRingPath();
12694
this.startUpNotifier = cfg.getStartUpNotifier();
12795
this.slackNotifier = cfg.getSlackNotifier();
12896
}
@@ -325,11 +293,7 @@ public PermissionsService getPermissionsService() {
325293
return this.permissionsService;
326294
}
327295

328-
public Path getPublishedContentPath() {
329-
return this.publishedContentPath;
330-
}
331-
332-
public Content getPublished() {
296+
public PublishedContent getPublished() {
333297
return this.published;
334298
}
335299

@@ -374,15 +338,7 @@ public KafkaService getKafkaService() {
374338
}
375339

376340
public ServiceStore getServiceStore() {
377-
return serviceStoreImpl;
378-
}
379-
380-
public Path getServicePath() {
381-
return servicePath;
382-
}
383-
384-
public Path getKeyRingPath() {
385-
return keyRingPath;
341+
return serviceStore;
386342
}
387343

388344
public CollectionKeyring getCollectionKeyring() {

0 commit comments

Comments
 (0)