Package com.funambol.syncclient.spds

Examples of com.funambol.syncclient.spds.SyncException


        }
       
        try {
            lastTimestamp = dataStore.getLastTimestamp();                  
        } catch (DataAccessException e) {
            throw new SyncException(e.getMessage());
        }

        nextTimestamp = System.currentTimeMillis();
       
        try {
            loadResources();
            sdh.loadLanguage(this.getClass());
            sdh.loadDefaultValue();           
        } catch (IOException e) {
            throw new UpdateException( "Error: ("
            + e.getClass().getName()
            + "): "
            + e.getMessage()
            );
        }
        if (sessionID == null) {
            sessionID = String.valueOf(System.currentTimeMillis());
           
            //to be used in static context in SyncMLClientImpl
            session_id = sessionID;
        }
       
        encryptType = sdh.getEncryptDefault();
       
        prepareInizializationMessage();

        StaticDataHelper.log("\n\n\n");
        StaticDataHelper.log("sending:\n" + clientInitXML);

        response = syncInitialization();
       
        StaticDataHelper.log(response);

        checkServerAlerts(response);

        // start debug
        StaticDataHelper.log("\n\n\n");
        String keyStr = "";
        Enumeration keys = serverAlerts.keys();
       
        while (keys.hasMoreElements()) {
            keyStr = (String)keys.nextElement();
            StaticDataHelper.log("source - Name: " + keyStr + " | Status: " + serverAlerts.get(keyStr));
        }
       
        dataStore.setAlertCode((String)serverAlerts.get(keyStr));
        // end debug
       
        StaticDataHelper.log("\n\n\n");
        StaticDataHelper.log("receiving\n:" + response);

        serverUrlStatus = serverUrl;
        serverUrl       = response.substring(response.indexOf("<RespURI>") + 9,
                                             response.indexOf("</RespURI>"));
        if (!DeviceInfo.isSimulator()) {
            serverUrl += gatewayUrl;
        }
       
        //
        // execute init dataStore operation
        //
        dataStore.startDSOperations();

        //
        // Notifies the sources that the synchronization is going to begin
        //
        boolean sendingClientModifications = true ;
        boolean done                       = false;
       
        // ================================================================
       
        /*
         * the implementation of the client/server multi-messaging
         * through a do while loop
         */
        do {
       
            int alertCode = -1;

            response = null;
           
            // --------------------------------------------------------
            sendingClientModifications =
                prepareModificationMessage(sendingClientModifications);
            // --------------------------------------------------------
           
            StaticDataHelper.log("\n\n\n\n\n\n\n");
            StaticDataHelper.log("sending\n:" + modificationsXML);
 
            response = syncModifications();
           
            StaticDataHelper.log("\n\n\n\n\n\n\n");
            StaticDataHelper.log("receiving\n:" + response);
        
            processModifications(response);
          
            done = ((response.indexOf("<Final/>") >= 0) ||
                    (response.indexOf("</Final>") >= 0));
        }
        while (!done);

        // ================================================================

        //
        // We still have to send the latest mappings
        //
        prepareMappingMessage();

        StaticDataHelper.log("\n\n\n\n\n\n\n");
        StaticDataHelper.log("sending\n:" + mappingXML);

        response = syncMapping();
   
        StaticDataHelper.log("\n\n\n\n\n\n\n");
        StaticDataHelper.log("receiving\n:" + response);

        //
        // Set the last anchor to the next timestamp for all the sources that
        // has been synchronized
        //
        try {   
            dataStore.commitDSOperations();
            dataStore.setLastTimestamp(nextTimestamp);         
        } catch (DataAccessException e) {
            throw new SyncException(e.getMessage());
        }
    }
View Full Code Here


        catch (Exception e) {
            String msg = e.getMessage();
           
            StaticDataHelper.log("[LOG]Error in Sync Initialization. Not specified Exception in SyncManagerImpl.postRequest(:String): " + e.toString());
                                
            throw new SyncException(msg);
        }

        checkStatus(response, TAG_SYNCHDR );
        checkStatus(response, TAG_ALERT   );
View Full Code Here

        }
        catch(SyncException e) {
            String msg = e.getMessage();
            StaticDataHelper.log("Error in SincManagerImpl.syncModifications(): "
                                 + msg);
            throw new SyncException(msg);
        }
        catch (Exception e) {
            String msg = e.getMessage();
            StaticDataHelper.log("Error in SincManagerImpl.syncModifications(): "
                                 + msg);
            throw new SyncException(msg);
        }
        StaticDataHelper.log("Modifications done!");
        return response;
    }
View Full Code Here

        try {
             response = postRequest(alertXML);
          
        } catch(SyncException e) {
            String msg = "Error Modifications: " + e.getMessage();
            throw new SyncException(msg);
        } catch (Exception e) {
            String msg = "Error Modifications: " + e.getMessage();
            StaticDataHelper.log(msg);
            throw new SyncException(msg);
        }
       
        StaticDataHelper.log("Modification done!");

        return response;
View Full Code Here

        try {
            return postRequest(mappingXML);
        } catch (Exception e) {
            String msg = "Error Sync Mapping: " + e.getMessage();
            StaticDataHelper.log(msg);
            throw new SyncException(msg);
        }
    }
