Example #1
0
std::shared_ptr<AclEntry> SwitchState::getAcl(const std::string& name) const {
  return getFields()->acls->getEntryIf(name);
}
Example #2
0
const value::Value* EventValue::getEventField(const std::string& name) const
{
    return getFields()->GetField(name);
}
Example #3
0
std::shared_ptr<Port> SwitchState::getPort(PortID id) const {
  return getFields()->ports->getPort(id);
}
TEST(FindAndModifyRequest, ParseWithUpdateOnlyRequiredFields) {
    BSONObj cmdObj(fromjson(R"json({
            query: { x: 1 },
            update: { y: 1 }
        })json"));

    auto parseStatus = FindAndModifyRequest::parseFromBSON(NamespaceString("a.b"), cmdObj);
    ASSERT_OK(parseStatus.getStatus());

    auto request = parseStatus.getValue();
    ASSERT_EQUALS(NamespaceString("a.b").toString(), request.getNamespaceString().toString());
    ASSERT_BSONOBJ_EQ(BSON("x" << 1), request.getQuery());
    ASSERT_BSONOBJ_EQ(BSON("y" << 1), request.getUpdateObj());
    ASSERT_EQUALS(false, request.isUpsert());
    ASSERT_EQUALS(false, request.isRemove());
    ASSERT_BSONOBJ_EQ(BSONObj(), request.getFields());
    ASSERT_BSONOBJ_EQ(BSONObj(), request.getSort());
    ASSERT_BSONOBJ_EQ(BSONObj(), request.getCollation());
    ASSERT_EQUALS(0u, request.getArrayFilters().size());
    ASSERT_EQUALS(false, request.shouldReturnNew());
}

