diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-07-03 14:49:39 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-07-03 15:08:06 +0200 |
commit | 5ccbb39d22b649cf47b0082b1b198783596b417e (patch) | |
tree | b58770fb8e1882c4108d0bfe4462d068edc56a00 /sonar-core/src/main | |
parent | bd9e609162e5c0420a7ac7c2d7c06580020db59d (diff) | |
download | sonarqube-5ccbb39d22b649cf47b0082b1b198783596b417e.tar.gz sonarqube-5ccbb39d22b649cf47b0082b1b198783596b417e.zip |
Refator permissions to share same constants between Ruby and Java
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/user/Permission.java | 64 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/user/Permissions.java | 36 |
2 files changed, 64 insertions, 36 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/user/Permission.java b/sonar-core/src/main/java/org/sonar/core/user/Permission.java new file mode 100644 index 00000000000..be5fb50a755 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/user/Permission.java @@ -0,0 +1,64 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.core.user; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * + * Holds the constants representing the various global permissions that can be assigned to users & groups + * + * @since 3.7 + */ +public class Permission { + + public static final Permission SYSTEM_ADMIN = new Permission("admin"); + public static final Permission QUALITY_PROFILE_ADMIN = new Permission("profileadmin"); + public static final Permission DASHBOARD_SHARING = new Permission("shareDashboard"); + public static final Permission SCAN_EXECUTION = new Permission("scan"); + public static final Permission DRY_RUN_EXECUTION = new Permission("dryRunScan"); + + private final String key; + // Use linked hash map to preserve order + private static Map<String, Permission> allGlobal = new LinkedHashMap<String, Permission>(); + + static { + allGlobal.put(SYSTEM_ADMIN.key, SYSTEM_ADMIN); + allGlobal.put(QUALITY_PROFILE_ADMIN.key, QUALITY_PROFILE_ADMIN); + allGlobal.put(DASHBOARD_SHARING.key, DASHBOARD_SHARING); + allGlobal.put(SCAN_EXECUTION.key, SCAN_EXECUTION); + allGlobal.put(DRY_RUN_EXECUTION.key, DRY_RUN_EXECUTION); + } + + private Permission(String key) { + this.key = key; + } + + public String key() { + return key; + } + + public static Map<String, Permission> allGlobal() { + return allGlobal; + } + +} diff --git a/sonar-core/src/main/java/org/sonar/core/user/Permissions.java b/sonar-core/src/main/java/org/sonar/core/user/Permissions.java deleted file mode 100644 index db6ad9d6e09..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/user/Permissions.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.core.user; - -/** - * - * Holds the constants representing the various permissions that can be assigned to users & groups - * - * @since 3.7 - */ -public interface Permissions { - - String SYSTEM_ADMIN = "admin"; - String QUALITY_PROFILE_ADMIN = "profileadmin"; - String DASHBOARD_SHARING = "shareDashboard"; - String SCAN_EXECUTION = "scan"; - String DRY_RUN_EXECUTION = "dryRunScan"; -} |