dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16259
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6143: (mobile) Code style fixed and added missing copyright.
------------------------------------------------------------
revno: 6143
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-01 15:56:47 +0700
message:
(mobile) Code style fixed and added missing copyright.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java
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/incoming/HibernateIncomingSmsStore.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/SmsMessageSender.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SimplisticHttpGetGateWay.java
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/test/java/org/hisp/dhis/sms/AbstractSmsTest.java
dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.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-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java 2012-03-01 08:56:47 +0000
@@ -1,10 +1,36 @@
package org.hisp.dhis.sms;
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.sms.config.SmsConfiguration;
public interface SmsConfigurationManager
{
-
public SmsConfiguration getSmsConfiguration();
public void updateSmsConfiguration( SmsConfiguration config );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +33,6 @@
public class SmsServiceException
extends RuntimeException
{
-
private static final long serialVersionUID = -7927288362330380301L;
public SmsServiceException( String message )
@@ -45,6 +44,4 @@
{
super( message, cause );
}
-
-
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java 2011-12-15 11:41:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.config;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,6 @@
public class BulkSmsGatewayConfig
extends SmsGatewayConfig
{
-
private static final long serialVersionUID = 5249703354480948250L;
private String username;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java 2011-12-15 11:41:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java 2012-03-01 08:56:47 +0000
@@ -1,8 +1,7 @@
package org.hisp.dhis.sms.config;
-
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,13 +30,14 @@
public class ClickatellGatewayConfig
extends SmsGatewayConfig
{
-
private static final long serialVersionUID = -4286107769356591957L;
private String username;
+
private String password;
+
private String apiId;
-
+
public String getUsername()
{
return username;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java 2011-12-20 12:46:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java 2012-03-01 08:56:47 +0000
@@ -1,13 +1,7 @@
package org.hisp.dhis.sms.config;
-import java.util.Map;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.hisp.dhis.common.adapter.ParametersMapXmlAdapter;
-
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,10 +27,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Map;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.hisp.dhis.common.adapter.ParametersMapXmlAdapter;
+
public class GenericHttpGatewayConfig
extends SmsGatewayConfig
{
-
private static final long serialVersionUID = 6340853488475760213L;
private String urlTemplate;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java 2011-12-15 11:41:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java 2012-03-01 08:56:47 +0000
@@ -1,8 +1,7 @@
package org.hisp.dhis.sms.config;
-
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +30,6 @@
public class ModemGatewayConfig
extends SmsGatewayConfig
{
-
private static final long serialVersionUID = 5824899163489665038L;
private String port;
@@ -44,12 +42,12 @@
private String pin;
+ private String simMemLocation;
+
private boolean inbound;
private boolean outbound;
- private String simMemLocation;
-
public String getPort()
{
return port;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java 2012-03-01 08:56:47 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.sms.config;
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.sms.SmsServiceException;
/**
@@ -7,7 +34,6 @@
*/
public interface SmsConfigurable
{
-
/**
* Initialize the service with the provided configuration.
* <p>
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java 2011-12-20 12:46:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.config;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@
public class SmsConfiguration
implements Serializable
{
-
private static final long serialVersionUID = 7460688383539123303L;
private String longNumber;
@@ -84,9 +83,9 @@
@XmlElementWrapper( name = "gateways" )
@XmlElements( { @XmlElement( name = "bulksms", type = BulkSmsGatewayConfig.class ),
- @XmlElement( name = "clickatell", type = ClickatellGatewayConfig.class ),
- @XmlElement( name = "http", type = GenericHttpGatewayConfig.class ),
- @XmlElement( name = "modem", type = ModemGatewayConfig.class ) } )
+ @XmlElement( name = "clickatell", type = ClickatellGatewayConfig.class ),
+ @XmlElement( name = "http", type = GenericHttpGatewayConfig.class ),
+ @XmlElement( name = "modem", type = ModemGatewayConfig.class ) } )
public List<SmsGatewayConfig> getGateways()
{
return gateways;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java 2011-12-15 11:41:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.config;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,9 +33,9 @@
* Super class for gateway configurations
*/
@SuppressWarnings( "serial" )
-public abstract class SmsGatewayConfig implements Serializable
+public abstract class SmsGatewayConfig
+ implements Serializable
{
-
private String name;
public String getName()
@@ -51,5 +51,5 @@
public abstract boolean isInbound();
public abstract boolean isOutbound();
-
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.incoming;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,5 +33,4 @@
public enum SmsMessageStatus
{
INCOMING, PROCESSING, UNHANDLED, FAILED, PROCESSED;
-
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.outbound;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,7 +34,6 @@
public class OutboundSms
{
-
private int id;
private Set<String> recipients;
@@ -115,7 +114,9 @@
private String getNumbers()
{
if ( this.recipients == null )
+ {
return null;
+ }
String numbers = "";
@@ -123,6 +124,7 @@
{
numbers += recipient + ", ";
}
+
return numbers.substring( 0, numbers.length() - 2 );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.outbound;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,9 +33,9 @@
/**
* OutboundSmsService provides support for sending SMSes.
*/
-public interface OutboundSmsService extends SmsConfigurable
+public interface OutboundSmsService
+ extends SmsConfigurable
{
-
String ID = OutboundSmsService.class.getName();
public boolean isEnabled();
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.outbound;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,5 @@
public enum OutboundSmsStatus
{
-
OUTBOUND, SENT, ERROR;
-
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java 2012-03-01 08:56:47 +0000
@@ -3,7 +3,7 @@
import java.util.List;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,10 @@
public interface OutboundSmsStore
{
-
public int save( OutboundSms sms );
public List<OutboundSms> getAll();
public OutboundSms get( int id );
-
-
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java 2012-03-01 08:56:47 +0000
@@ -1,10 +1,37 @@
package org.hisp.dhis.sms.outbound;
-
+/*
+ * Copyright (c) 2004-2011, 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.
+ */
+
/**
- * Marker interface for {@code OutboundSmsService outbound sms services} providing actual sms sending.
+ * Marker interface for {@code OutboundSmsService outbound sms services}
+ * providing actual sms sending.
*/
-public interface OutboundSmsTransportService extends OutboundSmsService
+public interface OutboundSmsTransportService
+ extends OutboundSmsService
{
-
}
=== 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-02-02 20:01:36 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java 2012-03-01 08:56:47 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.sms;
+/*
+ * Copyright (c) 2004-2011, 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.List;
import javax.annotation.PostConstruct;
@@ -19,9 +46,9 @@
* context, initializing them on startup and on any sms configuration changes.
*
*/
-public class SmsConfigurationManagerImpl implements SmsConfigurationManager
+public class SmsConfigurationManagerImpl
+ implements SmsConfigurationManager
{
-
private static final Log log = LogFactory.getLog( SmsConfigurationManagerImpl.class );
@Autowired
@@ -44,14 +71,13 @@
{
return;
}
-
+
for ( SmsConfigurable smsConfigurable : smsConfigurables )
{
-
try
{
smsConfigurable.initialize( smsConfiguration );
- log.debug( "Initialized " + smsConfigurable);
+ log.debug( "Initialized " + smsConfigurable );
}
catch ( Throwable t )
{
@@ -60,7 +86,6 @@
+ "with configuration " + smsConfiguration, t );
}
}
-
}
@Override
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.incoming;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@
public class HibernateIncomingSmsStore
implements IncomingSmsStore
{
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
=== 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 2012-02-02 13:08:43 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-03-01 08:56:47 +0000
@@ -1,15 +1,37 @@
package org.hisp.dhis.sms.outbound;
+/*
+ * Copyright (c) 2004-2011, 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 org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.SmsServiceNotEnabledException;
import org.hisp.dhis.sms.config.SmsConfiguration;
-import org.hisp.dhis.sms.outbound.OutboundSms;
-import org.hisp.dhis.sms.outbound.OutboundSmsService;
-import org.hisp.dhis.sms.outbound.OutboundSmsStatus;
-import org.hisp.dhis.sms.outbound.OutboundSmsStore;
-import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -21,29 +43,34 @@
public class OutboundSmsServiceImpl
implements OutboundSmsService
{
-
private static final Log log = LogFactory.getLog( OutboundSmsServiceImpl.class );
+ private boolean enabled;
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
private OutboundSmsStore outboundSmsStore;
- private OutboundSmsTransportService transportService;
-
- private boolean enabled;
-
- @Autowired
public void setOutboundSmsStore( OutboundSmsStore outboundSmsStore )
{
this.outboundSmsStore = outboundSmsStore;
}
+ private OutboundSmsTransportService transportService;
+
@Autowired( required = false )
protected void setTransportService( OutboundSmsTransportService transportService )
{
this.transportService = transportService;
log.debug( "Got OutboundSmsTransportService: " + transportService.getClass().getSimpleName() );
-
}
+ // -------------------------------------------------------------------------
+ // Implementation
+ // -------------------------------------------------------------------------
+
@Override
public void initialize( SmsConfiguration smsConfiguration )
throws SmsServiceException
@@ -78,6 +105,10 @@
}
}
+ // -------------------------------------------------------------------------
+ // Support methods
+ // -------------------------------------------------------------------------
+
private void sendMessageInternal( OutboundSms sms )
{
try
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java 2011-12-20 12:46:37 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java 2012-03-01 08:56:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.sms.outbound;
/*
- * Copyright (c) 2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -52,13 +52,13 @@
private UserService userService;
- private OutboundSmsService outboundSmsService;
-
public void setUserService( UserService userService )
{
this.userService = userService;
}
+ private OutboundSmsService outboundSmsService;
+
public void setOutboundSmsService( OutboundSmsService outboundSmsService )
{
this.outboundSmsService = outboundSmsService;
@@ -71,7 +71,6 @@
@Override
public void sendMessage( String subject, String text, User sender, Set<User> users )
{
-
if ( outboundSmsService == null || !outboundSmsService.isEnabled() )
{
return;
@@ -84,7 +83,6 @@
if ( !recipients.isEmpty() )
{
sendMessage( text, recipients );
-
}
else if ( log.isDebugEnabled() )
{
@@ -104,30 +102,36 @@
boolean smsNotification = settings.get( user ) != null && (Boolean) settings.get( user );
String phoneNumber = user.getPhoneNumber();
+
if ( smsNotification && phoneNumber != null && !phoneNumber.trim().isEmpty() )
{
recipients.add( phoneNumber );
if ( log.isDebugEnabled() )
+ {
log.debug( "Adding user as sms recipient: " + user + " with phone number: " + phoneNumber );
+ }
}
}
+
return recipients;
}
private String createMessage( String subject, String text, User sender )
{
String name = "unknown";
+
if ( sender != null )
+ {
name = sender.getUsername();
+ }
text = "From " + name + " - " + subject + ": " + text;
// Simplistic cutoff 160 characters..
int length = text.length();
- if ( length > 160 )
- text = text.substring( 0, 157 ) + "...";
- return text;
+
+ return (length > 160) ? text.substring( 0, 157 ) + "..." : text;
}
private void sendMessage( String text, Set<String> recipients )
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java 2011-12-20 12:46:37 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java 2012-03-01 08:56:47 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.sms.smslib;
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.config.BulkSmsGatewayConfig;
import org.hisp.dhis.sms.config.ClickatellGatewayConfig;
@@ -14,17 +41,24 @@
public class GateWayFactory
{
-
public AGateway create( SmsGatewayConfig config )
{
if ( config instanceof BulkSmsGatewayConfig )
+ {
return createBulkSmsGateway( (BulkSmsGatewayConfig) config );
+ }
else if ( config instanceof GenericHttpGatewayConfig )
+ {
return createSimplisticHttpGetGateway( (GenericHttpGatewayConfig) config );
+ }
else if ( config instanceof ClickatellGatewayConfig )
+ {
return createClickatellGateway( (ClickatellGatewayConfig) config );
+ }
else if ( config instanceof ModemGatewayConfig )
+ {
return createModemGateway( (ModemGatewayConfig) config );
+ }
throw new SmsServiceException( "Gateway config of unknown type: " + config.getClass().getName() );
@@ -32,8 +66,8 @@
public AGateway createBulkSmsGateway( BulkSmsGatewayConfig config )
{
- BulkSmsHTTPGateway gateway = new BulkSmsHTTPGateway( "bulksms.http.1", config.getUsername(),
- config.getPassword() );
+ BulkSmsHTTPGateway gateway = new BulkSmsHTTPGateway( "bulksms.http.1", config.getUsername(), config
+ .getPassword() );
gateway.setOutbound( true );
gateway.setInbound( false );
return gateway;
@@ -41,10 +75,9 @@
public AGateway createModemGateway( ModemGatewayConfig c )
{
-
// TODO: DETECT MODEM CLASS AND INSTANTIATE
- SerialModemGateway gateway = new SerialModemGateway( c.getName(), c.getPort(), c.getBaudRate(),
- c.getManufacturer(), c.getModel() );
+ SerialModemGateway gateway = new SerialModemGateway( c.getName(), c.getPort(), c.getBaudRate(), c
+ .getManufacturer(), c.getModel() );
if ( c.getSimMemLocation() != null )
{
@@ -65,8 +98,8 @@
public AGateway createClickatellGateway( ClickatellGatewayConfig c )
{
- ClickatellHTTPGateway gateway = new ClickatellHTTPGateway( c.getName(), c.getApiId(), c.getUsername(),
- c.getPassword() );
+ ClickatellHTTPGateway gateway = new ClickatellHTTPGateway( c.getName(), c.getApiId(), c.getUsername(), c
+ .getPassword() );
gateway.setOutbound( true );
gateway.setInbound( false );
return gateway;
@@ -74,10 +107,10 @@
public AGateway createSimplisticHttpGetGateway( GenericHttpGatewayConfig c )
{
- SimplisticHttpGetGateWay gateway = new SimplisticHttpGetGateWay( c.getName(), c.getUrlTemplate(), c.getParameters() );
+ SimplisticHttpGetGateWay gateway = new SimplisticHttpGetGateWay( c.getName(), c.getUrlTemplate(), c
+ .getParameters() );
gateway.setOutbound( true );
gateway.setInbound( false );
return gateway;
}
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SimplisticHttpGetGateWay.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SimplisticHttpGetGateWay.java 2012-02-02 13:08:43 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SimplisticHttpGetGateWay.java 2012-03-01 08:56:47 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.sms.smslib;
+/*
+ * Copyright (c) 2004-2011, 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.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -15,12 +42,15 @@
import org.springframework.web.client.RestTemplate;
/**
- * Simplistic http gateway sending smses through a get to a url constructed from the provided
- * urlTemplate and map of static parameters.
- * <p>This gateway is simplistic in that it can't evaluate the response from the provider, being most suitable as an
- * example gateway. For production use a more robust gateway should be used implemented for the specific provider.
+ * Simplistic http gateway sending smses through a get to a url constructed from
+ * the provided urlTemplate and map of static parameters.
+ * <p>
+ * This gateway is simplistic in that it can't evaluate the response from the
+ * provider, being most suitable as an example gateway. For production use a
+ * more robust gateway should be used implemented for the specific provider.
*
- * <p>The gateway adds the following keys to the parameters:
+ * <p>
+ * The gateway adds the following keys to the parameters:
* <ul>
* <li>recipient
* <li>message
@@ -39,7 +69,6 @@
public class SimplisticHttpGetGateWay
extends AGateway
{
-
private static final String SENDER = "sender";
private static final String RECIPIENT = "recipient";
@@ -49,10 +78,10 @@
RestTemplate restTemplate = new RestTemplate();
private Map<String, String> parameters;
-
+
private String urlTemplate;
- public SimplisticHttpGetGateWay( String id, String urlTemplate, Map<String, String> parameters)
+ public SimplisticHttpGetGateWay( String id, String urlTemplate, Map<String, String> parameters )
{
super( id );
this.urlTemplate = urlTemplate;
@@ -83,13 +112,14 @@
throws TimeoutException, GatewayException, IOException, InterruptedException
{
Logger.getInstance().logDebug( "Sending message " + msg, null, getGatewayId() );
-
- Map<String, String> requestParameters = new HashMap<String, String>(parameters);
-
+
+ Map<String, String> requestParameters = new HashMap<String, String>( parameters );
+
requestParameters.put( MESSAGE, msg.getText() );
requestParameters.put( RECIPIENT, msg.getRecipient() );
String sender = msg.getFrom();
- if (sender != null) {
+ if ( sender != null )
+ {
Logger.getInstance().logDebug( "Adding sender " + sender, null, getGatewayId() );
requestParameters.put( SENDER, sender );
}
@@ -97,7 +127,8 @@
{
ResponseEntity<String> response = restTemplate.getForEntity( urlTemplate, String.class, requestParameters );
- if (response.getStatusCode().series() != HttpStatus.Series.SUCCESSFUL) {
+ if ( response.getStatusCode().series() != HttpStatus.Series.SUCCESSFUL )
+ {
Logger.getInstance().logWarn( "Couldn't send message, got response " + response, null, getGatewayId() );
return false;
}
@@ -110,7 +141,7 @@
}
return true;
-
+
}
@Override
=== 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 2012-02-02 13:08:43 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-03-01 08:56:47 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.sms.smslib;
+/*
+ * Copyright (c) 2004-2011, 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.io.IOException;
import java.util.Set;
@@ -21,7 +48,6 @@
public class SmsLibService
implements OutboundSmsTransportService
{
-
private static final Log log = LogFactory.getLog( SmsLibService.class );
private GateWayFactory gatewayFactory = new GateWayFactory();
@@ -57,7 +83,9 @@
}
OutboundMessage message = new OutboundMessage( recipient, sms.getMessage() );
+
String longNumber = config.getLongNumber();
+
if ( longNumber != null && !longNumber.isEmpty() )
{
message.setFrom( longNumber );
@@ -96,9 +124,8 @@
if ( !sent )
{
-
+ log.warn( "Message not sent" );
}
-
}
@Override
@@ -116,6 +143,7 @@
this.config = smsConfiguration;
ServiceStatus status = getService().getServiceStatus();
+
if ( status == ServiceStatus.STARTED || status == ServiceStatus.STARTING )
{
log.debug( "Stopping SmsLib" );
@@ -123,6 +151,7 @@
}
log.debug( "Loading configuration" );
+
reloadConfig();
if ( config.isEnabled() )
@@ -141,10 +170,12 @@
String groupName = Thread.currentThread().getName();
getService().createGroup( groupName );
+
for ( String recepient : recipients )
{
getService().addToGroup( groupName, recepient );
}
+
return groupName;
}
@@ -229,10 +260,9 @@
}
}
- public class OutboundNotification
+ private class OutboundNotification
implements IOutboundMessageNotification
{
-
@Override
public void process( AGateway gateway, OutboundMessage msg )
{
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java 2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java 2012-03-01 08:56:47 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.sms;
+/*
+ * Copyright (c) 2004-2011, 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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -34,6 +61,7 @@
sessionFactory.getCurrentSession().evict( o );
}
+ @SuppressWarnings("serial")
protected OutboundSms getOutboundSms()
{
OutboundSms sms = new OutboundSms();
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java 2011-12-15 20:41:45 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java 2012-03-01 08:56:47 +0000
@@ -1,6 +1,32 @@
package org.hisp.dhis.sms.outbound;
-import static org.junit.Assert.assertEquals;
+/*
+ * Copyright (c) 2004-2011, 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 static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doThrow;
@@ -14,11 +40,6 @@
import org.hisp.dhis.sms.AbstractSmsTest;
import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.config.SmsConfiguration;
-import org.hisp.dhis.sms.outbound.OutboundSms;
-import org.hisp.dhis.sms.outbound.OutboundSmsService;
-import org.hisp.dhis.sms.outbound.OutboundSmsStatus;
-import org.hisp.dhis.sms.outbound.OutboundSmsStore;
-import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.beans.factory.annotation.Autowired;