| | |
| | | */ |
| | | package de.uhilger.mediaz.api; |
| | | |
| | | import com.sun.net.httpserver.Headers; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import de.uhilger.mediaz.App; |
| | | import de.uhilger.mediaz.Server; |
| | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.logging.Level; |
| | |
| | | File dir = new File(fileBase, fName); |
| | | logger.fine(dir.getAbsolutePath()); |
| | | File[] files = dir.listFiles(); |
| | | Arrays.sort(files); |
| | | ArrayList list = new ArrayList(); |
| | | if(files != null) { |
| | | for(File file : files) { |
| | |
| | | list.add(sf); |
| | | } |
| | | } |
| | | //Collections.sort(list); |
| | | String json = jsonWithCustomType(list, "Medialiste"); |
| | | logger.fine(json); |
| | | Headers headers = e.getResponseHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | e.sendResponseHeaders(200, json.length()); |
| | | OutputStream os = e.getResponseBody(); |
| | | os.write(json.getBytes()); |