dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15922
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5884: Validation of period identifier in save value action in data entry
------------------------------------------------------------
revno: 5884
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-02-08 12:51:34 +0100
message:
Validation of period identifier in save value action in data entry
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.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-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java 2012-02-08 11:51:34 +0000
@@ -29,6 +29,8 @@
import java.util.Date;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -49,6 +51,8 @@
public class SaveValueAction
implements Action
{
+ private static final Log log = LogFactory.getLog( SaveValueAction.class );
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -144,10 +148,15 @@
public String execute()
{
+ Period period = PeriodType.createPeriodExternalId( periodId );
+
+ if ( period == null )
+ {
+ return logError( "Illegal period identifier: " + periodId );
+ }
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
- Period period = PeriodType.createPeriodExternalId( periodId );
-
DataElement dataElement = dataElementService.getDataElement( dataElementId );
String storedBy = currentUserService.getCurrentUsername();
@@ -195,4 +204,17 @@
return SUCCESS;
}
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private String logError( String message )
+ {
+ log.info( message );
+
+ statusCode = 1;
+
+ return SUCCESS;
+ }
}