← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11234: sms-service, code style

 

------------------------------------------------------------
revno: 11234
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-06-19 19:22:47 +0200
message:
  sms-service, code style
modified:
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/SMPPInboundNotification.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DhisMessageAlertParser.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/IParser.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSConsumer.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSParserKeyValue.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/queue/DatabaseSupportedInternalMemoryMessageQueue.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.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-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java	2012-09-14 04:57:46 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java	2013-06-19 17:22:47 +0000
@@ -116,11 +116,12 @@
     @Override
     public SmsGatewayConfig checkInstanceOfGateway( Class<?> clazz )
     {
-        if( getSmsConfiguration() == null)
+        if ( getSmsConfiguration() == null )
         {
             SmsConfiguration smsConfig = new SmsConfiguration( true );
             updateSmsConfiguration( smsConfig );
         }
+        
         for ( SmsGatewayConfig gateway : getSmsConfiguration().getGateways() )
         {
             if ( gateway.getClass().equals( clazz ) )
@@ -128,6 +129,7 @@
                 return gateway;
             }
         }
+        
         return null;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java	2013-05-21 07:01:29 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java	2013-06-19 17:22:47 +0000
@@ -147,8 +147,8 @@
         {
             e.printStackTrace();
         }
+        
         msgList.clear();
-
     }
 
     @Override
@@ -168,7 +168,6 @@
     @Override
     public IncomingSms getNextUnprocessed()
     {
-        // TODO Auto-generated method stub
         return null;
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java	2013-04-04 18:06:19 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java	2013-06-19 17:22:47 +0000
@@ -50,7 +50,6 @@
 
     private SessionFactory sessionFactory;
     
-
     public void setSessionFactory( SessionFactory sessionFactory )
     {
         this.sessionFactory = sessionFactory;
@@ -63,8 +62,7 @@
     @Override
     public int save( IncomingSms sms )
     {
-        return (Integer) sessionFactory.getCurrentSession().save( sms );
-        
+        return (Integer) sessionFactory.getCurrentSession().save( sms );        
     }
 
     @Override
@@ -100,8 +98,7 @@
     }
 
     @Override
-    public long getSmsCount()
-    
+    public long getSmsCount()    
     {
         Session session = sessionFactory.getCurrentSession();
         Criteria criteria = session.createCriteria( IncomingSms.class );
@@ -130,5 +127,4 @@
         criteria.add( Restrictions.eq( "parsed", false ) );
         return criteria.list();
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/SMPPInboundNotification.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/SMPPInboundNotification.java	2013-05-09 17:21:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/SMPPInboundNotification.java	2013-06-19 17:22:47 +0000
@@ -59,7 +59,6 @@
         incomingSms.setStatusMessage( "imported" );
         
         incomingSmsService.save( incomingSms );
-
     }
 
     public void setIncomingSmsService( IncomingSmsService incomingSmsService )

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java	2013-04-04 18:06:19 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java	2013-06-19 17:22:47 +0000
@@ -53,14 +53,14 @@
     {
         this.sessionFactory = sessionFactory;
     }
-    
+
     private JdbcTemplate jdbcTemplate;
 
     public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
     {
         this.jdbcTemplate = jdbcTemplate;
     }
-    
+
     @Override
     public int save( OutboundSms sms )
     {
@@ -74,7 +74,6 @@
         {
             sms.setDate( new Date() );
         }
-
     }
 
     @Override
@@ -91,25 +90,28 @@
         Session session = sessionFactory.getCurrentSession();
         return session.createCriteria( OutboundSms.class ).addOrder( Order.asc( "date" ) ).list();
     }
