Beispiel #1
0
            public void execute()
            {
                NetResponse resp = null;
     	        try
     	        {
	                switch( m_eCmd )
	                {
	                    case hcGet:
	            	        ///m_pNetRequest.setIgnoreSuffixOnSim(false);
	                        resp = m_pNetRequest.doRequest( m_params.getString("http_command", "GET"), 
	                        m_params.getString("url"), m_params.getString("body"), null, m_mapHeaders);
	                        break;
	                    case hcPost:
	            	        ///m_pNetRequest.setIgnoreSuffixOnSim(false);
	                        resp = m_pNetRequest.doRequest(m_params.getString("http_command", "POST"), 
	                        m_params.getString("url"), m_params.getString("body"), null, m_mapHeaders);
	                        break;
	
	                    case hcDownload:
	                        resp = m_pNetRequest.pullFile(m_params.getString("url"), m_params.getString("filename"), null, m_mapHeaders);
	                        break;  
	
	            case hcUpload:
	                {
                        Vector<NetRequest.MultipartItem>/*Ptr<net::CMultipartItem*>*/ arMultipartItems = new Vector<NetRequest.MultipartItem>();
	
	                    RhoParamArray arParams = new RhoParamArray( m_params, "multipart");
	                    if ( arParams.size() > 0 )
	                    {
	                        for( int i = 0; i < arParams.size(); i++)
	                        {
	                            RhoParams oItem = arParams.getItem(i);

                                NetRequest.MultipartItem pItem = new NetRequest.MultipartItem();
	                            String strBody = oItem.getString("body");
	                            if ( strBody.length() > 0 )
	                            {
	                                pItem.m_strBody = strBody;
	                                pItem.m_strContentType = oItem.getString("content_type", "application/x-www-form-urlencoded");
	                            }
	                            else
	                            {
	                                pItem.m_strFilePath = oItem.getString("filename");
	                                pItem.m_strContentType = oItem.getString("content_type", "application/octet-stream");
	                            }
	
	                            pItem.m_strName = oItem.getString("name");
	                            pItem.m_strFileName = oItem.getString("filename_base");
	                            arMultipartItems.addElement(pItem);
	                        }
	                    }else
	                    {
                            NetRequest.MultipartItem pItem = new NetRequest.MultipartItem();
	                        pItem.m_strFilePath = m_params.getString("filename");
	                        pItem.m_strContentType = m_params.getString("file_content_type", "application/octet-stream");
	                        pItem.m_strName = m_params.getString("name");
	                        pItem.m_strFileName = m_params.getString("filename_base");
	                        arMultipartItems.addElement(pItem);
	
	                        String strBody = m_params.getString("body");
	                        if ( strBody.length() > 0 )
	                        {
                                NetRequest.MultipartItem pItem2 = new NetRequest.MultipartItem();
	                            pItem2.m_strBody = strBody;
	                            pItem2.m_strContentType = (String)m_mapHeaders.get("content-type");
	                            arMultipartItems.addElement(pItem2);
	                        }
	                    }
	
	                    resp = m_pNetRequest.pushMultipartData( m_params.getString("url"), arMultipartItems, null, m_mapHeaders );
	                    break;
	                }
	            }
	
	            if ( !m_pNetRequest.isCancelled())
	            {
				    processResponse(resp);
	                callNotify(resp,0);
	            }
    	    }catch(IOException exc)
    	    {
    	    	LOG.ERROR("command failed: " + m_eCmd + "url: " + m_params.getString("url"), exc);
    	    	callNotify(null, RhoAppAdapter.ERR_NETWORK);
    	    }catch(Exception exc)
    	    {
    	    	LOG.ERROR("command crashed: " + m_eCmd + "url: " + m_params.getString("url"), exc);
    	    	callNotify(null, RhoAppAdapter.ERR_RUNTIME);
    	    }
        }
Beispiel #2
0
        public string[] getAllTableNames()
        {
            IDBResult res = executeSQL("SELECT name FROM sqlite_master WHERE type='table'", null, false, false);

            Vector<Object> arTables = new Vector<Object>();
            for (; !res.isEnd(); res.next())
            {
                arTables.addElement(res.getCurData()[0]);
            }

            String[] vecTables = new String[arTables.size()];
            for (int i = 0; i < arTables.size(); i++)
                vecTables[i] = (String)arTables.elementAt(i);

            return vecTables;
        }
Beispiel #3
0
    void checkConflicts()
    {
        m_mapConflictedValues.clear();
        Hashtable<String, String>.Enumerator hashEnum = m_mapChangedValues.GetEnumerator();
		while( hashEnum.MoveNext() )
		{
			String key = hashEnum.Current.Key;
			String valueChanged = hashEnum.Current.Value;
			
			if ( !m_mapValues.containsKey(key) )
				continue;
			
            String strValue = (String)m_mapValues.get(key);
            if ( strValue.compareTo(valueChanged) != 0 )
            {
                Vector<String> values = new Vector<String>();
                values.addElement(valueChanged);
                values.addElement(strValue);
                m_mapConflictedValues.put(key, values);
            }
        }
    }