TEST(FindAndModifyRequest, ParseWithUpdateFullSpec) {
    BSONObj cmdObj(fromjson(R"json({
            query: { x: 1 },
            update: { y: 1 },
            upsert: true,
            fields: { x: 1, y: 1 },
            sort: { z: -1 },
            collation: {locale: 'en_US' },
            arrayFilters: [ { i: 0 } ],
// static
void LLPanelLogin::onClickConnect(void *)
{
	if (sInstance && sInstance->mCallback)
	{
		// tell the responder we're not here anymore
		if ( gResponsePtr )
			gResponsePtr->setParent( 0 );

		// JC - Make sure the fields all get committed.
		sInstance->setFocus(FALSE);

		LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
		LLSD combo_val = combo->getSelectedValue();
		if (combo_val.isUndefined())
		{
			combo_val = combo->getValue();
		}
		if(combo_val.isUndefined())
		{
			LLNotificationsUtil::add("StartRegionEmpty");
			return;
		}		
		if(!LLGridManager::getInstance()->setGridChoice(combo_val.asString()))
		{
			LLSD args;
			args["GRID"] = combo_val.asString();
			LLNotificationsUtil::add("InvalidGrid", args);
			return;
		}
		updateStartSLURL();
		std::string username = sInstance->getChild<LLUICtrl>("username_combo")->getValue().asString();

		LLSD blocked = FSData::allowed_login();
		if (!blocked.isMap()) //hack for testing for an empty LLSD
		{
			if(username.empty())
			{
				// user must type in something into the username field
				LLNotificationsUtil::add("MustHaveAccountToLogIn");
			}
			else
			{
				LLPointer<LLCredential> cred;
				BOOL remember;
				getFields(cred, remember);
				std::string identifier_type;
				cred->identifierType(identifier_type);
				LLSD allowed_credential_types;
				LLGridManager::getInstance()->getLoginIdentifierTypes(allowed_credential_types);
				
				// check the typed in credential type against the credential types expected by the server.
				for(LLSD::array_iterator i = allowed_credential_types.beginArray();
					i != allowed_credential_types.endArray();
					i++)
				{
					
					if(i->asString() == identifier_type)
					{
						// yay correct credential type
						sInstance->mCallback(0, sInstance->mCallbackData);
						return;
					}
				}
				
				// Right now, maingrid is the only thing that is picky about
				// credential format, as it doesn't yet allow account (single username)
				// format creds.  - Rox.  James, we wanna fix the message when we change
				// this.
				LLNotificationsUtil::add("InvalidCredentialFormat");			
			}
		}
		else
		{
			LLNotificationsUtil::add("BlockLoginInfo", blocked);
		}
	}
}
Example #6
0
void createTable(QString tableName,QList<QDomNode> fields,QTextStream &outstrm, QString tableDesc, bool isLookUp)
{    
    QStringList sfields;
    QStringList indexes;
    QStringList keys;
    QStringList rels;

    QString sql;
    QString keysql;
    QString field;

    QString index;
    QString constraint;
    int pos;

    QList <TrelatedTable> relTables;

    qDebug() << "Creating table: " + tableName;

    sfields << "CREATE TABLE IF NOT EXISTS " + tableName + "(" << "\n";
    keys << "PRIMARY KEY (";

    for (int fld = 0; fld < fields.count(); fld++)
    {
        QDomElement efield = fields[fld].toElement();

        field = "";
        if ((efield.attribute("type","") == "varchar") || (efield.attribute("type","") == "int"))
            field = efield.attribute("name","") + " " + efield.attribute("type","") + "(" + efield.attribute("size","") + ")";
        else
            if (efield.attribute("type","") == "decimal")
                field = efield.attribute("name","") + " " + efield.attribute("type","") + "(" + efield.attribute("size","") + "," + efield.attribute("decsize","") + ")";
            else
                field = efield.attribute("name","") + " " + efield.attribute("type","");

        if (efield.attribute("key","false") == "true")
        {
            field = field + " NOT NULL COMMENT \"" + efield.attribute("desc","") + "\", ";
            keys << efield.attribute("name","") + " , ";
        }
        else
            field = field + " COMMENT \"" + efield.attribute("desc","") + "\", ";

        sfields << field << "\n";

        if (efield.attribute("rtable","") != "")
        {
            if (efield.attribute("rlookup","") == "true")
            {
                idx++;
                index = "INDEX fk" + QString::number(idx) + "_" + tableName + "_" + efield.attribute("rtable","") ;
                indexes << index.left(64) + " (" + efield.attribute("name","") + ") , " << "\n";

                constraint = "CONSTRAINT fk" + QString::number(idx) + "_" + tableName + "_" + efield.attribute("rtable","");
                rels << constraint.left(64) << "\n";
                rels << "FOREIGN KEY (" + efield.attribute("name","") + ")" << "\n";
                rels << "REFERENCES " + efield.attribute("rtable","") + " (" + efield.attribute("rfield","") + ")" << "\n";

                rels << "ON DELETE RESTRICT " << "\n";
                rels << "ON UPDATE NO ACTION," << "\n";
            }
            else
            {                              
                pos = relTableFound(relTables,efield.attribute("rtable",""));
                if (pos >= 0)
                {
                    TrelatedField relfield;
                    relfield.name = efield.attribute("name","");
                    relfield.rname = efield.attribute("rfield","");
                    relTables[pos].fields.append(relfield);
                }
                else
                {
                    TrelatedTable relTable;
                    relTable.name = efield.attribute("rtable","");

                    TrelatedField relfield;
                    relfield.name = efield.attribute("name","");
                    relfield.rname = efield.attribute("rfield","");
                    relTable.fields.append(relfield);
                    relTables.append(relTable);
                }
            }
        }
    }
    //Process combined foreign keys
    for (pos = 0; pos < relTables.count();pos++)
    {
        idx++;
        index = "INDEX fk" + QString::number(idx) + "_" + tableName + "_" + relTables[pos].name ;
        indexes << index.left(64) + " (" + getFields(relTables[pos]) + ") , " << "\n";

        constraint = "CONSTRAINT fk" + QString::number(idx) + "_" + tableName + "_" + relTables[pos].name;
        rels << constraint.left(64) << "\n";
        rels << "FOREIGN KEY (" + getFields(relTables[pos]) + ")" << "\n";
        rels << "REFERENCES " + relTables[pos].name + " (" + getRelatedFields(relTables[pos]) + ")" << "\n";

        rels << "ON DELETE CASCADE " << "\n";
        rels << "ON UPDATE NO ACTION," << "\n";

    }
    int clm;
    //Contatenate al different pieces of the create script into one SQL
    for (clm = 0; clm <= sfields.count() -1;clm++)
    {
        sql = sql + sfields[clm];
    }
    for (clm = 0; clm <= keys.count() -1;clm++)
    {
        keysql = keysql + keys[clm];
    }
    clm = keysql.lastIndexOf(",");
    keysql = keysql.left(clm) + ") , \n";

    sql = sql + keysql;

    for (clm = 0; clm <= indexes.count() -1;clm++)
    {
        sql = sql + indexes[clm];
    }
    for (clm = 0; clm <= rels.count() -1;clm++)
    {
        sql = sql + rels[clm];
    }
    clm = sql.lastIndexOf(",");
    sql = sql.left(clm);
    sql = sql + ")" + "\n ENGINE = InnoDB CHARSET=utf8 COMMENT = \"" + tableDesc + "\"; \n";
    idx++;
    sql = sql + "CREATE UNIQUE INDEX rowuuid" + QString::number(idx) + " ON " + tableName + "(rowuuid);\n";
    if (isLookUp)
        sql = sql + "CREATE TRIGGER uudi_" + tableName + " BEFORE INSERT ON " + tableName + " FOR EACH ROW SET new.rowuuid = uuid();\n\n";
    else
        sql = sql + "\n";
    outstrm << sql;
}
Example #7
0
// static
void LLPanelLogin::onClickConnect(void *)
{
	if (sInstance && sInstance->mCallback)
	{
		// JC - Make sure the fields all get committed.
		sInstance->setFocus(FALSE);

		LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
		LLSD combo_val = combo->getSelectedValue();
		if (combo_val.isUndefined())
		{
			combo_val = combo->getValue();
		}
		if(combo_val.isUndefined())
		{
			LLNotificationsUtil::add("StartRegionEmpty");
			return;
		}		

		std::string new_combo_value = combo_val.asString();
		if (!new_combo_value.empty())
		{
			std::string match = "://";
			size_t found = new_combo_value.find(match);
			if (found != std::string::npos)	
				new_combo_value.erase( 0,found+match.length());
		}

		try
		{
			LLGridManager::getInstance()->setGridChoice(new_combo_value);
		}
		catch (LLInvalidGridName ex)
		{
			LLSD args;
			args["GRID"] = ex.name();
			LLNotificationsUtil::add("InvalidGrid", args);
			return;
		}
		updateStartSLURL();
		std::string username = sInstance->getChild<LLUICtrl>("username_combo")->getValue().asString();
		gSavedSettings.setString("UserLoginInfo", credential_name());

		LLSD blocked = FSData::getInstance()->allowed_login();
		if (!blocked.isMap()) //hack for testing for an empty LLSD
		{
			if(username.empty())
			{
				LLSD args;
				args["CURRENT_GRID"] = LLGridManager::getInstance()->getGridLabel();
				// user must type in something into the username field
				LLNotificationsUtil::add("MustHaveAccountToLogIn", args);
			}
			else
			{
				LLPointer<LLCredential> cred;
				BOOL remember;
				getFields(cred, remember);
				std::string identifier_type;
				cred->identifierType(identifier_type);
				LLSD allowed_credential_types;
				LLGridManager::getInstance()->getLoginIdentifierTypes(allowed_credential_types);
				
				// check the typed in credential type against the credential types expected by the server.
				for(LLSD::array_iterator i = allowed_credential_types.beginArray();
					i != allowed_credential_types.endArray();
					i++)
				{
					
					if(i->asString() == identifier_type)
					{
						// yay correct credential type
						sInstance->mCallback(0, sInstance->mCallbackData);
						return;
					}
				}
				
				// Right now, maingrid is the only thing that is picky about
				// credential format, as it doesn't yet allow account (single username)
				// format creds.  - Rox.  James, we wanna fix the message when we change
				// this.
				LLNotificationsUtil::add("InvalidCredentialFormat");			
			}
		}
	}
}
void ArchivingRulesDialog::executeArchiving()
{ 
  if(_changed)
  { 
    QMessageBox::StandardButton answer;
    answer = QMessageBox::question(this, tr("O banco de dados deve ser atulalizado antes da execução"), 
        tr("Deseja salvar as regras de arquivamento?"),
      QMessageBox::Yes | QMessageBox::Cancel,
      QMessageBox::Cancel);

    if(answer == QMessageBox::Cancel)
      return;

    // Save the archiving roles
    std::vector<struct wsArchivingRule> rules = getFields();
    _manager->saveArchivingRules(rules);
    
    // Update the table with the generated IDS for each archiving role in database
    std::vector<struct wsArchivingRule> archivingRules;
    _manager->getArchivingRules(archivingRules);
    setFields(archivingRules);

    saveBtn->setDisabled(true);
    _changed = false;
  }

  QList<QTableWidgetItem*> selectedItems = archivingItemsTbl->selectedItems();

  QStringList arguments;
  arguments.push_back(_configFileName);

  QTableWidgetItem* item;

  if (selectedItems.size() > 0)
  {
    for(int i=0; i<selectedItems.size(); i++)
    {
      item = selectedItems.at(i);
      if(item->column() != 0)
        continue;

      arguments.push_back(item->data(Qt::UserRole).toString());
    }
  }
  else
  {
    QMessageBox::warning(this, tr("Resultado"), tr("Nenhuma regra de arquivamento está selecionada!\nO arquivamento não foi realizado!"), QMessageBox::Ok);
    return;
  }

  enableButtons(false);
  QString archivingProgramPath = QCoreApplication::applicationDirPath() + "/arquivador";

  #ifdef WIN32
    archivingProgramPath.append(".exe");
  #endif

  // Check if the "arquivador" program is at correct folder and it can be executed
  if(!QFile::exists(archivingProgramPath))
  {
    enableButtons(true);
    QMessageBox::warning(this, tr("Resultado"), tr("O arquivamento não foi realizado!\n Programa \"arquivador\" não foi encontrado."), QMessageBox::Ok);
    return;
  }

  _process.start(archivingProgramPath, arguments);
}