commit | author | age
|
aed034
|
1 |
/* |
U |
2 |
neon-fm - Dateiverwaltung fuer neon |
|
3 |
Copyright (C) 2024 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.neon.fm; |
|
19 |
|
|
20 |
import com.sun.net.httpserver.HttpExchange; |
|
21 |
import de.uhilger.neon.FileServer; |
|
22 |
import de.uhilger.neon.HttpResponder; |
|
23 |
import de.uhilger.fm.FileHelper; |
|
24 |
import java.io.IOException; |
|
25 |
import java.util.logging.Level; |
|
26 |
import java.util.logging.Logger; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author Ulrich Hilger |
|
31 |
* @version 0.1, 08.11.2024 |
|
32 |
*/ |
|
33 |
public class FileCreator extends AbstractFileActor { |
|
34 |
|
|
35 |
public void run(HttpExchange exchange) { |
|
36 |
try { |
|
37 |
super.run(exchange); |
|
38 |
if (fileName.endsWith(FileServer.STR_SLASH)) { // es ist ein Ordner |
|
39 |
if (!file.exists()) { |
|
40 |
file.mkdir(); |
|
41 |
antwort(exchange, HttpResponder.SC_OK, file.getAbsolutePath()); |
|
42 |
} else { |
|
43 |
String antw = "Ordner existiert bereits."; |
|
44 |
antwort(exchange, HttpResponder.SC_UNPROCESSABLE_ENTITY, antw); |
|
45 |
} |
|
46 |
} else { // es ist eine Datei |
|
47 |
if (file.exists()) { |
|
48 |
FileHelper trans = new FileHelper(); |
|
49 |
file = trans.getNewFileName(file); |
|
50 |
} |
|
51 |
speichern(exchange); |
|
52 |
} |
|
53 |
} catch (IOException ex) { |
|
54 |
Logger.getLogger(FileEraser.class.getName()).log(Level.SEVERE, null, ex); |
|
55 |
} finally { |
|
56 |
free(); |
|
57 |
} |
|
58 |
} |
|
59 |
} |