Пример #1
0
bool SimpleTableDump::dumpDelta(std::string name, atable_ptr_t table) {
  verify(table);
  auto deltaTable = std::dynamic_pointer_cast<Store>(table)->getDeltaTable();
  prepare(name);
  for (size_t i = 0; i < deltaTable->columnCount(); ++i) {
    // For each attribute dump dictionary and values
    dumpDictionary(name, deltaTable, i, true);
    dumpAttribute(name, deltaTable, i);
  }

  dumpHeader(name, deltaTable);
  dumpMetaData(name, deltaTable);

  return true;
}
Пример #2
0
bool SimpleTableDump::dump(std::string name, std::shared_ptr<AbstractTable> table) {
  verify(table);
  auto mainTable = std::dynamic_pointer_cast<Store>(table)->getMainTables()[0];
  prepare(name);
  for(size_t i=0; i < mainTable->columnCount(); ++i) {
    // For each attribute dump dictionary and values
    dumpDictionary(name, mainTable, i);
    dumpAttribute(name, mainTable, i);
  }

  dumpHeader(name, mainTable);
  dumpMetaData(name, mainTable);
  
  return true;
}
Пример #3
0
OSStatus performAuthenticatedXMLRPC(
	CFURLRef		theURL, 
	CFStringRef		theMethod, 
	CFDictionaryRef argDict, 
	CFArrayRef		argOrder,
	CFStringRef		userName,
	CFStringRef		password,
	CFDictionaryRef *resultDict,	// RETURNED on success
	uint32_t		*httpErrStatus)	// possibly RETURNED on error (403, 500, etc.)
{
    CFDictionaryRef result = NULL;
	bool done = false;
	OSStatus ortn = -1;		// must set before return
	*httpErrStatus = 0;
	
    /*
	 * Create a WebServices Invocation
	 */
    WSMethodInvocationRef wsRef = WSMethodInvocationCreate(theURL, theMethod, 
		kWSXMLRPCProtocol);
    WSMethodInvocationSetParameters(wsRef, argDict, argOrder);

    for(unsigned attempt=0; attempt<2; attempt++) {
		xmlDebug("***************************************************************************\n");
		xmlDebug("performAuthenticatedXMLRPC: WSMethodInvocationInvoke (attempt %u)\n", attempt);
		xmlDebug("***************************************************************************\n");
        CFDictionaryRef response = WSMethodInvocationInvoke(wsRef);
		
        /*
		 * Since we can't reuse the Invocation dump it as we have our response
		 */
        if (wsRef) {
            CFRelease(wsRef);
            wsRef = NULL;
        }

        #if XML_DEBUG
        logCFstr("performAuthenticatedXMLRPC: userName:"******"performAuthenticatedXMLRPC: errorMsg", errorMsg);
				#endif
                UInt32 HTTPResponseCode = 
					getHTTPStatusCodeFromWSInvokationResponse(response);
				/* only try authentication once */
				xmlDebug("performAuthenticatedXMLRPC: HTTP status %lu\n", HTTPResponseCode);
                if ((HTTPResponseCode == 401) && (attempt == 0)) {
                    wsRef = WSMethodInvocationCreate(theURL, theMethod, kWSXMLRPCProtocol);
                    WSMethodInvocationSetParameters(wsRef, argDict, argOrder);
                    Boolean successful =  addAuthenticationToWSInvokation(wsRef, 
						userName, password, response);
                    if (!successful) {
						xmlDebug("performAuthenticatedXMLRPC: unable to add authentication\n");
						ortn = ioErr;
						done = TRUE;
                    }
					xmlDebug("performAuthenticatedXMLRPC: retrying with auth\n");
					/* else go one more time with authenticated invocation */
                } else {
					/* other fatal HTTP error */
					
                    /*
					 * From Scott Ryder:
					 *
					 * All other HTTP errs (eg 403 or 500) could / should be handled here
                     * this could include adding proxy support
					 *
					 * FIXME does this mean that this code won't work through proxies?
					 */
					xmlDebug("performAuthenticatedXMLRPC: fatal RPC error\n");
					*httpErrStatus = HTTPResponseCode;
					ortn = dotMacHttpStatToOs(HTTPResponseCode);
                    done = TRUE;
                }
            } 
			else {
				xmlDebug("performAuthenticatedXMLRPC: fault with no fault string!\n");
				ortn = ioErr;
				done = TRUE;
            }
        }   /* fault */
		else {
			/* success */
			xmlDebug("performAuthenticatedXMLRPC: success\n");
            result = CFDictionaryCreateCopy(NULL, 
				(CFDictionaryRef)CFDictionaryGetValue(
					response, kWSMethodInvocationResult));
			ortn = noErr;
			done = true;
        }
        if((response != NULL) /*&& done*/) {
			#if RESPONSE_DICTIONARY_DEBUG
			dumpDictionary("XMLRPC response", response);
			#endif
            CFRelease(response);
		}
		if(done) {
			break;
		}
    }
	if(result != NULL) {
		*resultDict = result;
	}
    return ortn;
}