diff --git a/core/src/main/java/studio/core/v1/utils/AudioConversion.java b/core/src/main/java/studio/core/v1/utils/AudioConversion.java index 12f4a71fd..2c56d8952 100644 --- a/core/src/main/java/studio/core/v1/utils/AudioConversion.java +++ b/core/src/main/java/studio/core/v1/utils/AudioConversion.java @@ -12,153 +12,134 @@ import javax.sound.sampled.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; public class AudioConversion { - private static final float WAVE_SAMPLE_RATE = 32000.0f; - private static final float OGG_SAMPLE_RATE = 44100.0f; - private static final float MP3_SAMPLE_RATE = 44100.0f; - private static final int BITSIZE = 16; - private static final int MP3_BITSIZE = 32; - private static final int CHANNELS = 1; + public static final float WAVE_SAMPLE_RATE = 32000.0f; + public static final float OGG_SAMPLE_RATE = 44100.0f; + public static final float MP3_SAMPLE_RATE = 44100.0f; + public static final int BITSIZE = 16; + public static final int MP3_BITSIZE = 32; + public static final int CHANNELS = 1; - public static byte[] oggToWave(byte[] oggData) throws IOException { + public static byte[] oggToWave(byte[] oggData) throws Exception { return anyToWave(oggData); } - public static byte[] mp3ToWave(byte[] mp3Data) throws IOException { + public static byte[] mp3ToWave(byte[] mp3Data) throws Exception { return anyToWave(mp3Data); } - public static byte[] anyToWave(byte[] data) throws IOException { - try { - AudioInputStream inputAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(data)); - - // First, convert to PCM - AudioFormat pcmFormat = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, - inputAudio.getFormat().getSampleRate(), - BITSIZE, - inputAudio.getFormat().getChannels(), - inputAudio.getFormat().getChannels()*2, - inputAudio.getFormat().getSampleRate(), - false - ); - AudioInputStream pcm = AudioSystem.getAudioInputStream(pcmFormat, inputAudio); - - // Then, convert sample rate to 32000Hz, and to mono channel (the only format that is supported by the story teller device) - AudioFormat pcm32000Format = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, - WAVE_SAMPLE_RATE, - BITSIZE, - CHANNELS, - CHANNELS *2, - WAVE_SAMPLE_RATE, - false - ); - AudioInputStream pcm32000 = AudioSystem.getAudioInputStream(pcm32000Format, pcm); - - // Read the whole stream in a byte array because length must be known - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - baos.writeBytes(pcm32000.readAllBytes()); - AudioInputStream waveStream = new AudioInputStream(new ByteArrayInputStream(baos.toByteArray()), pcm32000Format, baos.toByteArray().length); - - ByteArrayOutputStream output = new ByteArrayOutputStream(); - AudioSystem.write(waveStream, AudioFileFormat.Type.WAVE, output); - return output.toByteArray(); - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - throw new IOException("Unsupported audio format", e); - } + public static byte[] anyToWave(byte[] data) throws Exception { + AudioInputStream inputAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(data)); + + // First, convert to PCM + AudioFormat pcmFormat = new AudioFormat( + AudioFormat.Encoding.PCM_SIGNED, + inputAudio.getFormat().getSampleRate(), + BITSIZE, + inputAudio.getFormat().getChannels(), + inputAudio.getFormat().getChannels()*2, + inputAudio.getFormat().getSampleRate(), + false + ); + AudioInputStream pcm = AudioSystem.getAudioInputStream(pcmFormat, inputAudio); + + // Then, convert sample rate to 32000Hz, and to mono channel (the only format that is supported by the story teller device) + AudioFormat pcm32000Format = new AudioFormat( + AudioFormat.Encoding.PCM_SIGNED, + WAVE_SAMPLE_RATE, + BITSIZE, + CHANNELS, + CHANNELS *2, + WAVE_SAMPLE_RATE, + false + ); + AudioInputStream pcm32000 = AudioSystem.getAudioInputStream(pcm32000Format, pcm); + + // Read the whole stream in a byte array because length must be known + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.writeBytes(pcm32000.readAllBytes()); + AudioInputStream waveStream = new AudioInputStream(new ByteArrayInputStream(baos.toByteArray()), pcm32000Format, baos.toByteArray().length); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + AudioSystem.write(waveStream, AudioFileFormat.Type.WAVE, output); + return output.toByteArray(); } - public static byte[] waveToOgg(byte[] waveData) throws IOException { - try { - AudioInputStream inputAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(waveData)); - - // First, convert sample rate to 44100Hz (the only rate that is supported by the vorbis encoding library) - AudioFormat pcm44100Format = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, - OGG_SAMPLE_RATE, - BITSIZE, - CHANNELS, - CHANNELS*2, - OGG_SAMPLE_RATE, - false - ); - AudioInputStream pcm44100 = AudioSystem.getAudioInputStream(pcm44100Format, inputAudio); - - return VorbisEncoder.encode(pcm44100); - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - throw new IOException("Unsupported audio format", e); - } catch (VorbisEncodingException e) { - e.printStackTrace(); - throw new IOException("Audio compression to ogg format failed", e); - } + public static byte[] waveToOgg(byte[] waveData) throws Exception { + AudioInputStream inputAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(waveData)); + + // First, convert sample rate to 44100Hz (the only rate that is supported by the vorbis encoding library) + AudioFormat pcm44100Format = new AudioFormat( + AudioFormat.Encoding.PCM_SIGNED, + OGG_SAMPLE_RATE, + BITSIZE, + CHANNELS, + CHANNELS * 2, + OGG_SAMPLE_RATE, + false + ); + AudioInputStream pcm44100 = AudioSystem.getAudioInputStream(pcm44100Format, inputAudio); + + return VorbisEncoder.encode(pcm44100); } - public static byte[] anyToMp3(byte[] data) throws IOException { - try { + public static byte[] anyToMp3(byte[] data) throws Exception { AudioInputStream inputAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(data)); - // First, convert to PCM - AudioFormat pcmFormat = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, - inputAudio.getFormat().getSampleRate(), - BITSIZE, - inputAudio.getFormat().getChannels(), - inputAudio.getFormat().getChannels()*2, - inputAudio.getFormat().getSampleRate(), - false - ); - AudioInputStream pcm = AudioSystem.getAudioInputStream(pcmFormat, inputAudio); - - // Then, convert to mono **and oversample** (apparently the input stream in always empty unless the sample rate changes) - AudioFormat pcmOverSampledFormat = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, - inputAudio.getFormat().getSampleRate()*2, - BITSIZE, - CHANNELS, - CHANNELS*2, - inputAudio.getFormat().getSampleRate()*2, - false - ); - AudioInputStream pcmOverSampled = AudioSystem.getAudioInputStream(pcmOverSampledFormat, pcm); - - // Finally, convert sample rate to 44100Hz and sample bitsize to 32 bits - AudioFormat pcm44100Format = new AudioFormat( - AudioFormat.Encoding.PCM_FLOAT, - MP3_SAMPLE_RATE, - MP3_BITSIZE, - CHANNELS, - CHANNELS*4, - MP3_SAMPLE_RATE, - false - ); - AudioInputStream pcm44100 = AudioSystem.getAudioInputStream(pcm44100Format, pcmOverSampled); - - LameEncoder encoder = new LameEncoder(pcm44100.getFormat(), 64, MPEGMode.MONO.ordinal(), 1, false); - - ByteArrayOutputStream mp3 = new ByteArrayOutputStream(); - byte[] inputBuffer = new byte[encoder.getPCMBufferSize()]; - byte[] outputBuffer = new byte[encoder.getPCMBufferSize()]; - - int bytesRead; - int bytesWritten; - - while (0 < (bytesRead = pcm44100.read(inputBuffer))) { - bytesWritten = encoder.encodeBuffer(inputBuffer, 0, bytesRead, outputBuffer); - mp3.write(outputBuffer, 0, bytesWritten); - } - - encoder.close(); - return mp3.toByteArray(); - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - throw new IOException("Unsupported audio format", e); + // First, convert to PCM + AudioFormat pcmFormat = new AudioFormat( + AudioFormat.Encoding.PCM_SIGNED, + inputAudio.getFormat().getSampleRate(), + BITSIZE, + inputAudio.getFormat().getChannels(), + inputAudio.getFormat().getChannels() * 2, + inputAudio.getFormat().getSampleRate(), + false + ); + AudioInputStream pcm = AudioSystem.getAudioInputStream(pcmFormat, inputAudio); + + // Then, convert to mono **and oversample** (apparently the input stream in always empty unless the sample rate changes) + AudioFormat pcmOverSampledFormat = new AudioFormat( + AudioFormat.Encoding.PCM_SIGNED, + inputAudio.getFormat().getSampleRate() * 2, + BITSIZE, + CHANNELS, + CHANNELS * 2, + inputAudio.getFormat().getSampleRate() * 2, + false + ); + AudioInputStream pcmOverSampled = AudioSystem.getAudioInputStream(pcmOverSampledFormat, pcm); + + // Finally, convert sample rate to 44100Hz and sample bitsize to 32 bits + AudioFormat pcm44100Format = new AudioFormat( + AudioFormat.Encoding.PCM_FLOAT, + MP3_SAMPLE_RATE, + MP3_BITSIZE, + CHANNELS, + CHANNELS * 4, + MP3_SAMPLE_RATE, + false + ); + AudioInputStream pcm44100 = AudioSystem.getAudioInputStream(pcm44100Format, pcmOverSampled); + + LameEncoder encoder = new LameEncoder(pcm44100.getFormat(), 64, MPEGMode.MONO.ordinal(), 1, false); + + ByteArrayOutputStream mp3 = new ByteArrayOutputStream(); + byte[] inputBuffer = new byte[encoder.getPCMBufferSize()]; + byte[] outputBuffer = new byte[encoder.getPCMBufferSize()]; + + int bytesRead; + int bytesWritten; + + while (0 < (bytesRead = pcm44100.read(inputBuffer))) { + bytesWritten = encoder.encodeBuffer(inputBuffer, 0, bytesRead, outputBuffer); + mp3.write(outputBuffer, 0, bytesWritten); } + + encoder.close(); + return mp3.toByteArray(); } } diff --git a/core/src/main/java/studio/core/v1/utils/PackAssetsCompression.java b/core/src/main/java/studio/core/v1/utils/PackAssetsCompression.java index d8ce89808..5d738b888 100644 --- a/core/src/main/java/studio/core/v1/utils/PackAssetsCompression.java +++ b/core/src/main/java/studio/core/v1/utils/PackAssetsCompression.java @@ -10,11 +10,16 @@ import studio.core.v1.model.StageNode; import studio.core.v1.model.StoryPack; -import java.io.IOException; +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioSystem; +import java.io.ByteArrayInputStream; import java.util.TreeMap; +import java.util.logging.Logger; public class PackAssetsCompression { + private static final Logger LOGGER = Logger.getLogger(PackAssetsCompression.class.getName()); + public static boolean hasCompressedAssets(StoryPack pack) { for (int i = 0; i < pack.getStageNodes().size(); i++) { StageNode node = pack.getStageNodes().get(i); @@ -31,7 +36,7 @@ public static boolean hasCompressedAssets(StoryPack pack) { return false; } - public static StoryPack withCompressedAssets(StoryPack pack) throws IOException { + public static StoryPack withCompressedAssets(StoryPack pack) throws Exception { // Store compressed assets bytes TreeMap assets = new TreeMap<>(); @@ -43,6 +48,7 @@ public static StoryPack withCompressedAssets(StoryPack pack) throws IOException String assetHash = DigestUtils.sha1Hex(imageData); if (assets.get(assetHash) == null) { if ("image/bmp".equals(node.getImage().getMimeType())) { + LOGGER.fine("Compressing BMP image asset into PNG"); imageData = ImageConversion.bitmapToPng(imageData); } assets.put(assetHash, imageData); @@ -59,6 +65,7 @@ public static StoryPack withCompressedAssets(StoryPack pack) throws IOException String assetHash = DigestUtils.sha1Hex(audioData); if (assets.get(assetHash) == null) { if ("audio/x-wav".equals(node.getAudio().getMimeType())) { + LOGGER.fine("Compressing WAV audio asset into OGG"); audioData = AudioConversion.waveToOgg(audioData); node.getAudio().setMimeType("audio/ogg"); } @@ -75,7 +82,7 @@ public static StoryPack withCompressedAssets(StoryPack pack) throws IOException return pack; } - public static StoryPack withUncompressedAssets(StoryPack pack) throws IOException { + public static StoryPack withUncompressedAssets(StoryPack pack) throws Exception { // Store uncompressed assets bytes TreeMap assets = new TreeMap<>(); @@ -88,14 +95,17 @@ public static StoryPack withUncompressedAssets(StoryPack pack) throws IOExceptio if (assets.get(assetHash) == null) { switch (node.getImage().getMimeType()) { case "image/png": + LOGGER.fine("Uncompressing PNG image asset into BMP"); imageData = ImageConversion.anyToBitmap(imageData); break; case "image/jpeg": + LOGGER.fine("Uncompressing JPG image asset into BMP"); imageData = ImageConversion.anyToBitmap(imageData); break; case "image/bmp": // Convert from 4-bits depth / RLE encoding BMP if (imageData[28] == 0x04 && imageData[30] == 0x02) { + LOGGER.fine("Uncompressing 4-bits/RLE BMP image asset into BMP"); imageData = ImageConversion.anyToBitmap(imageData); } break; @@ -114,9 +124,11 @@ public static StoryPack withUncompressedAssets(StoryPack pack) throws IOExceptio if (!"audio/x-wav".equals(node.getAudio().getMimeType())) { switch (node.getAudio().getMimeType()) { case "audio/ogg": + LOGGER.fine("Uncompressing OGG audio asset into WAV"); audioData = AudioConversion.oggToWave(audioData); break; case "audio/mpeg": + LOGGER.fine("Uncompressing MP3 audio asset into WAV"); audioData = AudioConversion.mp3ToWave(audioData); break; } @@ -132,7 +144,7 @@ public static StoryPack withUncompressedAssets(StoryPack pack) throws IOExceptio return pack; } - public static StoryPack withPreparedAssetsFirmware2dot4(StoryPack pack) throws IOException { + public static StoryPack withPreparedAssetsFirmware2dot4(StoryPack pack) throws Exception { // Store prepared assets bytes TreeMap assets = new TreeMap<>(); @@ -145,6 +157,7 @@ public static StoryPack withPreparedAssetsFirmware2dot4(StoryPack pack) throws I if (assets.get(assetHash) == null) { // Convert to 4-bits depth / RLE encoding BMP if (!"image/bmp".equals(node.getImage().getMimeType()) || imageData[28] != 0x04 || imageData[30] != 0x02) { + LOGGER.fine("Converting image asset into 4-bits/RLE BMP"); imageData = ImageConversion.anyToRLECompressedBitmap(imageData); } assets.put(assetHash, imageData); @@ -159,7 +172,16 @@ public static StoryPack withPreparedAssetsFirmware2dot4(StoryPack pack) throws I String assetHash = DigestUtils.sha1Hex(audioData); if (assets.get(assetHash) == null) { if (!"audio/mp3".equals(node.getAudio().getMimeType()) && !"audio/mpeg".equals(node.getAudio().getMimeType())) { + LOGGER.fine("Converting audio asset into MP3"); audioData = AudioConversion.anyToMp3(audioData); + } else { + // Check that the file is MONO / 44100Hz + AudioFileFormat audioFileFormat = AudioSystem.getAudioFileFormat(new ByteArrayInputStream(audioData)); + if (audioFileFormat.getFormat().getChannels() != AudioConversion.CHANNELS + || audioFileFormat.getFormat().getSampleRate() != AudioConversion.MP3_SAMPLE_RATE) { + LOGGER.fine("Re-encoding MP3 audio asset"); + audioData = AudioConversion.anyToMp3(audioData); + } } assets.put(assetHash, audioData); } diff --git a/core/src/main/java/studio/core/v1/writer/fs/FsStoryPackWriter.java b/core/src/main/java/studio/core/v1/writer/fs/FsStoryPackWriter.java index ed29ed21c..4fd704680 100644 --- a/core/src/main/java/studio/core/v1/writer/fs/FsStoryPackWriter.java +++ b/core/src/main/java/studio/core/v1/writer/fs/FsStoryPackWriter.java @@ -9,8 +9,11 @@ import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; import studio.core.v1.model.*; +import studio.core.v1.utils.AudioConversion; import studio.core.v1.utils.XXTEACipher; +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioSystem; import java.io.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -129,9 +132,15 @@ public Path write(StoryPack pack, Path outputFolder) throws Exception { byte[] audioData = audio.getRawData(); String audioHash = DigestUtils.sha1Hex(audioData); if (!audioHashOrdered.contains(audioHash)) { - // TODO Check that the file is in MONO / 44100Hz if (!"audio/mp3".equals(audio.getMimeType()) && !"audio/mpeg".equals(audio.getMimeType())) { throw new IllegalArgumentException("FS pack file requires audio assets to be MP3."); + } else { + // Check that the file is MONO / 44100Hz + AudioFileFormat audioFileFormat = AudioSystem.getAudioFileFormat(new ByteArrayInputStream(audioData)); + if (audioFileFormat.getFormat().getChannels() != AudioConversion.CHANNELS + || audioFileFormat.getFormat().getSampleRate() != AudioConversion.MP3_SAMPLE_RATE) { + throw new IllegalArgumentException("FS pack file requires MP3 audio assets to be MONO / 44100Hz."); + } } audioIndex = audioHashOrdered.size(); audioHashOrdered.add(audioHash); diff --git a/web-ui/src/main/java/studio/webui/service/LibraryService.java b/web-ui/src/main/java/studio/webui/service/LibraryService.java index 4a23ed4a9..6cdaad0a3 100644 --- a/web-ui/src/main/java/studio/webui/service/LibraryService.java +++ b/web-ui/src/main/java/studio/webui/service/LibraryService.java @@ -55,7 +55,6 @@ public LibraryService(DatabaseMetadataService databaseMetadataService) { Files.createDirectories(Paths.get(libraryPath())); } catch (IOException e) { LOGGER.error("Failed to initialize local library", e); - e.printStackTrace(); throw new IllegalStateException("Failed to initialize local library"); } } @@ -145,9 +144,8 @@ public Optional getBinaryPackFile(String packPath, Boolean allowEnriched) fos.close(); return Optional.of(tmp); - } catch (IOException e) { - LOGGER.error("Failed to convert archive format pack to binary format"); - e.printStackTrace(); + } catch (Exception e) { + LOGGER.error("Failed to convert archive format pack to binary format", e); return Optional.empty(); } } else if (packPath.endsWith(".pack")) { @@ -178,8 +176,7 @@ public Optional getBinaryPackFile(String packPath, Boolean allowEnriched) return Optional.of(tmp); } catch (Exception e) { - LOGGER.error("Failed to convert binary format pack to archive format"); - e.printStackTrace(); + LOGGER.error("Failed to convert binary format pack to archive format", e); return Optional.empty(); } } @@ -213,9 +210,8 @@ public Optional getArchivePackFile(String packPath) { fos.close(); return Optional.of(tmp); - } catch (IOException e) { - LOGGER.error("Failed to convert binary format pack to archive format"); - e.printStackTrace(); + } catch (Exception e) { + LOGGER.error("Failed to convert binary format pack to archive format", e); return Optional.empty(); } } else { @@ -229,9 +225,7 @@ public Optional getArchivePackFile(String packPath) { FsStoryPackReader packReader = new FsStoryPackReader(); StoryPack storyPack = packReader.read(Paths.get(libraryPath() + packPath)); - // TODO Compress pack assets ? - /*LOGGER.warn("Compressing pack assets"); - StoryPack compressedPack = PackAssetsCompression.withCompressedAssets(storyPack);*/ + // No need to compress pack assets LOGGER.warn("Writing archive format pack"); ArchiveStoryPackWriter packWriter = new ArchiveStoryPackWriter(); @@ -241,8 +235,7 @@ public Optional getArchivePackFile(String packPath) { return Optional.of(tmp); } catch (Exception e) { - LOGGER.error("Failed to convert FS folder format pack to archive format"); - e.printStackTrace(); + LOGGER.error("Failed to convert FS folder format pack to archive format", e); return Optional.empty(); } } @@ -253,7 +246,6 @@ public Optional getFsPackFile(String packPath, String deviceUuid, Boolean if (packPath.endsWith(".zip")) { try { Path tmp = Files.createTempDirectory(packPath); - FileUtils.forceDeleteOnExit(tmp.toFile()); LOGGER.warn("Pack to transfer is in archive format. Converting to FS folder format and storing in temporary folder: " + tmp.toAbsolutePath().toString()); @@ -264,21 +256,47 @@ public Optional getFsPackFile(String packPath, String deviceUuid, Boolean fis.close(); // Prepare assets (RLE-encoded BMP, audio must already be MP3) + LOGGER.warn("Converting assets if necessary"); StoryPack packWithPreparedAssets = PackAssetsCompression.withPreparedAssetsFirmware2dot4(storyPack); LOGGER.warn("Writing FS folder format pack"); FsStoryPackWriter writer = new FsStoryPackWriter(Hex.decodeHex(deviceUuid)); Path folderPath = writer.write(packWithPreparedAssets, tmp); + FileUtils.forceDeleteOnExit(tmp.toFile()); + return Optional.of(folderPath.toFile()); } catch (Exception e) { - LOGGER.error("Failed to convert archive format pack to binary format"); - e.printStackTrace(); + LOGGER.error("Failed to convert archive format pack to FS folder format", e); return Optional.empty(); } } else if (packPath.endsWith(".pack")) { - // FIXME Support converting from binary pack to FS folder pack - return Optional.empty(); + try { + Path tmp = Files.createTempDirectory(packPath); + + LOGGER.warn("Pack is in binary format. Converting to FS folder format and storing in temporary folder: " + tmp.toAbsolutePath().toString()); + + LOGGER.warn("Reading binary format pack"); + BinaryStoryPackReader packReader = new BinaryStoryPackReader(); + FileInputStream fis = new FileInputStream(libraryPath() + packPath); + StoryPack storyPack = packReader.read(fis); + fis.close(); + + // Prepare assets (RLE-encoded BMP, audio must already be MP3) + LOGGER.warn("Converting assets if necessary"); + StoryPack packWithPreparedAssets = PackAssetsCompression.withPreparedAssetsFirmware2dot4(storyPack); + + LOGGER.warn("Writing FS folder format pack"); + FsStoryPackWriter writer = new FsStoryPackWriter(Hex.decodeHex(deviceUuid)); + Path folderPath = writer.write(packWithPreparedAssets, tmp); + + FileUtils.forceDeleteOnExit(tmp.toFile()); + + return Optional.of(folderPath.toFile()); + } catch (Exception e) { + LOGGER.error("Failed to convert binary format pack to FS folder format", e); + return Optional.empty(); + } } else { return getRawPackFile(packPath); } @@ -320,7 +338,6 @@ public boolean deletePack(String packPath) { } } catch (IOException e) { LOGGER.error("Failed to remove pack from library", e); - e.printStackTrace(); return false; } } @@ -341,7 +358,6 @@ private Optional readPackFile(Path path) { return Optional.ofNullable(packReader.readMetadata(fis)); } catch (IOException e) { LOGGER.error("Failed to read archive-format pack " + path.toString() + " from local library", e); - e.printStackTrace(); return Optional.empty(); } } else if (path.toString().endsWith(".pack")) { @@ -357,7 +373,6 @@ private Optional readPackFile(Path path) { return metadata; } catch (IOException e) { LOGGER.error("Failed to read binary-format pack " + path.toString() + " from local library", e); - e.printStackTrace(); return Optional.empty(); } } else if (Files.isDirectory(path)) { @@ -373,7 +388,6 @@ private Optional readPackFile(Path path) { return metadata; } catch (Exception e) { LOGGER.error("Failed to read FS folder format pack " + path.toString() + " from local library", e); - e.printStackTrace(); return Optional.empty(); } } diff --git a/web-ui/src/main/java/studio/webui/service/mock/MockStoryTellerService.java b/web-ui/src/main/java/studio/webui/service/mock/MockStoryTellerService.java index 6b8258942..a79c7bb23 100644 --- a/web-ui/src/main/java/studio/webui/service/mock/MockStoryTellerService.java +++ b/web-ui/src/main/java/studio/webui/service/mock/MockStoryTellerService.java @@ -54,7 +54,6 @@ public MockStoryTellerService(EventBus eventBus, DatabaseMetadataService databas Files.createDirectories(Paths.get(devicePath())); } catch (IOException e) { LOGGER.error("Failed to initialize mocked device", e); - e.printStackTrace(); throw new IllegalStateException("Failed to initialize mocked device"); } } @@ -124,7 +123,6 @@ private Optional readBinaryPackFile(Path path) { return metadata; } catch (IOException e) { LOGGER.error("Failed to read binary-format pack " + path.toString() + " from mocked device", e); - e.printStackTrace(); return Optional.empty(); } } else if (path.toString().endsWith(".zip")) { @@ -175,7 +173,6 @@ public void run() { eventBus.send("storyteller.transfer."+transferId+".done", new JsonObject().put("success", true)); } catch (IOException e) { LOGGER.error("Failed to add pack to mocked device", e); - e.printStackTrace(); // Send event on eventbus to signal transfer failure eventBus.send("storyteller.transfer." + transferId + ".done", new JsonObject().put("success", false)); } @@ -202,7 +199,6 @@ public CompletableFuture deletePack(String uuid) { } } catch (IOException e) { LOGGER.error("Failed to remove pack from mocked device", e); - e.printStackTrace(); return CompletableFuture.completedFuture(false); } } @@ -253,7 +249,6 @@ public void run() { eventBus.send("storyteller.transfer."+transferId+".done", new JsonObject().put("success", true)); } catch (IOException e) { LOGGER.error("Failed to extract pack from mocked device", e); - e.printStackTrace(); // Send event on eventbus to signal transfer failure eventBus.send("storyteller.transfer." + transferId + ".done", new JsonObject().put("success", false)); } diff --git a/web-ui/src/main/resources/log4j2.xml b/web-ui/src/main/resources/log4j2.xml index 7f9eb648f..6c104856c 100644 --- a/web-ui/src/main/resources/log4j2.xml +++ b/web-ui/src/main/resources/log4j2.xml @@ -37,6 +37,11 @@ + + + + + \ No newline at end of file