[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyn
From: |
nomail |
Subject: |
[Phpgroupware-cvs] sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java, 1.7 |
Date: |
Wed, 9 Jun 2004 20:35:09 +0200 |
Update of /sync/sync4j/de/probusiness/pbgroupware/sync
Modified Files:
Branch:
PHPGwSyncSource.java
date: 2004/06/09 18:35:09; author: mkaemmerer; state: Exp; lines: +64 -14
Log Message:
- new sourceinfo and mimetype handling
=====================================================================
Index: sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java
diff -u sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java:1.6
sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java:1.7
--- sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java:1.6
Sun Mar 28 13:08:59 2004
+++ sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java Wed Jun
9 18:35:09 2004
@@ -9,7 +9,7 @@
package de.probusiness.pbgroupware.sync;
import java.security.*;
-import java.sql.*;
+//import java.sql.*;
import java.util.*;
import java.util.logging.*;
@@ -25,6 +25,14 @@
*/
public class PHPGwSyncSource extends AbstractSyncSource {
+ public static final String SYNCITEM_ID = "syncItem.id";
+ public static final String SYNCITEM_DATA = "syncItem.data";
+ public static final String SYNCITEM_CONTENTTYPE =
"syncItem.contentType";
+ public static final String CONTENT_TYPE_KEY_TYPE =
+ PHPGwSyncStrategy.CONTENT_TYPE_KEY_TYPE;
+ public static final String CONTENT_TYPE_KEY_VERSION =
+ PHPGwSyncStrategy.CONTENT_TYPE_KEY_VERSION;
+
protected transient Logger logger = Sync4jLogger.getLogger();
private String targetURI = "http://localhost/phpgw/xmlrpc.php";
@@ -71,7 +79,7 @@
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getDeletedSyncItemKeys(java.security.Principal,
java.sql.Timestamp)
*/
- public SyncItemKey[] getDeletedSyncItemKeys(final Principal principal,
final Timestamp since) throws SyncSourceException {
+ public SyncItemKey[] getDeletedSyncItemKeys(final Principal principal,
final java.sql.Timestamp since) throws SyncSourceException {
logger.fine("getDeletedSyncItemKeys");
final Vector params = new Vector();
addTimestamp(since, params);
@@ -81,7 +89,7 @@
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getDeletedSyncItems(java.security.Principal,
java.sql.Timestamp)
*/
- public SyncItem[] getDeletedSyncItems(Principal principal, Timestamp
since) throws SyncSourceException {
+ public SyncItem[] getDeletedSyncItems(Principal principal,
java.sql.Timestamp since) throws SyncSourceException {
logger.fine("getDeletedSyncItems");
final Vector params = new Vector();
addTimestamp(since, params);
@@ -91,7 +99,7 @@
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getNewSyncItemKeys(java.security.Principal,
java.sql.Timestamp)
*/
- public SyncItemKey[] getNewSyncItemKeys(final Principal principal,
final Timestamp since) throws SyncSourceException {
+ public SyncItemKey[] getNewSyncItemKeys(final Principal principal,
final java.sql.Timestamp since) throws SyncSourceException {
logger.fine("getNewSyncItemKeys");
final Vector params = new Vector();
addTimestamp(since, params);
@@ -101,7 +109,7 @@
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getNewSyncItems(java.security.Principal,
java.sql.Timestamp)
*/
- public SyncItem[] getNewSyncItems(final Principal principal, final
Timestamp since) throws SyncSourceException {
+ public SyncItem[] getNewSyncItems(final Principal principal, final
java.sql.Timestamp since) throws SyncSourceException {
logger.fine("getNewSyncItems");
final Vector params = new Vector();
addTimestamp(since, params);
@@ -165,7 +173,7 @@
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getUpdatedSyncItemKeys(java.security.Principal,
java.sql.Timestamp)
*/
- public SyncItemKey[] getUpdatedSyncItemKeys(final Principal principal,
final Timestamp since) throws SyncSourceException {
+ public SyncItemKey[] getUpdatedSyncItemKeys(final Principal principal,
final java.sql.Timestamp since) throws SyncSourceException {
logger.fine("getUpdatedSyncItemKeys");
final Vector params = new Vector();
addTimestamp(since, params);
@@ -176,7 +184,7 @@
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getUpdatedSyncItems(java.security.Principal,
java.sql.Timestamp)
*/
- public SyncItem[] getUpdatedSyncItems(final Principal principal, final
Timestamp since) throws SyncSourceException {
+ public SyncItem[] getUpdatedSyncItems(final Principal principal, final
java.sql.Timestamp since) throws SyncSourceException {
logger.fine("getUpdatedSyncItems");
final Vector params = new Vector();
addTimestamp(since, params);
@@ -218,7 +226,7 @@
final SyncItemKey id = syncInstance.getKey();
// get the data
- final SyncProperty dataProperty =
syncInstance.getProperty(SyncItem.PROPERTY_BINARY_CONTENT);
+// final SyncProperty dataProperty =
syncInstance.getProperty(SyncItem.PROPERTY_BINARY_CONTENT);
final byte[] data = (byte[])
syncInstance.getPropertyValue(SyncItem.PROPERTY_BINARY_CONTENT);
final String dataString = new String(Base64.encode(data));
@@ -248,14 +256,56 @@
*/
public SyncItem[] setSyncItems(final Principal principal, final
SyncItem[] syncItems) throws SyncSourceException {
logger.fine("setSyncItems");
+// final int len = syncItems.length;
+// final SyncItem[] ret = new SyncItem[len];
+// for (int i = 0; i < len; i++) {
+// final SyncItem item = syncItems[i];
+// ret[i] = setSyncItem(principal, item);
+// }
+// return ret;
+ final Vector params = new Vector();
+ final Vector sits = new Vector();
+
+ // get content type (mime)
+ final SyncSourceInfo info = (SyncSourceInfo) getInfo();
+ //TODO: later we should implement a callback to get other types
if needed by phpgw
+ final ContentType sourceType = info.getPreferredType();
+// recursive arrays not available in phpgw:
+// final Hashtable ct = new Hashtable();
+// ct.put(CONTENT_TYPE_KEY_TYPE, sourceType.getType());
+// ct.put(CONTENT_TYPE_KEY_VERSION, sourceType.getVersion());
+// ret.put(SYNCITEM_CONTENTTYPE, ct);
+
+ params.add(sourceType.getType());
+ params.add(sourceType.getVersion());
+
final int len = syncItems.length;
- final SyncItem[] ret = new SyncItem[len];
+ params.add(new Integer(syncItems.length).toString());
for (int i = 0; i < len; i++) {
final SyncItem item = syncItems[i];
- ret[i] = setSyncItem(principal, item);
+ transformSyncItem(sits, item);
}
- return ret;
+ params.add(sits);
+ final Vector results = (Vector) executeXMLRPC(principal,
"setSyncItems", params);
+ for (int i = 0; i < len; i++) {
+ final Boolean res = (Boolean) results.get(i);
+ if (res.booleanValue())
+ syncItems[i].setState(SyncItemState.UPDATED);
+ };
+ return syncItems;
+ }
+
+ public void transformSyncItem(final Vector itemtable, final SyncItem
syncInstance) throws SyncSourceException {
+ final byte[] data = (byte[])
syncInstance.getPropertyValue(SyncItem.PROPERTY_BINARY_CONTENT);
+ final String dataString = new String(Base64.encode(data));
+// ret.put(SYNCITEM_ID, syncInstance.getKey().getKeyAsString());
+// ret.put(SYNCITEM_DATA, dataString);
+ itemtable.add(syncInstance.getKey().getKeyAsString());
+ itemtable.add(dataString);
+
+// return ret;
}
+
/* (non-Javadoc)
* @see
sync4j.framework.engine.source.SyncSource#getSyncItemFromTwin(java.security.Principal,
sync4j.framework.engine.SyncItem)
*/
@@ -346,7 +396,7 @@
// return
PHPGwSyncXMLRPCClient.getInstance().execute("phpgwapi.ipc_manager.execIPC",
fparams);
// }
- private final void addTimestamp(final Timestamp since, final Vector
vector) {
+ private final void addTimestamp(final java.sql.Timestamp since, final
Vector vector) {
// php uses seconds instead of milliseconds for unix-timestamp
vector.add (new Long(since.getTime() / 1000).toString());
}
@@ -411,9 +461,9 @@
Object data = null;
final int len = idlist.size();
for (i = 0; i < len; i++) {
- keys[i] = new SyncItemKey(items.toArray()[i]);
data = ValidateData((Vector) items.toArray()[i]);
if (data != null) {
+ keys[i] = new SyncItemKey(((Vector)
items.toArray()[i]).toArray()[1].toString());
ret[i] = createSyncItem(keys[i], data);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncSource.java, 1.7,
nomail <=