dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20539
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9408: minor fixes
------------------------------------------------------------
revno: 9408
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-12-27 22:07:09 +0100
message:
minor fixes
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AccessHelper.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.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/AccessHelper.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AccessHelper.java 2012-12-27 19:01:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AccessHelper.java 2012-12-27 21:07:09 +0000
@@ -75,18 +75,32 @@
this.access = access.toCharArray();
}
- public void enable( Permission permission )
+ public static AccessHelper newInstance()
+ {
+ return new AccessHelper();
+ }
+
+ public AccessHelper enable( Permission permission )
{
access[permission.getPosition()] = permission.getValue();
+
+ return this;
}
- public void disable( Permission permission )
+ public AccessHelper disable( Permission permission )
{
access[permission.getPosition()] = '-';
+
+ return this;
+ }
+
+ public String build()
+ {
+ return new String( access );
}
public String toString()
{
- return access.toString();
+ return build();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2012-12-27 14:07:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2012-12-27 21:07:09 +0000
@@ -44,6 +44,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -103,7 +104,7 @@
/**
* Access for userGroups
*/
- protected Set<UserGroupAccess> userGroupAccesses;
+ protected Set<UserGroupAccess> userGroupAccesses = new HashSet<UserGroupAccess>();
/**
* The i18n variant of the name. Should not be persisted.
@@ -225,8 +226,8 @@
@Override
@JsonProperty
- @JsonView( { DetailedView.class, BasicView.class, ExportView.class } )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ @JsonView({ DetailedView.class, BasicView.class, ExportView.class })
+ @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
public String getPublicAccess()
{
return publicAccess;
@@ -239,9 +240,9 @@
@Override
@JsonProperty
- @JsonSerialize( as = BaseIdentifiableObject.class )
- @JsonView( { BasicView.class, DetailedView.class, ExportView.class } )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ @JsonSerialize(as = BaseIdentifiableObject.class)
+ @JsonView({ BasicView.class, DetailedView.class, ExportView.class })
+ @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
public User getUser()
{
return user;
@@ -253,9 +254,9 @@
}
@JsonProperty
- @JsonView( { BasicView.class, DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "userGroupAccesses", namespace = Dxf2Namespace.NAMESPACE )
- @JacksonXmlProperty( localName = "userGroupAccess", namespace = Dxf2Namespace.NAMESPACE )
+ @JsonView({ BasicView.class, DetailedView.class, ExportView.class })
+ @JacksonXmlElementWrapper(localName = "userGroupAccesses", namespace = Dxf2Namespace.NAMESPACE)
+ @JacksonXmlProperty(localName = "userGroupAccess", namespace = Dxf2Namespace.NAMESPACE)
public Set<UserGroupAccess> getUserGroupAccesses()
{
return userGroupAccesses;
@@ -335,8 +336,19 @@
setUid( CodeGenerator.generateCode() );
}
+ if ( user == null && publicAccess == null && userGroupAccesses.isEmpty() )
+ {
+ publicAccess = AccessHelper.newInstance().enable( AccessHelper.Permission.READ )
+ .enable( AccessHelper.Permission.WRITE ).build();
+ }
+
Date date = new Date();
+ if ( created == null )
+ {
+ created = date;
+ }
+
setLastUpdated( date );
}