dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15560
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5661: (mobile) added param validation
------------------------------------------------------------
revno: 5661
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-01-04 13:55:23 +0100
message:
(mobile) added param validation
modified:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/GetSettingsAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/SaveSettingsFormAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectOrganisationUnit.vm
--
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-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/GetSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/GetSettingsAction.java 2012-01-04 11:36:32 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/GetSettingsAction.java 2012-01-04 12:55:23 +0000
@@ -28,6 +28,7 @@
package org.hisp.dhis.light.action.settings.action;
import com.opensymphony.xwork2.Action;
+import org.apache.commons.lang.Validate;
import org.hisp.dhis.i18n.I18nService;
import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.i18n.resourcebundle.ResourceBundleManager;
@@ -169,6 +170,7 @@
// ---------------------------------------------------------------------
User user = currentUserService.getCurrentUser();
+ Validate.notNull( user );
firstName = user.getFirstName();
surname = user.getSurname();
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/SaveSettingsFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/SaveSettingsFormAction.java 2012-01-04 11:37:46 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/settings/action/SaveSettingsFormAction.java 2012-01-04 12:55:23 +0000
@@ -146,9 +146,9 @@
@Override
public String execute()
{
- Validate.notEmpty( currentLocale );
- Validate.notEmpty( firstName );
- Validate.notEmpty( surname );
+ Validate.notNull( currentLocale );
+ Validate.notNull( firstName );
+ Validate.notNull( surname );
// ---------------------------------------------------------------------
// Update user account settings
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java 2011-12-27 12:16:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java 2012-01-04 12:55:23 +0000
@@ -28,6 +28,7 @@
package org.hisp.dhis.light.dataentry.action;
import com.opensymphony.xwork2.Action;
+import org.apache.commons.lang.Validate;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
import org.hisp.dhis.dataset.DataSet;
@@ -185,6 +186,10 @@
@Override
public String execute()
{
+ Validate.notNull( organisationUnitId );
+ Validate.notNull( periodId );
+ Validate.notNull( dataSetId );
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
Period period = periodService.getPeriodByExternalId( periodId );
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java 2011-12-09 21:21:03 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java 2012-01-04 12:55:23 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.Validate;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -94,18 +95,17 @@
@Override
public String execute()
{
- if ( organisationUnitId != null )
+ Validate.notNull( organisationUnitId );
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
+
+ UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials();
+
+ if ( !userCredentials.isSuper() )
{
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
- dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
-
- UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials();
-
- if ( !userCredentials.isSuper() )
- {
- dataSets.retainAll( userCredentials.getAllDataSets() );
- }
+ dataSets.retainAll( userCredentials.getAllDataSets() );
}
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java 2011-11-01 18:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java 2012-01-04 12:55:23 +0000
@@ -27,17 +27,17 @@
package org.hisp.dhis.light.dataentry.action;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
+import org.apache.commons.lang.Validate;
import org.hisp.dhis.light.dataentry.utils.FormUtils;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
* @author mortenoh
@@ -67,7 +67,7 @@
{
return formUtils;
}
-
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -87,12 +87,10 @@
public String execute()
{
User user = currentUserService.getCurrentUser();
+ Validate.notNull( user );
- if ( user != null )
- {
- organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
- Collections.sort( organisationUnits, new OrganisationUnitNameComparator() );
- }
+ organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
+ Collections.sort( organisationUnits, new OrganisationUnitNameComparator() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java 2011-11-01 15:01:22 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java 2012-01-04 12:55:23 +0000
@@ -33,6 +33,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang.Validate;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
import org.hisp.dhis.dataset.DataSet;
@@ -172,30 +173,31 @@
@Override
public String execute()
{
- if ( dataSetId != null )
- {
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
- dataSet = dataSetService.getDataSet( dataSetId );
- CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType();
- periods = periodType.generateLast5Years( new Date() );
- FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
- Collections.reverse( periods );
-
- if ( periods.size() > MAX_PERIODS )
- {
- periods = periods.subList( 0, MAX_PERIODS );
- }
-
- for ( Period period : periods )
- {
- period.setName( format.formatPeriod( period ) );
-
- CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet,
- period, organisationUnit );
-
- periodCompletedMap.put( period, registration != null ? true : false );
- }
+ Validate.notNull( organisationUnitId );
+ Validate.notNull( dataSetId );
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ dataSet = dataSetService.getDataSet( dataSetId );
+
+ CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType();
+ periods = periodType.generateLast5Years( new Date() );
+ FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+ Collections.reverse( periods );
+
+ if ( periods.size() > MAX_PERIODS )
+ {
+ periods = periods.subList( 0, MAX_PERIODS );
+ }
+
+ for ( Period period : periods )
+ {
+ period.setName( format.formatPeriod( period ) );
+
+ CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet,
+ period, organisationUnit );
+
+ periodCompletedMap.put( period, registration != null ? true : false );
}
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java 2011-12-27 13:06:26 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java 2012-01-04 12:55:23 +0000
@@ -28,6 +28,7 @@
package org.hisp.dhis.light.dataentry.action;
import com.opensymphony.xwork2.Action;
+import org.apache.commons.lang.Validate;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementOperand;
@@ -202,6 +203,10 @@
@Override
public String execute()
{
+ Validate.notNull( organisationUnitId );
+ Validate.notNull( periodId );
+ Validate.notNull( dataSetId );
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
Period period = periodService.getPeriodByExternalId( periodId );
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2011-12-29 10:40:04 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2012-01-04 12:55:23 +0000
@@ -29,6 +29,8 @@
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.Validate;
import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataelement.DataElement;
@@ -261,6 +263,10 @@
@Override
public String execute()
{
+ Validate.notNull( organisationUnitId );
+ Validate.notNull( periodId );
+ Validate.notNull( dataSetId );
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
Period period = periodService.getPeriodByExternalId( periodId );
@@ -271,7 +277,7 @@
dataSet = dataSetService.getDataSet( dataSetId );
- if ( storedBy == null )
+ if ( StringUtils.isNotBlank( storedBy ) )
{
storedBy = "[unknown]";
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectOrganisationUnit.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectOrganisationUnit.vm 2011-11-01 18:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectOrganisationUnit.vm 2012-01-04 12:55:23 +0000
@@ -7,7 +7,7 @@
#if( $organisationUnit.children.size() == 0 && $organisationUnit.dataSets.size() > 0 )
<li><a href="selectDataSet.action?organisationUnitId=$organisationUnit.id">$!encoder.htmlEncode( ${organisationUnit.name} )</a></li>
#else
- #if( $organisationUnit.children.size() > 0 )
+ #if( $organisationUnit.children.size() > 0 )
#set( $children = $formUtils.organisationUnitWithDataSetsFilter( $organisationUnit.children ) )
#if( $organisationUnit.dataSets.size() > 0 )