dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24429
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11973: fix bug for register SMS command
------------------------------------------------------------
revno: 11973
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-09-08 22:32:46 +0700
message:
fix bug for register SMS command
added:
dhis-2/dhis-dxf2/
dhis-2/dhis-dxf2/bin/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDefaultPopulator.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DatabaseSupportedInternalMemoryMessageQueue.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/UnregisteredSMSListener.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
--
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
=== added directory 'dhis-2/dhis-dxf2'
=== added directory 'dhis-2/dhis-dxf2/bin'
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DatabaseSupportedInternalMemoryMessageQueue.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DatabaseSupportedInternalMemoryMessageQueue.java 2013-09-04 08:29:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DatabaseSupportedInternalMemoryMessageQueue.java 2013-09-08 15:32:46 +0000
@@ -70,6 +70,7 @@
@Override
public void remove( IncomingSms message )
{
+ System.out.println("IMPORTANT POINT IS HERE");
message.setParsed( true );
message.setStatus( SmsMessageStatus.PROCESSED );
smsStore.update( message );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/UnregisteredSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/UnregisteredSMSListener.java 2013-09-04 10:01:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/UnregisteredSMSListener.java 2013-09-08 15:32:46 +0000
@@ -125,24 +125,13 @@
{
Set<User> receivers = new HashSet<User>( userGroup.getMembers() );
- UserCredentials anonymousUser = userService.getUserCredentialsByUsername( "system" );
+ UserCredentials anonymousUser = userService.getUserCredentialsByUsername( "anonymous" );
if ( anonymousUser == null )
{
anonymousUser = userService.getUserCredentialsByUsername( "admin" );
}
- /*
- * MessageConversation conversation = new MessageConversation(
- * smsCommand.getName(), anonymousUser.getUser() );
- *
- * conversation.addMessage( new Message( message, null,
- * anonymousUser.getUser() ) );
- *
- * for ( User receiver : receivers ) { boolean read = false;
- *
- * conversation.addUserMessage( new UserMessage( receiver, read
- * ) ); }
- */
+
// forward to user group by SMS, E-mail, DHIS conversation
messageService.sendMessage( smsCommand.getName(), message, null, receivers, anonymousUser.getUser(),
@@ -184,4 +173,9 @@
this.smsMessageSender = smsMessageSender;
}
+ public void setIncomingSmsService( IncomingSmsService incomingSmsService )
+ {
+ this.incomingSmsService = incomingSmsService;
+ }
+
}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDefaultPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDefaultPopulator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDefaultPopulator.java 2013-09-08 15:32:46 +0000
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+package org.hisp.dhis.user;
+
+import org.hisp.dhis.system.startup.AbstractStartupRoutine;
+
+ /**
+ * @author Nguyen Kim Lai
+ *
+ * @version UserDefaultPopulator.java 9:06:11 PM Sep 8, 2013 $
+ */
+public class UserDefaultPopulator
+ extends AbstractStartupRoutine
+{
+ public static final String USER_NAME = "anonymous";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private UserService userService;
+
+ public void setUserService( UserService userService )
+ {
+ this.userService = userService;
+ }
+
+ // -------------------------------------------------------------------------
+ // AbstractStartupRoutine implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void execute()
+ throws Exception
+ {
+ UserCredentials usercredential = userService.getUserCredentialsByUsername( USER_NAME );
+
+ if( usercredential == null )
+ {
+ User user = new User();
+ usercredential = new UserCredentials();
+ usercredential.setUsername( USER_NAME );
+ usercredential.setPassword( USER_NAME );
+ usercredential.setUser( user );
+ user.setSurname( USER_NAME );
+ user.setFirstName( USER_NAME );
+ user.setUserCredentials( usercredential );
+
+ userService.addUserCredentials( usercredential );
+ userService.addUser( user );
+ }
+ }
+}
+
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-04 13:52:48 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-08 15:32:46 +0000
@@ -767,6 +767,7 @@
<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
<property name="smsMessageSender" ref="org.hisp.dhis.sms.SmsMessageSender" />
<property name="userService" ref="org.hisp.dhis.user.UserService" />
+ <property name="incomingSmsService" ref="org.hisp.dhis.sms.incoming.IncomingSmsService"/>
</bean>
<bean id="org.hisp.dhis.sms.DHISMessageAlertListener" class="org.hisp.dhis.sms.DHISMessageAlertListener">
@@ -881,6 +882,12 @@
<property name="skipInTests" value="true" />
</bean>
+ <bean id="org.hisp.dhis.user.UserDefaultPopulator" class="org.hisp.dhis.user.UserDefaultPopulator">
+ <property name="userService" ref="org.hisp.dhis.user.UserService" />
+ <property name="runlevel" value="5" />
+ <property name="skipInTests" value="true" />
+ </bean>
+
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="org.hisp.dhis.system.startup.StartupRoutineExecutor" />
<property name="targetMethod" value="addStartupRoutines" />
@@ -897,6 +904,7 @@
<ref local="org.hisp.dhis.dataentryform.DataEntryFormUpgrader" />
<ref local="org.hisp.dhis.startup.ExpressionUpgrader" />
<ref local="org.hisp.dhis.startup.ConfigurationPopulator" />
+ <ref local="org.hisp.dhis.user.UserDefaultPopulator" />
</list>
</list>
</property>