View Full Code Here

            return syncMLClient.sendMessage(request);
        }
        catch (NetworkException e) {
            String msg = "Synchronization failed in SyncManagerImpl.postRequest(request): no network available --> ";
            StaticDataHelper.log( msg + e.toString() );
            throw new SyncException(e.getMessage());
        }
        catch (ConnectionNotFoundException e) {
            //e.g. missing "http://" in the Server URI (Admin Tool) like "localhost:8080/funambol/ds"
            //instead of "http://localhost:8080/funambol/ds"
            //causes the system to search for the not existing class
            //"net.rim.device.cldc.io.localhost.Protocol"
            String msg = "Synchronization failed in SyncManagerImpl.postRequest(request): protocol not found --> ";
            StaticDataHelper.log( msg + e.toString() );
            throw new SyncException(e.getMessage());
        } catch (EOFException e) {
            String msg = "Synchronization failed in SyncManagerImpl.postRequest(request): connection broken because of end of stream --> ";
            StaticDataHelper.log( msg + e.toString() );
            if (null != e.getMessage()) {
                throw new SyncException(e.getMessage());
            } else {//normally this exception has no message, but 'null'
                throw new SyncException("End of stream has been reached unexpectedly during input");
            }
        } catch (IOException e) {
            String msg = "Synchronization failed in SyncManagerImpl.postRequest(request): connection broken --> ";
            StaticDataHelper.log( msg + e.toString() );
            throw new SyncException(e.getMessage() != null ? e.getMessage() : e.toString());//see SyncClient::getSynchError() the last 'else' clause
        } catch (Exception e) {
            String msg = "Error sending the request in SyncManagerImpl.postRequest(request): network error --> ";
            StaticDataHelper.log( msg + e.toString() );
            throw new SyncException(e.getMessage());
        }
    }
View Full Code Here

                        //
                        try {
                            dataStore.setLastTimestamp(0l);

                        } catch (DataAccessException e) {
                            throw new SyncException(e.getMessage());
                        }
                        throw new UpdateException(statusCode);
                    }
                }

            }  // next i

            String msgE = msg;
            StaticDataHelper.log(msgE);
            throw new SyncException(msgE);
        }
View Full Code Here

            cmd.put(TAG_CMDID, cmdId);
        }
        catch (StringIndexOutOfBoundsException e){
            sdh.log("[processModificationCommand]" +
                                 "Invalid command Id from server: " + command);
            throw new SyncException("Invalid command from server.");
        }
        // Get item key
        try {
            key = getXMLTagValue(command, TAG_LOC_URI);
            cmd.put(TAG_LOC_URI, key);
        }
        catch (StringIndexOutOfBoundsException e) { 
            sdh.log("[add]Invalid item key from server: " + command);
            sdh.log("[key]Exception in SyncManagerImpl.processMdifications(:String) invoking the getXMLTagValue(...) method: " + e.toString());
            // FIXME: report the error to the server? How to report if the
            //        key is invalid?
            throw new SyncException("Invalid item key from server.");
        }
        // Get item data
        try {
            content = getXMLTagValue(command, TAG_DATA);
        }
View Full Code Here

        try {
            msgId = getXMLTagValue(modifications, TAG_MSGID );
        }
        catch (StringIndexOutOfBoundsException e){
            sdh.log("[processModification]Invalid message Id from server: " + modifications);
            throw new SyncException("Invalid message from server.");
        }

        // Get message parts
        xmlResponse.addElement(modifications);
        bodyTags    = getXMLTag(getXMLTag(xmlResponse, TAG_SYNCML),   TAG_SYNCBODY );
        addTags     = getXMLTag(bodyTags, TAG_ADD      );
        replaceTags = getXMLTag(bodyTags, TAG_REPLACE  );
        deleteTags  = getXMLTag(bodyTags, TAG_DELETE   );
        //statusTags  = getXMLTag(bodyTags, TAG_STATUS   );

        if (modifications.indexOf("<" + TAG_SYNC + ">") != - 1) {
            ret = true;
        }

        Hashtable cmd = null;

        // ADD
        for (int i=0, l = addTags.size(); i < l; i++) {
           
            cmd = processModificationCommand( (String)addTags.elementAt(i) );
            // If there is an error status,
            if(cmd.get(TAG_STATUS) != null){
                // Add the status command for this item to the list
                addStatusCommand(TAG_ADD, msgId, cmd);
                continue;
            }

            record = new Record( (String)cmd.get(TAG_LOC_URI), ' ',
                                 (String)cmd.get(TAG_DATA));
            String bbKey = "";
           
            try {
                bbKey = dataStore.setRecord(record, false).getKey();
                // Okay, set status code 200
                cmd.put(TAG_STATUS, String.valueOf(STATUS_CODE_OK));
            }
            catch (DataAccessException e) {
                StaticDataHelper.log("[ERROR]Exception in SyncManagerImpl.processModifications(add) invoking setRecord(...): " + e.toString());
                //e.printStackTrace();
                // Set error status code for this item
                cmd.put(TAG_STATUS, String.valueOf(STATUS_CODE_ERROR));
                String msg = e.getMessage();
                throw new SyncException(msg);//it should be enough to break the sync process
            }
            finally {
                // Add the status command for this item to the list
                addStatusCommand(TAG_ADD, msgId, cmd);
            }
View Full Code Here

                }

            }

        } catch (Exception e) {
            throw new SyncException("Parsing XML error, TAG " +
                                    tag                       +
                                    " - : "                   +
                                    e.getMessage()            );
        }
View Full Code Here

TOP

Related Classes of com.funambol.syncclient.spds.SyncException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.