Class MetadataService
java.lang.Object
com.linecorp.centraldogma.server.metadata.MetadataService
A service class for metadata management.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMetadataService
(ProjectManager projectManager, CommandExecutor executor) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionactivateToken
(Author author, String appId) Activates theToken
of the specifiedappId
.addMember
(Author author, String projectName, User member, ProjectRole projectRole) Adds the specifiedmember
to theProjectMetadata
of the specifiedprojectName
with the specifiedprojectRole
.Adds aRepositoryMetadata
of the specifiedrepoName
to the specifiedprojectName
with a defaultRepositoryRole
.addRepo
(Author author, String projectName, String repoName, ProjectRoles projectRoles) Adds aRepositoryMetadata
of the specifiedrepoName
to the specifiedprojectName
with the specifiedProjectRoles
.addToken
(Author author, String projectName, Token token, ProjectRole role) Adds the specifiedToken
to the specifiedprojectName
.addToken
(Author author, String projectName, String appId, ProjectRole role) addTokenRepositoryRole
(Author author, String projectName, String repoName, String appId, RepositoryRole role) Adds theRepositoryRole
for theToken
of the specifiedappId
to the specifiedrepoName
in the specifiedprojectName
.addUserRepositoryRole
(Author author, String projectName, String repoName, User member, RepositoryRole role) Adds theRepositoryRole
for the specifiedmember
to the specifiedrepoName
in the specifiedprojectName
.createToken
(Author author, String appId) Creates a new user-levelToken
with the specifiedappId
.createToken
(Author author, String appId, boolean isSystemAdmin) createToken
(Author author, String appId, String secret) createToken
(Author author, String appId, String secret, boolean isSystemAdmin) deactivateToken
(Author author, String appId) Deactivates theToken
of the specifiedappId
.destroyToken
(Author author, String appId) Removes theToken
of the specifiedappId
completely from the system.findProjectRole
(String projectName, User user) findRepositoryRole
(String projectName, String repoName, User user) FindsRepositoryRole
of the specifiedUser
orUserWithToken
from the specifiedrepoName
in the specifiedprojectName
.findRepositoryRole
(String projectName, String repoName, String appId) FindsRepositoryRole
of the specifiedappId
from the specifiedrepoName
in the specifiedprojectName
.findTokenByAppId
(String appId) Returns aToken
which has the specifiedappId
.findTokenBySecret
(String secret) Returns aToken
which has the specifiedsecret
.getProject
(String projectName) Returns aProjectMetadata
whose name equals to the specifiedprojectName
.Returns aTokens
.purgeToken
(Author author, String appId) Purges theToken
of the specifiedappId
that was removed before.removeMember
(Author author, String projectName, User user) removeProject
(Author author, String projectName) Removes aProjectMetadata
whose name equals to the specifiedprojectName
.removeRepo
(Author author, String projectName, String repoName) removeToken
(Author author, String projectName, Token token) Removes the specifiedToken
from the specifiedprojectName
.removeToken
(Author author, String projectName, String appId) removeTokenRepositoryRole
(Author author, String projectName, String repoName, String appId) Removes theRepositoryRole
for theToken
of the specifiedappId
of the specifiedrepoName
in the specifiedprojectName
.removeUserRepositoryRole
(Author author, String projectName, String repoName, User member) Removes theRepositoryRole
for the specifiedmember
from the specifiedrepoName
in the specifiedprojectName
.restoreProject
(Author author, String projectName) Restores aProjectMetadata
whose name equals to the specifiedprojectName
.restoreRepo
(Author author, String projectName, String repoName) updateMemberRole
(Author author, String projectName, User member, ProjectRole projectRole) updateRepositoryProjectRoles
(Author author, String projectName, String repoName, ProjectRoles projectRoles) updateTokenLevel
(Author author, String appId, boolean toBeSystemAdmin) Update theToken
of the specifiedappId
to user or admin.updateTokenRepositoryRole
(Author author, String projectName, String repoName, String appId, RepositoryRole role) Updates theRepositoryRole
for theToken
of the specifiedappId
of the specifiedrepoName
in the specifiedprojectName
.updateTokenRole
(Author author, String projectName, Token token, ProjectRole role) updateUserRepositoryRole
(Author author, String projectName, String repoName, User member, RepositoryRole role) Updates theRepositoryRole
for the specifiedmember
of the specifiedrepoName
in the specifiedprojectName
.updateWriteQuota
(Author author, String projectName, String repoName, QuotaConfig writeQuota)
-
Field Details
-
METADATA_JSON
A path of metadata file.- See Also:
-
TOKEN_JSON
A path of token list file.- See Also:
-
-
Constructor Details
-
MetadataService
Creates a new instance.
-
-
Method Details
-
getProject
Returns aProjectMetadata
whose name equals to the specifiedprojectName
. -
removeProject
Removes aProjectMetadata
whose name equals to the specifiedprojectName
. -
restoreProject
Restores aProjectMetadata
whose name equals to the specifiedprojectName
. -
getMember
-
addMember
public CompletableFuture<Revision> addMember(Author author, String projectName, User member, ProjectRole projectRole) Adds the specifiedmember
to theProjectMetadata
of the specifiedprojectName
with the specifiedprojectRole
. -
removeMember
Removes the specifieduser
from theProjectMetadata
in the specifiedprojectName
. It also removes theRepositoryRole
of the specifieduser
from everyRepositoryMetadata
. -
updateMemberRole
public CompletableFuture<Revision> updateMemberRole(Author author, String projectName, User member, ProjectRole projectRole) -
getRepo
-
addRepo
Adds aRepositoryMetadata
of the specifiedrepoName
to the specifiedprojectName
with a defaultRepositoryRole
. The member will have theRepositoryRole.WRITE
role and the guest won't have any role. -
addRepo
public CompletableFuture<Revision> addRepo(Author author, String projectName, String repoName, ProjectRoles projectRoles) Adds aRepositoryMetadata
of the specifiedrepoName
to the specifiedprojectName
with the specifiedProjectRoles
. -
removeRepo
-
purgeRepo
-
restoreRepo
-
updateRepositoryProjectRoles
public CompletableFuture<Revision> updateRepositoryProjectRoles(Author author, String projectName, String repoName, ProjectRoles projectRoles) -
addToken
public CompletableFuture<Revision> addToken(Author author, String projectName, Token token, ProjectRole role) Adds the specifiedToken
to the specifiedprojectName
. -
addToken
public CompletableFuture<Revision> addToken(Author author, String projectName, String appId, ProjectRole role) -
removeToken
Removes the specifiedToken
from the specifiedprojectName
. It also removes every token repository role belonging to theToken
from everyRepositoryMetadata
. -
removeToken
Removes theToken
of the specifiedappId
from the specifiedprojectName
. It also removes every token repository role belonging toToken
from everyRepositoryMetadata
. -
updateTokenRole
public CompletableFuture<Revision> updateTokenRole(Author author, String projectName, Token token, ProjectRole role) -
addUserRepositoryRole
public CompletableFuture<Revision> addUserRepositoryRole(Author author, String projectName, String repoName, User member, RepositoryRole role) Adds theRepositoryRole
for the specifiedmember
to the specifiedrepoName
in the specifiedprojectName
. -
removeUserRepositoryRole
public CompletableFuture<Revision> removeUserRepositoryRole(Author author, String projectName, String repoName, User member) Removes theRepositoryRole
for the specifiedmember
from the specifiedrepoName
in the specifiedprojectName
. -
updateUserRepositoryRole
public CompletableFuture<Revision> updateUserRepositoryRole(Author author, String projectName, String repoName, User member, RepositoryRole role) Updates theRepositoryRole
for the specifiedmember
of the specifiedrepoName
in the specifiedprojectName
. -
addTokenRepositoryRole
public CompletableFuture<Revision> addTokenRepositoryRole(Author author, String projectName, String repoName, String appId, RepositoryRole role) Adds theRepositoryRole
for theToken
of the specifiedappId
to the specifiedrepoName
in the specifiedprojectName
. -
removeTokenRepositoryRole
public CompletableFuture<Revision> removeTokenRepositoryRole(Author author, String projectName, String repoName, String appId) Removes theRepositoryRole
for theToken
of the specifiedappId
of the specifiedrepoName
in the specifiedprojectName
. -
updateTokenRepositoryRole
public CompletableFuture<Revision> updateTokenRepositoryRole(Author author, String projectName, String repoName, String appId, RepositoryRole role) Updates theRepositoryRole
for theToken
of the specifiedappId
of the specifiedrepoName
in the specifiedprojectName
. -
updateWriteQuota
public CompletableFuture<Revision> updateWriteQuota(Author author, String projectName, String repoName, QuotaConfig writeQuota) -
findRepositoryRole
public CompletableFuture<RepositoryRole> findRepositoryRole(String projectName, String repoName, User user) FindsRepositoryRole
of the specifiedUser
orUserWithToken
from the specifiedrepoName
in the specifiedprojectName
. If theUser
is not found, it will returnnull
. -
findRepositoryRole
public CompletableFuture<RepositoryRole> findRepositoryRole(String projectName, String repoName, String appId) FindsRepositoryRole
of the specifiedappId
from the specifiedrepoName
in the specifiedprojectName
. If theappId
is not found, it will returnnull
. -
findProjectRole
-
getTokens
Returns aTokens
. -
createToken
Creates a new user-levelToken
with the specifiedappId
. A secret for theappId
will be automatically generated. -
createToken
-
createToken
-
createToken
public CompletableFuture<Revision> createToken(Author author, String appId, String secret, boolean isSystemAdmin) -
destroyToken
Removes theToken
of the specifiedappId
completely from the system. -
purgeToken
Purges theToken
of the specifiedappId
that was removed before.Note that this is a blocking method that should not be invoked in an event loop.
-
activateToken
Activates theToken
of the specifiedappId
. -
deactivateToken
Deactivates theToken
of the specifiedappId
. -
updateTokenLevel
public CompletableFuture<Revision> updateTokenLevel(Author author, String appId, boolean toBeSystemAdmin) Update theToken
of the specifiedappId
to user or admin. -
findTokenByAppId
Returns aToken
which has the specifiedappId
. -
findTokenBySecret
Returns aToken
which has the specifiedsecret
.
-