[Comsuite-svn] SF.net SVN: comsuite: [126] trunk/code/CSRemoteClient/src/org/commsuite
Brought to you by:
zduniak
|
From: <ma...@us...> - 2006-09-03 14:59:51
|
Revision: 126
http://svn.sourceforge.net/comsuite/?rev=126&view=rev
Author: marasm
Date: 2006-09-03 07:59:02 -0700 (Sun, 03 Sep 2006)
Log Message:
-----------
javadocs added
Modified Paths:
--------------
trunk/code/CSRemoteClient/src/org/commsuite/client/GUI.java
trunk/code/CSRemoteClient/src/org/commsuite/client/MessageFrame.java
trunk/code/CSRemoteClient/src/org/commsuite/client/MessageLabel.java
trunk/code/CSRemoteClient/src/org/commsuite/client/MessagePanel.java
trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClient.java
trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClientAppContext.java
trunk/code/CSRemoteClient/src/org/commsuite/model/CSTupleBinding.java
trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessage.java
trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDao.java
trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDaoImpl.java
trunk/code/CSRemoteClient/src/org/commsuite/utils/CommunicateUtil.java
trunk/code/CSRemoteClient/src/org/commsuite/utils/MessageSavingUtil.java
Modified: trunk/code/CSRemoteClient/src/org/commsuite/client/GUI.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/client/GUI.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/client/GUI.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -394,6 +394,12 @@
configure();
}
+ /**
+ * Displayes message box with appriopriate message
+ *
+ * @param t
+ * exception that is to be showed
+ */
public void showException(Throwable t) {
String message = "Unknown error";
if (t instanceof AxisFault) {
@@ -659,7 +665,7 @@
mimeType = RemoteClientAppContext.getMimetypesMap()
.getContentType(fc.getSelectedFile());
-
+
if (mimeType.equals("application/octet-stream")) {
showException(new Exception("RC:Format of file \""
+ tempFileName + "\" is not supported"));
@@ -806,6 +812,10 @@
return isRunning;
}
+ /**
+ * Create or refresh frame with messages
+ *
+ */
public void reloadMessagesFrame() {
try {
messages = MessageSavingUtil.loadMessages();
Modified: trunk/code/CSRemoteClient/src/org/commsuite/client/MessageFrame.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/client/MessageFrame.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/client/MessageFrame.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -38,57 +38,74 @@
/**
* Frame for viewing sent messages
+ *
* @since 1.0
* @author Agnieszka Wi�niewska
* @author Marek Musielak
*/
-public class MessageFrame extends JFrame implements WindowListener{
+public class MessageFrame extends JFrame implements WindowListener {
private static final long serialVersionUID = -3589020867401107576L;
protected GUI framework = null;
-
- public MessageFrame(GUI controller, List messagesList){
+
+ public MessageFrame(GUI controller, List messagesList) {
super("Messages");
framework = controller;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.reloadFrame(messagesList);
}
+ /**
+ * Refresh view of messages frame
+ *
+ * @param messagesList
+ * messages to be displayed on frame
+ */
public void reloadFrame(List messagesList) {
- setSize(new Dimension(925, Math.min(39 + Math.max(50,messagesList.size()*58), 500)));
+ setSize(new Dimension(925, Math.min(39 + Math.max(50, messagesList
+ .size() * 58), 500)));
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.setBackground(Color.BLACK);
JScrollPane scroll = new JScrollPane(mainPanel);
- scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-
+ scroll
+ .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ scroll
+ .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+
Iterator messageIterator = messagesList.iterator();
-
- while (messageIterator.hasNext()){
- mainPanel.add(Box.createRigidArea(new Dimension(0,3)));
- RemoteClientMessage rcMessage = (RemoteClientMessage)messageIterator.next();
+
+ while (messageIterator.hasNext()) {
+ mainPanel.add(Box.createRigidArea(new Dimension(0, 3)));
+ RemoteClientMessage rcMessage = (RemoteClientMessage) messageIterator
+ .next();
JPanel messagePanel = new MessagePanel(rcMessage, framework);
mainPanel.add(messagePanel);
}
this.setContentPane(scroll);
}
-
- public void windowOpened(WindowEvent e) {}
- public void windowClosing(WindowEvent e) {}
+ public void windowOpened(WindowEvent e) {
+ }
+ public void windowClosing(WindowEvent e) {
+ }
+
public void windowClosed(WindowEvent e) {
framework.messagesFrame = null;
}
- public void windowIconified(WindowEvent e) {}
+ public void windowIconified(WindowEvent e) {
+ }
- public void windowDeiconified(WindowEvent e) {}
+ public void windowDeiconified(WindowEvent e) {
+ }
- public void windowActivated(WindowEvent e) {}
+ public void windowActivated(WindowEvent e) {
+ }
- public void windowDeactivated(WindowEvent e) {}
-
+ public void windowDeactivated(WindowEvent e) {
+ }
+
}
Modified: trunk/code/CSRemoteClient/src/org/commsuite/client/MessageLabel.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/client/MessageLabel.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/client/MessageLabel.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -29,6 +29,8 @@
import javax.swing.JLabel;
/**
+ * class extending JLabel with special formatting
+ *
* @since 1.0
* @author Marek Musielak
*/
Modified: trunk/code/CSRemoteClient/src/org/commsuite/client/MessagePanel.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/client/MessagePanel.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/client/MessagePanel.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -41,6 +41,7 @@
/**
* New panel for each message
+ *
* @since 1.0
* @author Agnieszka Wisniewska
* @author Marek Musielak
Modified: trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClient.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClient.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClient.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -36,6 +36,8 @@
import com.sleepycat.je.DatabaseException;
/**
+ * Remote Client main class
+ *
* @since 1.0
* @author Agnieszka Wisniewska
* @author Marek Musielak
@@ -43,54 +45,58 @@
public class RemoteClient extends JPanel implements WindowListener {
private static final long serialVersionUID = -1546309280862711828L;
-
+
private DatagramSocket socket;
public RemoteClient() {
-
+
/**
- * trying to bind port 2013
- * we are checking if there is any other instance of our application running simultaneously
- * if there is one - we can not bind and exception will be thrown
+ * trying to bind port 2013 we are checking if there is any other
+ * instance of our application running simultaneously if there is one -
+ * we can not bind and exception will be thrown
*/
- try {
- socket = new DatagramSocket(2013);
- } catch (SocketException e){
- JOptionPane.showMessageDialog(null, "Your application is already running", "Info", JOptionPane.INFORMATION_MESSAGE);
+ try {
+ socket = new DatagramSocket(2013);
+ } catch (SocketException e) {
+ JOptionPane.showMessageDialog(null,
+ "Your application is already running", "Info",
+ JOptionPane.INFORMATION_MESSAGE);
return;
}
-
- final JFrame f = new JFrame("Remote Client");
- final GUI g = new GUI(f);
- g.setOpaque(true);
+ final JFrame f = new JFrame("Remote Client");
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- f.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent event) {
- try {
- RemoteClientAppContext.getMessageDao().close();
- } catch (DatabaseException e) {
- g.showException(e);
- }
- // try{ g.onExit(); }
- // catch( Exception e ) { e.printStackTrace(); }
- }
- });
+ final GUI g = new GUI(f);
+ g.setOpaque(true);
- f.getContentPane().add(g);
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent event) {
+ try {
+ RemoteClientAppContext.getMessageDao().close();
+ } catch (DatabaseException e) {
+ g.showException(e);
+ }
+ // try{ g.onExit(); }
+ // catch( Exception e ) { e.printStackTrace(); }
+ }
+ });
- f.pack();
- f.setVisible(true);
- }
+ f.getContentPane().add(g);
- /**
- * @param args
- */
- public static void main(String[] args) {
- try {
- // REVIEW [AW] to nie dzialalo Rafalowi pod linuxem a klient ma byc przeznaczony dla dowolnej platformy
- UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ f.pack();
+ f.setVisible(true);
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ try {
+ // REVIEW [AW] to nie dzialalo Rafalowi pod linuxem a klient ma byc
+ // przeznaczony dla dowolnej platformy
+ UIManager
+ .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -104,30 +110,36 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
- JFrame.setDefaultLookAndFeelDecorated(true);
- JDialog.setDefaultLookAndFeelDecorated(true);
- javax.swing.SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- new RemoteClient();
- }
- });
+ JFrame.setDefaultLookAndFeelDecorated(true);
+ JDialog.setDefaultLookAndFeelDecorated(true);
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ new RemoteClient();
+ }
+ });
- }
+ }
- public void windowOpened(WindowEvent e) {}
+ public void windowOpened(WindowEvent e) {
+ }
- public void windowClosing(WindowEvent e) {}
+ public void windowClosing(WindowEvent e) {
+ }
public void windowClosed(WindowEvent e) {
socket.close();
}
- public void windowIconified(WindowEvent e) {}
+ public void windowIconified(WindowEvent e) {
+ }
- public void windowDeiconified(WindowEvent e) {}
+ public void windowDeiconified(WindowEvent e) {
+ }
- public void windowActivated(WindowEvent e) {}
+ public void windowActivated(WindowEvent e) {
+ }
- public void windowDeactivated(WindowEvent e) {}
+ public void windowDeactivated(WindowEvent e) {
+ }
}
Modified: trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClientAppContext.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClientAppContext.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/client/RemoteClientAppContext.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -27,31 +27,33 @@
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
+ * Application context for Remote Client
+ *
* @since 1.0
* @author Agnieszka Wisniewska
* @author Marek Musielak
*/
public class RemoteClientAppContext {
- private static ClassPathXmlApplicationContext appCtx;
+ private static ClassPathXmlApplicationContext appCtx;
- static {
- appCtx = new ClassPathXmlApplicationContext("remoteClientContext.xml");
- }
+ static {
+ appCtx = new ClassPathXmlApplicationContext("remoteClientContext.xml");
+ }
- protected RemoteClientAppContext() {
- }
+ protected RemoteClientAppContext() {
+ }
- public static IMessagingWSLocator getMessagingWS() {
- return (IMessagingWSLocator) appCtx.getBean("messaging");
- }
+ public static IMessagingWSLocator getMessagingWS() {
+ return (IMessagingWSLocator) appCtx.getBean("messaging");
+ }
- public static RemoteClientMessageDao getMessageDao() {
- return (RemoteClientMessageDao) appCtx.getBean("messageDao");
- }
-
- public static MimetypesFileTypeMap getMimetypesMap() {
- return (MimetypesFileTypeMap) appCtx.getBean("mimetypeMap");
- }
+ public static RemoteClientMessageDao getMessageDao() {
+ return (RemoteClientMessageDao) appCtx.getBean("messageDao");
+ }
+ public static MimetypesFileTypeMap getMimetypesMap() {
+ return (MimetypesFileTypeMap) appCtx.getBean("mimetypeMap");
+ }
+
}
Modified: trunk/code/CSRemoteClient/src/org/commsuite/model/CSTupleBinding.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/model/CSTupleBinding.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/model/CSTupleBinding.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -27,24 +27,28 @@
import com.sleepycat.bind.tuple.TupleOutput;
/**
+ * Tuple Binding for Remote Client
+ *
* @since 1.0
* @author Marek Musielak
*/
public class CSTupleBinding extends TupleBinding {
-
- // Write a RemoteClientMessage object to a TupleOutput
+
+ /**
+ * Write a RemoteClientMessage object to a TupleOutput
+ */
public void objectToEntry(Object object, TupleOutput to) {
- final RemoteClientMessage message = (RemoteClientMessage)object;
- // Write the data to the TupleOutput (a DatabaseEntry).
- // Order is important. The first data written will be
- // the first bytes used by the default comparison routines.
+ final RemoteClientMessage message = (RemoteClientMessage) object;
+ // Write the data to the TupleOutput (a DatabaseEntry).
+ // Order is important. The first data written will be
+ // the first bytes used by the default comparison routines.
to.writeLong(message.getId());
to.writeLong(message.getSendDate());
to.writeInt(message.getMessageContent().length);
try {
to.write(message.getMessageContent());
} catch (IOException e) {
- // REVIEW: [MM] is this correct exception handling ?
+ // REVIEW: [MM] is this correct exception handling ?
e.printStackTrace();
}
to.writeString(message.getMimeType());
@@ -56,19 +60,21 @@
to.writeString(message.getMessageServerId());
to.writeString(message.getFileName());
}
-
- // Convert a TupleInput to a RemoteClientMessage object
+
+ /**
+ * Convert a TupleInput to a RemoteClientMessage object
+ */
public Object entryToObject(TupleInput ti) {
- // Data must be read in the same order that it was
- // originally written.
+ // Data must be read in the same order that it was
+ // originally written.
final RemoteClientMessage message = new RemoteClientMessage();
message.setId(ti.readLong());
message.setSendDate(ti.readLong());
- final byte [] file = new byte[ti.readInt()];
+ final byte[] file = new byte[ti.readInt()];
try {
ti.read(file);
} catch (IOException e) {
- // REVIEW: [MM] is this correct exception handling ?
+ // REVIEW: [MM] is this correct exception handling ?
e.printStackTrace();
}
message.setMessageContent(file);
Modified: trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessage.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessage.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessage.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -28,6 +28,8 @@
import org.apache.commons.lang.builder.ToStringBuilder;
/**
+ * Format of RemoteClient message
+ *
* @since 1.0
* @author Marek Musielak
* @author Marcin Zduniak
Modified: trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDao.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDao.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDao.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -27,6 +27,8 @@
import com.sleepycat.je.OperationStatus;
/**
+ * Interface of dao to retreive RC messages from database
+ *
* @since 1.0
* @author Marek Musielak
*/
Modified: trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDaoImpl.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDaoImpl.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/model/RemoteClientMessageDaoImpl.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -37,67 +37,92 @@
import com.sleepycat.je.OperationStatus;
/**
+ * maintenance communication with database containing RemoteClientMessages
+ *
* @since 1.0
* @author Marek Musielak
*/
public class RemoteClientMessageDaoImpl implements RemoteClientMessageDao {
- private final Environment csDBEnvironment;
+ private final Environment csDBEnvironment;
- private final DatabaseConfig dbConfig;
+ private final DatabaseConfig dbConfig;
- private final Database csDB;
+ private final Database csDB;
- private final TupleBinding csTupleBinding;
+ private final TupleBinding csTupleBinding;
- public RemoteClientMessageDaoImpl() throws DatabaseException {
- final EnvironmentConfig envConfig = new EnvironmentConfig();
- envConfig.setAllowCreate(true);
- // REVIEW: [MM] a co w przypadkach gdy takie property nic nie zwroci?
- // Nie wiem czy to wogole mozliwe, ale na pewno warte zastanowienia
- final File dbFile = new File(System.getProperty("user.home") + File.separator + "RemoteClientDB");
- dbFile.mkdir();
- csDBEnvironment = new Environment(dbFile, envConfig);
- dbConfig = new DatabaseConfig();
- dbConfig.setAllowCreate(true);
- csDB = csDBEnvironment.openDatabase(null, System.getProperty("user.name"), dbConfig);
- csTupleBinding = new CSTupleBinding();
- }
+ public RemoteClientMessageDaoImpl() throws DatabaseException {
+ final EnvironmentConfig envConfig = new EnvironmentConfig();
+ envConfig.setAllowCreate(true);
+ // REVIEW: [MM] a co w przypadkach gdy takie property nic nie zwroci?
+ // Nie wiem czy to wogole mozliwe, ale na pewno warte zastanowienia
+ final File dbFile = new File(System.getProperty("user.home")
+ + File.separator + "RemoteClientDB");
+ dbFile.mkdir();
+ csDBEnvironment = new Environment(dbFile, envConfig);
+ dbConfig = new DatabaseConfig();
+ dbConfig.setAllowCreate(true);
+ csDB = csDBEnvironment.openDatabase(null, System
+ .getProperty("user.name"), dbConfig);
+ csTupleBinding = new CSTupleBinding();
+ }
- public void close() throws DatabaseException {
- if (csDBEnvironment != null) {
- csDBEnvironment.sync();
- if (csDB != null) {
- csDB.close();
- }
- csDBEnvironment.cleanLog();
- csDBEnvironment.close();
- }
- }
+ public void close() throws DatabaseException {
+ if (csDBEnvironment != null) {
+ csDBEnvironment.sync();
+ if (csDB != null) {
+ csDB.close();
+ }
+ csDBEnvironment.cleanLog();
+ csDBEnvironment.close();
+ }
+ }
- public List getRemoteClientMessages() throws DatabaseException, UnsupportedEncodingException {
- Cursor csCursor = null;
- final List resultList = new ArrayList();
- try {
- csCursor = csDB.openCursor(null, null);
- final DatabaseEntry foundKey = new DatabaseEntry();
- final DatabaseEntry foundData = new DatabaseEntry();
- while (csCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
- resultList.add((RemoteClientMessage) csTupleBinding.entryToObject(foundData));
- }
- } finally {
- if (null != csCursor) {
- csCursor.close();
- }
- csDBEnvironment.cleanLog();
- }
- return resultList;
- }
+ /**
+ * Lists all RemoteClientMessages
+ *
+ * @throws DatabaseException
+ * when there is a problem while retreiving data from database
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public List getRemoteClientMessages() throws DatabaseException,
+ UnsupportedEncodingException {
+ Cursor csCursor = null;
+ final List resultList = new ArrayList();
+ try {
+ csCursor = csDB.openCursor(null, null);
+ final DatabaseEntry foundKey = new DatabaseEntry();
+ final DatabaseEntry foundData = new DatabaseEntry();
+ while (csCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
+ resultList.add((RemoteClientMessage) csTupleBinding
+ .entryToObject(foundData));
+ }
+ } finally {
+ if (null != csCursor) {
+ csCursor.close();
+ }
+ csDBEnvironment.cleanLog();
+ }
+ return resultList;
+ }
- public RemoteClientMessage saveOrUpdateRemoteClientMessage(RemoteClientMessage message)
- throws DatabaseException, UnsupportedEncodingException {
-
- Cursor csCursor = null;
+ /**
+ * Saves or updates RemoteClientMessage
+ *
+ * @param message
+ * message to be saved
+ * @throws DatabaseException
+ * when occurs a problem while saving message
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public RemoteClientMessage saveOrUpdateRemoteClientMessage(
+ RemoteClientMessage message) throws DatabaseException,
+ UnsupportedEncodingException {
+
+ Cursor csCursor = null;
try {
csCursor = csDB.openCursor(null, null);
final DatabaseEntry csValue = new DatabaseEntry();
@@ -121,17 +146,29 @@
if (null != csCursor) {
csCursor.close();
}
- csDBEnvironment.cleanLog();
+ csDBEnvironment.cleanLog();
}
return message;
}
- public OperationStatus deleteRemoteClientMessage(RemoteClientMessage message)
+ /**
+ * deletes message from database
+ *
+ * @param message
+ * to be deleted
+ * @return OperationStatus of delete operation
+ *
+ * @throws DatabaseException
+ * when there is a problem while deleting data
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public OperationStatus deleteRemoteClientMessage(RemoteClientMessage message)
throws DatabaseException, UnsupportedEncodingException {
-
+
OperationStatus status;
Cursor csCursor = null;
-
+
try {
csCursor = csDB.openCursor(null, null);
final DatabaseEntry key = new DatabaseEntry(Long.valueOf(
@@ -141,70 +178,132 @@
if (null != csCursor) {
csCursor.close();
}
- csDBEnvironment.cleanLog();
+ csDBEnvironment.cleanLog();
}
return status;
}
- public List getRemoteClientMessagesByUserLogin(String login)
- throws UnsupportedEncodingException, DatabaseException {
- final List result = new ArrayList();
- final List list = this.getRemoteClientMessages();
- for (int i = 0; i < list.size(); i++) {
- if (login.equalsIgnoreCase(((RemoteClientMessage) list.get(i)).getUserLogin())) {
- result.add(list.get(i));
- }
- }
- return result;
- }
+ /**
+ * Lists all messages for user with given id
+ *
+ * @param login
+ * login of user
+ * @return list of messages for given user
+ *
+ * @throws DatabaseException
+ * when there is a problem while retreiving data from database
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public List getRemoteClientMessagesByUserLogin(String login)
+ throws UnsupportedEncodingException, DatabaseException {
+ final List result = new ArrayList();
+ final List list = this.getRemoteClientMessages();
+ for (int i = 0; i < list.size(); i++) {
+ if (login.equalsIgnoreCase(((RemoteClientMessage) list.get(i))
+ .getUserLogin())) {
+ result.add(list.get(i));
+ }
+ }
+ return result;
+ }
- public List getRemoteClientMessagesByServerAddress(String serverAddress)
- throws UnsupportedEncodingException, DatabaseException {
- final List result = new ArrayList();
- final List list = this.getRemoteClientMessages();
- for (int i = 0; i < list.size(); i++) {
- if (serverAddress.equalsIgnoreCase(((RemoteClientMessage) list.get(i))
- .getServerAddress())) {
- result.add(list.get(i));
- }
- }
- return result;
- }
+ /**
+ * Lists all messages for server with given address
+ *
+ * @param serverAddress
+ * adress of server
+ * @return list of messages for given server
+ *
+ * @throws DatabaseException
+ * when there is a problem while retreiving data from database
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public List getRemoteClientMessagesByServerAddress(String serverAddress)
+ throws UnsupportedEncodingException, DatabaseException {
+ final List result = new ArrayList();
+ final List list = this.getRemoteClientMessages();
+ for (int i = 0; i < list.size(); i++) {
+ if (serverAddress.equalsIgnoreCase(((RemoteClientMessage) list
+ .get(i)).getServerAddress())) {
+ result.add(list.get(i));
+ }
+ }
+ return result;
+ }
- public List getRemoteClientMessagesByReceiverAddress(String receiverAddress)
- throws UnsupportedEncodingException, DatabaseException {
- final List result = new ArrayList();
- final List list = this.getRemoteClientMessages();
- for (int i = 0; i < list.size(); i++) {
- if (receiverAddress.equalsIgnoreCase(((RemoteClientMessage) list.get(i))
- .getReceiverAddress())) {
- result.add(list.get(i));
- }
- }
- return result;
- }
+ /**
+ * Lists all messages for receiver with given address
+ *
+ * @param receiverAddress
+ * address of recevier
+ * @return list of messages for given receiver
+ *
+ * @throws DatabaseException
+ * when there is a problem while retreiving data from database
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public List getRemoteClientMessagesByReceiverAddress(String receiverAddress)
+ throws UnsupportedEncodingException, DatabaseException {
+ final List result = new ArrayList();
+ final List list = this.getRemoteClientMessages();
+ for (int i = 0; i < list.size(); i++) {
+ if (receiverAddress.equalsIgnoreCase(((RemoteClientMessage) list
+ .get(i)).getReceiverAddress())) {
+ result.add(list.get(i));
+ }
+ }
+ return result;
+ }
- public List getRemoteClientMessagesByMimeType(String mimeType)
- throws UnsupportedEncodingException, DatabaseException {
- final List result = new ArrayList();
- final List list = this.getRemoteClientMessages();
- for (int i = 0; i < list.size(); i++) {
- if (mimeType.equalsIgnoreCase(((RemoteClientMessage) list.get(i)).getMimeType())) {
- result.add(list.get(i));
- }
- }
- return result;
- }
+ /**
+ * Lists all messages for user with given mimetype
+ *
+ * @param mimeType
+ * mimetype of messages
+ * @return list of messages with given mimetype
+ *
+ * @throws DatabaseException
+ * when there is a problem while retreiving data from database
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public List getRemoteClientMessagesByMimeType(String mimeType)
+ throws UnsupportedEncodingException, DatabaseException {
+ final List result = new ArrayList();
+ final List list = this.getRemoteClientMessages();
+ for (int i = 0; i < list.size(); i++) {
+ if (mimeType.equalsIgnoreCase(((RemoteClientMessage) list.get(i))
+ .getMimeType())) {
+ result.add(list.get(i));
+ }
+ }
+ return result;
+ }
- public List getRemoteClientMessagesByState(int state) throws UnsupportedEncodingException,
- DatabaseException {
- final List result = new ArrayList();
- final List list = this.getRemoteClientMessages();
- for (int i = 0; i < list.size(); i++) {
- if (state == ((RemoteClientMessage) list.get(i)).getState()) {
- result.add(list.get(i));
- }
- }
- return result;
- }
+ /**
+ * Lists all messages for with given state
+ *
+ * @param state
+ * state of messages
+ * @return list of messages with given state
+ *
+ * @throws DatabaseException
+ * when there is a problem while retreiving data from database
+ * @throws UnsupportedEncodingException
+ * when data has unsupported encoding
+ */
+ public List getRemoteClientMessagesByState(int state)
+ throws UnsupportedEncodingException, DatabaseException {
+ final List result = new ArrayList();
+ final List list = this.getRemoteClientMessages();
+ for (int i = 0; i < list.size(); i++) {
+ if (state == ((RemoteClientMessage) list.get(i)).getState()) {
+ result.add(list.get(i));
+ }
+ }
+ return result;
+ }
}
Modified: trunk/code/CSRemoteClient/src/org/commsuite/utils/CommunicateUtil.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/utils/CommunicateUtil.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/utils/CommunicateUtil.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -43,6 +43,18 @@
private static final Logger logger = Logger
.getLogger(CommunicateUtil.class);
+ /**
+ * Sends message to webservice
+ *
+ * @param rcMessage
+ * message to be sent
+ * @param format
+ * format of the message
+ * @return status of sending message
+ *
+ * @throws Throwable
+ * when problem occurs while sending message
+ */
public static String sendMessage(RemoteClientMessage rcMessage,
FormatType format) throws Throwable {
@@ -70,8 +82,18 @@
}
}
- public static RemoteClientMessage getMessageStatus(RemoteClientMessage rcMessage)
- throws Throwable {
+ /**
+ * Check status of given message
+ *
+ * @param rcMessage
+ * message to be checked
+ * @return checked message
+ *
+ * @throws Throwable
+ * when problem while checking state happened
+ */
+ public static RemoteClientMessage getMessageStatus(
+ RemoteClientMessage rcMessage) throws Throwable {
final IMessagingWSLocator locator = RemoteClientAppContext
.getMessagingWS();
int lastState = rcMessage.getState();
@@ -92,14 +114,24 @@
rcMessage.setState(RemoteClientMessage.RCM_SENT);
}
if (lastState != rcMessage.getState()) {
- RemoteClientAppContext.getMessageDao().saveOrUpdateRemoteClientMessage(rcMessage);
+ RemoteClientAppContext.getMessageDao()
+ .saveOrUpdateRemoteClientMessage(rcMessage);
}
return rcMessage;
}
}
- public static List getMessagesStatus(List messages)
- throws Throwable {
+ /**
+ * Check status of all messages from the list. Deprecated. Use
+ * getMessageStatus( RemoteClientMessage rcMessage) instead
+ *
+ * @param messages
+ * message to be checked
+ * @return list of updated messages
+ * @throws Throwable
+ * when problem while checking state happened
+ */
+ public static List getMessagesStatus(List messages) throws Throwable {
if (messages == null)
return new ArrayList();
@@ -133,11 +165,13 @@
}
}
if (lastState != message.getState()) {
- RemoteClientAppContext.getMessageDao().saveOrUpdateRemoteClientMessage(message);
+ RemoteClientAppContext.getMessageDao()
+ .saveOrUpdateRemoteClientMessage(message);
}
} catch (Throwable t) {
message.setState(RemoteClientMessage.RCM_UNKNOWN_STATE);
- logger.info("error while checking state of message: " + message + "\r\n" + t);
+ logger.info("error while checking state of message: " + message
+ + "\r\n" + t);
}
}
Modified: trunk/code/CSRemoteClient/src/org/commsuite/utils/MessageSavingUtil.java
===================================================================
--- trunk/code/CSRemoteClient/src/org/commsuite/utils/MessageSavingUtil.java 2006-09-03 09:38:59 UTC (rev 125)
+++ trunk/code/CSRemoteClient/src/org/commsuite/utils/MessageSavingUtil.java 2006-09-03 14:59:02 UTC (rev 126)
@@ -26,6 +26,8 @@
import org.commsuite.model.RemoteClientMessage;
/**
+ * util class to communcation with database
+ *
* @since 1.0
* @author Marek Musielak
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|