summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java22
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java17
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java5
3 files changed, 22 insertions, 22 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
index 1d3657b576d..ae42df99f3a 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
@@ -45,6 +45,23 @@ public class QProfileFactory implements ServerComponent {
this.previewCache = previewCache;
}
+ @CheckForNull
+ QualityProfileKey getDefault(String language) {
+ DbSession dbSession = db.openSession(false);
+ try {
+ QualityProfileDto profile = getDefault(dbSession, language);
+ return profile != null ? profile.getKey() : null;
+ } finally {
+ dbSession.close();
+ }
+ }
+
+ @CheckForNull
+ QualityProfileDto getDefault(DbSession session, String language) {
+ return db.qualityProfileDao().selectDefaultProfile(language, PROFILE_PROPERTY_PREFIX + language, session);
+ }
+
+
void setDefault(QualityProfileKey key) {
DbSession dbSession = db.openSession(false);
try {
@@ -66,11 +83,6 @@ public class QProfileFactory implements ServerComponent {
.setValue(profile.getName()));
}
- @CheckForNull
- private QualityProfileDto getDefault(DbSession session, String language) {
- return db.qualityProfileDao().selectDefaultProfile(language, PROFILE_PROPERTY_PREFIX + language, session);
- }
-
void delete(QualityProfileKey key) {
DbSession session = db.openSession(false);
try {
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
index 0aa53c0c725..8d890cdab0a 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
@@ -148,23 +148,6 @@ public class QProfileLookup implements ServerComponent {
return ancestors;
}
- public boolean isDeletable(QProfile profile, DbSession session) {
- QProfile defaultProfile = defaultProfile(profile.language(), session);
- if (defaultProfile != null && (defaultProfile.id() == profile.id())) {
- return false;
- }
- return countChildren(profile, session) == 0;
- }
-
- public boolean isDeletable(QProfile profile) {
- DbSession session = myBatis.openSession(false);
- try {
- return isDeletable(profile, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
private void incrementAncestors(QProfile profile, List<QProfile> ancestors, DbSession session) {
if (profile.parent() != null) {
QualityProfileDto parentDto = dao.selectParent(profile.id(), session);
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
index 9e044a0f6a9..41b98160a97 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
@@ -193,6 +193,11 @@ public class QProfileService implements ServerComponent {
factory.setDefault(key);
}
+ @CheckForNull
+ public QualityProfileKey getDefault(String language) {
+ return factory.getDefault(language);
+ }
+
private void verifyAdminPermission() {
UserSession.get().checkLoggedIn();
UserSession.get().checkGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN);