xlawrence 2004/12/17 16:47:01 CET
Modified files:
src/java log4j.properties
src/java/org/jahia/suite/calendar JORAMAdmin.java
src/java/org/jahia/suite/calendar/calServer
Calendarclient.java
SyncManager.java
UwCalConnector.java
src/java/org/jahia/suite/calendar/framework LockEvent.java
src/java/org/jahia/suite/calendar/sync4jModule
CalendarSyncSource.java
CalendarSyncSourceConfigPanel.java
src/java/org/jahia/suite/calendar/syncClients
ICalendarSyncSource.java
SyncClientFrame.java
src/java/org/jahia/suite/calendar/syncServer
CalendarManager.java
src/java/org/jahia/suite/calendar/test DummyCalServerGUI.java
DummyCalendarServer.java
Revision Changes Path
1.5 +1 -0 uwcal_JSR168/src/java/log4j.properties
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/log4j.properties.diff?r1=1.4&r2=1.5&f=h
1.4 +15 -13
uwcal_JSR168/src/java/org/jahia/suite/calendar/JORAMAdmin.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/JORAMAdmin.java.diff?r1=1.3&r2=1.4&f=h
1.3 +11 -5
uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/Calendarclient.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/Calendarclient.java.diff?r1=1.2&r2=1.3&f=h
1.3 +115 -23
uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/SyncManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/SyncManager.java.diff?r1=1.2&r2=1.3&f=h
1.5 +15 -5
uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/UwCalConnector.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/UwCalConnector.java.diff?r1=1.4&r2=1.5&f=h
1.2 +27 -3
uwcal_JSR168/src/java/org/jahia/suite/calendar/framework/LockEvent.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/framework/LockEvent.java.diff?r1=1.1&r2=1.2&f=h
1.9 +4 -0
uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSource.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSource.java.diff?r1=1.8&r2=1.9&f=h
1.6 +45 -49
uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSourceConfigPanel.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSourceConfigPanel.java.diff?r1=1.5&r2=1.6&f=h
1.9 +2 -1
uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/ICalendarSyncSource.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/ICalendarSyncSource.java.diff?r1=1.8&r2=1.9&f=h
1.9 +1 -0
uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClientFrame.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClientFrame.java.diff?r1=1.8&r2=1.9&f=h
1.6 +4 -4
uwcal_JSR168/src/java/org/jahia/suite/calendar/syncServer/CalendarManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncServer/CalendarManager.java.diff?r1=1.5&r2=1.6&f=h
1.5 +22 -4
uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalServerGUI.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalServerGUI.java.diff?r1=1.4&r2=1.5&f=h
1.8 +25 -18
uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java.diff?r1=1.7&r2=1.8&f=h
Index: log4j.properties
===================================================================
RCS file: /home/cvs/repository/uwcal_JSR168/src/java/log4j.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- log4j.properties 13 Dec 2004 09:57:16 -0000 1.4
+++ log4j.properties 17 Dec 2004 15:46:59 -0000 1.5
@@ -15,6 +15,7 @@
#log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
#log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p: %m%n
+log4j.logger.org.jahia.suite.calendar=INFO
log4j.logger.org.jahia.suite.calendar.sync4jModule=DEBUG
log4j.logger.org.jahia.suite.calendar.syncServer=DEBUG
log4j.logger.org.jahia.suite.calendar.syncClients=DEBUG
\ No newline at end of file
Index: JORAMAdmin.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/JORAMAdmin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JORAMAdmin.java 23 Nov 2004 10:30:16 -0000 1.3
+++ JORAMAdmin.java 17 Dec 2004 15:46:59 -0000 1.4
@@ -42,7 +42,6 @@
import org.objectweb.joram.client.jms.tcp.QueueTcpConnectionFactory;
import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
import javax.naming.Context;
@@ -52,22 +51,16 @@
/**
- * Simple JORAM configuration program to create needed JMS ressources on the
+ * Simple JORAM configuration program to create needed JMS ressources on the
* JMS server.
*
* @author Xavier Lawrence
*/
-public class JORAMAdmin {
+public class JORAMAdmin {
static Logger log = Logger.getLogger(JORAMAdmin.class);
- static String configFile =
- "C:\\Documents and Settings\\jahia\\Desktop\\cal\\src\\log4j.properties";
- /**
- * Start the program
- * @param args the command line arguments
- */
- public static void main(String[] args) throws Exception {
+ public void start() throws Exception {
log.info("JORAM Server administration...");
AdminModule.connect("root", "root", 60);
@@ -99,9 +92,18 @@
jndiCtx.bind(JMSAgent.CAL_SERVER_QUEUE, calQueue);
jndiCtx.bind(JMSAgent.CONN_FACTORY, cnxFact);
jndiCtx.close();
- log.info("Ressources bounded into JNDI");
+ log.info("Ressources bound into JNDI");
AdminModule.disconnect();
- log.info("Admin closed.");
- }
+ log.info("Admin closed.");
+ }
+
+ /**
+ * Start the program
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Exception {
+ JORAMAdmin app = new JORAMAdmin();
+ app.start();
+ }
}
Index: Calendarclient.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/Calendarclient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Calendarclient.java 23 Nov 2004 10:30:16 -0000 1.2
+++ Calendarclient.java 17 Dec 2004 15:46:59 -0000 1.3
@@ -54,6 +54,7 @@
import org.jahia.suite.calendar.framework.SyncException;
import org.jahia.suite.calendar.framework.TransportReceiver;
+import org.jahia.suite.calendar.framework.LockEvent;
import org.jahia.suite.calendar.framework.Storable;
import org.apache.log4j.Logger;
@@ -71,8 +72,10 @@
static Logger log = Logger.getLogger(Calendarclient.class);
// A TransportReceiver to receive requests
private TransportReceiver agent;
- // A Storable to store/retreive data from the calendar server
- private Storable syncManager;
+ // A LockEvent to store/retreive data from the calendar server and
lock/unlock it
+ private LockEvent syncManager;
+ // A Storable for getting new GUIDs for new client events
+ private Storable calServer;
// Simple counter variable (see method newID())
private static int respID = 0;
@@ -84,6 +87,8 @@
"calServer", "calServer");
agent.start();
agent.setMessageListener(this);
+ syncManager = SyncManager.getInstance();
+ calServer = UwCalConnector.getInstance();
}
/**
@@ -100,7 +105,7 @@
Calendar calendar = null;
- calendar = new Calendar(syncManager.getAllEvents(
+ calendar = new Calendar(syncManager.getLockedEvents(
req.getUserName()+req.getDeviceID()));
GetCalendarRequestResponse resp = (GetCalendarRequestResponse)
@@ -116,7 +121,7 @@
SyncOperation[] ops = req.getOperations();
// update the events on the calendar server
- syncManager.updateEvents(ops);
+ syncManager.unlockAndUpdateEvents(req.getCalendarID(), ops);
resp = req.makeResponse(newID(),
UpdateCalendarRequestResponse.OK);
agent.sendResponse(resp, req);
@@ -130,7 +135,7 @@
} else if (msg instanceof GetGUIDRequest) {
GetGUIDRequest req = (GetGUIDRequest)msg;
- GUID newGUID = syncManager.getNewGUID();
+ GUID newGUID = calServer.getNewGUID();
GetGUIDRequestResponse resp = (GetGUIDRequestResponse)
req.makeResponse(newID(), newGUID);
@@ -157,6 +162,7 @@
* @param args the command line arguments
*/
public static void main(String[] args) {
+ log.info("Starting Calendar Client...");
Calendarclient app = new Calendarclient();
log.info("Calendar Client successfully started");
}
Index: SyncManager.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/SyncManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SyncManager.java 23 Nov 2004 10:30:16 -0000 1.2
+++ SyncManager.java 17 Dec 2004 15:46:59 -0000 1.3
@@ -45,17 +45,22 @@
import org.jahia.suite.calendar.framework.model.GUID;
import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Timer;
+import java.util.TimerTask;
import org.apache.log4j.Logger;
/**
- * This class implements interfaces LockEvent and Storable. It thus can be
- * viewed as a Transaction Manager as it is able to grant/release locks for
+ * This class implements interfaces LockEvent and Storable. It thus can be
+ * viewed as a Transaction Manager as it is able to grant/release locks for
* particular events and can store changes in the calendar server.
*
* @author Xavier Lawrence
*/
-public class SyncManager implements LockEvent, Storable {
+public class SyncManager implements LockEvent {
+
+ public static final int TIMEOUT = 45;
// Single Object of this class (Singleton pattern)
private static SyncManager client = new SyncManager();
@@ -69,10 +74,15 @@
// A Vector of current locked events (identified by their eventID (key))
private Vector lockedEvents;
+ private Hashtable sessionToEvents;
+ private Hashtable sessionToTimer;
+
// Don't let anyone else instantiate this class (Singleton pattern)
private SyncManager() {
this.lockedEvents = new Vector(0);
- this.calServer = new UwCalConnector();
+ this.calServer = UwCalConnector.getInstance();
+ sessionToEvents = new Hashtable();
+ sessionToTimer = new Hashtable();
}
/**
@@ -84,7 +94,8 @@
}
/**
- * Thread safe method for locking a particular event.
+ * Thread safe method for locking a particular event. The method will
only
+ * return once the lock has been granted.
* @see LockEvent
*/
public synchronized void getLock(SyncEvent event) throws SyncException {
@@ -101,6 +112,23 @@
}
/**
+ * Thread safe method for locking a particular event. The method will
only
+ * return once all locks have been granted.
+ * @see LockEvent
+ */
+ public synchronized SyncEvent[] getLockedEvents(String calendarID)
+ throws SyncException {
+ SyncEvent[] sessionEvents = calServer.getAllEvents(calendarID);
+ for (int i=0; i<sessionEvents.length; i++) {
+ getLock(sessionEvents[i]);
+ }
+ sessionToEvents.put(calendarID, sessionEvents);
+ CleanUpTimer timer = new CleanUpTimer(TIMEOUT, calendarID);
+ sessionToTimer.put(calendarID, timer);
+ return sessionEvents;
+ }
+
+ /**
* Thread safe method for unlocking a particular event.
* @see LockEvent
*/
@@ -116,6 +144,29 @@
}
/**
+ * Thread safe method for unlocking all the events of a calendar.
+ * @see LockEvent
+ */
+ public synchronized void unlockAndUpdateEvents(String calendarID,
+ SyncOperation[] operations) throws SyncException {
+ SyncEvent[] sessionEvents =
(SyncEvent[])sessionToEvents.get(calendarID);
+
+ if (operations != null) {
+ calServer.updateEvents(operations);
+ }
+
+ if (sessionEvents != null) {
+ for (int i=0; i<sessionEvents.length; i++) {
+ unlock(sessionEvents[i]);
+ }
+ sessionToEvents.remove(calendarID);
+ CleanUpTimer timer =
(CleanUpTimer)sessionToTimer.get(calendarID);
+ timer.stop();
+ sessionToEvents.remove(calendarID);
+ }
+ }
+
+ /**
* Tests if a given event is allready locked. (Thread-safe)
* @param event The event to test
* @returns True if the testes event is allready locked
@@ -127,23 +178,6 @@
/**
* @see Storable
*/
- public synchronized SyncEvent[] getAllEvents(String calendarID)
- throws SyncException {
- try {
- SyncEvent[] result = calServer.getAllEvents(calendarID);
- for (int i=0; i<result.length; i++) {
- getLock(result[i]);
- }
- return result;
- } catch (Exception e) {
- log.error(e);
- throw new SyncException(e.getMessage(), e);
- }
- }
-
- /**
- * @see Storable
- */
public synchronized void updateEvents(SyncOperation[] operations)
throws SyncException {
try {
@@ -162,5 +196,63 @@
*/
public GUID getNewGUID() throws SyncException {
return calServer.getNewGUID();
- }
+ }
+
+ /**
+ * A simple Timer that will automatically release the locks after a given
+ * time.
+ */
+ private class CleanUpTimer {
+
+ private Timer timer;
+
+ /**
+ * Creates a new instance of CleanUpTimer
+ */
+ public CleanUpTimer(int seconds, String calendarID) {
+ timer = new Timer(true);
+ timer.schedule(new RemindTask(calendarID), seconds*1000);
+ }
+
+ /**
+ * Stops the current timer
+ */
+ public void stop() {
+ timer.cancel();
+ }
+
+ /**
+ *
+ */
+ private class RemindTask extends TimerTask {
+
+ private String calendarID;
+
+ /**
+ * Creates a new instance of RemindTask
+ */
+ public RemindTask(String calendarID) {
+ this.calendarID = calendarID;
+ }
+
+ /**
+ *
+ */
+ public synchronized void run() {
+ log.info("Time's up for session: "+calendarID);
+
+ try {
+ // Time is up and locks are still held. We assume we have
+ // a failure and release the locks.
+ unlockAndUpdateEvents(calendarID, null);
+
+ } catch (Exception e) {
+
+ } finally {
+ //Terminate the timer thread
+ timer.cancel();
+ }
+ }
+ }
+ }
}
Index: UwCalConnector.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/UwCalConnector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UwCalConnector.java 30 Nov 2004 17:08:54 -0000 1.4
+++ UwCalConnector.java 17 Dec 2004 15:46:59 -0000 1.5
@@ -36,7 +36,7 @@
*/
package org.jahia.suite.calendar.calServer;
-import org.jahia.suite.calendar.framework.Storable;
+import org.jahia.suite.calendar.framework.Storable;
import org.jahia.suite.calendar.framework.model.GUID;
import org.jahia.suite.calendar.framework.SyncException;
import org.jahia.suite.calendar.framework.model.SyncEvent;
@@ -56,13 +56,23 @@
*/
public class UwCalConnector implements Storable {
+ // Single Object of this class (Singleton pattern)
+ private static UwCalConnector uwCalConnector = new UwCalConnector();
+
+ /**
+ * Common method for getting an instance of this class (singleton
pattern).
+ * @return The reference to the singleton object
+ */
+ public static UwCalConnector getInstance() {
+ return uwCalConnector;
+ }
+
// Connection to uwCal
private Synch calServer;
- /**
- * Creates a new instance of CalendarServerConnector
- */
- public UwCalConnector() {
+ // Disable default constructor
+ private UwCalConnector() {
+
}
/**
Index: LockEvent.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/framework/LockEvent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LockEvent.java 19 Nov 2004 15:02:45 -0000 1.1
+++ LockEvent.java 17 Dec 2004 15:46:59 -0000 1.2
@@ -37,6 +37,7 @@
package org.jahia.suite.calendar.framework;
import org.jahia.suite.calendar.framework.model.SyncEvent;
+import org.jahia.suite.calendar.framework.model.SyncOperation;
/**
* <p>This interface defines methods for locking and unlocking a calendar
event.
@@ -46,8 +47,8 @@
* with the data from the calendar server. All modifications are directly
* applied to the server, without an intermediate synchronization.</p>
* <p>
- * Typically, the logic of a WEB application would need to use this interface
- * when accessing the data from the calendar server.
+ * Typically, the logic of a WEB application or a Sync Manager would need to
use
+ * this interface when accessing the data from the calendar server.
* </p>
*
* @author Xavier Lawrence
@@ -55,7 +56,8 @@
public interface LockEvent {
/**
- * Prevents any other operations from modifying or reading a calendar
event.
+ * Prevents any other operations from modifying or reading an allready
+ * locked calendar event.
* @param event The event to lock
* @throws SyncException If something goes wrong
*/
@@ -68,4 +70,26 @@
* @throws SyncException If something goes wrong
*/
public void unlock(SyncEvent event) throws SyncException;
+
+ /**
+ * Prevents any other operations from modifying or reading some calendar
+ * allready locked events.
+ * @param calendarID The ID of the calendar. This parameter will be used
to
+ * identify a group of events. It will be used for unlocking all
the
+ * events of a sync Session, ie, of a calendar
+ * @return The locked events of the specified calendar
+ * @throws SyncException If something goes wrong
+ */
+ public SyncEvent[] getLockedEvents(String calendarID) throws
SyncException;
+
+ /**
+ * Unlocks and updates previously locked events allowing other
operations
+ * to read or modify these events.
+ * @param calendarID The sync session ID of the given events. This ID is
+ * nothing else than the calendar ID.
+ * @param operations The operations needed to synchronize the calendar
events
+ * @throws SyncException If something goes wrong
+ */
+ public void unlockAndUpdateEvents(String calendarID,
+ SyncOperation[] operations) throws SyncException;
}
Index: CalendarSyncSource.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSource.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CalendarSyncSource.java 13 Dec 2004 14:45:49 -0000 1.8
+++ CalendarSyncSource.java 17 Dec 2004 15:47:00 -0000 1.9
@@ -80,6 +80,10 @@
private CalendarManager cm;
private boolean loaded;
+ public String getName() {
+ return NAME;
+ }
+
/**
* Creates a new instance of CalendarSyncSource
*/
Index: CalendarSyncSourceConfigPanel.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSourceConfigPanel.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CalendarSyncSourceConfigPanel.java 8 Dec 2004 16:07:16 -0000
1.5
+++ CalendarSyncSourceConfigPanel.java 17 Dec 2004 15:47:00 -0000
1.6
@@ -37,7 +37,7 @@
package org.jahia.suite.calendar.sync4jModule;
-import javax.swing.JOptionPane;
+import javax.swing.*;
import sync4j.syncadmin.ui.ManagementPanel;
import sync4j.framework.engine.source.SyncSource;
@@ -47,43 +47,41 @@
import org.apache.commons.lang.StringUtils;
/**
- * This class implements the configuration panel for a CalendarSyncSource.
It
+ * This class implements the configuration panel for a CalendarSyncSource. It
* will be used by the SyncAdmin tool provided by the Sync4J distribution
* release.
*
* @author Xavier Lawrence
*/
public class CalendarSyncSourceConfigPanel extends ManagementPanel {
-
+
/**
* Allowed characters for name and uri
*/
public static final String ALLOWED_CHARS
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_.";
-
+
private CalendarSyncSource syncSource;
-
+
/**
* Creates new form CalendarSyncSourceConfigPanel
*/
public CalendarSyncSourceConfigPanel() {
initComponents();
}
-
+
/** This method is called from within the constructor to
* initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
*/
- private void initComponents() {//GEN-BEGIN:initComponents
- panelName = new javax.swing.JLabel();
- sourceUriLabel = new javax.swing.JLabel();
- sourceUriValue = new javax.swing.JTextField();
- nameLabel = new javax.swing.JLabel();
- nameValue = new javax.swing.JTextField();
- typeLabel = new javax.swing.JLabel();
- typeValue = new javax.swing.JTextField();
- confirmButton = new javax.swing.JButton();
+ private void initComponents() {
+ panelName = new JLabel();
+ sourceUriLabel = new JLabel();
+ sourceUriValue = new JTextField();
+ nameLabel = new JLabel();
+ nameValue = new JTextField();
+ typeLabel = new JLabel();
+ typeValue = new JTextField();
+ confirmButton = new JButton();
setLayout(null);
@@ -121,7 +119,7 @@
typeValue.setText("text/plain");
add(typeValue);
typeValue.setBounds(150, 120, 350, 18);
-
+
confirmButton.setFont(new java.awt.Font("Arial", 0, 11));
confirmButton.setText("Add");
confirmButton.addActionListener(new java.awt.event.ActionListener() {
@@ -138,22 +136,22 @@
add(confirmButton);
confirmButton.setBounds(150, 200, 70, 25);
- }//GEN-END:initComponents
+ }
/**
- * If focus is on the confirm button and "ENTER" is pressed, perform the
+ * If focus is on the confirm button and "ENTER" is pressed, perform the
* action associated with the ActionListener.
*/
- private void confirmButtonKeyPressed(java.awt.event.KeyEvent evt)
{//GEN-FIRST:event_confirmButtonKeyPressed
+ private void confirmButtonKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyChar() == '\n') {
confirmButtonActionPerformed(null);
}
- }//GEN-LAST:event_confirmButtonKeyPressed
-
+ }
+
/**
* Adds a SyncSource to sync4j.
*/
- private void confirmButtonActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_confirmButtonActionPerformed
+ private void confirmButtonActionPerformed(java.awt.event.ActionEvent
evt) {
try {
validateValues();
getUserValues();
@@ -166,7 +164,7 @@
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e);
}
- }//GEN-LAST:event_confirmButtonActionPerformed
+ }
/**
* Loads the given syncSource showing the name, uri and type in the
panel's
@@ -181,29 +179,29 @@
"SyncSource values.");
return;
}
-
+
if (getState() == ManagementPanel.STATE_INSERT) {
confirmButton.setText("Add");
} else if (getState() == ManagementPanel.STATE_UPDATE) {
confirmButton.setText("Save");
}
-
+
this.syncSource = (CalendarSyncSource)syncSource;
-
+
sourceUriValue.setText(this.syncSource.getSourceURI() );
nameValue.setText (this.syncSource.getName() );
-
+
if (this.syncSource.getSourceURI() != null) {
sourceUriValue.setEditable(false);
}
-
+
} catch (Exception e) {
showError(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e);
}
}
-
+
/**
* Checks if the values provided by the user are all valid. In caso of
errors,
* an IllegalArgumentException is thrown.
@@ -212,24 +210,24 @@
*/
private void validateValues() throws IllegalArgumentException {
String value = null;
-
+
value = nameValue.getText();
if (StringUtils.isEmpty(value)) {
throw new IllegalArgumentException("Field 'Name' cannot be
empty. "+
"Please provide a SyncSource name.");
}
-
+
if (!StringUtils.containsOnly(value, ALLOWED_CHARS.toCharArray())) {
throw new IllegalArgumentException("Only the following
characters "+
"are allowed for field 'Name': \n" + ALLOWED_CHARS);
}
-
+
value = typeValue.getText();
if (StringUtils.isEmpty(value)) {
throw new IllegalArgumentException("Field 'Type' cannot be
empty. "+
"Please provide a SyncSource type. (eg: 'text/plain')");
}
-
+
value = sourceUriValue.getText();
if (StringUtils.isEmpty(value)) {
throw new
@@ -237,7 +235,7 @@
"Field 'Source URI' cannot be empty. Please provide a SyncSource
URI.");
}
}
-
+
/**
* Set syncSource properties with the values provided by the user.
*/
@@ -245,7 +243,7 @@
syncSource.setSourceURI(sourceUriValue.getText().trim());
syncSource.setName(nameValue.getText().trim());
syncSource.setType(typeValue.getText().trim());
-
+
ContentType[] contentTypes = new ContentType[] {
new ContentType("text/plain", "1.0")
};
@@ -260,16 +258,14 @@
private void showError(String msg) {
JOptionPane.showMessageDialog(null, msg, "Error",
JOptionPane.ERROR_MESSAGE);
}
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton confirmButton;
- private javax.swing.JLabel nameLabel;
- private javax.swing.JTextField nameValue;
- private javax.swing.JLabel panelName;
- private javax.swing.JLabel sourceUriLabel;
- private javax.swing.JTextField sourceUriValue;
- private javax.swing.JLabel typeLabel;
- private javax.swing.JTextField typeValue;
- // End of variables declaration//GEN-END:variables
-
+
+ // Variables declaration
+ private JButton confirmButton;
+ private JLabel nameLabel;
+ private JTextField nameValue;
+ private JLabel panelName;
+ private JLabel sourceUriLabel;
+ private JTextField sourceUriValue;
+ private JLabel typeLabel;
+ private JTextField typeValue;
}
Index: ICalendarSyncSource.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/ICalendarSyncSource.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ICalendarSyncSource.java 13 Dec 2004 14:46:58 -0000 1.8
+++ ICalendarSyncSource.java 17 Dec 2004 15:47:00 -0000 1.9
@@ -270,7 +270,8 @@
final String fileName;
if (!(new String(fileContent).startsWith("BEGIN"))) {
- // It is the item containing the calendar properties
+ // It is the item containing the calendar properties and it
should
+ // allways have the lowest index, ie 0
fileName = "0";
} else {
String key = syncItem.getKey().getKeyAsString();
Index: SyncClientFrame.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClientFrame.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SyncClientFrame.java 13 Dec 2004 16:06:29 -0000 1.8
+++ SyncClientFrame.java 17 Dec 2004 15:47:00 -0000 1.9
@@ -129,6 +129,7 @@
setFrameLocation();
show();
setDefaultCloseOperation(super.DO_NOTHING_ON_CLOSE);
+ setResizable(false);
}
/**
Index: CalendarManager.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncServer/CalendarManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CalendarManager.java 8 Dec 2004 16:07:56 -0000 1.5
+++ CalendarManager.java 17 Dec 2004 15:47:00 -0000 1.6
@@ -51,7 +51,7 @@
import org.jahia.suite.calendar.framework.model.GUID;
import org.jahia.suite.calendar.util.StateValueConverter;
-import org.jahia.suite.calendar.sync4jModule.CalendarSyncSource;
+import sync4j.framework.engine.source.SyncSource;
import sync4j.framework.engine.SyncItem;
import sync4j.framework.engine.SyncItemImpl;
@@ -93,14 +93,14 @@
// All the events of a calendar
private Vector allItems;
- private CalendarSyncSource source;
+ private SyncSource source;
/**
* Creates a new instance of CalendarManager
- * @param source The CalendarSyncSource Object that created this
+ * @param source The SyncSource Object that created this
* CalendarManager
*/
- public CalendarManager(CalendarSyncSource source) {
+ public CalendarManager(SyncSource source) {
JMSAgent tAgent = new JMSAgent(JMSAgent.CAL_SERVER_QUEUE,
"syncServer",
"syncServer");
try {
Index: DummyCalServerGUI.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalServerGUI.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DummyCalServerGUI.java 13 Dec 2004 14:45:08 -0000 1.4
+++ DummyCalServerGUI.java 17 Dec 2004 15:47:01 -0000 1.5
@@ -136,6 +136,7 @@
gridBagConstraints.gridy = 5;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
+ gridBagConstraints.weightx = 0.5;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
getContentPane().add(printButton, gridBagConstraints);
@@ -151,6 +152,7 @@
gridBagConstraints.gridy = 5;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.weightx = 0.5;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
getContentPane().add(clearButton, gridBagConstraints);
@@ -164,7 +166,9 @@
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
getContentPane().add(stateSelecter, gridBagConstraints);
- keysContainer.setPreferredSize(new java.awt.Dimension(80, 80));
+ keysContainer.setMaximumSize(new java.awt.Dimension(0, 0));
+ keysContainer.setMinimumSize(new java.awt.Dimension(0, 0));
+ keysContainer.setPreferredSize(new java.awt.Dimension(0, 0));
keyList.addListSelectionListener(new
javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent
evt) {
keyListValueChanged(evt);
@@ -181,6 +185,8 @@
gridBagConstraints.ipadx = 47;
gridBagConstraints.ipady = 27;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 0, 3);
+ gridBagConstraints.weightx = 0.1;
+ gridBagConstraints.weighty = 0.2;
getContentPane().add(keysContainer, gridBagConstraints);
keysName.setFont(new java.awt.Font("Arial", 1, 12));
@@ -239,7 +245,7 @@
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
- gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
+ gridBagConstraints.insets = new java.awt.Insets(40, 3, 0, 0);
getContentPane().add(editButton, gridBagConstraints);
newButton.setText("New");
@@ -256,6 +262,7 @@
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
+ gridBagConstraints.insets = new java.awt.Insets(40, 0, 0, 0);
getContentPane().add(newButton, gridBagConstraints);
deleteButton.setText("Delete");
@@ -272,6 +279,7 @@
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
+ gridBagConstraints.insets = new java.awt.Insets(40, 0, 0, 0);
getContentPane().add(deleteButton, gridBagConstraints);
fileMEnu.setText("File");
@@ -299,9 +307,19 @@
JOptionPane.ERROR_MESSAGE);
return;
}
- server.getCalendar().removeEvent(key);
- removeItem(key);
+ if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(this,
+ "This operation will directly delete the event without marking it
as\n"+
+ "deleted. It will then not be sent to the sync server and not
deleted\n"+
+ "by the client.\n"+
+ "To delete an event from the client, you have to set its state to
'DELETED'\n"+
+ "and perform a synchronization.\n"+
+ "Continue anyway ?", "Warning", JOptionPane.YES_NO_OPTION,
+ JOptionPane.INFORMATION_MESSAGE)) {
+
+ server.getCalendar().removeEvent(key);
+ removeItem(key);
+ }
}//GEN-LAST:event_deleteButtonActionPerformed
private void newButtonActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_newButtonActionPerformed
Index: DummyCalendarServer.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DummyCalendarServer.java 13 Dec 2004 14:45:08 -0000 1.7
+++ DummyCalendarServer.java 17 Dec 2004 15:47:01 -0000 1.8
@@ -76,38 +76,43 @@
private DummyCalServerGUI gui;
private final String data0 =
- "VERSION:2.0\n"+
- "X-WR-CALNAME:UK Holidays\n"+
- "PRODID:-//Apple Computer\\, Inc//iCal 1.5//EN\n"+
- "X-WR-RELCALID:9DE52D32-D020-11D8-9530-000A958A3252\n"+
- "X-WR-TIMEZONE:Europe/Paris\n"+
- "CALSCALE:GREGORIAN\n"+
- "METHOD:PUBLISH";
+// "VERSION:2.0\n"+
+// "X-WR-CALNAME:UK Holidays\n"+
+// "PRODID:-//Apple Computer\\, Inc//iCal 1.5//EN\n"+
+// "X-WR-RELCALID:9DE52D32-D020-11D8-9530-000A958A3252\n"+
+// "X-WR-TIMEZONE:Europe/Paris\n"+
+// "CALSCALE:GREGORIAN\n"+
+// "METHOD:PUBLISH";
+ "BEGIN:VEVENT\n"+
+ "DTSTART;VALUE=DATE:20041116\n"+
+ "DTEND;VALUE=DATE:20041116\n"+
+ "SUMMARY:Dummy SyncItem 0 (data0)\n"+
+ "UID:DUMMY-SYNC-ITEM-20-FOR-TESTING\n"+
+ "DTSTAMP:20040707T140415Z\n"+
+ "END:VEVENT";
private final String data1 =
"BEGIN:VEVENT\n"+
- "DTSTART;VALUE=DATE:20020101\n"+
- "DTEND;VALUE=DATE:20020102\n"+
+ "DTSTART;VALUE=DATE:20041116\n"+
+ "DTEND;VALUE=DATE:20041116\n"+
"SUMMARY:Dummy SyncItem 1 (data1)\n"+
"UID:DUMMY-SYNC-ITEM-20-FOR-TESTING\n"+
"DTSTAMP:20040707T140415Z\n"+
- "RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=2\n"+
"END:VEVENT";
private final String data2 =
"BEGIN:VEVENT\n"+
- "DTSTART;VALUE=DATE:20020101\n"+
- "DTEND;VALUE=DATE:20020102\n"+
+ "DTSTART;VALUE=DATE:20041217\n"+
+ "DTEND;VALUE=DATE:20041218\n"+
"SUMMARY:Dummy SyncItem 2 (data2)\n"+
"UID:DUMMY-SYNC-ITEM-30-FOR-TESTING\n"+
"DTSTAMP:20040707T140415Z\n"+
- "RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=3\n"+
"END:VEVENT";
private final String data3 =
"BEGIN:VEVENT\n"+
- "DTSTART;VALUE=DATE:20030418\n"+
- "DTEND;VALUE=DATE:20030419\n"+
+ "DTSTART;VALUE=DATE:20041215\n"+
+ "DTEND;VALUE=DATE:20041216\n"+
"SUMMARY:Dummy SyncItem 3 (data3)\n"+
"UID:9DE4B99A-D020-11D8-9530-000A958A3252\n"+
"DTSTAMP:20040707T140415Z\n"+
@@ -136,6 +141,7 @@
events[2] = new SyncEvent("key2", data2.getBytes("ISO-8859-1"),
SyncEvent.UNKNOWN);
events[3] = new SyncEvent("key3", data3.getBytes("ISO-8859-1"),
SyncEvent.UNKNOWN);
calendar = new Calendar(events);
+ respID = 4;
} catch (Exception e) {
e.printStackTrace();
}
@@ -192,8 +198,9 @@
for (int i=0; i<calendar.getEvents().length; i++) {
if (calendar.getEvents()[i].getState() ==
SyncEvent.DELETED) {
+ String key = (calendar.getEvents()[i]).getKey();
calendar.removeEvent(calendar.getEvents()[i]);
- gui.removeItem((calendar.getEvents()[i]).getKey());
+ gui.removeItem(key);
} else {
calendar.getEvents()[i].setState(SyncEvent.SYNCHRONIZED);
@@ -211,9 +218,9 @@
} else if (msg instanceof GetGUIDRequest) {
log.info("GetGUIDRequest");
GetGUIDRequest req = (GetGUIDRequest)msg;
- GUID newGUID = new GUID("key_", calendar.getEvents().length);
+ GUID newGUID = new GUID("key_", new Integer(newID()).intValue());
GetGUIDRequestResponse resp = (GetGUIDRequestResponse)
- req.makeResponse(newID(), newGUID);
+ req.makeResponse(new Integer(newID()).intValue(), newGUID);
agent.sendResponse(resp, req);
} else {