Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
ba4905a3
Commit
ba4905a3
authored
9 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Remove code duplication bwteen createBootstrapAdminAndHostNoAuth() and createAdminUser()
parent
4727fa4a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
catalogue/SqliteCatalogue.cpp
+31
-52
31 additions, 52 deletions
catalogue/SqliteCatalogue.cpp
catalogue/SqliteCatalogue.hpp
+13
-0
13 additions, 0 deletions
catalogue/SqliteCatalogue.hpp
with
44 additions
and
52 deletions
catalogue/SqliteCatalogue.cpp
+
31
−
52
View file @
ba4905a3
...
...
@@ -89,49 +89,12 @@ void cta::catalogue::SqliteCatalogue::createBootstrapAdminAndHostNoAuth(
const
std
::
string
&
comment
)
{
const
uint64_t
now
=
time
(
NULL
);
{
const
char
*
const
sql
=
"INSERT INTO ADMIN_USER("
"USER_NAME,"
"GROUP_NAME,"
"COMMENT,"
"CREATION_LOG_USER_NAME,"
"CREATION_LOG_GROUP_NAME,"
"CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME,"
"LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME)"
"VALUES("
":USER_NAME,"
":GROUP_NAME,"
":COMMENT,"
":CREATION_LOG_USER_NAME,"
":CREATION_LOG_GROUP_NAME,"
":CREATION_LOG_HOST_NAME,"
":CREATION_LOG_TIME,"
":CREATION_LOG_USER_NAME,"
":CREATION_LOG_GROUP_NAME,"
":CREATION_LOG_HOST_NAME,"
":CREATION_LOG_TIME);"
;
SqliteStmt
stmt
(
m_conn
,
sql
);
stmt
.
bind
(
":USER_NAME"
,
user
.
name
);
stmt
.
bind
(
":GROUP_NAME"
,
user
.
group
);
stmt
.
bind
(
":COMMENT"
,
comment
);
stmt
.
bind
(
":CREATION_LOG_USER_NAME"
,
cliIdentity
.
user
.
name
);
stmt
.
bind
(
":CREATION_LOG_GROUP_NAME"
,
cliIdentity
.
user
.
group
);
stmt
.
bind
(
":CREATION_LOG_HOST_NAME"
,
cliIdentity
.
host
);
stmt
.
bind
(
":CREATION_LOG_TIME"
,
now
);
stmt
.
step
();
}
common
::
dataStructures
::
EntryLog
creationLog
;
creationLog
.
user
.
name
=
cliIdentity
.
user
.
name
;
creationLog
.
user
.
group
=
cliIdentity
.
user
.
group
;
creationLog
.
host
=
cliIdentity
.
host
;
creationLog
.
time
=
now
;
insertAdminUser
(
user
,
comment
,
creationLog
);
{
const
char
*
const
sql
=
...
...
@@ -176,13 +139,12 @@ void cta::catalogue::SqliteCatalogue::createBootstrapAdminAndHostNoAuth(
}
//------------------------------------------------------------------------------
//
create
AdminUser
//
insert
AdminUser
//------------------------------------------------------------------------------
void
cta
::
catalogue
::
SqliteCatalogue
::
createAdminUser
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
void
cta
::
catalogue
::
SqliteCatalogue
::
insertAdminUser
(
const
common
::
dataStructures
::
UserIdentity
&
user
,
const
std
::
string
&
comment
)
{
const
uint64_t
now
=
time
(
NULL
);
const
std
::
string
&
comment
,
const
common
::
dataStructures
::
EntryLog
&
creationLog
)
{
const
char
*
const
sql
=
"INSERT INTO ADMIN_USER("
"USER_NAME,"
...
...
@@ -218,14 +180,31 @@ void cta::catalogue::SqliteCatalogue::createAdminUser(
stmt
.
bind
(
":GROUP_NAME"
,
user
.
group
);
stmt
.
bind
(
":COMMENT"
,
comment
);
stmt
.
bind
(
":CREATION_LOG_USER_NAME"
,
c
liIdentity
.
user
.
name
);
stmt
.
bind
(
":CREATION_LOG_GROUP_NAME"
,
c
liIdentity
.
user
.
group
);
stmt
.
bind
(
":CREATION_LOG_HOST_NAME"
,
c
liIdentity
.
host
);
stmt
.
bind
(
":CREATION_LOG_TIME"
,
now
);
stmt
.
bind
(
":CREATION_LOG_USER_NAME"
,
c
reationLog
.
user
.
name
);
stmt
.
bind
(
":CREATION_LOG_GROUP_NAME"
,
c
reationLog
.
user
.
group
);
stmt
.
bind
(
":CREATION_LOG_HOST_NAME"
,
c
reationLog
.
host
);
stmt
.
bind
(
":CREATION_LOG_TIME"
,
creationLog
.
time
);
stmt
.
step
();
}
//------------------------------------------------------------------------------
// createAdminUser
//------------------------------------------------------------------------------
void
cta
::
catalogue
::
SqliteCatalogue
::
createAdminUser
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
common
::
dataStructures
::
UserIdentity
&
user
,
const
std
::
string
&
comment
)
{
const
uint64_t
now
=
time
(
NULL
);
common
::
dataStructures
::
EntryLog
creationLog
;
creationLog
.
user
.
name
=
cliIdentity
.
user
.
name
;
creationLog
.
user
.
group
=
cliIdentity
.
user
.
group
;
creationLog
.
host
=
cliIdentity
.
host
;
creationLog
.
time
=
now
;
insertAdminUser
(
user
,
comment
,
creationLog
);
}
//------------------------------------------------------------------------------
// deleteAdminUser
//------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
catalogue/SqliteCatalogue.hpp
+
13
−
0
View file @
ba4905a3
...
...
@@ -172,6 +172,19 @@ private:
*/
void
createDbSchema
();
/**
* Inserts a row into the ADMIN_USER table.
*
* @param user The admin user.
* @param comment The comment.
* @param creationLog The log to be used as both the creation and last
* modification logs.
*/
void
insertAdminUser
(
const
common
::
dataStructures
::
UserIdentity
&
user
,
const
std
::
string
&
comment
,
const
common
::
dataStructures
::
EntryLog
&
creationLog
);
};
// class SqliteCatalogue
}
// namespace catalogue
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment