Skip to content

Commit

Permalink
GH-458 Fix compatibility with JDK8
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Jun 26, 2021
1 parent a5d8c64 commit 249efb6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .run/Reposilite.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Reposilite" type="Application" factoryName="Application" singleton="false">
<option name="ALTERNATIVE_JRE_PATH" value="8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="org.panda_lang.reposilite.ReposiliteLauncherKt" />
<module name="reposilite-parent.reposilite-backend.main" />
<option name="VM_PARAMETERS" value="-Xmx14M -Dreposilite.debugEnabled=true -Dtinylog.writerActive.level=DEBUG" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import org.panda_lang.reposilite.maven.api.LookupRequest
import org.panda_lang.reposilite.maven.api.LookupResponse
import org.panda_lang.reposilite.maven.api.Repository
import org.panda_lang.reposilite.web.orNull
import org.panda_lang.reposilite.web.toPath
import org.panda_lang.utilities.commons.function.Result
import java.nio.file.Path

internal class LookupService(
private val repositoryService: RepositoryService,
Expand All @@ -33,7 +33,7 @@ internal class LookupService(

fun lookup(lookupRequest: LookupRequest): Result<LookupResponse, ErrorResponse> {
val repository = repositoryService.getRepository(lookupRequest.repository) ?: return errorResponse(NOT_FOUND, "Repository not found")
val gav = Path.of(lookupRequest.gav)
val gav = lookupRequest.gav.toPath()

if (repository.isDirectory(gav) && repositorySecurityProvider.canBrowseResource(lookupRequest.accessToken, repository, gav).not()) {
return errorResponse(UNAUTHORIZED, "Unauthorized indexing request")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.panda_lang.reposilite.maven.api.FileDetails
import org.panda_lang.utilities.commons.function.Result
import java.io.InputStream
import java.io.OutputStream
import java.nio.file.Path
import java.nio.file.Paths

/**
* Extends Javalin's context with a support for [ErrorResponse] results
Expand Down Expand Up @@ -71,6 +73,9 @@ fun OutputStream.isProbablyOpen(): Boolean =
else -> true
}

fun String.toPath(): Path =
Paths.get(this)

/**
* Project non-existing value of errored [Result] to simplify error handling by convenient way to match expected signatures.
* This method throws [IllegalArgumentException] if the given [Result] does not contain error.
Expand Down

0 comments on commit 249efb6

Please sign in to comment.