@@ -15,8 +15,10 @@ dependencies { | |||
compile 'com.google.guava:guava' | |||
compile 'org.slf4j:slf4j-api' | |||
compile project(':sonar-core') | |||
compile 'com.squareup.okhttp3:okhttp' | |||
compile project(':server:sonar-db-dao') | |||
compile project(':sonar-core') | |||
compile project(':sonar-ws') | |||
compileOnly project(path: ':sonar-plugin-api') | |||
compileOnly project(path: ':server:sonar-process') | |||
@@ -25,6 +27,7 @@ dependencies { | |||
testCompile 'com.google.code.findbugs:jsr305' | |||
testCompile 'com.h2database:h2' | |||
testCompile 'com.squareup.okhttp3:mockwebserver' | |||
testCompile 'com.tngtech.java:junit-dataprovider' | |||
testCompile 'junit:junit' | |||
testCompile 'org.assertj:assertj-core' |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2018 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program 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. | |||
* | |||
* This program 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. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.project; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2018 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program 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. | |||
* | |||
* This program 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. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.qualitygate; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -23,6 +23,8 @@ import java.util.List; | |||
import java.util.Optional; | |||
import java.util.function.Supplier; | |||
import java.util.stream.Stream; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.util.stream.MoreCollectors; | |||
@@ -33,9 +35,11 @@ import org.sonar.db.webhook.WebhookDao; | |||
import org.sonar.db.webhook.WebhookDto; | |||
import org.sonar.server.async.AsyncExecution; | |||
import static java.lang.String.format; | |||
import static java.util.Optional.ofNullable; | |||
import static org.sonar.server.ws.WsUtils.checkStateWithOptional; | |||
@ServerSide | |||
@ComputeEngineSide | |||
public class WebHooksImpl implements WebHooks { | |||
private static final Logger LOGGER = Loggers.get(WebHooksImpl.class); | |||
@@ -77,6 +81,14 @@ public class WebHooksImpl implements WebHooks { | |||
} | |||
} | |||
private static <T> T checkStateWithOptional(java.util.Optional<T> value, String message, Object... messageArguments) { | |||
if (!value.isPresent()) { | |||
throw new IllegalStateException(format(message, messageArguments)); | |||
} | |||
return value.get(); | |||
} | |||
@Override | |||
public void sendProjectAnalysisUpdate(Analysis analysis, Supplier<WebhookPayload> payloadSupplier) { | |||
List<Webhook> webhooks = readWebHooksFrom(analysis.getProjectUuid()) |
@@ -28,6 +28,7 @@ import okhttp3.Request; | |||
import okhttp3.RequestBody; | |||
import okhttp3.Response; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.api.utils.System2; | |||
import static java.lang.String.format; | |||
@@ -38,6 +39,7 @@ import static okhttp3.internal.http.StatusLine.HTTP_PERM_REDIRECT; | |||
import static okhttp3.internal.http.StatusLine.HTTP_TEMP_REDIRECT; | |||
import static org.apache.commons.lang.StringUtils.isNotEmpty; | |||
@ServerSide | |||
@ComputeEngineSide | |||
public class WebhookCallerImpl implements WebhookCaller { | |||
@@ -21,6 +21,7 @@ package org.sonar.server.webhook; | |||
import com.google.common.base.Throwables; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.core.util.UuidFactory; | |||
import org.sonar.db.DbClient; | |||
@@ -31,6 +32,7 @@ import org.sonar.db.webhook.WebhookDeliveryDto; | |||
/** | |||
* Persist and purge {@link WebhookDelivery} into database | |||
*/ | |||
@ServerSide | |||
@ComputeEngineSide | |||
public class WebhookDeliveryStorage { | |||
@@ -28,6 +28,7 @@ import java.util.Map; | |||
import java.util.Optional; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.server.project.Project; | |||
@@ -38,6 +39,7 @@ import org.sonar.server.qualitygate.EvaluatedQualityGate; | |||
import static java.lang.String.format; | |||
import static org.sonar.core.config.CorePropertyDefinitions.SONAR_ANALYSIS; | |||
@ServerSide | |||
@ComputeEngineSide | |||
public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory { | |||
@@ -34,7 +34,6 @@ import org.sonar.db.webhook.WebhookDeliveryDto; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
import static org.sonar.db.webhook.WebhookDbTesting.newDto; | |||
import static org.sonar.db.webhook.WebhookDbTesting.selectAllDeliveryUuids; | |||
public class WebhookDeliveryStorageTest { |
@@ -21,9 +21,6 @@ package org.sonar.server.webhook; | |||
import java.io.IOException; | |||
import org.junit.Test; | |||
import org.sonar.server.webhook.Webhook; | |||
import org.sonar.server.webhook.WebhookDelivery; | |||
import org.sonar.server.webhook.WebhookPayload; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -23,6 +23,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.core.platform.ComponentContainer; | |||
import org.sonar.server.webhook.WebhookModule; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER; |
@@ -28,7 +28,6 @@ import org.sonar.api.resources.ResourceTypes; | |||
import org.sonar.api.rules.AnnotationRuleParser; | |||
import org.sonar.api.rules.XMLRuleParser; | |||
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; | |||
import org.sonar.server.ce.CeModule; | |||
import org.sonar.ce.notification.ReportAnalysisFailureNotificationModule; | |||
import org.sonar.core.component.DefaultResourceTypes; | |||
import org.sonar.core.extension.CoreExtensionsInstaller; | |||
@@ -42,6 +41,7 @@ import org.sonar.server.batch.BatchWsModule; | |||
import org.sonar.server.branch.BranchFeatureProxyImpl; | |||
import org.sonar.server.branch.pr.ws.PullRequestWsModule; | |||
import org.sonar.server.branch.ws.BranchWsModule; | |||
import org.sonar.server.ce.CeModule; | |||
import org.sonar.server.ce.ws.CeWsModule; | |||
import org.sonar.server.component.ComponentCleanerService; | |||
import org.sonar.server.component.ComponentFinder; |