-    
+
     @Override
     public List<OutboundSms> get( OutboundSmsStatus status )
     {
         int realStatus = 0;
-        
-        if(status.equals( OutboundSmsStatus.OUTBOUND )){
+
+        if ( status.equals( OutboundSmsStatus.OUTBOUND ) )
+        {
             realStatus = OutboundSmsStatus.OUTBOUND.ordinal();
         }
-        else if(status.equals( OutboundSmsStatus.SENT )){
+        else if ( status.equals( OutboundSmsStatus.SENT ) )
+        {
             realStatus = OutboundSmsStatus.SENT.ordinal();
         }
-        else{
+        else
+        {
             realStatus = OutboundSmsStatus.ERROR.ordinal();
         }
-        
+
         String sql = "select osm.id as outboundsmsid, message, ore.elt as phonenumber, date "
-        		+ "from outbound_sms osm inner join outbound_sms_recipients ore " 
-        		+ "on osm.id=ore.outbound_sms_id where status = " + realStatus ;
+            + "from outbound_sms osm inner join outbound_sms_recipients ore "
+            + "on osm.id=ore.outbound_sms_id where status = " + realStatus;
         try
         {
             List<OutboundSms> OutboundSmsList = jdbcTemplate.query( sql, new RowMapper<OutboundSms>()
@@ -118,12 +120,12 @@
                     throws SQLException
                 {
                     OutboundSms outboundSms = new OutboundSms( rs.getString( 2 ), rs.getString( 3 ) );
-                    outboundSms.setId(  rs.getInt( 1 ) );
+                    outboundSms.setId( rs.getInt( 1 ) );
                     outboundSms.setDate( rs.getDate( 4 ) );
                     return outboundSms;
                 }
-            });
-            
+            } );
+
             return OutboundSmsList;
         }
         catch ( Exception ex )
@@ -132,7 +134,7 @@
             return null;
         }
     }
-    
+
     @Override
     public void update( OutboundSms sms )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	2013-05-15 04:10:55 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	2013-06-19 17:22:47 +0000
@@ -158,6 +158,4 @@
             return "Exception sending message " + sms + e.getMessage();
         }
     }
-
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java	2013-06-17 03:27:43 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java	2013-06-19 17:22:47 +0000
@@ -186,19 +186,19 @@
 
     private boolean isQualifiedReceiver( User user )
     {
-        // if receiver is raw number
-        if ( user.getFirstName() == null )
+        if ( user.getFirstName() == null ) // If receiver is raw number
         {
             return true;
-        }
-        // if receiver is user
-        else
+        }        
+        else // If receiver is user
         {
             UserSetting userSetting = userService
                 .getUserSetting( user, UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION );
+            
             if ( userSetting != null )
             {
                 boolean sendSMSNotification = (Boolean) userSetting.getValue();
+                
                 if ( sendSMSNotification == true )
                 {
                     return true;
@@ -235,8 +235,7 @@
 
         text = name + subject + ": " + text;
 
-        // Simplistic cut off 160 characters
-        int length = text.length();
+        int length = text.length(); // Simplistic cut off 160 characters
 
         return (length > 160) ? text.substring( 0, 157 ) + "..." : text;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	2013-05-09 17:21:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	2013-06-19 17:22:47 +0000
@@ -128,41 +128,34 @@
     @Override
     public List<OutboundSms> getAllOutboundSms()
     {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public int saveOutboundSms( OutboundSms sms )
     {
-        // TODO Auto-generated method stub
         return 0;
     }
 
     @Override
     public void updateOutboundSms( OutboundSms sms )
     {
-        // TODO Auto-generated method stub
     }
 
     @Override
     public List<OutboundSms> getOutboundSms( OutboundSmsStatus status )
     {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public void deleteById( Integer outboundSmsId )
     {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public String getDefaultGateway()
     {
-        // TODO Auto-generated method stub
         return null;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java	2013-06-19 16:52:48 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java	2013-06-19 17:22:47 +0000
@@ -92,7 +92,6 @@
 public class DefaultParserManager
     implements ParserManager
 {
-
     public static final String ANONYMOUS_USER_NAME = "Anonymous";
 
     private static final Log log = LogFactory.getLog( DefaultParserManager.class );

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DhisMessageAlertParser.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DhisMessageAlertParser.java	2013-05-20 09:40:29 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DhisMessageAlertParser.java	2013-06-19 17:22:47 +0000
@@ -24,6 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 package org.hisp.dhis.sms.parse;
 
 import java.util.HashMap;
@@ -35,8 +36,7 @@
  * @version DhisMessageAlertParser.java 2:09:49 PM May 17, 2013 $
  */
 public class DhisMessageAlertParser implements IParser
-{
-    
+{    
     @Override
     public Map<String, String> parse( String sms )
     {
@@ -54,5 +54,4 @@
     public void setSeparator( String separator )
     {
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/IParser.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/IParser.java	2013-05-21 07:01:29 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/IParser.java	2013-06-19 17:22:47 +0000
@@ -6,11 +6,6 @@
 
 import java.util.Map;
 
-/**
- * 
- * @author Christian
- */
-
 public interface IParser
 {
     static final String DATA_ENTRY_KEYWORD = "DHISDATAENTRYKEYWORD";

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSConsumer.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSConsumer.java	2013-05-21 07:01:29 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSConsumer.java	2013-06-19 17:22:47 +0000
@@ -40,11 +40,12 @@
 
     private MessageQueue messageQueue;
 
-    SMSConsumerThread thread;
+    private SMSConsumerThread thread;
 
     public void start()
     {
         messageQueue.initialize();
+        
         if ( thread == null )
         {
             thread = new SMSConsumerThread();
@@ -75,9 +76,9 @@
                 {
                     fetchAndParseSMS();
                 }
-                catch ( Exception e )
+                catch ( Exception ex )
                 {
-//                    e.printStackTrace();
+                    //ex.printStackTrace();
                 }
                 try
                 {

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSParserKeyValue.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSParserKeyValue.java	2013-05-09 17:21:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/SMSParserKeyValue.java	2013-06-19 17:22:47 +0000
@@ -26,7 +26,6 @@
     @Override
     public Map<String, String> parse( String sms )
     {
-
         HashMap<String, String> output = new HashMap<String, String>();
 
         Matcher m = pattern.matcher( sms );

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/queue/DatabaseSupportedInternalMemoryMessageQueue.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/queue/DatabaseSupportedInternalMemoryMessageQueue.java	2013-05-09 17:21:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/queue/DatabaseSupportedInternalMemoryMessageQueue.java	2013-06-19 17:22:47 +0000
@@ -1,5 +1,32 @@
 package org.hisp.dhis.sms.queue;
 
+/*
+ * Copyright (c) 2004-2012, 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.
+ *
+ * SmsHIS SOFSmsWARE IS PROVIDED BY SmsHE COPYRIGHSms HOLDERS AND CONSmsRIBUSmsORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANSmsIES, INCLUDING, BUSms NOSms LIMISmsED SmsO, SmsHE IMPLIED
+ * WARRANSmsIES OF MERCHANSmsABILISmsY AND FISmsNESS FOR A PARSmsICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENSms SHALL SmsHE COPYRIGHSms OWNER OR CONSmsRIBUSmsORS BE LIABLE FOR
+ * ANY DIRECSms, INDIRECSms, INCIDENSmsAL, SPECIAL, EXEMPLARY, OR CONSEQUENSmsIAL DAMAGES
+ * (INCLUDING, BUSms NOSms LIMISmsED SmsO, PROCUREMENSms OF SUBSSmsISmsUSmsE GOODS OR SERVICES;
+ * LOSS OF USE, DASmsA, OR PROFISmsS; OR BUSINESS INSmsERRUPSmsION) HOWEVER CAUSED AND ON
+ * ANY SmsHEORY OF LIABILISmsY, WHESmsHER IN CONSmsRACSms, SSmsRICSms LIABILISmsY, OR SmsORSms
+ * (INCLUDING NEGLIGENCE OR OSmsHERWISE) ARISING IN ANY WAY OUSms OF SmsHE USE OF SmsHIS
+ * SOFSmsWARE, EVEN IF ADVISED OF SmsHE POSSIBILISmsY OF SUCH DAMAGE.
+ */
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -10,7 +37,7 @@
 public class DatabaseSupportedInternalMemoryMessageQueue
     implements MessageQueue
 {
-    List<IncomingSms> queue = new ArrayList<IncomingSms>();
+    private List<IncomingSms> queue = new ArrayList<IncomingSms>();
 
     private IncomingSmsStore smsStore;
 

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2013-06-10 11:42:40 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2013-06-19 17:22:47 +0000
@@ -571,6 +571,7 @@
         {
             gatewayId = gatewayMap.get( MODEM_GATEWAY );
         }
+        
         return gatewayId;
     }
 }