This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit f434463be0119cb76be179bae073772d4f19c0fa Author: Tony CHEMIT <dev@tchemit.fr> Date: Fri Jan 6 11:48:43 2017 +0100 Utilisation de nuiton-config pour générer la configuration + normalisation des options de la configuration --- .../rest/api/PollenRestApiApplicationContext.java | 12 +- pollen-services/pom.xml | 14 + pollen-services/src/main/config/PollenServices.ini | 150 ++++++++++ .../services/DefaultPollenServiceContext.java | 15 +- .../pollen/services/PollenApplicationContext.java | 4 +- .../pollen/services/PollenServiceContext.java | 4 +- .../services/config/PollenServiceConfig.java | 228 --------------- .../services/config/PollenServiceConfigOption.java | 307 --------------------- .../services/config/PollenServicesConfig.java | 131 +++++++++ .../pollen/services/service/CommentService.java | 2 +- .../services/service/FavoriteListService.java | 9 +- .../pollen/services/service/FixturesService.java | 2 +- .../pollen/services/service/PollService.java | 2 +- .../services/service/PollenServiceSupport.java | 6 +- .../services/service/PollenUIUrlRenderService.java | 10 +- .../pollen/services/service/PollenUserService.java | 2 +- .../pollen/services/service/mail/EmailService.java | 4 +- .../test/FakePollenApplicationContext.java | 12 +- .../services/test/FakePollenServiceContext.java | 6 +- .../service/PollenUIUrlRenderServiceTest.java | 16 +- pom.xml | 11 +- 21 files changed, 353 insertions(+), 594 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java index fc3f06d..3aa6796 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java @@ -36,7 +36,7 @@ import org.chorem.pollen.persistence.entity.SessionToken; import org.chorem.pollen.services.DefaultPollenServiceContext; import org.chorem.pollen.services.PollenApplicationContext; import org.chorem.pollen.services.PollenServiceContext; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.InvalidFormException; import org.chorem.pollen.services.service.PollenUserService; import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext; @@ -73,7 +73,7 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext if (applicationContext == null) { - PollenServiceConfig applicationConfig = new PollenServiceConfig("pollen-rest-api.properties"); + PollenServicesConfig applicationConfig = new PollenServicesConfig("pollen-rest-api.properties"); Map<String, String> topiaProperties = applicationConfig.getTopiaProperties(); @@ -107,11 +107,11 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext protected final PollenTopiaApplicationContext topiaApplicationContext; - protected final PollenServiceConfig applicationConfig; + protected final PollenServicesConfig applicationConfig; protected VoteCountingFactory voteCountingFactory; - protected PollenRestApiApplicationContext(PollenServiceConfig applicationConfig, PollenTopiaApplicationContext topiaApplicationContext) { + protected PollenRestApiApplicationContext(PollenServicesConfig applicationConfig, PollenTopiaApplicationContext topiaApplicationContext) { Preconditions.checkNotNull(applicationConfig, "Configuration can not be null!"); Preconditions.checkNotNull(topiaApplicationContext, "topiaApplicationContext can not be null!"); @@ -128,7 +128,7 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext } @Override - public PollenServiceConfig getApplicationConfig() { + public PollenServicesConfig getApplicationConfig() { return applicationConfig; } @@ -154,7 +154,7 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) { DefaultPollenServiceContext newServiceContext = new DefaultPollenServiceContext(); - newServiceContext.setPollenServiceConfig(applicationConfig); + newServiceContext.setPollenServicesConfig(applicationConfig); newServiceContext.setTopiaApplicationContext(topiaApplicationContext); newServiceContext.setPersistenceContext(persistenceContext); newServiceContext.setVoteCountingFactory(getVoteCountingFactory()); diff --git a/pollen-services/pom.xml b/pollen-services/pom.xml index ee81b99..4330fe5 100644 --- a/pollen-services/pom.xml +++ b/pollen-services/pom.xml @@ -189,6 +189,20 @@ </testResources> <plugins> <plugin> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-config-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <packageName>org.chorem.pollen.services.config</packageName> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.nuiton.i18n</groupId> <artifactId>i18n-maven-plugin</artifactId> <executions> diff --git a/pollen-services/src/main/config/PollenServices.ini b/pollen-services/src/main/config/PollenServices.ini new file mode 100644 index 0000000..3674e01 --- /dev/null +++ b/pollen-services/src/main/config/PollenServices.ini @@ -0,0 +1,150 @@ +description = PollenServicesConfig.description + +[option devMode] +description = pollen.configuration.devMode +key = pollen.devMode +type = Boolean +defaultValue = true +transient = true +final = true + +[option dataDirectory] +description = pollen.configuration.data.directory +key = pollen.data.directory +type = file +transient = true +final = true + +[option defaultPollType] +description = pollen.configuration.defaultPollType +key = pollen.default.pollType +type = org.chorem.pollen.persistence.entity.PollType +defaultValue = FREE + +[option defaultVoteCountingType] +description = pollen.configuration.defaultVoteCountingType +key = pollen.default.voteCountingType +type = int +defaultValue = 1 + +[option defaultVoteVisibility] +description = pollen.configuration.defaultVoteVisibility +key = pollen.default.voteVisibility +type = org.chorem.pollen.persistence.entity.VoteVisibility +defaultValue = EVERYBODY + +[option defaultCommentVisibility] +description = pollen.configuration.defaultCommentVisibility +key = pollen.default.commentVisibility +type = org.chorem.pollen.persistence.entity.CommentVisibility +defaultValue = EVERYBODY + +[option defaultResultVisibility] +description = pollen.configuration.defaultResultVisibility +key = pollen.default.resultVisibility +type = org.chorem.pollen.persistence.entity.ResultVisibility +defaultValue = EVERYBODY + +[option defaultChoiceType] +description = pollen.configuration.defaultChoiceType +key = pollen.default.choiceType +type = org.chorem.pollen.persistence.entity.ChoiceType +defaultValue = TEXT + +[option defaultPollPageSize] +description = pollen.configuration.defaultPollPageSize +key = pollen.default.pollPageSize +type = int +defaultValue = 10 + +[option defaultCommentPageSize] +description = pollen.configuration.defaultCommentPageSize +key = pollen.default.commentPageSize +type = int +defaultValue = 10 + +[option defaultFavoriteListPageSize] +description = pollen.configuration.defaultFavoriteListPageSize +key = pollen.default.favoriteListPageSize +type = int +defaultValue = 10 + +[option defaultFavoriteListMemberPageSize] +description = pollen.configuration.defaultFavoriteListMemberPageSize +key = pollen.default.favoriteListMemberPageSize +type = int +defaultValue = 10 + +[option defaultPollenUserPageSize] +description = pollen.configuration.defaultPollenUserPageSize +key = pollen.default.pollenUserPageSize +type = int +defaultValue = 10 + +[option sessionTimeoutDelay] +description = pollen.configuration.sessionTimeoutDelay +key = pollen.default.sessionTimeoutDelay +type = int +# 1 hour = 3600 s +defaultValue = 3600 + +[option smtpHost] +description = pollen.configuration.smptHost +key = pollen.smtp.host +type = string +defaultValue = localhost + +[option smtpPort] +description = pollen.configuration.smtpPort +key = pollen.smtp.port +type = int +defaultValue = 25 + +[option smtpFrom] +description = pollen.configuration.smtpFrom +key = pollen.smtp.from +type = string +defaultValue = "Pollen" + +[option logConfigurationFile] +description = pollen.configuration.logConfigurationFile +key = pollen.logConfigurationFile +type = file + +[option version] +description = pollen.configuration.version +key = pollen.version +type = string +defaultValue = sa +transient = true +final = true + +[option uiEndPoint] +description = pollen.configuration.uiEndPoint +key = pollen.ui.host +type = url +defaultValue = http://localhost:8888/index.html + +[option uiUrlPollEdit] +description = pollen.configuration.uiUrlPollEdit +key = pollen.ui.url.poll.edit +type = string +defaultValue = ${pollen.ui.host}#/poll/edit/{pollId}/{pollToken} + +[option uiUrlPollVote] +description = pollen.configuration.uiUrlPollVote +key = pollen.ui.url.poll.vote +type = url +defaultValue = ${pollen.ui.host}#/poll/vote/{pollId}/{pollToken} + +[option uiUrlPollVoteEdit] +description = pollen.configurqtion.uiUrlPollVoteEdit +key = pollen.ui.url.poll.vote.edit +type = url +defaultValue = ${pollen.ui.url.poll.vote}/vote/{voteToken} + +[option uiUrlUserValidate] +description = pollen.configurqtion.uiUrlUserValidate +key = pollen.ui.url.user.validate +type = url +defaultValue = ${pollen.ui.host}#/user/{userId}/{token} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java index 8cb863b..ce45c8f 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java @@ -33,7 +33,7 @@ import org.apache.shiro.crypto.hash.HashRequest; import org.apache.shiro.util.ByteSource; import org.chorem.pollen.persistence.PollenPersistenceContext; import org.chorem.pollen.persistence.PollenTopiaApplicationContext; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.security.PollenSecurityContext; import org.chorem.pollen.votecounting.VoteCountingFactory; @@ -45,7 +45,7 @@ import java.util.UUID; public class DefaultPollenServiceContext implements PollenServiceContext { - protected PollenServiceConfig pollenServiceConfig; + protected PollenServicesConfig pollenServicesConfig; protected PollenPersistenceContext persistenceContext; @@ -62,8 +62,8 @@ public class DefaultPollenServiceContext implements PollenServiceContext { protected VoteCountingFactory voteCountingFactory; - public void setPollenServiceConfig(PollenServiceConfig pollenServiceConfig) { - this.pollenServiceConfig = pollenServiceConfig; + public void setPollenServicesConfig(PollenServicesConfig pollenServicesConfig) { + this.pollenServicesConfig = pollenServicesConfig; } public void setTopiaApplicationContext(PollenTopiaApplicationContext topiaApplicationContext) { @@ -88,9 +88,8 @@ public class DefaultPollenServiceContext implements PollenServiceContext { return topiaApplicationContext; } - @Override - public PollenServiceConfig getPollenServiceConfig() { - return pollenServiceConfig; + public PollenServicesConfig getPollenServicesConfig() { + return pollenServicesConfig; } @Override @@ -208,7 +207,7 @@ public class DefaultPollenServiceContext implements PollenServiceContext { if (hashService == null) { hashService = new DefaultHashService(); - String hashAlgorithmName = getPollenServiceConfig().getHashAlgorithmName(); + String hashAlgorithmName = getPollenServicesConfig().getHashAlgorithmName(); hashService.setHashAlgorithmName(hashAlgorithmName); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java index 89ae651..7ca9dc5 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java @@ -26,7 +26,7 @@ import org.chorem.pollen.persistence.PollenTopiaApplicationContext; import org.chorem.pollen.persistence.PollenTopiaPersistenceContext; import org.chorem.pollen.persistence.entity.PollenPrincipal; import org.chorem.pollen.persistence.entity.SessionToken; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.security.PollenSecurityContext; import org.chorem.pollen.votecounting.VoteCountingFactory; @@ -43,7 +43,7 @@ public interface PollenApplicationContext extends Closeable { PollenTopiaApplicationContext getTopiaApplicationContext(); - PollenServiceConfig getApplicationConfig(); + PollenServicesConfig getApplicationConfig(); VoteCountingFactory getVoteCountingFactory(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java index 771aeed..c41ce0e 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java @@ -23,7 +23,7 @@ package org.chorem.pollen.services; import org.chorem.pollen.persistence.PollenPersistenceContext; import org.chorem.pollen.persistence.PollenTopiaApplicationContext; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.security.PollenSecurityContext; import org.chorem.pollen.votecounting.VoteCountingFactory; @@ -48,7 +48,7 @@ public interface PollenServiceContext { PollenPersistenceContext getPersistenceContext(); - PollenServiceConfig getPollenServiceConfig(); + PollenServicesConfig getPollenServicesConfig(); <E extends PollenService> E newService(Class<E> serviceClass); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java b/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java deleted file mode 100644 index 435728b..0000000 --- a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.chorem.pollen.services.config; - -/* - * #%L - * Pollen :: Service - * %% - * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.shiro.crypto.hash.Sha512Hash; -import org.chorem.pollen.persistence.entity.ChoiceType; -import org.chorem.pollen.persistence.entity.CommentVisibility; -import org.chorem.pollen.persistence.entity.PollType; -import org.chorem.pollen.persistence.entity.ResultVisibility; -import org.chorem.pollen.persistence.entity.VoteVisibility; -import org.chorem.pollen.services.PollenTechnicalException; -import org.nuiton.config.ApplicationConfig; -import org.nuiton.config.ArgumentsParserException; -import org.nuiton.version.Version; - -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * TODO - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.0 - */ -public class PollenServiceConfig { - - private static final Log log = LogFactory.getLog(PollenServiceConfig.class); - - protected final ApplicationConfig applicationConfig; - - public PollenServiceConfig(String filename) { - this(filename, null); - } - - public PollenServiceConfig(String filename, Properties defaultValues) { - applicationConfig = new ApplicationConfig(); - applicationConfig.loadDefaultOptions(PollenServiceConfigOption.values()); - applicationConfig.setAppName("pollen"); - applicationConfig.setConfigFileName(filename); - if (defaultValues != null) { - for (Map.Entry<Object, Object> entry : defaultValues.entrySet()) { - - applicationConfig.setOption((String) entry.getKey(), (String) entry.getValue()); - } - } - try { - applicationConfig.parse(); - } catch (ArgumentsParserException e) { - throw new PollenTechnicalException(e); - } - if (log.isInfoEnabled()) { - StringBuilder builder = new StringBuilder("Pollen configuration:"); - builder.append("\nFilename: ").append(filename); - List<PollenServiceConfigOption> options = Lists.newArrayList(PollenServiceConfigOption.values()); - for (PollenServiceConfigOption option : options) { - builder.append(String.format("\n%1$-40s = %2$s", - option.getKey(), - applicationConfig.getOption(option))); - } - log.info(builder.toString()); - } - } - - public Map<String, String> getTopiaProperties() { - Map<String, String> topiaParameters = Maps.newHashMap(); - Properties properties = applicationConfig.getOptionStartsWith("hibernate"); - properties.putAll(applicationConfig.getOptionStartsWith("topia")); - - for (Object o : properties.keySet()) { - String key = String.valueOf(o); - String value = applicationConfig.getOption(String.class, key); - topiaParameters.put(key, value); - } - return topiaParameters; - } - - public boolean isLogConfigurationProvided() { - return StringUtils.isNotBlank(applicationConfig.getOption(PollenServiceConfigOption.LOG_CONFIGURATION_FILE.key)); - } - - public File getLogConfigurationFile() { - return applicationConfig.getOptionAsFile(PollenServiceConfigOption.LOG_CONFIGURATION_FILE.key); - } - - public boolean isDevMode() { - return applicationConfig.getOptionAsBoolean(PollenServiceConfigOption.DEV_MODE.key); - } - - public int getDefaultVoteCountingType() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.DEFAULT_VOTE_COUNTING_TYPE.key); - } - - public PollType getDefaultPollType() { - return applicationConfig.getOption( - PollType.class, - PollenServiceConfigOption.DEFAULT_POLL_TYPE.key); - } - - public VoteVisibility getDefaultVoteVisibility() { - return applicationConfig.getOption( - VoteVisibility.class, - PollenServiceConfigOption.DEFAULT_VOTE_VISIBILITY.key); - } - - public CommentVisibility getDefaultCommentVisibility() { - return applicationConfig.getOption( - CommentVisibility.class, - PollenServiceConfigOption.DEFAULT_COMMENT_VISIBILITY.key); - } - - public ResultVisibility getDefaultResultVisibility() { - return applicationConfig.getOption( - ResultVisibility.class, - PollenServiceConfigOption.DEFAULT_RESULT_VISIBILITY.key); - } - - public ChoiceType getDefaultChoiceType() { - return applicationConfig.getOption( - ChoiceType.class, - PollenServiceConfigOption.DEFAULT_CHOICE_TYPE.key); - } - - public int getDefaultPollPaginationSize() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.DEFAULT_POLLS_PAGE_SIZE.key); - } - - public int getDefaultCommentPaginationSize() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.DEFAULT_COMMENTS_PAGE_SIZE.key); - } - - public int getDefaultFavoriteListPaginationSize() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.DEFAULT_FAVORITE_LISTS_PAGE_SIZE.key); - } - - public int getDefaultFavoriteListMemberPaginationSize() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.DEFAULT_FAVORITE_LIST_MEMBERS_PAGE_SIZE.key); - } - - public int getDefaultPollenUserPaginationSize() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.DEFAULT_POLLEN_USERS_PAGE_SIZE.key); - } - - public int getSessionTimeoutDelay() { - return applicationConfig.getOptionAsInt( - PollenServiceConfigOption.SESSION_TIMEOUT_DELAY.key); - } - - /** - * @return Le nom d'hôte du serveur SMTP. - */ - public String getSmtpHost() { - return applicationConfig.getOption(PollenServiceConfigOption.SMTP_HOST.key); - } - - /** - * @return Le port du serveur SMTP. - */ - public int getSmtpPort() { - return applicationConfig.getOptionAsInt(PollenServiceConfigOption.SMTP_PORT.key); - } - - /** - * @return L'adresse d'expéditeur pour les mails de notifications - */ - public String getSmtpFrom() { - return applicationConfig.getOption(PollenServiceConfigOption.SMTP_FROM.key); - } - - public String getHashAlgorithmName() { - return Sha512Hash.ALGORITHM_NAME; - } - - public Version getVersion() { - return applicationConfig.getOptionAsVersion(PollenServiceConfigOption.APPLICATION_VERSION.key); - } - - public String getPollEditUrl() { - return applicationConfig.getOption(PollenServiceConfigOption.URL_POLL_EDIT.key); - } - - public String getPollVoteUrl() { - return applicationConfig.getOption(PollenServiceConfigOption.URL_POLL_VOTE.key); - } - - public String getPollEditVoteUrl() { - return applicationConfig.getOption(PollenServiceConfigOption.URL_POLL_VOTE_EDIT.key); - } - - public String getUserValidateUrl() { - return applicationConfig.getOption(PollenServiceConfigOption.URL_USER_VALIDATE.key); - } - - public String getPollenUrl() { - return applicationConfig.getOption(PollenServiceConfigOption.UI_HOST.key); - } -} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java b/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java deleted file mode 100644 index 605b908..0000000 --- a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java +++ /dev/null @@ -1,307 +0,0 @@ -package org.chorem.pollen.services.config; - -/* - * #%L - * Pollen :: Service - * %% - * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import org.chorem.pollen.persistence.entity.ChoiceType; -import org.chorem.pollen.persistence.entity.CommentVisibility; -import org.chorem.pollen.persistence.entity.PollType; -import org.chorem.pollen.persistence.entity.ResultVisibility; -import org.chorem.pollen.persistence.entity.VoteVisibility; -import org.nuiton.config.ConfigOptionDef; -import org.nuiton.version.Version; - -import java.io.File; -import java.net.URL; - -import static org.nuiton.i18n.I18n.n; - - -/** - * TODO - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.0 - */ -public enum PollenServiceConfigOption implements ConfigOptionDef { - - /** - * Where to stroe any data for pollen application. - * - * @since 2.0 - */ - DATA_DIRECTORY( - "pollen.data.directory", - n("pollen.configuration.data.directory"), - "${java.io.tmpdir}/pollen", - File.class), - /** - * Default poll type to use at a new poll creation. - * - * @since 2.0 - */ - DEFAULT_POLL_TYPE( - "pollen.default.pollType", - n("pollen.configuration.defaultPollType"), - PollType.FREE.name(), - PollType.class), - - /** - * Default vote counting type to use at a new poll creation. - * - * @since 2.0 - */ - DEFAULT_VOTE_COUNTING_TYPE( - "pollen.default.voteCountingType", - n("pollen.configuration.defaultVoteCountingType"), - "1", - Integer.class), - - /** - * Default poll vote visibility to use at a new poll creation. - * - * @since 2.0 - */ - DEFAULT_VOTE_VISIBILITY( - "pollen.default.pollVoteVisibility", - n("pollen.configuration.defaultPollVoteVisibility"), - VoteVisibility.EVERYBODY.name(), - VoteVisibility.class), - - /** - * Default poll comment visibility to use at a new poll creation. - * - * @since 2.0 - */ - DEFAULT_COMMENT_VISIBILITY( - "pollen.default.pollCommentVisibility", - n("pollen.configuration.defaultPollCommentVisibility"), - CommentVisibility.EVERYBODY.name(), - CommentVisibility.class), - - /** - * Default poll comment visibility to use at a new poll creation. - * - * @since 2.0 - */ - DEFAULT_RESULT_VISIBILITY( - "pollen.default.pollResultVisibility", - n("pollen.configuration.defaultPollResultVisibility"), - ResultVisibility.EVERYBODY.name(), - ResultVisibility.class), - - /** - * Default poll choice type to use at a new choice creation. - * - * @since 2.0 - */ - DEFAULT_CHOICE_TYPE( - "pollen.default.pollChoiceType", - n("pollen.configuration.defaultPollChoiceType"), - ChoiceType.TEXT.name(), - ChoiceType.class), - - /** - * Default polls pagination page size. - * - * @since 2.0 - */ - DEFAULT_POLLS_PAGE_SIZE( - "pollen.default.pollPageSize", - n("pollen.configuration.defaultPollPageSize"), - "10", - int.class), - - /** - * Default comments pagination page size. - * - * @since 2.0 - */ - DEFAULT_COMMENTS_PAGE_SIZE( - "pollen.default.commentPageSize", - n("pollen.configuration.defaultCommentPageSize"), - "10", - int.class), - - /** - * Default favorite lists pagination page size. - * - * @since 2.0 - */ - DEFAULT_FAVORITE_LISTS_PAGE_SIZE( - "pollen.default.favoriteListPageSize", - n("pollen.configuration.defaultFavoriteListPageSize"), - "10", - int.class), - - /** - * Default favorite list members pagination page size. - * - * @since 2.0 - */ - DEFAULT_FAVORITE_LIST_MEMBERS_PAGE_SIZE( - "pollen.default.favoriteListMemberPageSize", - n("pollen.configuration.defaultFavoriteListMemberPageSize"), - "10", - int.class), - - /** - * Default pollen users pagination page size. - * - * @since 2.0 - */ - DEFAULT_POLLEN_USERS_PAGE_SIZE( - "pollen.default.pollenUserPageSize", - n("pollen.configuration.defaultPollenUserPageSize"), - "10", - int.class), - - - /** - * Default poll choice type to use at a new choice creation. - * - * @since 2.0 - */ - SESSION_TIMEOUT_DELAY( - "pollen.default.sessionTimeoutDelay", - n("pollen.configuration.sessionTimeoutDelay"), - "3600", // 1 hour = 3600s - int.class), - - SMTP_HOST( - "pollen.smtp.host", - "Nom d'hôte du serveur SMTP", - "", String.class), - - SMTP_PORT( - "pollen.smtp.port", - "Le port du serveur SMTP", - "25", Integer.class), - - SMTP_FROM( - "pollen.smtp.from", - "L'adresse d'expéditeur pour les mails de notifications", - "", String.class), - - DEV_MODE( - "pollen.devMode", - "Mode développement, court-circuite l'envoi de mail", - "true", Boolean.class), - - LOG_CONFIGURATION_FILE( - "pollen.logConfigurationFile", - "Chemin vers le fichier de configuration des journaux", - null, - String.class), - - APPLICATION_VERSION( - "pollen.version", - "Version de l'application", - null, - Version.class), - UI_HOST( - "pollen.ui.host", - "Url de l'interface utilisateur", - "http://localhost:8888/index.html", - URL.class), - URL_POLL_EDIT( - "pollen.ui.url.poll.edit", - "Url d'édition de sondage", - "${pollen.ui.host}#/poll/edit/{pollId}/{pollToken}", - String.class), - URL_POLL_VOTE( - "pollen.ui.url.poll.vote", - "Url de vote", - "${pollen.ui.host}#/poll/vote/{pollId}/{pollToken}", - String.class), - URL_POLL_VOTE_EDIT( - "pollen.ui.url.poll.vote.edit", - "Url d'edition vote", - "${pollen.ui.url.poll.vote}/vote/{voteToken}", - String.class), - URL_USER_VALIDATE( - "pollen.ui.url.user.validate", - "Url de validation d'utilisateur", - "${pollen.ui.host}#/user/{userId}/{token}", - String.class),; - - protected final String key; - - protected final String description; - - protected final Class<?> type; - - protected String defaultValue; - - PollenServiceConfigOption(String key, String description, - String defaultValue, Class<?> type) { - this.key = key; - this.description = description; - this.defaultValue = defaultValue; - this.type = type; - } - - @Override - public String getKey() { - return key; - } - - @Override - public Class<?> getType() { - return type; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getDefaultValue() { - return defaultValue; - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isFinal() { - return false; - } - - @Override - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - @Override - public void setTransient(boolean isTransient) { - // Nothing to do - } - - @Override - public void setFinal(boolean isFinal) { - // Nothing to do - } - -} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java b/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java new file mode 100644 index 0000000..4cab0c3 --- /dev/null +++ b/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java @@ -0,0 +1,131 @@ +package org.chorem.pollen.services.config; + +/* + * #%L + * Pollen :: Service + * %% + * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.shiro.crypto.hash.Sha512Hash; +import org.chorem.pollen.persistence.entity.ChoiceType; +import org.chorem.pollen.persistence.entity.CommentVisibility; +import org.chorem.pollen.persistence.entity.PollType; +import org.chorem.pollen.persistence.entity.ResultVisibility; +import org.chorem.pollen.persistence.entity.VoteVisibility; +import org.chorem.pollen.services.PollenTechnicalException; +import org.nuiton.config.ApplicationConfig; +import org.nuiton.config.ArgumentsParserException; + +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * TODO + * + * @author Tony Chemit - dev@tchemit.fr + * @since 2.0 + */ +public class PollenServicesConfig extends GeneratedPollenServicesConfig { + + private static final Log log = LogFactory.getLog(PollenServicesConfig.class); + + public PollenServicesConfig(String filename) { + this(filename, null); + } + + public PollenServicesConfig(String filename, Properties defaultValues) { + super(); + ApplicationConfig applicationConfig = get(); + applicationConfig.setAppName("pollen"); + applicationConfig.setConfigFileName(filename); + if (defaultValues != null) { + for (Map.Entry<Object, Object> entry : defaultValues.entrySet()) { + + applicationConfig.setOption((String) entry.getKey(), (String) entry.getValue()); + } + } + try { + applicationConfig.parse(); + } catch (ArgumentsParserException e) { + throw new PollenTechnicalException(e); + } + if (log.isInfoEnabled()) { + StringBuilder builder = new StringBuilder("Pollen configuration:"); + builder.append("\nFilename: ").append(filename); + List<PollenServicesConfigOption> options = Lists.newArrayList(PollenServicesConfigOption.values()); + for (PollenServicesConfigOption option : options) { + builder.append(String.format("\n%1$-40s = %2$s", + option.getKey(), + applicationConfig.getOption(option))); + } + log.info(builder.toString()); + } + } + + public Map<String, String> getTopiaProperties() { + Map<String, String> topiaParameters = Maps.newHashMap(); + Properties properties = get().getOptionStartsWith("hibernate"); + properties.putAll(get().getOptionStartsWith("topia")); + + for (Object o : properties.keySet()) { + String key = String.valueOf(o); + String value = get().getOption(String.class, key); + topiaParameters.put(key, value); + } + return topiaParameters; + } + + public boolean isLogConfigurationProvided() { + return StringUtils.isNotBlank(get().getOption(PollenServicesConfigOption.LOG_CONFIGURATION_FILE.getKey())); + } + + public String getHashAlgorithmName() { + return Sha512Hash.ALGORITHM_NAME; + } + + @Override + public PollType getDefaultPollType() { + return PollType.valueOf(get().getOption(PollenServicesConfigOption.DEFAULT_POLL_TYPE.getKey())); + } + + @Override + public VoteVisibility getDefaultVoteVisibility() { + return VoteVisibility.valueOf(get().getOption(PollenServicesConfigOption.DEFAULT_VOTE_VISIBILITY.getKey())); + } + + @Override + public CommentVisibility getDefaultCommentVisibility() { + return CommentVisibility.valueOf(get().getOption(PollenServicesConfigOption.DEFAULT_COMMENT_VISIBILITY.getKey())); + } + + @Override + public ResultVisibility getDefaultResultVisibility() { + return ResultVisibility.valueOf(get().getOption(PollenServicesConfigOption.DEFAULT_RESULT_VISIBILITY.getKey())); + } + + @Override + public ChoiceType getDefaultChoiceType() { + return ChoiceType.valueOf(get().getOption(PollenServicesConfigOption.DEFAULT_CHOICE_TYPE.getKey())); + } +} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java index c2b47e4..4267231 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java @@ -222,7 +222,7 @@ public class CommentService extends PollenServiceSupport { if (paginationParameter == null) { - int pageSize = getPollenServiceConfig().getDefaultCommentPaginationSize(); + int pageSize = getPollenServiceConfig().getDefaultCommentPageSize(); paginationParameter = PaginationParameterBean.of( 0, pageSize, diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java index 94e57eb..03d0634 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java @@ -24,8 +24,6 @@ package org.chorem.pollen.services.service; import com.google.common.collect.Sets; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.chorem.pollen.persistence.entity.FavoriteList; import org.chorem.pollen.persistence.entity.FavoriteListMember; import org.chorem.pollen.persistence.entity.FavoriteListMemberTopiaDao; @@ -53,9 +51,6 @@ import static org.nuiton.i18n.I18n.l; */ public class FavoriteListService extends PollenServiceSupport { - /** Logger. */ - private static final Log log = LogFactory.getLog(FavoriteListService.class); - public PaginationResultBean<FavoriteListBean> getFavoriteLists(PaginationParameterBean paginationParameter) { checkIsConnected(); @@ -467,7 +462,7 @@ public class FavoriteListService extends PollenServiceSupport { if (paginationParameter == null) { - int pageSize = getPollenServiceConfig().getDefaultFavoriteListPaginationSize(); + int pageSize = getPollenServiceConfig().getDefaultFavoriteListPageSize(); paginationParameter = PaginationParameterBean.of(0, pageSize); } @@ -484,7 +479,7 @@ public class FavoriteListService extends PollenServiceSupport { if (paginationParameter == null) { - int pageSize = getPollenServiceConfig().getDefaultFavoriteListMemberPaginationSize(); + int pageSize = getPollenServiceConfig().getDefaultFavoriteListMemberPageSize(); paginationParameter = PaginationParameterBean.of(0, pageSize); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java index 2ea714b..4e08d8f 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java @@ -64,7 +64,7 @@ public class FixturesService extends PollenServiceSupport { protected PollenFixtures loadFixtures(String fixturesSetName, boolean cleanDatabase) { - boolean devMode = serviceContext.getPollenServiceConfig().isDevMode(); + boolean devMode = serviceContext.getPollenServicesConfig().isDevMode(); Preconditions.checkState(devMode); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index c660a24..dc79560 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -477,7 +477,7 @@ public class PollService extends PollenServiceSupport { if (paginationParameter == null) { - int pageSize = getPollenServiceConfig().getDefaultPollPaginationSize(); + int pageSize = getPollenServiceConfig().getDefaultPollPageSize(); paginationParameter = PaginationParameterBean.of(0, pageSize); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java index 03882c2..5b46c28 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java @@ -47,7 +47,7 @@ import org.chorem.pollen.services.PollenServiceContext; import org.chorem.pollen.services.bean.PaginationResultBean; import org.chorem.pollen.services.bean.PollenBean; import org.chorem.pollen.services.bean.PollenBeans; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.mail.EmailService; import org.chorem.pollen.services.service.security.PermissionVerb; import org.chorem.pollen.services.service.security.PollenSecurityContext; @@ -96,8 +96,8 @@ public abstract class PollenServiceSupport implements PollenService { return serviceContext.getPersistenceContext(); } - protected PollenServiceConfig getPollenServiceConfig() { - return serviceContext.getPollenServiceConfig(); + protected PollenServicesConfig getPollenServiceConfig() { + return serviceContext.getPollenServicesConfig(); } protected Locale getLocale() { diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java index 7fb6b39..65271ca 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java @@ -29,13 +29,13 @@ package org.chorem.pollen.services.service; public class PollenUIUrlRenderService extends PollenServiceSupport { public String getPollenUrl() { - return serviceContext.getPollenServiceConfig().getPollenUrl(); + return serviceContext.getPollenServicesConfig().getUiEndPoint().toString(); } public String getPollEditUrl(String pollId, String token) { checkNotNull(pollId); - String url = serviceContext.getPollenServiceConfig().getPollEditUrl(); + String url = serviceContext.getPollenServicesConfig().getUiUrlPollEdit(); url = url.replace("{pollId}", pollId); @@ -50,7 +50,7 @@ public class PollenUIUrlRenderService extends PollenServiceSupport { public String getPollVoteUrl(String pollId, String token) { checkNotNull(pollId); - String url = serviceContext.getPollenServiceConfig().getPollVoteUrl(); + String url = serviceContext.getPollenServicesConfig().getUiUrlPollVote().toString(); url = url.replace("{pollId}", pollId); @@ -67,7 +67,7 @@ public class PollenUIUrlRenderService extends PollenServiceSupport { checkNotNull(pollId); checkNotNull(voteToken); - String url = serviceContext.getPollenServiceConfig().getPollEditVoteUrl(); + String url = serviceContext.getPollenServicesConfig().getUiUrlPollVoteEdit().toString(); url = url.replace("{pollId}", pollId); if (pollToken == null) { @@ -85,7 +85,7 @@ public class PollenUIUrlRenderService extends PollenServiceSupport { checkNotNull(userId); checkNotNull(token); - String url = serviceContext.getPollenServiceConfig().getUserValidateUrl(); + String url = serviceContext.getPollenServicesConfig().getUiUrlUserValidate().toString(); url = url.replace("{userId}", userId); url = url.replace("{token}", token); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index 221c449..feccb7c 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -395,7 +395,7 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer if (paginationParameter == null) { - int pageSize = getPollenServiceConfig().getDefaultPollenUserPaginationSize(); + int pageSize = getPollenServiceConfig().getDefaultPollenUserPageSize(); paginationParameter = PaginationParameterBean.of(0, pageSize); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java index 74f0bf6..824b125 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java @@ -39,7 +39,7 @@ import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.Vote; import org.chorem.pollen.services.PollenTechnicalException; import org.chorem.pollen.services.bean.PollenEntityId; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.PollenServiceSupport; import java.io.StringWriter; @@ -225,7 +225,7 @@ public class EmailService extends PollenServiceSupport { protected void doSend(PollenMail mail) { - PollenServiceConfig applicationConfig = getPollenServiceConfig(); + PollenServicesConfig applicationConfig = getPollenServiceConfig(); String body = getBody(mail); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java index 3e2b415..11f6ea3 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java @@ -37,8 +37,8 @@ import org.chorem.pollen.persistence.entity.SessionToken; import org.chorem.pollen.services.PollenApplicationContext; import org.chorem.pollen.services.PollenFixtures; import org.chorem.pollen.services.PollenServiceContext; -import org.chorem.pollen.services.config.PollenServiceConfig; -import org.chorem.pollen.services.config.PollenServiceConfigOption; +import org.chorem.pollen.services.config.PollenServicesConfig; +import org.chorem.pollen.services.config.PollenServicesConfigOption; import org.chorem.pollen.services.service.FixturesService; import org.chorem.pollen.services.service.security.PollenSecurityRealm; import org.chorem.pollen.votecounting.VoteCountingFactory; @@ -76,7 +76,7 @@ public class FakePollenApplicationContext extends TestWatcher implements PollenA protected PollenTopiaApplicationContext applicationContext; - protected PollenServiceConfig configuration; + protected PollenServicesConfig configuration; protected PollenFixtures fixtures; @@ -141,9 +141,9 @@ public class FakePollenApplicationContext extends TestWatcher implements PollenA // --- create configuration --- // Properties defaultvalues = new Properties(); - defaultvalues.put(PollenServiceConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath()); + defaultvalues.put(PollenServicesConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath()); - configuration = new PollenServiceConfig(configurationPath, defaultvalues); + configuration = new PollenServicesConfig(configurationPath, defaultvalues); // --- create topia application context --- // @@ -194,7 +194,7 @@ public class FakePollenApplicationContext extends TestWatcher implements PollenA } @Override - public PollenServiceConfig getApplicationConfig() { + public PollenServicesConfig getApplicationConfig() { return configuration; } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java index b928153..349a79e 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java @@ -27,7 +27,7 @@ import org.apache.commons.logging.LogFactory; import org.chorem.pollen.persistence.PollenTopiaApplicationContext; import org.chorem.pollen.persistence.PollenTopiaPersistenceContext; import org.chorem.pollen.services.DefaultPollenServiceContext; -import org.chorem.pollen.services.config.PollenServiceConfig; +import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.votecounting.VoteCountingFactory; import java.util.Date; @@ -43,13 +43,13 @@ public class FakePollenServiceContext extends DefaultPollenServiceContext { public static FakePollenServiceContext newServiceContext(Date now, Locale locale, - PollenServiceConfig serviceConfig, + PollenServicesConfig serviceConfig, PollenTopiaApplicationContext applicationcontext, PollenTopiaPersistenceContext persistenceContext, VoteCountingFactory voteCountingFactory) { FakePollenServiceContext serviceContext = new FakePollenServiceContext(); serviceContext.setPersistenceContext(persistenceContext); - serviceContext.setPollenServiceConfig(serviceConfig); + serviceContext.setPollenServicesConfig(serviceConfig); serviceContext.setTopiaApplicationContext(applicationcontext); serviceContext.setVoteCountingFactory(voteCountingFactory); serviceContext.setSecurityContext(new FakePollenSecurityContext()); diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java index 514726d..d270687 100644 --- a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java +++ b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java @@ -45,7 +45,7 @@ public class PollenUIUrlRenderServiceTest extends AbstractPollenServiceTest { url = service.getPollenUrl(); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl(), url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint().toString(), url); } @Test @@ -54,11 +54,11 @@ public class PollenUIUrlRenderServiceTest extends AbstractPollenServiceTest { url = service.getPollEditUrl("PollId", null); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/poll/edit/PollId", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/poll/edit/PollId", url); url = service.getPollEditUrl("PollId", "Token"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/poll/edit/PollId/Token", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/poll/edit/PollId/Token", url); } @Test @@ -67,11 +67,11 @@ public class PollenUIUrlRenderServiceTest extends AbstractPollenServiceTest { url = service.getPollVoteUrl("PollId", null); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/poll/vote/PollId", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/poll/vote/PollId", url); url = service.getPollVoteUrl("PollId", "Token"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/poll/vote/PollId/Token", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/poll/vote/PollId/Token", url); } @Test @@ -80,11 +80,11 @@ public class PollenUIUrlRenderServiceTest extends AbstractPollenServiceTest { url = service.getPollVoteEditUrl("PollId", null, "VoteToken"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/poll/vote/PollId/vote/VoteToken", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/poll/vote/PollId/vote/VoteToken", url); url = service.getPollVoteEditUrl("PollId", "Token", "VoteToken"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/poll/vote/PollId/Token/vote/VoteToken", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/poll/vote/PollId/Token/vote/VoteToken", url); } @Test @@ -94,7 +94,7 @@ public class PollenUIUrlRenderServiceTest extends AbstractPollenServiceTest { url = service.getUserValidateUrl("UserId", "Token"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServiceConfig().getPollenUrl() + "#/user/UserId/Token", url); + Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#/user/UserId/Token", url); } } diff --git a/pom.xml b/pom.xml index 3c06669..3223038 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,8 @@ #L% --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -204,7 +205,7 @@ <!--Site configuration --> <locales>en,fr</locales> <siteSourcesType>rst</siteSourcesType> - + <ciViewId>Pollen</ciViewId> <javaVersion>1.8</javaVersion> <signatureArtifactId>java18</signatureArtifactId> @@ -706,7 +707,11 @@ <artifactId>i18n-maven-plugin</artifactId> <version>${nuitonI18nVersion}</version> </plugin> - + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-config-maven-plugin</artifactId> + <version>${nuitonConfigVersion}</version> + </plugin> <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> <version>${projectInfoReportsPluginVersion}</version> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.