Ejemplo n.º 1
0
        public int getVaultObjectId(VaultObject vaultObject)
        {
            int id = -1;
            try {
                String tableName = tableNameFromPluginName(vaultObject.getPluginName());
                String query = "select id \"id\"";
                query += " from " + tableName;
                query += " where objectName = \"" + vaultObject.getObjectName() + "\"";

                // use passport info if present
                if (vaultObject.getPassport() != null) {
                    String username = vaultObject.getPassport().getUser().username;
                    query += " and passportUsername = \"" + username + "\"";
                } else {
                    query += " and passportUsername ISNULL";
                }
                debug(query);

                DataTable results = database.GetDataTable(query);
                // there should only ever be one copy of an object in the database
                DataRow row = results.Rows[0];
                id = Int32.Parse(row["id"].ToString());
            } catch (Exception e) {
                id = -1;
            }
            return id;
        }
Ejemplo n.º 2
0
        public void getVaultObject(VaultObject vaultObject)
        {
            try {
                String tableName = tableNameFromPluginName(vaultObject.getPluginName());
                String query = "select id \"id\",";
                query += "objectName \"objectName\", xml \"xml\"";
                query += " from " + tableName;
                query += " where objectName = \"" + vaultObject.getObjectName() + "\"";

                // use passport info if present
                if (vaultObject.getPassport() != null) {
                    String username = vaultObject.getPassport().getUser().username;
                    query += " and passportUsername = \"" + username + "\"";
                } else {
                    query += " and passportUsername ISNULL";
                }

                debug(query);

                DataTable results = database.GetDataTable(query);
                // there should only ever be one copy of an object in the database
                DataRow row = results.Rows[0];
                vaultObject.fromDataRow(row);
            } catch (Exception e) {
                throw new VaultObjectNotFoundException();
            }
        }