diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm
index 646aca77b..b6131856e 100644
--- a/api-docs/apiLive.htm
+++ b/api-docs/apiLive.htm
@@ -10225,9 +10225,17 @@ GET https://DomainName/api/v1/configurations
{
"globalConfiguration": [
{
- "name": "maker-checker",
- "enabled": false
- }
+ "name": "maker-checker",
+ "enabled": true,
+ "value": 0,
+ "id": 1
+ },
+ {
+ "name": "amazon-S3",
+ "enabled": false,
+ "value": 0,
+ "id": 2
+ },
]
}
@@ -10242,22 +10250,24 @@ GET https://DomainName/api/v1/configurations
-PUT https://DomainName/api/v1/configurations?maker-checker=false
+PUT https://DomainName/api/v1/configurations/9
PUT configurations
Content-Type: application/json
-Request Body: { }
+Request Body: {
+ "enabled":"true",
+ "value":2
+
+ }
{
- "changes": {
- "globalConfiguration": {
- "maker-checker": false
+ "resourceId": 9,
+ "changes": {
+ "enabled": true
}
- }
-}
-
+}
diff --git a/mifosng-db/migrations/core_db/V145__add_force_password_reset_in_c_configuration.sql b/mifosng-db/migrations/core_db/V145__add_force_password_reset_in_c_configuration.sql
new file mode 100644
index 000000000..0b38dd918
--- /dev/null
+++ b/mifosng-db/migrations/core_db/V145__add_force_password_reset_in_c_configuration.sql
@@ -0,0 +1,17 @@
+INSERT INTO `c_configuration` (`id`, `name`, `value`, `enabled`) VALUES (NULL, 'force-password-reset-days', '0', '0');
+
+ALTER TABLE `m_appuser` ADD `last_time_password_updated` DATE NOT NULL ,
+ADD INDEX ( `last_time_password_updated` ) ;
+
+UPDATE `m_appuser` SET `last_time_password_updated` = NOW() WHERE `m_appuser`.`last_time_password_updated` ='0000-00-00';
+
+CREATE TABLE IF NOT EXISTS `m_appuser_previews_passwords` (
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `user_id` bigint(20) NOT NULL,
+ `password` varchar(255) NOT NULL,
+ `removal_date` date NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+ALTER TABLE m_appuser_previews_passwords
+ADD FOREIGN KEY (user_id) REFERENCES m_appuser(id);
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
index 535ad77c8..1e1aa0127 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
@@ -54,11 +54,12 @@ public class CommandWrapperBuilder {
return this;
}
- public CommandWrapperBuilder updateGlobalConfiguration() {
+ public CommandWrapperBuilder updateGlobalConfiguration(final Long configId) {
this.actionName = "UPDATE";
this.entityName = "CONFIGURATION";
- this.entityId = null;
- this.href = "/configurations";
+ this.entityId = configId;
+
+ this.href = "/configurations/"+configId;
return this;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java
index e506b75f4..ccb64d6d6 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java
@@ -47,7 +47,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
boolean isApprovedByChecker = false;
// check if is update of own account details
- if (wrapper.isUpdateOfOwnUserDetails(this.context.authenticatedUser().getId())) {
+ if (wrapper.isUpdateOfOwnUserDetails(this.context.authenticatedUser(wrapper).getId())) {
// then allow this operation to proceed.
// maker checker doesnt mean anything here.
isApprovedByChecker = true; // set to true in case permissions have
@@ -56,7 +56,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
} else {
// if not user changing their own details - check user has
// permission to perform specific task.
- this.context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
+ this.context.authenticatedUser(wrapper).validateHasPermissionTo(wrapper.getTaskPermissionName());
}
validateIsUpdateAllowed();
@@ -72,6 +72,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
} catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
+
result = this.processAndLogCommandService.logCommand(e.getCommandSourceResult());
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
index bbfbd0f8c..4dc7901bf 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
@@ -59,7 +59,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
final NewCommandSourceHandler handler = findCommandHandler(wrapper);
final CommandProcessingResult result = handler.processCommand(command);
- final AppUser maker = this.context.authenticatedUser();
+ final AppUser maker = this.context.authenticatedUser(wrapper);
CommandSource commandSourceResult = null;
if (command.commandId() != null) {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiConstant.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiConstant.java
new file mode 100644
index 000000000..e24f32293
--- /dev/null
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiConstant.java
@@ -0,0 +1,22 @@
+package org.mifosplatform.infrastructure.configuration.api;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Created by Cieyou on 1/16/14.
+ */
+public class GlobalConfigurationApiConstant {
+
+
+ public static final String enabled = "enabled";
+ public static final String value = "value";
+ public static final String id ="id";
+ public static final String CONFIGURATION_RESOURCE_NAME = "globalConfiguration";
+
+
+ public static final Set UPDATE_CONFIGURATION_DATA_PARAMETERS = new HashSet(Arrays.asList(enabled,
+ value));
+
+}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiResource.java
index a98929123..8a644935d 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/GlobalConfigurationApiResource.java
@@ -11,12 +11,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
+import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
@@ -76,25 +73,21 @@ public class GlobalConfigurationApiResource {
return this.toApiJsonSerializer.serialize(settings, configurationData, this.RESPONSE_DATA_PARAMETERS);
}
+
@PUT
+ @Path("{configId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
- public String updateConfiguration(@Context final UriInfo uriInfo) {
+ public String updateConfiguration(@PathParam("configId") final Long configId,final String apiRequestBodyAsJson) {
- final Map configurationParameters = ApiParameterHelper.asMap(uriInfo.getQueryParameters());
-
- final Map globalConfiguration = new HashMap();
- globalConfiguration.put("globalConfiguration", configurationParameters);
-
- final String apiRequestJson = this.toApiJsonSerializer.serialize(globalConfiguration);
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
- .updateGlobalConfiguration() //
- .withJson(apiRequestJson) //
+ .updateGlobalConfiguration(configId) //
+ .withJson(apiRequestBodyAsJson) //
.build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result);
- }
+ }
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/data/GlobalConfigurationDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/data/GlobalConfigurationDataValidator.java
new file mode 100644
index 000000000..b02cd0878
--- /dev/null
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/data/GlobalConfigurationDataValidator.java
@@ -0,0 +1,67 @@
+package org.mifosplatform.infrastructure.configuration.data;
+
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.lang.StringUtils;
+import org.joda.time.LocalDate;
+import org.mifosplatform.infrastructure.core.api.JsonCommand;
+import org.mifosplatform.infrastructure.core.data.ApiParameterError;
+import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
+import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
+import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static org.mifosplatform.infrastructure.configuration.api.GlobalConfigurationApiConstant.*;
+import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by Cieyou on 1/16/14.
+ */
+@Component
+public class GlobalConfigurationDataValidator {
+
+ private final FromJsonHelper fromApiJsonHelper;
+
+ @Autowired
+ public GlobalConfigurationDataValidator(final FromJsonHelper fromApiJsonHelper) {
+ this.fromApiJsonHelper = fromApiJsonHelper;
+ }
+
+ public void validateForUpdate(final JsonCommand command) {
+ final String json = command.json();
+ if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
+
+ final Type typeOfMap = new TypeToken