use of org.finos.legend.sdlc.server.project.ProjectFileAccessProvider.WorkspaceAccessType in project legend-sdlc by finos.
the class BaseGitLabApi method parseWorkspaceBranchName.
protected static WorkspaceInfo parseWorkspaceBranchName(String branchName) {
int firstDelimiter = branchName.indexOf(BRANCH_DELIMITER);
if (firstDelimiter == -1) {
return null;
}
WorkspaceType type;
WorkspaceAccessType accessType;
switch(branchName.substring(0, firstDelimiter)) {
case WORKSPACE_BRANCH_PREFIX:
{
type = WorkspaceType.USER;
accessType = WorkspaceAccessType.WORKSPACE;
break;
}
case CONFLICT_RESOLUTION_BRANCH_PREFIX:
{
type = WorkspaceType.USER;
accessType = WorkspaceAccessType.CONFLICT_RESOLUTION;
break;
}
case BACKUP_BRANCH_PREFIX:
{
type = WorkspaceType.USER;
accessType = WorkspaceAccessType.BACKUP;
break;
}
case GROUP_BRANCH_PREFIX:
{
type = WorkspaceType.GROUP;
accessType = WorkspaceAccessType.WORKSPACE;
break;
}
case GROUP_CONFLICT_RESOLUTION_BRANCH_PREFIX:
{
type = WorkspaceType.GROUP;
accessType = WorkspaceAccessType.CONFLICT_RESOLUTION;
break;
}
case GROUP_BACKUP_BRANCH_PREFIX:
{
type = WorkspaceType.GROUP;
accessType = WorkspaceAccessType.BACKUP;
break;
}
default:
{
return null;
}
}
switch(type) {
case USER:
{
// <prefix>/<userId>/<workspaceId>
int nextDelimiter = branchName.indexOf(BRANCH_DELIMITER, firstDelimiter + 1);
if (nextDelimiter == -1) {
return null;
}
String workspaceId = branchName.substring(nextDelimiter + 1);
String userId = branchName.substring(firstDelimiter + 1, nextDelimiter);
return new WorkspaceInfo(workspaceId, type, accessType, userId);
}
case GROUP:
{
// <prefix>/<workspaceId>
String workspaceId = branchName.substring(firstDelimiter + 1);
return new WorkspaceInfo(workspaceId, type, accessType, null);
}
default:
{
throw new IllegalStateException("Unknown workspace type: " + type);
}
}
}
Aggregations