← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12356: minor fixes

 

------------------------------------------------------------
revno: 12356
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-01 11:57:01 +0200
message:
  minor fixes
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.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-api/src/main/java/org/hisp/dhis/common/SharingUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java	2013-09-18 13:26:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java	2013-10-01 09:57:01 +0000
@@ -216,7 +216,7 @@
             || (object.getUser() == null && canCreatePublic( user, object ) && PRIVATE_AUTHORITIES.get( object.getClass() ) != null)
             || user.equals( object.getUser() )
             //|| authorities.contains( PRIVATE_AUTHORITIES.get( object.getClass() ) )
-            || ( (object instanceof User) && canCreatePrivate( user, object ) )
+            || ((object instanceof User) && canCreatePrivate( user, object ))
             || AccessStringHelper.canWrite( object.getPublicAccess() ) )
         {
             return true;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2013-09-18 13:26:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2013-10-01 09:57:01 +0000
@@ -28,11 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseIdentifiableObject;
@@ -44,12 +45,10 @@
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * @author Nguyen Hong Duc

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java	2013-10-01 09:45:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java	2013-10-01 09:57:01 +0000
@@ -28,11 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObjectUtils;
@@ -41,19 +42,17 @@
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataset.DataSet;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * @author Nguyen Hong Duc
  */
-@JacksonXmlRootElement( localName = "userCredentials", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement(localName = "userCredentials", namespace = DxfNamespaces.DXF_2_0)
 public class UserCredentials
-        extends BaseIdentifiableObject
+    extends BaseIdentifiableObject
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
@@ -85,7 +84,7 @@
      * Date of the user's last login.
      */
     private Date lastLogin;
-    
+
     /**
      * The token used for a user account restore. Will be stored as a hash.
      */
@@ -95,23 +94,23 @@
      * The code used for a user account restore. Will be stored as a hash.
      */
     private String restoreCode;
-    
+
     /**
      * The timestamp representing when the restore window expires.
      */
     private Date restoreExpiry;
-    
+
     /**
      * Indicates whether this user was originally self registered.
      */
     private boolean selfRegistered;
-    
+
     /**
      * Indicates whether this is user is disabled, which means the user cannot
      * be authenticated.
      */
     private boolean disabled;
-    
+
     /**
      * The date this credentials was created.
      */
@@ -126,7 +125,7 @@
         this.lastLogin = new Date();
         this.created = new Date();
     }
-    
+
     // -------------------------------------------------------------------------
     // Logic
     // -------------------------------------------------------------------------
@@ -139,7 +138,7 @@
     {
         return IdentifiableObjectUtils.join( userAuthorityGroups );
     }
-    
+
     /**
      * Returns a set of the aggregated authorities for all user authority groups
      * of this user credentials.
@@ -155,11 +154,11 @@
 
         return authorities;
     }
-    
+
     /**
      * Tests whether this user credentials has any of the authorities in the
      * given set.
-     * 
+     *
      * @param auths the authorities to compare with.
      * @return true or false.
      */
@@ -229,12 +228,12 @@
 
         return !userAuthorityGroups.contains( group ) && authorities.containsAll( group.getAuthorities() );
     }
-    
+
     /**
-     * Indicates whether this user credentials can modify the given user 
+     * Indicates whether this user credentials can modify the given user
      * credentials. This user credentials must have the ALL authority or possess
      * all user authorities of the other user credentials to do so.
-     * 
+     *
      * @param other the user credentials to modify.
      */
     public boolean canModify( UserCredentials other )
@@ -243,14 +242,14 @@
         {
             return false;
         }
-        
+
         final Set<String> authorities = getAllAuthorities();
 
         if ( authorities.contains( UserAuthorityGroup.AUTHORITY_ALL ) )
         {
             return true;
-        }      
-        
+        }
+
         return authorities.containsAll( other.getAllAuthorities() );
     }
 
@@ -297,10 +296,10 @@
      * if the expiry date arguement is after the expiry date of the credentials.
      * Returns false if any of the given token or code arguments are not equal to
      * the respective properties the the credentials. Returns true otherwise.
-     * 
-     * @param token the restore token.
-     * @param code the restore code.
-     * @param expiry the expiry date.
+     *
+     * @param token  the restore token.
+     * @param code   the restore code.
+     * @param date the expiry date.
      * @return true or false.
      */
     public boolean canRestore( String token, String code, Date date )
@@ -309,20 +308,20 @@
         {
             return false;
         }
