void StorageService::FindDocumentByQuery(string dbName, string collectionName, Query *query, CCObject* pTarget, cocos2d::SEL_CallFuncND pSelector)
{
    App42StorageResponse *response = new App42StorageResponse(pTarget,pSelector);
    
    try
    {
        Util::throwExceptionIfStringNullOrBlank(dbName, "Database Name");
        Util::throwExceptionIfStringNullOrBlank(collectionName, "Collection Name");
        Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target");
        Util::throwExceptionIfCallBackIsNull(pSelector, "Callback");
    }
    catch (App42Exception *e)
    {
        std::string ex = e->what();
        response->httpErrorCode = e->getHttpErrorCode();
        response->appErrorCode  = e->getAppErrorCode();
        response->errorDetails  = ex;
        response->isSuccess = false;
        if (pTarget && pSelector)
        {
            (pTarget->*pSelector)((cocos2d::CCNode *)pTarget, response);
        }
        delete e;
        e = NULL;
        return;
    }
    
    string resource = "storage/findDocsByQuery/dbName/";
	resource.append(dbName + "/collectionName/");
	resource.append(collectionName);
    
	string url = getBaseUrl(resource);
	string timestamp = Util::getTimeStamp();
    
    map<string, string> getMap;
	Util::BuildGetSigningMap(apiKey, timestamp, VERSION, getMap);
    getMap["dbName"] = dbName;
    getMap["collectionName"] = collectionName;
    getMap["jsonQuery"] = query->getString();
    //Util::printMap(getMap);
	string signature = Util::signMap(secretKey, getMap);
    url.append("?");

    map<string, string> queryParamsMap;
    queryParamsMap["jsonQuery"]=query->getString();
    string queryString = buildQueryString(queryParamsMap);
    url.append(queryString);
    //char *encodedUrl = Util::url_encode(url);
    printf("\nQueryString=%s",queryString.c_str());
    
    std::vector<std::string> headers;
    map<string, string> metaHeaders;
    populateMetaHeaderParams(metaHeaders);
    Util::BuildHeaders(metaHeaders, headers);
    Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers);
    
    Util::executeGet(url.c_str(),headers, response, callfuncND_selector(App42StorageResponse::onComplete));
    
}
jobject wyHttpRequest_android::createHttpRequest(JNIEnv* env) {
	// check method, create java side request object
	jobject request = NULL;
	switch(m_method) {
		case wyHttpRequest::GET:
		case wyHttpRequest::DELETE:
		{
			const char* fullUrl = buildQueryString();
			jstring jFullUrl = env->NewStringUTF(fullUrl);
			request = env->CallStaticObjectMethod(gClass_Network, g_mid_Network_createHttpRequest, jFullUrl, (jint)m_method);
			env->DeleteLocalRef(jFullUrl);
			wyFree((void*)fullUrl);
			break;
		}
		default:
		{
			// create request for post or put
			jstring jUrl = env->NewStringUTF(m_url);
			request = env->CallStaticObjectMethod(gClass_Network, g_mid_Network_createHttpRequest, jUrl, (jint)m_method);
			env->DeleteLocalRef(jUrl);

			// build post body
			if(hasBlobParam())
				buildMultipart(env, request);
			else
				buildKeyValuePost(env, request);

			break;
		}
	}

	// install headers
	setHeaders(env, request);

	// return
	return request;
}