Skip to content

Commit c317411

Browse files
authored
Merge pull request #35 from FusionAuth/degroff/0.3.5.maintenance-file_manager
degroff/0.3.5.maintenance file manager
2 parents 8632a40 + 1d426e8 commit c317411

20 files changed

+980
-58
lines changed

build.savant

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jackson5Version = "3.0.1"
1717
restifyVersion = "4.2.1"
1818
testngVersion = "7.10.2"
1919

20-
project(group: "io.fusionauth", name: "java-http", version: "0.3.6", licenses: ["ApacheV2_0"]) {
20+
project(group: "io.fusionauth", name: "java-http", version: "0.3.7", licenses: ["ApacheV2_0"]) {
2121
workflow {
2222
fetch {
2323
// Dependency resolution order:

java-http.ipr

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,14 @@
346346
</HTMLCodeStyleSettings>
347347
<JavaCodeStyleSettings>
348348
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
349+
<option name="BLANK_LINES_AROUND_FIELD_WITH_ANNOTATIONS" value="1" />
349350
<option name="CLASS_NAMES_IN_JAVADOC" value="3" />
350351
<option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
351352
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
352353
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
353354
<option name="IMPORT_LAYOUT_TABLE">
354355
<value>
356+
<package name="" withSubpackages="true" static="false" module="true" />
355357
<package name="javax" withSubpackages="true" static="false" />
356358
<package name="java" withSubpackages="true" static="false" />
357359
<emptyLine />
@@ -1394,7 +1396,45 @@
13941396
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="Java 17" project-jdk-type="JavaSDK">
13951397
<output url="file://$PROJECT_DIR$/out" />
13961398
</component>
1399+
<component name="ProjectRunConfigurationManager">
1400+
<configuration default="true" type="TestNG">
1401+
<shortenClasspath name="NONE" />
1402+
<useClassPathOnly />
1403+
<option name="SUITE_NAME" value="" />
1404+
<option name="PACKAGE_NAME" value="" />
1405+
<option name="MAIN_CLASS_NAME" value="" />
1406+
<option name="GROUP_NAME" value="" />
1407+
<option name="TEST_OBJECT" value="CLASS" />
1408+
<option name="VM_PARAMETERS" value="-ea --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.util=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED" />
1409+
<option name="PARAMETERS" value="" />
1410+
<option name="OUTPUT_DIRECTORY" value="" />
1411+
<option name="TEST_SEARCH_SCOPE">
1412+
<value defaultName="moduleWithDependencies" />
1413+
</option>
1414+
<option name="PROPERTIES_FILE" value="" />
1415+
<properties />
1416+
<listeners>
1417+
<listener class="io.fusionauth.http.BaseTest$TestListener" />
1418+
</listeners>
1419+
<method v="2">
1420+
<option name="Make" enabled="true" />
1421+
</method>
1422+
</configuration>
1423+
</component>
13971424
<component name="VcsDirectoryMappings">
13981425
<mapping directory="$PROJECT_DIR$" vcs="Git" />
13991426
</component>
1427+
<component name="libraryTable">
1428+
<library name=".kts definition dependencies">
1429+
<CLASSES>
1430+
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
1431+
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-script-runtime.jar!/" />
1432+
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib.jar!/" />
1433+
</CLASSES>
1434+
<JAVADOC />
1435+
<SOURCES>
1436+
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-sources.jar!/" />
1437+
</SOURCES>
1438+
</library>
1439+
</component>
14001440
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* Thrown when a request exceeds the total configured maximum size.
20+
*
21+
* @author Daniel DeGroff
22+
*/
23+
public class ContentTooLargeException extends HTTPProcessingException {
24+
public long maximumRequestSize;
25+
26+
public ContentTooLargeException(long maximumRequestSize, String detailedMessage) {
27+
super(413, "Content Too Large", detailedMessage);
28+
this.maximumRequestSize = maximumRequestSize;
29+
}
30+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* A base HTTP processing exception that is able to suggest a status code to return the client.
20+
*/
21+
public abstract class HTTPProcessingException extends RuntimeException {
22+
protected final int status;
23+
24+
protected final String statusMessage;
25+
26+
protected HTTPProcessingException(int status, String statusMessage) {
27+
this.status = status;
28+
this.statusMessage = statusMessage;
29+
}
30+
31+
protected HTTPProcessingException(int status, String statusMessage, String detailedMessage) {
32+
super(detailedMessage);
33+
this.status = status;
34+
this.statusMessage = statusMessage;
35+
}
36+
37+
public int getStatus() {
38+
return status;
39+
}
40+
41+
public String getStatusMessage() {
42+
return statusMessage;
43+
}
44+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* Thrown when a multipart request cannot be parsed because a processor was not specified.
20+
*
21+
* @author Daniel DeGroff
22+
*/
23+
public class UnprocessableContentException extends HTTPProcessingException {
24+
public UnprocessableContentException(String message) {
25+
super(422, "Unprocessable Content", message);
26+
}
27+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http.io;
17+
18+
import java.io.IOException;
19+
import java.nio.file.Files;
20+
import java.nio.file.Path;
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
24+
/**
25+
* Manage file creation for multipart streams.
26+
*
27+
* @author Daniel DeGroff
28+
*/
29+
public class DefaultMultipartFileManager implements MultipartFileManager {
30+
private final String optionalPrefix;
31+
32+
private final String optionalSuffix;
33+
34+
private final Path tempDir;
35+
36+
private final List<Path> tempFiles = new ArrayList<>(0);
37+
38+
public DefaultMultipartFileManager(Path tempDir, String optionalPrefix, String optionalSuffix) {
39+
this.tempDir = tempDir;
40+
this.optionalPrefix = optionalPrefix;
41+
this.optionalSuffix = optionalSuffix;
42+
}
43+
44+
public Path createTemporaryFile() throws IOException {
45+
Path tempFile = Files.createTempFile(tempDir, optionalPrefix, optionalSuffix);
46+
tempFiles.add(tempFile);
47+
return tempFile;
48+
}
49+
50+
public List<Path> getTemporaryFiles() {
51+
return List.copyOf(tempFiles);
52+
}
53+
}

0 commit comments

Comments
 (0)