KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > business > sms > SMSManagerImpl


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: SMSManagerImpl.java,v 1.1 2004/08/16 09:33:11 slobodan Exp $
18  */

19
20 package com.lutris.airsent.business.sms;
21
22 import com.lutris.util.Config;
23 import com.lutris.util.KeywordValueTable;
24 import com.lutris.airsent.business.AirSentBusinessException;
25 import com.lutris.airsent.spec.sms.SMSManager;
26
27 /**
28  * Class declaration
29  *
30  *
31  * @author
32  * @version %I%, %G%
33  */

34 public class SMSManagerImpl implements SMSManager {
35     
36     
37     protected final static String JavaDoc SMS_ACTIVE = "Active";
38     protected final static String JavaDoc SMS_KEY = "SMS";
39     protected final static String JavaDoc SMS_HOSTNAME = "Hostname";
40     protected final static String JavaDoc SMS_PORT = "Port";
41     protected final static String JavaDoc SMS_SYSID = "Sysid";
42     protected final static String JavaDoc SMS_SYSTYPE = "Systype";
43     protected final static String JavaDoc SMS_SYSPASSWORD = "Password";
44
45     protected String JavaDoc smsServer = null;
46     protected String JavaDoc smsPort = null;
47     protected String JavaDoc smsSysid = null;
48     protected String JavaDoc smsSystype = null;
49     protected String JavaDoc smsSyspassword = null;
50     protected boolean active = false;
51
52     /**
53      * Plain Constructor
54      *
55      *
56      * @see
57      */

58     public SMSManagerImpl() {}
59
60     /**
61      * Constructor using the Config object to set config variables.
62      *
63      *
64      * @param config
65      *
66      * @see
67      */

68     public SMSManagerImpl(Config config) throws AirSentBusinessException {
69     try {
70         // Get the email config.
71
KeywordValueTable section = config.getSection(SMS_KEY);
72         smsServer = section.getString(SMS_HOSTNAME);
73         smsPort = section.getString(SMS_PORT);
74         smsSysid = section.getString(SMS_SYSID);
75         smsSystype = section.getString(SMS_SYSTYPE);
76         smsSyspassword = section.getString(SMS_SYSPASSWORD);
77         active = Boolean.valueOf(section.getString(SMS_ACTIVE)).booleanValue();
78     } catch (Exception JavaDoc ex) {
79         throw new AirSentBusinessException("Error sending mail:", ex);
80     }
81     }
82     
83     
84     /**
85      * Sends sms message.
86      *
87      *
88      * @param to
89      * @param toAddress
90      * @param subject
91      * @param body
92      * @param type
93      *
94      * @throws AirSentBusinessException
95      *
96      * @see
97      */

98     public void send(String JavaDoc id, String JavaDoc body) throws AirSentBusinessException {
99     try {
100         if(active) {
101         SMS sms = new SMS(smsServer, smsPort, smsSysid,
102                       smsSystype, smsSyspassword);
103         sms.sendMessage(id, body);
104         } else {
105         System.out.println("SMS is not active. Edit airSent.conf to activate.");
106         }
107     } catch (Exception JavaDoc ex) {
108         throw new AirSentBusinessException("Error sending SMS:", ex);
109     }
110     }
111
112 }
113
114
Popular Tags