-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2449 from hdurix/forced-project-folder
Forced project folder
- Loading branch information
Showing
59 changed files
with
253 additions
and
53 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...main/java/tech/jhipster/lite/generator/project/infrastructure/primary/dto/ProjectDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...h/jhipster/lite/generator/project/infrastructure/primary/rest/ProjectFoldersResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tech.jhipster.lite.generator.project.infrastructure.primary.rest; | ||
|
||
import java.util.UUID; | ||
import org.apache.commons.lang3.SystemUtils; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/project-folders") | ||
class ProjectFoldersResource { | ||
|
||
@Value("${application.forced-project-folder:}") | ||
private String forcedProjectFolder; | ||
|
||
@GetMapping | ||
public String getAvailableFolderName() { | ||
return rootFolder().replaceAll("([^/])$", "$1/") + UUID.randomUUID(); | ||
} | ||
|
||
private String rootFolder() { | ||
if (forcedProjectFolder.isBlank()) { | ||
return SystemUtils.JAVA_IO_TMPDIR; | ||
} | ||
|
||
return forcedProjectFolder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...jhipster/lite/technical/infrastructure/primary/jackson/InvalidProjectFolderException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tech.jhipster.lite.technical.infrastructure.primary.jackson; | ||
|
||
import tech.jhipster.lite.error.domain.GeneratorException; | ||
|
||
public class InvalidProjectFolderException extends GeneratorException { | ||
|
||
public InvalidProjectFolderException(String fixedFolderPath) { | ||
super("Should start with " + fixedFolderPath); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...pster/lite/technical/infrastructure/primary/jackson/JacksonProjectFolderDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tech.jhipster.lite.technical.infrastructure.primary.jackson; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import java.io.IOException; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class JacksonProjectFolderDeserializer extends JsonDeserializer<String> { | ||
|
||
@Value("${application.forced-project-folder:}") | ||
private String forcedProjectFolder; | ||
|
||
@Override | ||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { | ||
String text = jsonParser.getText(); | ||
if (forcedProjectFolder != null && (!text.startsWith(forcedProjectFolder) || text.contains(".."))) { | ||
throw new InvalidProjectFolderException(forcedProjectFolder); | ||
} | ||
return text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type FolderName = string; |
5 changes: 5 additions & 0 deletions
5
src/main/webapp/app/springboot/domain/ProjectFolderService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FolderName } from '@/springboot/domain/FolderName'; | ||
|
||
export interface ProjectFolderService { | ||
get(): Promise<FolderName>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/webapp/app/springboot/secondary/ProjectFolderRepository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { AxiosHttp } from '@/http/AxiosHttp'; | ||
import { ProjectFolderService } from '@/springboot/domain/ProjectFolderService'; | ||
import { FolderName } from '@/springboot/domain/FolderName'; | ||
|
||
export default class ProjectFolderRepository implements ProjectFolderService { | ||
constructor(private axiosHttp: AxiosHttp) {} | ||
|
||
get(): Promise<FolderName> { | ||
return this.axiosHttp.get<FolderName>('api/project-folders').then(res => res.data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ava/tech/jhipster/lite/generator/buildtool/generic/domain/BuildToolDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...st/java/tech/jhipster/lite/generator/buildtool/gradle/domain/GradleDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...tech/jhipster/lite/generator/ci/github/actions/domain/GitHubActionsDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ava/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ipster/lite/generator/client/angular/security/jwt/domain/AngularJwtDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...st/java/tech/jhipster/lite/generator/client/react/core/domain/ReactDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...h/jhipster/lite/generator/client/react/security/jwt/domain/ReactJwtDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
.../java/tech/jhipster/lite/generator/client/svelte/core/domain/SvelteDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...va/tech/jhipster/lite/generator/client/tools/cypress/domain/CypressDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...jhipster/lite/generator/packagemanager/npm/infrastructure/primary/rest/NpmResourceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...jhipster/lite/generator/project/infrastructure/primary/rest/ProjectFoldersResourceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tech.jhipster.lite.generator.project.infrastructure.primary.rest; | ||
|
||
import static org.hamcrest.Matchers.matchesRegex; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import tech.jhipster.lite.IntegrationTest; | ||
|
||
@IntegrationTest | ||
@AutoConfigureMockMvc | ||
class ProjectFoldersResourceIT { | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
void shouldGetProject() throws Exception { | ||
mockMvc.perform(get("/api/project-folders")).andExpect(content().string(matchesRegex("^.*/.{36}$"))); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
.../jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...r/lite/generator/server/javatool/frontendmaven/domain/FrontendMavenDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ipster/lite/generator/server/springboot/broker/pulsar/domain/PulsarDomainServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.