-        
+
         if ( token == null || code == null || date == null )
         {
             return false;
         }
-        
+
         if ( date.after( this.restoreExpiry ) )
         {
             return false;
         }
-        
+
         return token.equals( this.restoreToken ) && code.equals( this.restoreCode );
     }
-    
+
     // -------------------------------------------------------------------------
     // hashCode and equals
     // -------------------------------------------------------------------------
@@ -397,10 +396,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "userAuthorityGroups", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "userAuthorityGroup", namespace = DxfNamespaces.DXF_2_0)
+    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlElementWrapper(localName = "userAuthorityGroups", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "userAuthorityGroup", namespace = DxfNamespaces.DXF_2_0)
     public Set<UserAuthorityGroup> getUserAuthorityGroups()
     {
         return userAuthorityGroups;
@@ -412,8 +411,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public String getUsername()
     {
         return username;
@@ -425,8 +424,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public Date getLastLogin()
     {
         return lastLogin;
@@ -468,8 +467,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isSelfRegistered()
     {
         return selfRegistered;
@@ -481,8 +480,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isDisabled()
     {
         return disabled;

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2013-09-18 13:26:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2013-10-01 09:57:01 +0000
@@ -112,7 +112,7 @@
     @Autowired
     private SessionFactory sessionFactory;
 
-    @Autowired(required = false)
+    @Autowired( required = false )
     private List<ObjectHandler<T>> objectHandlers;
 
     //-------------------------------------------------------------------------------------------------------
@@ -398,7 +398,7 @@
                 new ImportConflict( ImportUtils.getDisplayName( object ), "You do not have create access to class type." ) );
 
             log.warn( "You do have create access to class type." );
-            
+
             return false;
         }
 
@@ -411,8 +411,9 @@
         nonIdentifiableObjects.extract( object );
 
         UserCredentials userCredentials = null;
-        if (object instanceof User) {
-            userCredentials = ((User)object).getUserCredentials();
+        if ( object instanceof User )
+        {
+            userCredentials = ((User) object).getUserCredentials();
         }
 
         Map<Field, Object> fields = detachFields( object );
@@ -428,21 +429,22 @@
 
         objectBridge.updateObject( object );
 
-        if (object instanceof User) {
-            userCredentials.setUser((User)object);
-            userCredentials.setId( ((User)object).getId());
+        if ( object instanceof User )
+        {
+            userCredentials.setUser( (User) object );
+            userCredentials.setId( ((User) object).getId() );
 
             Map<Field, Collection<Object>> collectionFieldsUserCredentials = detachCollectionFields( userCredentials );
 
-            sessionFactory.getCurrentSession().save(userCredentials);
+            sessionFactory.getCurrentSession().save( userCredentials );
 
             reattachCollectionFields( userCredentials, collectionFieldsUserCredentials );
 
-            sessionFactory.getCurrentSession().saveOrUpdate(userCredentials);
-
-            ((User) object).setUserCredentials(userCredentials);
-
-            objectBridge.updateObject( (User)object );
+            sessionFactory.getCurrentSession().saveOrUpdate( userCredentials );
+
+            ((User) object).setUserCredentials( userCredentials );
+
+            objectBridge.updateObject( (User) object );
         }
 
         if ( !options.isDryRun() )
@@ -486,8 +488,9 @@
         nonIdentifiableObjects.delete( persistedObject );
 
         UserCredentials userCredentials = null;
-        if (object instanceof User) {
-            userCredentials = ((User)object).getUserCredentials();
+        if ( object instanceof User )
+        {
+            userCredentials = ((User) object).getUserCredentials();
         }
 
         Map<Field, Object> fields = detachFields( object );
@@ -505,13 +508,12 @@
 
         objectBridge.updateObject( persistedObject );
 
-        if (object instanceof User) {
-
+        if ( object instanceof User )
+        {
             Map<Field, Collection<Object>> collectionFieldsUserCredentials = detachCollectionFields( userCredentials );
 
-            reattachCollectionFields( ((User)persistedObject).getUserCredentials(), collectionFieldsUserCredentials );
-            sessionFactory.getCurrentSession().saveOrUpdate(((User)persistedObject).getUserCredentials());
-
+            reattachCollectionFields( ((User) persistedObject).getUserCredentials(), collectionFieldsUserCredentials );
+            sessionFactory.getCurrentSession().saveOrUpdate( ((User) persistedObject).getUserCredentials() );
         }
 
         if ( !options.isDryRun() )