00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.openmobileis.synchro.sync4j.server;
00026
00027 import java.security.Principal;
00028 import java.sql.Timestamp;
00029 import java.util.ArrayList;
00030
00031 import org.openmobileis.common.util.log.LogManager;
00032
00033 import sync4j.framework.engine.SyncItem;
00034 import sync4j.framework.engine.SyncItemKey;
00035 import sync4j.framework.engine.SyncItemState;
00036 import sync4j.framework.engine.source.AbstractSyncSource;
00037 import sync4j.framework.engine.source.SyncSource;
00038 import sync4j.framework.engine.source.SyncSourceException;
00039
00046 public abstract class FODBSync4JSource extends AbstractSyncSource implements SyncSource {
00047 protected static final String MIMETYPE = "text/plain";
00048
00052 public FODBSync4JSource() {
00053 super();
00054 setType(MIMETYPE);
00055 }
00056
00062 public FODBSync4JSource(String arg0, String arg1, String arg2) {
00063 super(arg0, arg1, arg2);
00064 setType(MIMETYPE);
00065 }
00066
00070 public FODBSync4JSource(String arg0) {
00071 super(arg0);
00072 setType(MIMETYPE);
00073 }
00074
00075
00076
00077
00078 public SyncItem[] getAllSyncItems(Principal principal) throws SyncSourceException {
00079 LogManager.traceDebug(0, "Calling getAllSyncItems [" + sourceURI + "]");
00080 return getSyncItems(principal, null, null);
00081 }
00082
00083
00084
00085
00086 public SyncItemKey[] getDeletedSyncItemKeys(Principal arg0, Timestamp arg1) throws SyncSourceException {
00087 LogManager.traceDebug(0, "Calling getDeletedSyncItemKeys [" + sourceURI + "]");
00088 return new SyncItemKey[0];
00089 }
00090
00091
00092
00093
00094 public SyncItem[] getDeletedSyncItems(Principal principal, Timestamp since) throws SyncSourceException {
00095 LogManager.traceDebug(0, "Calling getDeletedSyncItems [" + sourceURI + "]");
00096
00097 return getSyncItems(principal, String.valueOf(SyncItemState.DELETED), since);
00098 }
00099
00100
00101
00102
00103 public SyncItemKey[] getNewSyncItemKeys(Principal arg0, Timestamp arg1) throws SyncSourceException {
00104 LogManager.traceDebug(0, "Calling getNewSyncItemKeys [" + sourceURI + "]");
00105 return new SyncItemKey[0];
00106 }
00107
00108
00109
00110
00111 public SyncItem[] getNewSyncItems(Principal principal, Timestamp since) throws SyncSourceException {
00112 LogManager.traceDebug(0, "Calling getNewSyncItemKeys [" + sourceURI + "]");
00113 return getSyncItems(principal, String.valueOf(SyncItemState.NEW), since);
00114 }
00115
00116
00117
00118
00119 public SyncItem getSyncItemFromId(Principal principal, SyncItemKey syncItemKey) throws SyncSourceException {
00120 LogManager.traceDebug(0, "Calling getSyncItemFromId [" + sourceURI + "]");
00121 return getSyncItem(principal, syncItemKey.getKeyAsString());
00122 }
00123
00124
00125
00126
00127 public SyncItem[] getSyncItemsFromIds(Principal principal, SyncItemKey[] syncItemsKeys) throws SyncSourceException {
00128 LogManager.traceDebug(0, "Calling getSyncItemsFromIds [" + sourceURI + "]");
00129 ArrayList listItem = new ArrayList();
00130
00131 int num = syncItemsKeys.length;
00132 for (int i = 0; i < num; i++) {
00133 listItem.add(getSyncItemFromId(principal, syncItemsKeys[i]));
00134 }
00135
00136 SyncItem[] toReturn = (SyncItem[]) (listItem.toArray(new SyncItem[
00137 0]));
00138
00139 return toReturn;
00140 }
00141
00142
00143
00144
00145 public SyncItem[] getUpdatedSyncItems(Principal principal, Timestamp since) throws SyncSourceException {
00146 LogManager.traceDebug(0, "Calling getUpdatedSyncItems [" + sourceURI + "]");
00147 return getSyncItems(principal, String.valueOf(SyncItemState.UPDATED), since);
00148 }
00149
00150
00151
00152
00153 public void removeSyncItem(Principal arg0, SyncItem arg1) throws SyncSourceException {
00154 LogManager.traceDebug(0, "Calling removeSyncItem [" + sourceURI + "]");
00155 }
00156
00157
00158
00159
00160 public void removeSyncItems(Principal principal, SyncItem[] syncItems) throws SyncSourceException {
00161 LogManager.traceDebug(0, "Calling removeSyncItem [" + sourceURI + "]");
00162 for (int i = 0; (syncItems != null) && (i < syncItems.length); i++) {
00163 removeSyncItem(principal, syncItems[i]);
00164 }
00165 }
00166
00167
00168
00169
00170 public SyncItem setSyncItem(Principal arg0, SyncItem arg1) throws SyncSourceException {
00171 LogManager.traceDebug(0, "Calling setSyncItem [" + sourceURI + "]");
00172 return null;
00173 }
00174
00175
00176
00177
00178 public SyncItem[] setSyncItems(Principal principal, SyncItem[] syncItems) throws SyncSourceException {
00179 LogManager.traceDebug(0, "Calling setSyncItems [" + sourceURI + "]");
00180 for (int i = 0; (syncItems != null) && (i < syncItems.length); i++) {
00181 setSyncItem(principal, syncItems[i]);
00182 }
00183
00184 return syncItems;
00185 }
00186
00187
00188
00189
00190 public SyncItem getSyncItemFromTwin(Principal arg0, SyncItem arg1) throws SyncSourceException {
00191 LogManager.traceDebug(0, "Calling getSyncItemFromTwin [" + sourceURI + "]");
00192 return null;
00193 }
00194
00195
00196
00197
00198 public SyncItem[] getSyncItemsFromTwins(Principal arg0, SyncItem[] arg1) throws SyncSourceException {
00199 LogManager.traceDebug(0, "Calling getSyncItemsFromTwins [" + sourceURI + "]");
00200 return new SyncItem[0];
00201 }
00202
00203
00204
00205
00206 public SyncItemKey[] getUpdatedSyncItemKeys(Principal arg0, Timestamp arg1) throws SyncSourceException {
00207 LogManager.traceDebug(0, "Calling getUpdatedSyncItemKeys [" + sourceURI + "]");
00208 return new SyncItemKey[0];
00209 }
00210
00219 protected abstract SyncItem[] getSyncItems(Principal principal,
00220 String type,
00221 Timestamp since) throws SyncSourceException;
00222
00230 protected abstract SyncItem getSyncItem(Principal principal, String itemId)
00231 throws SyncSourceException;
00232
00233 }