void TableWidget::removeObject(int row) { Table *table=nullptr; BaseObject *object=nullptr; ObjectType obj_type=BASE_OBJECT; try { table=dynamic_cast<Table *>(this->object); obj_type=getObjectType(sender()); object=table->getObject(row, obj_type); if(!object->isProtected() && !dynamic_cast<TableObject *>(object)->isAddedByRelationship()) { op_list->registerObject(object, Operation::OBJECT_REMOVED, row, this->object); table->removeObject(object); } else throw Exception(Exception::getErrorMessage(ERR_REM_PROTECTED_OBJECT) .arg(Utf8String::create(object->getName())) .arg(object->getTypeName()), ERR_REM_PROTECTED_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void TableWidget::TableWidget::swapObjects(int idx1, int idx2) { ObjectType obj_type=BASE_OBJECT; Table *table=nullptr; int count; try { obj_type=getObjectType(sender()); table=dynamic_cast<Table *>(this->object); count=table->getObjectCount(obj_type); if(idx1 >= count) //Special case 1: the object was moved to the first row, its index is swapped with index 0 op_list->updateObjectIndex(table->getObject(idx2, obj_type), 0); else if(idx2 >= count) //Special case 2: the object was moved to the last row, its index is swapped with index count-1 op_list->updateObjectIndex(table->getObject(idx1, obj_type), count-1); else { op_list->updateObjectIndex(table->getObject(idx1, obj_type), idx2); op_list->updateObjectIndex(table->getObject(idx2, obj_type), idx1); } table->swapObjectsIndexes(obj_type, idx1, idx2); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void TableWidget::handleObject(void) { ObjectType obj_type=BASE_OBJECT; try { obj_type=getObjectType(sender()); showTableObjectForm(obj_type); listObjects(obj_type); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void DataManipulationForm::setAttributes(Connection conn, const QString curr_schema, const QString curr_table) { try { QString db_name; tmpl_conn_params=conn.getConnectionParams(); db_name=QString("<strong>%1</strong>@<em>%2:%3</em>").arg(conn.getConnectionParam(Connection::PARAM_DB_NAME)) .arg(conn.getConnectionParam(Connection::PARAM_SERVER_IP).isEmpty() ? conn.getConnectionParam(Connection::PARAM_SERVER_FQDN) : conn.getConnectionParam(Connection::PARAM_SERVER_IP)) .arg(conn.getConnectionParam(Connection::PARAM_PORT)); db_name_lbl->setText(db_name); db_name.remove(QRegExp("<(/)?(strong|em)>")); this->setWindowTitle(this->windowTitle() + QString(" - ") + db_name); schema_cmb->clear(); listObjects(schema_cmb, { OBJ_SCHEMA }); schema_cmb->setCurrentText(curr_schema); table_cmb->setCurrentText(curr_table); disableControlButtons(); if(!curr_table.isEmpty()) retrieveData(); } catch(Exception &e) { throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void listObjects(const QString &service, const QString &path) { QDBusInterfacePtr iface(*connection, service, path.isEmpty() ? "/" : path, "org.freedesktop.DBus.Introspectable"); if (!iface->isValid()) { QDBusError err(iface->lastError()); fprintf(stderr, "Cannot introspect object %s at %s:\n%s (%s)\n", qPrintable(path.isEmpty() ? "/" : path), qPrintable(service), qPrintable(err.name()), qPrintable(err.message())); exit(1); } QDBusReply<QString> xml = iface->call("Introspect"); if (xml.isError()) return; // silently QDomDocument doc; doc.setContent(xml); QDomElement node = doc.documentElement(); QDomElement child = node.firstChildElement(); while (!child.isNull()) { if (child.tagName() == QLatin1String("node")) { QString sub = path + '/' + child.attribute("name"); printf("%s\n", qPrintable(sub)); listObjects(service, sub); } child = child.nextSiblingElement(); } }
void DataManipulationForm::listTables(void) { table_cmb->clear(); if(schema_cmb->currentIndex() > 0) { if(hide_views_chk->isChecked()) listObjects(table_cmb, { OBJ_TABLE }, schema_cmb->currentText()); else listObjects(table_cmb, { OBJ_TABLE, OBJ_VIEW }, schema_cmb->currentText()); } table_lbl->setEnabled(table_cmb->count() > 0); table_cmb->setEnabled(table_cmb->count() > 0); row_cnt_lbl->setVisible(false); rows_ret_lbl->setVisible(false); limit_lbl->setVisible(false); }
int main(void) { char request[200]; char token[] = "aldkfhvcuihefasclhaskvjlhds239hphsfha9"; char url[] = "http://www.wordpress.com/Auth/v1.0/PikkuJose"; char container[] = "MiContenedorChachiPiruli"; listObjects(request, token, url, container); printf("Request:\n%s", request); return 0; }
void deleteAllObjects(ClientPtrType client, String bucketName) { String base = "=== Delete All Objects [" + bucketName; std::cout << base << "]: Start ===\n"; auto objects = listObjects(client, bucketName, "", -1, 0, true); for (auto obj: objects) { deleteObject(client, bucketName, obj.GetKey()); } std::cout << base << "]: End ===\n\n"; }
void TableWidget::removeObjects(void) { Table *table=nullptr; unsigned count, op_count=0, i; BaseObject *object=nullptr; ObjectType obj_type=BASE_OBJECT; try { table=dynamic_cast<Table *>(this->object); obj_type=getObjectType(sender()); count=table->getObjectCount(obj_type); op_count=op_list->getCurrentSize(); for(i=0; i < count; i++) { object=table->getObject(0, obj_type); if(!object->isProtected() && !dynamic_cast<TableObject *>(object)->isAddedByRelationship()) { op_list->registerObject(object, Operation::OBJECT_REMOVED, 0, this->object); table->removeObject(object); } else throw Exception(Exception::getErrorMessage(ERR_REM_PROTECTED_OBJECT) .arg(Utf8String::create(object->getName())) .arg(object->getTypeName()), ERR_REM_PROTECTED_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__); } } catch(Exception &e) { if(op_count < op_list->getCurrentSize()) { count=op_list->getCurrentSize()-op_count; op_list->ignoreOperationChain(true); for(i=0; i < count; i++) { op_list->undoOperation(); op_list->removeLastOperation(); } op_list->ignoreOperationChain(false); } listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void TableWidget::handleObject(void) { ObjectType obj_type=BASE_OBJECT; TableObject *object=nullptr; ObjectTableWidget *obj_table=nullptr; try { obj_type=getObjectType(sender()); //Selects the object table based upon the passed object type obj_table=getObjectTable(obj_type); //Gets the object reference if there is an item select on table if(obj_table->getSelectedRow()>=0) object=reinterpret_cast<TableObject *>(obj_table->getRowData(obj_table->getSelectedRow()).value<void *>()); if(obj_type==OBJ_COLUMN) openEditingForm<Column, ColumnWidget>(object); else if(obj_type==OBJ_CONSTRAINT) openEditingForm<Constraint, ConstraintWidget>(object); else if(obj_type==OBJ_TRIGGER) openEditingForm<Trigger, TriggerWidget>(object); else if(obj_type==OBJ_INDEX) openEditingForm<Index, IndexWidget>(object); else openEditingForm<Rule, RuleWidget>(object); listObjects(obj_type); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void TableWidget::setAttributes(DatabaseModel *model, OperationList *op_list, Schema *schema, Table *table, float pos_x, float pos_y) { try { unsigned i, count; Table *aux_tab=nullptr; ObjectType types[]={ OBJ_COLUMN, OBJ_CONSTRAINT, OBJ_TRIGGER, OBJ_RULE, OBJ_INDEX }; if(!table) { table=new Table; if(schema) table->setSchema(schema); /* Sets the 'new_object' flag as true indicating that the alocated table must be treated as a recently created object */ this->new_object=true; } BaseObjectWidget::setAttributes(model, op_list, table, schema, pos_x, pos_y); op_list->startOperationChain(); operation_count=op_list->getCurrentSize(); if(this->new_object) op_list->registerObject(table, Operation::OBJECT_CREATED); /* Listing all objects (column, constraint, trigger, index, rule) on the respective table objects */ for(i=0; i < 5; i++) { listObjects(types[i]); objects_tab_map[types[i]]->setButtonConfiguration(ObjectTableWidget::ALL_BUTTONS ^ (ObjectTableWidget::UPDATE_BUTTON)); } //Listing the ancestor tables count=table->getAncestorTableCount(); for(i=0; i < count; i++) { aux_tab=table->getAncestorTable(i); parent_tables->addRow(); parent_tables->setCellText(Utf8String::create(aux_tab->getName()), i, 0); parent_tables->setCellText(Utf8String::create(aux_tab->getSchema()->getName()), i, 1); parent_tables->setCellText(trUtf8("Parent"), i, 2); } aux_tab=table->getCopyTable(); if(aux_tab) { parent_tables->addRow(); parent_tables->setCellText(Utf8String::create(aux_tab->getName()), i, 0); parent_tables->setCellText(Utf8String::create(aux_tab->getSchema()->getName()), i, 1); parent_tables->setCellText(trUtf8("Copy"), i, 2); } parent_tables->clearSelection(); with_oids_chk->setChecked(table->isWithOIDs()); gen_alter_cmds_chk->setChecked(table->isGenerateAlterCmds()); } catch(Exception &e) { throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
int main(int argc, char** argv) { String base = "=== [AWS API Init"; std::cout << base << "]: Start===\n"; Aws::SDKOptions options; // set the options options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info; // end of options Aws::InitAPI(options); // setup String signVer = SIGN_VER, host = HOST, portStr = PORT, bucketName = BUCKET; if (argc == 5) { signVer = argv[1]; host = argv[2]; portStr = argv[3]; bucketName = argv[4]; } auto client = init(host, portStr); std::cout << base << "]: End ===\n\n"; // call tests here createBucket(client, bucketName); std::cout << '\n'; // put object putObject(client, bucketName, "test.simple", SMALL_TEST_FILE); putObject(client, bucketName, "test.medium", MED_TEST_FILE); putObject(client, bucketName, "test.large", LARGE_TEST_FILE); // put object with metadata Map metadata; metadata[METADATA_KEY] = METADATA_VAL; putObject(client, bucketName, "test.simple.meta", SMALL_TEST_FILE, metadata); putObject(client, bucketName, "test.medium.meta", MED_TEST_FILE, metadata); putObject(client, bucketName, "test.large.meta", LARGE_TEST_FILE, metadata); // put object in parts putObjectMp(client, bucketName, "test.simple.mp", SMALL_TEST_FILE); putObjectMp(client, bucketName, "test.medium.mp", MED_TEST_FILE); putObjectMp(client, bucketName, "test.large.mp", LARGE_TEST_FILE); // put object in parts with metadata putObjectMp(client, bucketName, "test.simple.meta.mp", SMALL_TEST_FILE, metadata); putObjectMp(client, bucketName, "test.medium.meta.mp", MED_TEST_FILE, metadata); putObjectMp(client, bucketName, "test.large.meta.mp", LARGE_TEST_FILE, metadata); // head is already tested // get object getObject(client, bucketName, "test.simple", SMALL_TEST_FILE); getObject(client, bucketName, "test.medium", MED_TEST_FILE); getObject(client, bucketName, "test.large", LARGE_TEST_FILE); getObject(client, bucketName, "test.simple.mp", SMALL_TEST_FILE); getObject(client, bucketName, "test.medium.mp", MED_TEST_FILE); getObject(client, bucketName, "test.large.mp", LARGE_TEST_FILE); getObject(client, bucketName, "test.simple.meta", SMALL_TEST_FILE, metadata); getObject(client, bucketName, "test.medium.meta", MED_TEST_FILE, metadata); getObject(client, bucketName, "test.large.meta", LARGE_TEST_FILE, metadata); getObject(client, bucketName, "test.simple.meta.mp", SMALL_TEST_FILE, metadata); getObject(client, bucketName, "test.medium.meta.mp", MED_TEST_FILE, metadata); getObject(client, bucketName, "test.large.meta.mp", LARGE_TEST_FILE, metadata); // get fake object getFakeObject(client, bucketName, "test.noexist"); // range get object rangeObject(client, bucketName, "test.simple", SMALL_TEST_FILE, 1, 4); // rangeObject(client, bucketName, "test.simple.mp", SMALL_TEST_FILE, 1, 4); rangeObject(client, bucketName, "test.large", LARGE_TEST_FILE, 1048576, 40485760); // rangeObject(client, bucketName, "test.large.mp", LARGE_TEST_FILE, 1048576, 10485760); // copy object copyObject(client, bucketName, "test.simple", "test.simple.copy"); getObject(client, bucketName, "test.simple.copy", SMALL_TEST_FILE); // list object listObjects(client, bucketName, "", -1); // delete all objects deleteAllObjects(client, bucketName); listObjects(client, bucketName, "", 0); // put dummy objects putObject(client, bucketName, "list/test.small.", SMALL_TEST_FILE, Map(), 35); // multi-page list obj listObjects(client, bucketName, "list/", 35, 10); // multi-delete deleteObjects(client, bucketName, "list/test.small.", 10); listObjects(client, bucketName, "list/", 25); // get-put acl // delete bucket deleteBucket(client, bucketName); // end of tests std::cout << "=== AWS API Shutdown: Start===\n"; Aws::ShutdownAPI(options); std::cout << "=== AWS API Shutdown: End ===\n"; return 0; }
shared_ptr<FDSObjectListing> GalaxyFDSClient::listObjects(const string& bucketName, const string& prefix) { return listObjects(bucketName, prefix, "/"); }
int main(int argc, char **argv) { QCoreApplication app(argc, argv); if (argc >= 1 && qstrcmp(argv[1], "--system") == 0) { connection = &QDBus::systemBus(); --argc; ++argv; } else connection = &QDBus::sessionBus(); if (!connection->isConnected()) { fprintf(stderr, "Could not connect to D-Bus server: %s: %s\n", qPrintable(connection->lastError().name()), qPrintable(connection->lastError().message())); return 1; } QDBusBusService *bus = connection->busService(); if (argc == 1) { QStringList names = bus->ListNames(); foreach (QString name, names) printf("%s\n", qPrintable(name)); exit(0); } QString service = QLatin1String(argv[1]); if (!QDBusUtil::isValidBusName(service)) { fprintf(stderr, "Service '%s' is not a valid name.\n", qPrintable(service)); exit(1); } if (!bus->NameHasOwner(service)) { fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); exit(1); } if (argc == 2) { printf("/\n"); listObjects(service, QString()); exit(0); } QString path = QLatin1String(argv[2]); if (!QDBusUtil::isValidObjectPath(path)) { fprintf(stderr, "Path '%s' is not a valid path name.\n", qPrintable(path)); exit(1); } if (argc == 3) { listAllInterfaces(service, path); exit(0); } QString interface = QLatin1String(argv[3]); QString member; int pos = interface.lastIndexOf(QLatin1Char('.')); if (pos == -1) { member = interface; interface.clear(); } else { member = interface.mid(pos + 1); interface.truncate(pos); } if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) { fprintf(stderr, "Interface '%s' is not a valid interface name.\n", qPrintable(interface)); exit(1); } if (!QDBusUtil::isValidMemberName(member)) { fprintf(stderr, "Method name '%s' is not a valid member name.\n", qPrintable(member)); exit(1); } if (interface.isEmpty()) { if (member.toLower() == QLatin1String("get") && argc == 5) { getProperty(service, path, QLatin1String(argv[4])); return 0; } else if (member.toLower() == QLatin1String("set") && argc == 6) { setProperty(service, path, QLatin1String(argv[4]), QLatin1String(argv[5])); return 0; } } placeCall(service, path, interface, member, argc - 4, argv + 4); }