Exemplo n.º 1
0
bool listAll(SDBConnectionPtr aSDB){
  try {
    ListDomainsResponsePtr lRes = aSDB->listDomains();
    std::cout << "list domains successfully" << std::endl;
    lRes->open();
    std::string lDomain;
    while (lRes->next (lDomain)) {
      std::cout << "  Domain: " << lDomain  << std::endl;
      SDBQueryResponsePtr lRes = aSDB->query (lDomain, "");
      int lCounter = 0;
      lRes->open();
      std::string lItem;
      while (lRes->next (lItem)) {
        std::cout << "    " << ++lCounter << ". Item: " << lItem;
        GetAttributesResponsePtr lRes = aSDB->getAttributes (lDomain, lItem);
        lRes->open();
        std::pair<std::string, std::string> lAttr;
        while (lRes->next (lAttr)) {
          std::cout << " " << lAttr.first << ":" <<  lAttr.second ;
        }
        lRes->close();
        std::cout << std::endl;
      }
      lRes->close();
    }
    lRes->close();
  } catch (ListDomainsException &e) {
    std::cerr << e.what() << std::endl;
    return false;
  }
  return true;
  
}
Exemplo n.º 2
0
bool listDomains (SDBConnectionPtr aSDB, int aMaxNumberOfDomains, const std::string& aNextToken) {
  try {
    ListDomainsResponsePtr lRes = aSDB->listDomains(aMaxNumberOfDomains, aNextToken);
      std::cout << "list domains successfully" << std::endl;
      lRes->open();
      std::string lDomain;
      while (lRes->next (lDomain)) {
          std::cout << "   Domain: " << lDomain  << std::endl;
        }
      lRes->close();
    } catch (ListDomainsException &e) {
      std::cerr << e.what() << std::endl;
      return false;
    }
  return true;
}
Exemplo n.º 3
0
int listDomains(SDBConnection* lCon) {
    try {
        ListDomainsResponsePtr lPtr = lCon->listDomains();
        std::cout << "Listing of domains: " << std::endl;
        lPtr->open();
        std::string name;
        while (lPtr->next(name)) {
            std::cout << name << std::endl;
        }
        printBoxUsage(*lPtr);
    }
    catch (ListDomainsException& e) {
        std::cerr << "Couldn't list domains" << std::endl;
        std::cerr << e.what() << std::endl;
        return 1;
    }
    return 0;
}
Exemplo n.º 4
0
bool deleteAllDomains (SDBConnectionPtr aSDB, std::string aPrefix) {
  try {
      ListDomainsResponsePtr lRes = aSDB->listDomains();
      std::cout << "start deleting" << std::endl;
      lRes->open();
      std::string lDomain;
      while (lRes->next (lDomain)) {
        if(aPrefix.length() == 0 || lDomain.compare(0, aPrefix.length(),aPrefix) == 0){
            std::cout << "   " << lDomain  << std::endl;
            aSDB->deleteDomain (lDomain);
          }
        }
      lRes->close();
    } catch (PutAttributesException &e) {
      std::cerr << e.what() << std::endl;
      return false;
    }
  return true;
}