=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java 2015-06-11 21:37:27 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java 2015-06-16 18:30:37 +0000 @@ -32,6 +32,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; + import org.hisp.dhis.period.BiMonthlyPeriodType; import org.hisp.dhis.period.DailyPeriodType; import org.hisp.dhis.period.FinancialAprilPeriodType; @@ -45,7 +46,6 @@ import org.hisp.dhis.period.SixMonthlyPeriodType; import org.hisp.dhis.period.WeeklyPeriodType; import org.hisp.dhis.period.YearlyPeriodType; -import org.hisp.dhis.system.util.DateUtils; /** * ADXPeriod @@ -56,7 +56,6 @@ */ public class ADXPeriod { - public static class ADXPeriodException extends RuntimeException { @@ -68,7 +67,6 @@ public static enum Duration { - P1D, // daily P7D, // weekly P1M, // monthly @@ -83,6 +81,7 @@ public static Period parse( String periodString ) throws ADXPeriodException { String[] tokens = periodString.split( "/" ); + if ( tokens.length != 2 ) { throw new ADXPeriodException( periodString + " not in valid / format" ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2015-06-16 18:30:37 +0000 @@ -29,9 +29,9 @@ */ import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdentifiers; +import static org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString; import static org.hisp.dhis.system.util.DateUtils.getLongGmtDateString; import static org.hisp.dhis.system.util.DateUtils.getMediumDateString; -import static org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString; import java.io.OutputStream; import java.io.Writer; @@ -42,6 +42,7 @@ import java.util.Set; import org.amplecode.staxwax.factory.XMLFactory; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.calendar.Calendar; @@ -51,7 +52,6 @@ import org.hisp.dhis.dxf2.datavalue.DataValue; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.util.DateUtils; -import org.hisp.dhis.commons.util.StreamUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowCallbackHandler; @@ -82,7 +82,7 @@ writeDataValueSet( getDataValueSql( params ), params, completeDate, dataValueSet ); - StreamUtils.closeOutputStream( out ); + IOUtils.closeQuietly( out ); } @Override @@ -92,7 +92,7 @@ writeDataValueSet( getDataValueSql( params ), params, completeDate, dataValueSet ); - StreamUtils.closeOutputStream( out ); + IOUtils.closeQuietly( out ); } @Override @@ -102,7 +102,7 @@ writeDataValueSet( getDataValueSql( params ), params, completeDate, dataValueSet ); - StreamUtils.closeWriter( writer ); + IOUtils.closeQuietly( writer ); } @Override === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2015-06-16 18:30:37 +0000 @@ -39,6 +39,7 @@ import org.amplecode.staxwax.factory.XMLFactory; import org.amplecode.staxwax.reader.XMLReader; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.common.ProcessState; @@ -102,7 +103,7 @@ BufferedOutputStream ostream = new BufferedOutputStream( new FileOutputStream( tempZipFile ) ); // Save it to disk - StreamUtils.streamcopy( bufin, ostream ); + IOUtils.copy( bufin, ostream ); bufin.close(); === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportPipeThread.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportPipeThread.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportPipeThread.java 2015-06-16 18:30:37 +0000 @@ -33,6 +33,7 @@ import java.util.zip.ZipOutputStream; import org.amplecode.staxwax.writer.XMLWriter; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.SessionFactory; @@ -193,7 +194,7 @@ { writer.closeWriter(); - StreamUtils.closeOutputStream( zipOutputStream ); + IOUtils.closeQuietly( zipOutputStream ); NameMappingUtil.clearMapping(); } === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java 2015-06-16 18:30:37 +0000 @@ -38,11 +38,12 @@ import org.amplecode.quick.BatchHandlerFactory; import org.amplecode.staxwax.factory.XMLFactory; import org.amplecode.staxwax.reader.XMLReader; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.hisp.dhis.cache.HibernateCacheManager; import org.hisp.dhis.common.ProcessState; +import org.hisp.dhis.commons.util.StreamUtils; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.dataelement.DataElementService; @@ -74,7 +75,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.system.process.OutputHolderState; -import org.hisp.dhis.commons.util.StreamUtils; /** @@ -313,7 +313,7 @@ state.setOutput( importAnalyser.getImportAnalysis() ); } - StreamUtils.closeInputStream( zipIn ); + IOUtils.closeQuietly( zipIn ); NameMappingUtil.clearMapping(); === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xls/exporter/XLSExportPipeThread.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xls/exporter/XLSExportPipeThread.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xls/exporter/XLSExportPipeThread.java 2015-06-16 18:30:37 +0000 @@ -32,6 +32,7 @@ import jxl.write.WritableWorkbook; +import org.apache.commons.io.IOUtils; import org.hibernate.SessionFactory; import org.hisp.dhis.importexport.ExportParams; import org.hisp.dhis.importexport.XLSConverter; @@ -125,7 +126,7 @@ finally { StreamUtils.closeZipEntry( outputStream ); - StreamUtils.closeOutputStream( outputStream ); + IOUtils.closeQuietly( outputStream ); } } } === modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/StreamUtils.java' --- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/StreamUtils.java 2015-06-16 17:57:23 +0000 +++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/StreamUtils.java 2015-06-16 18:30:37 +0000 @@ -28,25 +28,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.commons.comparator.FileLastModifiedComparator; - import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.Reader; import java.io.UnsupportedEncodingException; -import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -58,6 +51,8 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import org.hisp.dhis.commons.comparator.FileLastModifiedComparator; + /** * @author Lars Helge Overland */ @@ -67,70 +62,6 @@ public static final String ENCODING_UTF8 = "UTF-8"; /** - * Loads a resorce from the classpath defined by the name parameter. - * - * @param name the name of the resource. - * @return an InputStream. - */ - public static InputStream loadResource( String name ) - { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - - return classLoader.getResourceAsStream( name ); - } - - public static void streamcopy( BufferedInputStream in, BufferedOutputStream out ) - { - int b = 0; - - try - { - while ( (b = in.read()) != -1 ) - { - out.write( b ); - } - } - catch ( IOException ex ) - { - throw new RuntimeException( ex ); - } - finally - { - closeInputStream( in ); - closeOutputStream( out ); - } - } - - /** - * Writes the content of the first File to the second File. - * - * @param inFile the input File. - * @param outFile the output File. - */ - public static void write( File inFile, File outFile ) - { - BufferedInputStream in = null; - BufferedOutputStream out = null; - - try - { - in = new BufferedInputStream( new FileInputStream( inFile ) ); - out = new BufferedOutputStream( new FileOutputStream( outFile ) ); - - streamcopy( in, out ); - } - catch ( IOException ex ) - { - throw new RuntimeException( ex ); - } - finally - { - closeInputStream( in ); - closeOutputStream( out ); - } - } - - /** * Returns all Files in the given directory. * * @param directory a File representing the relevant directory. @@ -208,25 +139,7 @@ throw new RuntimeException( ex ); } } - - /** - * Creates a FileWriter. - * - * @param file the name of the file. - * @return a FileWriter. - */ - public static Writer getFileWriter( String file ) - { - try - { - return new BufferedWriter( new FileWriter( file ) ); - } - catch ( IOException ex ) - { - throw new RuntimeException( ex ); - } - } - + /** * Returns the content of the File as a String. * @@ -327,60 +240,11 @@ } /** - * Closes the given Reader. - * - * @param reader the Reader to close. - */ - public static void closeReader( Reader reader ) - { - if ( reader != null ) - { - try - { - reader.close(); - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - } - } - - /** - * Closes the given Writer. - * - * @param writer the Writer to close. - */ - public static void closeWriter( Writer writer ) - { - if ( writer != null ) - { - try - { - writer.flush(); - } - catch ( IOException ex ) - { - ex.printStackTrace(); - } - - try - { - writer.close(); - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - } - } - - /** * Closes the given InputStream. * * @param in the InputStream to close. */ - public static void closeInputStream( InputStream in ) + private static void closeInputStream( InputStream in ) { if ( in != null ) { @@ -396,35 +260,6 @@ } /** - * Closes and flushes the given OutputStream. - * - * @param out the OutputStream to close. - */ - public static void closeOutputStream( OutputStream out ) - { - if ( out != null ) - { - try - { - out.flush(); - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - - try - { - out.close(); - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - } - } - - /** * Test for ZIP/GZIP stream signature. Wraps the input stream in a * BufferedInputStream. If ZIP/GZIP test is true wraps again in ZipInputStream/GZIPInputStream. * @@ -576,26 +411,4 @@ throw new RuntimeException( "Failed to finish the content of the ZipOutputStream", ex ); } } - - /** - * Attempts to delete the File with the given path. - * - * @param path the File path. - * @return true if the operation succeeded, false otherwise. - */ - public static boolean delete( String path ) - { - return new File( path ).delete(); - } - - /** - * Tests whether the File with the given path exists. - * - * @param path the File path. - * @return true if the File exists, false otherwise. - */ - public static boolean exists( String path ) - { - return new File( path ).exists(); - } } === modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.java' --- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.java 2015-06-16 18:30:37 +0000 @@ -369,20 +369,7 @@ return null; } - - /** - * Returns null if the given string is not null and contains no characters, - * the string itself otherwise. - * - * @param string the string. - * @return null if the given string is not null and contains no characters, - * the string itself otherwise. - */ - public static String nullIfEmpty( String string ) - { - return string != null && string.trim().length() == 0 ? null : string; - } - + /** * Checks the two strings for equality. * === removed file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/UUIdUtils.java' --- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/UUIdUtils.java 2015-06-16 17:57:23 +0000 +++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/UUIdUtils.java 1970-01-01 00:00:00 +0000 @@ -1,46 +0,0 @@ -package org.hisp.dhis.commons.util; - -/* - * Copyright (c) 2004-2015, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.UUID; - -/** - * @author Lars Helge Overland - */ -public class UUIdUtils -{ - /** - * Generates a random based universal unique identifier. - * @return a random based universal unique identifier. - */ - public static String getUUId() - { - return UUID.randomUUID().toString().toUpperCase(); - } -} === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java 2015-06-16 18:30:37 +0000 @@ -30,7 +30,6 @@ import static com.lowagie.text.Element.ALIGN_CENTER; import static com.lowagie.text.Element.ALIGN_LEFT; -import static org.hisp.dhis.commons.util.TextUtils.nullIfEmpty; import java.io.OutputStream; import java.util.Calendar; @@ -38,6 +37,7 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.hisp.dhis.attribute.AttributeValue; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.expression.ExpressionService; @@ -391,23 +391,23 @@ table.addCell( getItalicCell( i18n.getString( "short_name" ) ) ); table.addCell( getTextCell( element.getShortName() ) ); - if ( nullIfEmpty( element.getCode() ) != null ) + if ( StringUtils.trimToNull( element.getCode() ) != null ) { table.addCell( getItalicCell( i18n.getString( "code" ) ) ); table.addCell( getTextCell( element.getCode() ) ); } - if ( nullIfEmpty( element.getDescription() ) != null ) + if ( StringUtils.trimToNull( element.getDescription() ) != null ) { table.addCell( getItalicCell( i18n.getString( "description" ) ) ); table.addCell( getTextCell( element.getDescription() ) ); } - if ( nullIfEmpty( element.getType() ) != null ) + if ( StringUtils.trimToNull( element.getType() ) != null ) { table.addCell( getItalicCell( i18n.getString( "value_type" ) ) ); table.addCell( getTextCell( i18n.getString( getType().get( element.getType() ) ) ) ); } - if ( nullIfEmpty( element.getAggregationOperator() ) != null ) + if ( StringUtils.trimToNull( element.getAggregationOperator() ) != null ) { table.addCell( getItalicCell( i18n.getString( "aggregation_operator" ) ) ); table.addCell( getTextCell( i18n.getString( getAggregationOperator().get( element.getAggregationOperator() ) ) ) ); @@ -449,12 +449,12 @@ table.addCell( getItalicCell( i18n.getString( "short_name" ) ) ); table.addCell( getTextCell( indicator.getShortName() ) ); - if ( nullIfEmpty( indicator.getCode() ) != null ) + if ( StringUtils.trimToNull( indicator.getCode() ) != null ) { table.addCell( getItalicCell( i18n.getString( "code" ) ) ); table.addCell( getTextCell( indicator.getCode() ) ); } - if ( nullIfEmpty( indicator.getDescription() ) != null ) + if ( StringUtils.trimToNull( indicator.getDescription() ) != null ) { table.addCell( getItalicCell( i18n.getString( "description" ) ) ); table.addCell( getTextCell( indicator.getDescription() ) ); @@ -514,7 +514,7 @@ table.addCell( getItalicCell( i18n.getString( "short_name" ) ) ); table.addCell( getTextCell( unit.getShortName() ) ); - if ( nullIfEmpty( unit.getCode() ) != null ) + if ( StringUtils.trimToNull( unit.getCode() ) != null ) { table.addCell( getItalicCell( i18n.getString( "code" ) ) ); table.addCell( getTextCell( unit.getCode() ) ); @@ -531,7 +531,7 @@ table.addCell( getItalicCell( i18n.getString( "active" ) ) ); - if ( nullIfEmpty( unit.getComment() ) != null ) + if ( StringUtils.trimToNull( unit.getComment() ) != null ) { table.addCell( getItalicCell( i18n.getString( "comment" ) ) ); table.addCell( getTextCell( unit.getComment() ) ); @@ -572,13 +572,13 @@ table.addCell( getItalicCell( i18n.getString( "username" ) ) ); table.addCell( getTextCell( userCredentials.getUsername() ) ); - if ( nullIfEmpty( user.getEmail() ) != null ) + if ( StringUtils.trimToNull( user.getEmail() ) != null ) { table.addCell( getItalicCell( i18n.getString( "email" ) ) ); table.addCell( getTextCell( user.getEmail() ) ); } - if ( nullIfEmpty( user.getPhoneNumber() ) != null ) + if ( StringUtils.trimToNull( user.getPhoneNumber() ) != null ) { table.addCell( getItalicCell( i18n.getString( "phone_number" ) ) ); table.addCell( getTextCell( user.getPhoneNumber() ) ); @@ -646,7 +646,7 @@ table.addCell( getEmptyCell( 2, 15 ) ); - if ( nullIfEmpty( validationRule.getDescription() ) != null ) + if ( StringUtils.trimToNull( validationRule.getDescription() ) != null ) { table.addCell( getItalicCell( i18n.getString( "description" ) ) ); table.addCell( getTextCell( validationRule.getDescription() ) ); === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java 2015-06-16 18:30:37 +0000 @@ -28,8 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.commons.util.TextUtils.nullIfEmpty; - +import org.apache.commons.lang3.StringUtils; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.user.User; @@ -181,15 +180,15 @@ // Prepare values // --------------------------------------------------------------------- - email = nullIfEmpty( email ); - phoneNumber = nullIfEmpty( phoneNumber ); - introduction = nullIfEmpty( introduction ); - jobTitle = nullIfEmpty( jobTitle ); - nationality = nullIfEmpty( nationality ); - employer = nullIfEmpty( employer ); - education = nullIfEmpty( education ); - interests = nullIfEmpty( interests ); - languages = nullIfEmpty( languages ); + email = StringUtils.trimToNull( email ); + phoneNumber = StringUtils.trimToNull( phoneNumber ); + introduction = StringUtils.trimToNull( introduction ); + jobTitle = StringUtils.trimToNull( jobTitle ); + nationality = StringUtils.trimToNull( nationality ); + employer = StringUtils.trimToNull( employer ); + education = StringUtils.trimToNull( education ); + interests = StringUtils.trimToNull( interests ); + languages = StringUtils.trimToNull( languages ); User user = userService.getUser( id ); === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java 2015-06-16 18:30:37 +0000 @@ -32,10 +32,10 @@ import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.commons.util.StreamUtils; import com.opensymphony.xwork2.Action; @@ -78,7 +78,7 @@ } finally { - StreamUtils.closeOutputStream( out ); + IOUtils.closeQuietly( out ); } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/DataBrowserAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/DataBrowserAction.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/DataBrowserAction.java 2015-06-16 18:30:37 +0000 @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.commons.util.TextUtils.nullIfEmpty; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -38,6 +36,7 @@ import java.util.Map; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.common.Grid; @@ -419,7 +418,7 @@ // Check if the second selected date is later than the first - if ( nullIfEmpty( fromDate ) == null && nullIfEmpty( toDate ) == null ) + if ( StringUtils.trimToNull( fromDate ) == null && StringUtils.trimToNull( toDate ) == null ) { if ( DateUtils.checkDates( fromDate, toDate ) ) { === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java 2015-06-16 18:30:37 +0000 @@ -39,13 +39,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import org.hisp.dhis.importexport.synchronous.ExportPivotViewService; import org.hisp.dhis.importexport.synchronous.ExportPivotViewService.RequestType; import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.commons.util.StreamUtils; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.util.ContextUtils; @@ -256,7 +256,7 @@ } finally { - StreamUtils.closeOutputStream( out ); + IOUtils.closeQuietly( out ); } return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java 2015-06-16 18:30:37 +0000 @@ -35,8 +35,8 @@ import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.commons.util.StreamUtils; import org.hisp.dhis.util.ContextUtils; import org.springframework.core.io.ClassPathResource; @@ -82,7 +82,7 @@ ContextUtils.configureResponse( response, contentType, false, template, true ); - StreamUtils.streamcopy( new BufferedInputStream( new ClassPathResource( template ).getInputStream() ), + IOUtils.copy( new BufferedInputStream( new ClassPathResource( template ).getInputStream() ), new BufferedOutputStream( response.getOutputStream() ) ); }