← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16646: User account invite, separate service method for validation

 

------------------------------------------------------------
revno: 16646
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-09-07 23:44:30 -0400
message:
  User account invite, separate service method for validation
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java	2014-09-08 03:44:30 +0000
@@ -145,9 +145,9 @@
         return true;
     }
 
-    public boolean sendRestoreMessage( UserCredentials credentials, String rootPath, RestoreOptions restoreOptions )
+    public boolean validateRestore( UserCredentials credentials, RestoreOptions restoreOptions )
     {
-        if ( credentials == null || rootPath == null )
+        if ( credentials == null || restoreOptions == null )
         {
             return false;
         }
@@ -174,7 +174,24 @@
 
         if ( credentials.hasAnyAuthority( Arrays.asList( UserAuthorityGroup.CRITICAL_AUTHS ) ) )
         {
-            log.info( "Not allowed to  " + restoreType.name() + " users with critical authorities" );
+            log.info( "Not allowed to " + restoreType.name() + " users with critical authorities" );
+            return false;
+        }
+
+        return true;
+    }
+    
+    public boolean sendRestoreMessage( UserCredentials credentials, String rootPath, RestoreOptions restoreOptions )
+    {
+        if ( credentials == null || rootPath == null || restoreOptions == null )
+        {
+            return false;
+        }
+
+        RestoreType restoreType = restoreOptions.getRestoreType();
+
+        if ( validateRestore( credentials, restoreOptions ) == false )
+        {
             return false;
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java	2014-05-24 18:16:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java	2014-09-08 03:44:30 +0000
@@ -45,6 +45,14 @@
      * @return true if the invitation was sent, otherwise false.
      */
     boolean prepareUserForInvite( User user );
+    
+    /**
+     * Validates whether a restore is allowed.
+     * 
+     * @param credentials the credentials for the user to send restore message.
+     * @param restoreOptions restore options, including type of restore.
+     */
+    boolean validateRestore( UserCredentials credentials, RestoreOptions restoreOptions );
 
     /**
      * Invokes the initRestore method and dispatches email messages with