[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/PHPGwSyncInputMessageProcessor.java, 1.1 |
Date: |
Wed, 9 Jun 2004 20:35:09 +0200 |
Update of /sync/sync4j/de/probusiness/pbgroupware/sync
Added Files:
Branch:
PHPGwSyncInputMessageProcessor.java
date: 2004/06/09 18:35:09; author: mkaemmerer; state: Exp;
Log Message:
- new sourceinfo and mimetype handling
=====================================================================
/*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Created on 06.06.2004
* $Id: PHPGwSyncInputMessageProcessor.java,v 1.1 2004/06/09 18:35:09
mkaemmerer Exp $
*/
package de.probusiness.pbgroupware.sync;
import java.util.*;
import java.util.logging.*;
import sync4j.framework.core.*;
import sync4j.framework.engine.pipeline.*;
import sync4j.framework.engine.source.*;
import sync4j.framework.logging.*;
import sync4j.framework.protocol.*;
/**
* @author cawgod
*
* @version $Revision: 1.1 $
*/
public class PHPGwSyncInputMessageProcessor implements InputMessageProcessor {
public static final String CONTENT_TYPE_KEY_TYPE_RX =
"contentType.RX.type";
public static final String CONTENT_TYPE_KEY_VERSION_RX =
"contentType.RX.version";
public static final String CONTENT_TYPE_KEY_TYPE_TX =
"contentType.TX.type";
public static final String CONTENT_TYPE_KEY_VERSION_TX =
"contentType.TX.version";
public static final String STORE_INFO_TARGET_URI =
"SourceInfo.targetUri";
public static final String STORE_INFO_PREFFERED =
"SourceInfo.preferredType";
public static final String STORE_INFO_SUPPORTED =
"SourceInfo.supportedTypes";
protected static transient Logger logger = Sync4jLogger.getLogger();
/**
*
*/
public PHPGwSyncInputMessageProcessor() {
super();
}
/* (non-Javadoc)
* @see
sync4j.framework.engine.pipeline.InputMessageProcessor#preProcessMessage(sync4j.framework.engine.pipeline.MessageProcessingContext,
sync4j.framework.core.Message)
*/
public void preProcessMessage(final MessageProcessingContext
processingContext,
final Message message) throws
Sync4jException {
// final SyncHeader header = message.getHeader();
final SyncBody body = message.getBody();
final AbstractCommand[] commands = body.getCommands();
final List alertCommands = ProtocolUtil.filterCommands(commands,
AlertCommand.class);
final List putCommands = ProtocolUtil.filterCommands(commands,
PutCommand.class);
if (! alertCommands.isEmpty() && ! putCommands.isEmpty()) {
final AlertCommand alert = (AlertCommand) alertCommands.get(0);
final Item[] items = alert.getItems();
if (items.length > 0) {
final Item item = items[0];
final String sourceUri = item.getSource().getURI();
final String targetUri = item.getTarget().getURI();
final PutCommand put = (PutCommand) putCommands.get(0);
final DeviceInfo devinf = ProtocolUtil.getDeviceInfo(put);
final String devid = devinf.getDeviceIdentifier();
final DataStore[] datastores = devinf.getDataStores();
logger.fine(datastores.length + " datastores found");
for (int i = 0; i < datastores.length; i++) {
final DataStore store = datastores[i];
if
(store.getSourceRef().getValue().equals(sourceUri)) {
final Hashtable storeInfo =
transformCTInfo(store.getPreferredReceiveContentTypeInfo(),
store.getPreferredTransmitContentTypeInfo());
storeInfo.put(STORE_INFO_TARGET_URI, targetUri);
// no recursive arrays
// storeInfo.put(
// STORE_INFO_PREFFERED,
//
transformCTInfo(store.getPreferredReceiveContentTypeInfo())
// );
// final Vector supportedTypes = new Vector();
// final ContentTypeInfo[] supportedTypesInfo =
// store.getSupportedReceiveContentTypeInfo();
// for (
// int j = 0;
// j < supportedTypesInfo.length;
//
supportedTypes.add(transformCTInfo(supportedTypesInfo[j++]))
// );
// storeInfo.put(STORE_INFO_SUPPORTED, supportedTypes);
publishStoreInfo(devid, storeInfo);
return;
}
}
}
}
}
private static final Hashtable transformCTInfo(final ContentTypeInfo
inforx, final ContentTypeInfo infotx) {
final Hashtable ret = new Hashtable();
ret.put(CONTENT_TYPE_KEY_TYPE_RX, inforx.getContentType());
ret.put(CONTENT_TYPE_KEY_VERSION_RX, inforx.getVersion());
ret.put(CONTENT_TYPE_KEY_TYPE_TX, infotx.getContentType());
ret.put(CONTENT_TYPE_KEY_VERSION_TX, infotx.getVersion());
logger.fine("transformCTInfo Type: rx: " +
inforx.getContentType() +
" Version: " + inforx.getVersion() +
" | tx: " + infotx.getContentType() +
" Version: " + infotx.getVersion());
return ret;
}
private static final void publishStoreInfo(final String devid, final
Hashtable storeInfo) {
final Vector params = new Vector();
// prepend device_id to parameter-list
params.add(devid);
params.add(storeInfo);
// prepare ipc-dispatch
final Vector fparams = new Vector();
fparams.add("sync.setPrefSourceInfo");
fparams.add(params);
try {
PHPGwSyncXMLRPCClient.getInstance().execute("phpgwapi.ipc_manager.execIPC",
fparams);
}
catch (final SyncSourceException e) {
logger.throwing(PHPGwSyncStrategy.class.getName(),
"error publishing storeInfo", e);
}
}
private static final void publishDevInfo(final String devid, final
Hashtable storeInfo) {
final Vector params = new Vector();
// prepend device_id to parameter-list
params.add(devid);
params.add(storeInfo);
// prepare ipc-dispatch
final Vector fparams = new Vector();
fparams.add("sync.setPrefSourceInfo");
fparams.add(params);
try {
PHPGwSyncXMLRPCClient.getInstance().execute("phpgwapi.ipc_manager.execIPC",
fparams);
}
catch (final SyncSourceException e) {
logger.throwing(PHPGwSyncStrategy.class.getName(),
"error publishing storeInfo", e);
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sync/sync4j/de/probusiness/pbgroupware/sync/PHPGwSyncInputMessageProcessor.java, 1.1,
nomail <=