Skip to content

Commit

Permalink
#207 Update dependencies [version does not work]
Browse files Browse the repository at this point in the history
  • Loading branch information
sklein94 committed Mar 29, 2023
1 parent 2b7ec2f commit d063bfd
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 60 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11.0.10-jdk as builder
FROM eclipse-temurin:17.0.6_10-jdk as builder

ENV SMEAGOL_DIR=/usr/src/smeagol
COPY mvnw pom.xml package.json yarn.lock .prettierrc ${SMEAGOL_DIR}/
Expand All @@ -16,7 +16,7 @@ RUN set -x \



FROM registry.cloudogu.com/official/java:11.0.18-1
FROM registry.cloudogu.com/official/java:17.0.6-1
LABEL NAME="official/smeagol" \
VERSION="1.6.2-3" \
maintainer="Sebastian Sdorra <sebastian.sdorra@cloudogu.com>"
Expand Down
35 changes: 11 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.0.7</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -183,31 +184,17 @@
<scope>compile</scope>
</dependency>

<!-- <dependency>-->
<!-- <groupId>jakarta.servlet</groupId>-->
<!-- <artifactId>jakarta.servlet-api</artifactId>-->
<!-- <version>6.0.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>org.apache.httpcomponents.client5</groupId>-->
<!-- <artifactId>httpclient5</artifactId>-->
<!-- <version>5.2.1</version>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>com.jcraft</groupId>-->
<!-- <artifactId>jsch</artifactId>-->
<!-- <version>0.1.55</version>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>org.codehaus.groovy</groupId>-->
<!-- <artifactId>groovy-all</artifactId>-->
<!-- <version>2.4.21</version>-->
<!-- </dependency>-->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>

</dependencies>

Expand Down
28 changes: 15 additions & 13 deletions src/main/java/com/cloudogu/smeagol/ScmHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -61,7 +62,8 @@ protected static RestTemplate createRestTemplate(RestTemplateBuilder restTemplat
.disableCookieManagement();

if (stage == Stage.DEVELOPMENT) {
httpClientBuilder = disableSSLVerification(httpClientBuilder);
throw new RuntimeException("IMPLEMENT ME: TODO");
// httpClientBuilder = disableSSLVerification(httpClientBuilder);
}

HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
Expand All @@ -71,14 +73,14 @@ protected static RestTemplate createRestTemplate(RestTemplateBuilder restTemplat
.build();
}

private static HttpClientBuilder disableSSLVerification(HttpClientBuilder httpClientBuilder) {
LOG.warn("disable ssl verification for scm-manager communication, because we are in development stage");
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = createSSLContext(acceptingTrustStrategy);

SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
return httpClientBuilder.setSSLSocketFactory(csf);
}
// private static HttpClientBuilder disableSSLVerification(HttpClientBuilder httpClientBuilder) {
// LOG.warn("disable ssl verification for scm-manager communication, because we are in development stage");
// TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
// SSLContext sslContext = createSSLContext(acceptingTrustStrategy);
//
// SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
// return httpClientBuilder .setSSLSocketFactory(csf);
// }

private static SSLContext createSSLContext(TrustStrategy acceptingTrustStrategy) {
try {
Expand Down Expand Up @@ -153,10 +155,10 @@ public ScmHttpClientResponse load(CacheKey key) {
key.urlVariables
);

return ScmHttpClientResponse.of(response.getStatusCode(), response.getBody());
return ScmHttpClientResponse.of((HttpStatus) response.getStatusCode(), response.getBody());
} catch (HttpClientErrorException ex) {
if (ex.getStatusCode() == HttpStatus.NOT_FOUND) {
return ScmHttpClientResponse.of(ex.getStatusCode());
return ScmHttpClientResponse.of((HttpStatus) ex.getStatusCode());
}
throw ex;
} finally {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/cloudogu/smeagol/ServletInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder applicatio
return application.sources(Smeagol.class);
}

@Override
public void onStartup(jakarta.servlet.ServletContext servletContext){
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
package com.cloudogu.smeagol.wiki.infrastructure;

import com.cloudogu.smeagol.wiki.domain.CommitId;
import com.cloudogu.smeagol.wiki.domain.Content;
import com.cloudogu.smeagol.wiki.domain.Message;
import com.cloudogu.smeagol.wiki.domain.Page;
import com.cloudogu.smeagol.wiki.domain.PageRepository;
import com.cloudogu.smeagol.wiki.domain.Path;
import com.cloudogu.smeagol.wiki.domain.WikiId;
import com.cloudogu.smeagol.wiki.usecase.CreatePageCommand;
import com.cloudogu.smeagol.wiki.usecase.DeletePageCommand;
import com.cloudogu.smeagol.wiki.usecase.EditPageCommand;
import com.cloudogu.smeagol.wiki.usecase.MovePageCommand;
import com.cloudogu.smeagol.wiki.usecase.RestorePageCommand;
import com.cloudogu.smeagol.wiki.domain.*;
import com.cloudogu.smeagol.wiki.usecase.*;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.google.common.base.Strings;
import de.triology.cb.CommandBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.net.URI;
Expand Down Expand Up @@ -106,7 +91,7 @@ public ResponseEntity<Void> createOrEdit(
return restore(id, path, payload);
}

if ( repository.exists(id, path) ) {
if (repository.exists(id, path)) {
return edit(id, path, payload);
}
return create(request, id, path, payload);
Expand Down Expand Up @@ -142,7 +127,7 @@ public ResponseEntity<Void> delete(
@PathVariable("repositoryId") String repositoryId,
@PathVariable("branch") String branch,
@RequestBody DeleteRequestPayload payload
) {
) {
WikiId id = new WikiId(repositoryId, branch);
Path path = pathExtractor.extractPathFromRequest(request, MAPPING, id);

Expand All @@ -153,6 +138,7 @@ public ResponseEntity<Void> delete(

public abstract static class RequestPayload {
private String message;

protected Message getMessage() {
return Message.valueOf(message);
}
Expand All @@ -163,15 +149,18 @@ public static class PostRequestPayload extends RequestPayload {
private String content;
private String moveTo;
private String restore;

private Content getContent() {
return Content.valueOf(content);
}

private Path getMoveTo() {
if (Strings.isNullOrEmpty(moveTo)) {
return null;
}
return Path.valueOf(moveTo);
}

private CommitId getRestore() {
if (Strings.isNullOrEmpty(restore)) {
return null;
Expand All @@ -181,6 +170,7 @@ private CommitId getRestore() {
}

@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
public static class DeleteRequestPayload extends RequestPayload {}
public static class DeleteRequestPayload extends RequestPayload {
}

}

0 comments on commit d063bfd

Please sign in to comment.